use of org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter in project wildfly by wildfly.
the class ExportJournalOperation method executeRuntimeStep.
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (context.getRunningMode() != ADMIN_ONLY) {
throw MessagingLogger.ROOT_LOGGER.managementOperationAllowedOnlyInRunningMode("export-journal", ADMIN_ONLY);
}
final ServiceController<PathManager> service = (ServiceController<PathManager>) context.getServiceRegistry(false).getService(PathManagerService.SERVICE_NAME);
final PathManager pathManager = service.getService().getValue();
final String journal = resolvePath(context, pathManager, JOURNAL_DIRECTORY_PATH);
final String bindings = resolvePath(context, pathManager, BINDINGS_DIRECTORY_PATH);
final String paging = resolvePath(context, pathManager, PAGING_DIRECTORY_PATH);
final String largeMessages = resolvePath(context, pathManager, LARGE_MESSAGES_DIRECTORY_PATH);
final XmlDataExporter exporter = new XmlDataExporter();
String name = String.format(FILE_NAME_FORMAT, new Date());
// write the exported dump at the same level than the journal directory
File dump = new File(new File(journal).getParent(), name);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(dump);
exporter.process(fos, bindings, journal, paging, largeMessages);
context.getResult().set(dump.getAbsolutePath());
} catch (Exception e) {
throw new OperationFailedException(e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
}
}
Aggregations