Skip to content
Snippets Groups Projects
Commit 4e204e8a authored by Gwenaelle ABEILLE's avatar Gwenaelle ABEILLE
Browse files

Merge branch 'TANGOARCH-895' into 'master'

TANGOARCH-895 : Added shiftArchiver command

See merge request !3
parents 27b95a3e 5e767dcb
No related branches found
No related tags found
1 merge request!3TANGOARCH-895 : Added shiftArchiver command
...@@ -590,4 +590,18 @@ public class ArchivingManager { ...@@ -590,4 +590,18 @@ public class ArchivingManager {
return res; return res;
} }
/**
* Moves an attribute from one archiver to another
* @param argin attributeName,archiverName
* @throws DevFailed if the attribute cannot be moved since it is not archived or if it failed
*/
@Command(name = "ShiftArchiver", inTypeDesc = "attributeName,archiverName")
public void shiftArchiver(final String[] argin) throws DevFailed {
auditLogger.debug("Entering ShiftArchiver with params {}", String.join(",", argin));
if (argin.length != 2) {
throw DevFailedUtils.newDevFailed("Invalid number of arguments");
}
databaseAccess.shiftArchiver(argin[0], argin[1]);
auditLogger.debug("Exiting ShiftArchiver");
}
} }
...@@ -217,4 +217,26 @@ public class HDBTDBAccess implements IArchivingAccess { ...@@ -217,4 +217,26 @@ public class HDBTDBAccess implements IArchivingAccess {
public int createNewContext(final String contextName, String description) throws DevFailed { public int createNewContext(final String contextName, String description) throws DevFailed {
throw DevFailedUtils.newDevFailed("Not supported for HDB or TDB"); throw DevFailedUtils.newDevFailed("Not supported for HDB or TDB");
} }
@Override
public void shiftArchiver(final String attributeName, final String archiverName) throws DevFailed {
Mode m;
final ArchivingMessConfig archivingMessConfig = ArchivingMessConfig.basicObjectCreation();
try {
m = dbManager.getArchivingMode(attributeName);
} catch (ArchivingException e) {
throw e.toTangoException();
}
AttributeLightMode mode = new AttributeLightMode();
mode.setDevice_in_charge(archiverName);
mode.setAttributeCompleteName(attributeName);
mode.setMode(m);
archivingMessConfig.add(mode);
try {
dbManager.archivingStopConf(attributeName);
dbManager.archivingStart(archivingMessConfig);
} catch (ArchivingException e) {
throw e.toTangoException();
}
}
} }
...@@ -33,4 +33,6 @@ public interface IArchivingAccess { ...@@ -33,4 +33,6 @@ public interface IArchivingAccess {
String[] getAllContexts() throws DevFailed; String[] getAllContexts() throws DevFailed;
int createNewContext(final String contextName, String description) throws DevFailed; int createNewContext(final String contextName, String description) throws DevFailed;
void shiftArchiver(final String attributeName, final String archiverName) throws DevFailed;
} }
...@@ -198,4 +198,18 @@ public class TimeseriesAccess implements IArchivingAccess { ...@@ -198,4 +198,18 @@ public class TimeseriesAccess implements IArchivingAccess {
} }
return inserterService.createNewContext(contextName, description); return inserterService.createNewContext(contextName, description);
} }
@Override
public void shiftArchiver(final String attributeName, final String archiverName) throws DevFailed {
ArchivingConfigs configs = new ArchivingConfigs();
ArchivingConfig archivingConfig = new ArchivingConfig();
archivingConfig.setArchiver(archiverName);
configService.getAttributeConfig(attributeName).ifPresent(attributeConfig -> {
archivingConfig.setAttributeConfig(attributeConfig);
archivingConfig.setModes(configService.getCurrentInsertionModes(attributeConfig.getId()).orElse(null));
configs.addConfiguration(archivingConfig);
service.stopArchiving(attributeName);
service.startArchiving(configs);
});
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment