use of org.springframework.jmx.export.annotation.ManagedOperation in project symmetric-ds by JumpMind.
the class NodeManagementService method extractBatcheRange.
@ManagedOperation(description = "Extract multiple batches to a file for a time range")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "fileName", description = "The file to write the batch output to"), @ManagedOperationParameter(name = "nodeId", description = "The target node id whose batches need extracted"), @ManagedOperationParameter(name = "startTime", description = "The start time range to extract. The format is yyyy-MM-dd hh:mm"), @ManagedOperationParameter(name = "endTime", description = "The start time range to extract. The format is yyyy-MM-dd hh:mm"), @ManagedOperationParameter(name = "channelIdList", description = "A comma separated list of channels to extract") })
public boolean extractBatcheRange(String fileName, String nodeId, String startTime, String endTime, String channelIdList) {
File file = new File(fileName);
file.getParentFile().mkdirs();
Date startBatchTime = FormatUtils.parseDate(startTime, FormatUtils.TIMESTAMP_PATTERNS);
Date endBatchTime = FormatUtils.parseDate(endTime, FormatUtils.TIMESTAMP_PATTERNS);
String[] channelIds = channelIdList.split(",");
IDataExtractorService dataExtractorService = engine.getDataExtractorService();
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(file));
dataExtractorService.extractBatchRange(writer, nodeId, startBatchTime, endBatchTime, channelIds);
return true;
} catch (Exception ex) {
log.error("Failed to write batch range to file", ex);
return false;
} finally {
IOUtils.closeQuietly(writer);
}
}
use of org.springframework.jmx.export.annotation.ManagedOperation in project symmetric-ds by JumpMind.
the class NodeManagementService method setSyncEnabledForNode.
@ManagedOperation(description = "Enable or disable synchronization completely for a node")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "nodeId", description = "The node to enable or disable"), @ManagedOperationParameter(name = "syncEnabled", description = "true is enabled, false is disabled") })
public boolean setSyncEnabledForNode(String nodeId, boolean syncEnabled) {
Node node = engine.getNodeService().findNode(nodeId);
if (node != null) {
node.setSyncEnabled(syncEnabled);
engine.getNodeService().save(node);
return true;
} else {
return false;
}
}
use of org.springframework.jmx.export.annotation.ManagedOperation in project spring-boot by spring-projects.
the class LoggersEndpointMBean method setLogLevel.
@ManagedOperation(description = "Set log level for a given logger")
public void setLogLevel(String loggerName, String logLevel) {
Assert.notNull(logLevel, "LogLevel must not be null");
LogLevel level = LogLevel.valueOf(logLevel.toUpperCase());
getEndpoint().setLogLevel(loggerName, level);
}
use of org.springframework.jmx.export.annotation.ManagedOperation in project symmetric-ds by JumpMind.
the class NodeManagementService method writeBatchRangeToFile.
@ManagedOperation(description = "Write a range of batches to a file in SymmetricDS Data Format.")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "nodeId", description = "The node id for the batches which will be written"), @ManagedOperationParameter(name = "startBatchId", description = "Starting batch ID of range"), @ManagedOperationParameter(name = "endBatchId", description = "Ending batch ID of range"), @ManagedOperationParameter(name = "fileName", description = "File name to write batches") })
public void writeBatchRangeToFile(String nodeId, String startBatchId, String endBatchId, String fileName) throws Exception {
Writer writer = new FileWriter(new File(fileName));
engine.getDataExtractorService().extractBatchRange(writer, nodeId, Long.valueOf(startBatchId), Long.valueOf(endBatchId));
IOUtils.closeQuietly(writer);
}
use of org.springframework.jmx.export.annotation.ManagedOperation in project symmetric-ds by JumpMind.
the class AbstractXmlPublisherExtensionPoint method resend.
@ManagedOperation(description = "Looks up rows in the database and resends them to the publisher")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "args", description = "A pipe deliminated list of key values to use to look up the tables to resend") })
public boolean resend(String args) {
try {
String[] argArray = args != null ? args.split("\\|") : new String[0];
DataContext context = new DataContext();
IDatabasePlatform platform = engine.getDatabasePlatform();
for (String tableName : tableNamesToPublishAsGroup) {
Table table = platform.getTableFromCache(tableName, false);
List<String[]> dataRowsForTable = readData(table, argArray);
for (String[] values : dataRowsForTable) {
Batch batch = new Batch();
batch.setBinaryEncoding(engine.getSymmetricDialect().getBinaryEncoding());
batch.setSourceNodeId("republish");
context.setBatch(batch);
CsvData data = new CsvData(DataEventType.INSERT);
data.putParsedData(CsvData.ROW_DATA, values);
Element xml = getXmlFromCache(context, context.getBatch().getBinaryEncoding(), table.getColumnNames(), data.getParsedData(CsvData.ROW_DATA), table.getPrimaryKeyColumnNames(), data.getParsedData(CsvData.PK_DATA));
if (xml != null) {
toXmlElement(data.getDataEventType(), xml, table.getCatalog(), table.getSchema(), table.getName(), table.getColumnNames(), data.getParsedData(CsvData.ROW_DATA), table.getPrimaryKeyColumnNames(), data.getParsedData(CsvData.PK_DATA));
}
}
}
if (doesXmlExistToPublish(context)) {
finalizeXmlAndPublish(context);
return true;
} else {
log.warn(String.format("Failed to resend message for tables %s, columns %s, and args %s", tableNamesToPublishAsGroup, groupByColumnNames, args));
}
} catch (RuntimeException ex) {
log.error(String.format("Failed to resend message for tables %s, columns %s, and args %s", tableNamesToPublishAsGroup, groupByColumnNames, args), ex);
}
return false;
}
Aggregations