use of com.wavefront.agent.queueing.QueueExporter in project java by wavefrontHQ.
the class AbstractAgent method start.
/**
* Entry-point for the application.
*
* @param args Command-line parameters passed on to JCommander to configure the daemon.
*/
public void start(String[] args) {
try {
/* ------------------------------------------------------------------------------------
* Configuration Setup.
* ------------------------------------------------------------------------------------ */
// Parse commandline arguments and load configuration file
parseArguments(args);
postProcessConfig();
initSslContext();
initPreprocessors();
if (proxyConfig.isTestLogs() || proxyConfig.getTestPreprocessorForPort() != null || proxyConfig.getTestSpanPreprocessorForPort() != null) {
InteractiveTester interactiveTester;
if (proxyConfig.isTestLogs()) {
logger.info("Reading line-by-line sample log messages from STDIN");
interactiveTester = new InteractiveLogsTester(this::loadLogsIngestionConfig, proxyConfig.getPrefix());
} else if (proxyConfig.getTestPreprocessorForPort() != null) {
logger.info("Reading line-by-line points from STDIN");
interactiveTester = new InteractivePreprocessorTester(preprocessors.get(proxyConfig.getTestPreprocessorForPort()), ReportableEntityType.POINT, proxyConfig.getTestPreprocessorForPort(), proxyConfig.getCustomSourceTags());
} else if (proxyConfig.getTestSpanPreprocessorForPort() != null) {
logger.info("Reading line-by-line spans from STDIN");
interactiveTester = new InteractivePreprocessorTester(preprocessors.get(String.valueOf(proxyConfig.getTestPreprocessorForPort())), ReportableEntityType.TRACE, proxyConfig.getTestPreprocessorForPort(), proxyConfig.getCustomSourceTags());
} else {
throw new IllegalStateException();
}
// noinspection StatementWithEmptyBody
while (interactiveTester.interactiveTest()) {
// empty
}
System.exit(0);
}
// If we are exporting data from the queue, run export and exit
if (proxyConfig.getExportQueueOutputFile() != null && proxyConfig.getExportQueuePorts() != null) {
TaskQueueFactory tqFactory = new TaskQueueFactoryImpl(proxyConfig.getBufferFile(), false, false, proxyConfig.getBufferShardSize());
EntityPropertiesFactory epFactory = new EntityPropertiesFactoryImpl(proxyConfig);
QueueExporter queueExporter = new QueueExporter(proxyConfig.getBufferFile(), proxyConfig.getExportQueuePorts(), proxyConfig.getExportQueueOutputFile(), proxyConfig.isExportQueueRetainData(), tqFactory, epFactory);
logger.info("Starting queue export for ports: " + proxyConfig.getExportQueuePorts());
queueExporter.export();
logger.info("Done");
System.exit(0);
}
// 2. Read or create the unique Id for the daemon running on this machine.
agentId = getOrCreateProxyId(proxyConfig);
apiContainer = new APIContainer(proxyConfig, proxyConfig.isUseNoopSender());
// Perform initial proxy check-in and schedule regular check-ins (once a minute)
proxyCheckinScheduler = new ProxyCheckInScheduler(agentId, proxyConfig, apiContainer, this::processConfiguration, () -> System.exit(1), this::truncateBacklog);
proxyCheckinScheduler.scheduleCheckins();
// Start the listening endpoints
startListeners();
Timer startupTimer = new Timer("Timer-startup");
shutdownTasks.add(startupTimer::cancel);
startupTimer.schedule(new TimerTask() {
@Override
public void run() {
// exit if no active listeners
if (activeListeners.count() == 0) {
logger.severe("**** All listener threads failed to start - there is already a " + "running instance listening on configured ports, or no listening ports " + "configured!");
logger.severe("Aborting start-up");
System.exit(1);
}
Runtime.getRuntime().addShutdownHook(new Thread("proxy-shutdown-hook") {
@Override
public void run() {
shutdown();
}
});
logger.info("setup complete");
}
}, 5000);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
// logger.severe(e.getMessage());
System.exit(1);
}
}
Aggregations