use of com.linkedin.databus2.core.container.request.ContainerOperationProcessor in project databus by linkedin.
the class ClusterFileLoggingClient method mainFunction.
public void mainFunction(String[] args) throws Exception {
String[] leftOverArgs = processLocalArgs(args);
Properties startupProps = DatabusHttpClientImpl.processCommandLineArgs(leftOverArgs);
DatabusHttpClientImpl.Config clientConfigBuilder = new DatabusHttpClientImpl.Config();
clientConfigBuilder.getContainer().setIdFromName(MODULE + ".localhost");
if (_enableBootStrap) {
clientConfigBuilder.getRuntime().getBootstrap().setEnabled(true);
}
ConfigLoader<DatabusHttpClientImpl.StaticConfig> configLoader = new ConfigLoader<DatabusHttpClientImpl.StaticConfig>("databus.client.", clientConfigBuilder);
String[] sources = getSources();
StringBuilder sourcesString = new StringBuilder();
boolean firstSrc = true;
for (String source : sources) {
if (!firstSrc)
sourcesString.append(",");
firstSrc = false;
sourcesString.append(source);
}
if (_httpPort != null) {
startupProps.put("databus.client.container.httpPort", _httpPort);
}
if (_jmxServicePort != null) {
startupProps.put("databus.client.container.jmx.jmxServicePort", _jmxServicePort);
}
if (_checkpointFileRootDir != null) {
startupProps.put("databus.client.checkpointPersistence.fileSystem.rootDirectory", _checkpointFileRootDir);
}
DatabusHttpClientImpl.StaticConfig clientConfig = configLoader.loadConfig(startupProps);
// set up relay
ServerInfoBuilder relayBuilder = clientConfig.getRuntime().getRelay("1");
relayBuilder.setName("DefaultRelay");
if (_relayHost != null) {
relayBuilder.setHost(_relayHost);
}
if (_relayPort != null) {
relayBuilder.setPort(Integer.parseInt(_relayPort));
}
relayBuilder.setSources(sourcesString.toString());
// set up bootstrap
if (_enableBootStrap) {
ServerInfoBuilder bootstrapBuilder = clientConfig.getRuntime().getBootstrap().getService("2");
bootstrapBuilder.setName("DefaultBootstrapServices");
if (_bootstrapHost != null) {
bootstrapBuilder.setHost(_bootstrapHost);
}
if (_bootstrapPort != null) {
bootstrapBuilder.setPort(Integer.parseInt(_bootstrapPort));
}
bootstrapBuilder.setSources(sourcesString.toString());
}
// set up listeners
DatabusHttpClientImpl client = new DatabusHttpClientImpl(clientConfig);
List<DatabusRegistration> regs = new ArrayList<DatabusRegistration>();
for (String cluster : _clusters) {
DatabusRegistration reg = client.registerCluster(cluster, createConsumerFactory(cluster, _valueDumpFile, _eventDumpFile), createServerSideFactory(cluster), createPartitionListener(cluster), sources);
regs.add(reg);
}
// add pause processor
try {
client.getProcessorRegistry().register(ContainerOperationProcessor.COMMAND_NAME, new ContainerOperationProcessor(null, client));
} catch (ProcessorRegistrationConflictException e) {
LOG.error("Failed to register " + ConsumerPauseRequestProcessor.COMMAND_NAME);
}
DatabusClientShutdownThread shutdownThread = new DatabusClientShutdownThread(client);
Runtime.getRuntime().addShutdownHook(shutdownThread);
client.startAndBlock();
}
use of com.linkedin.databus2.core.container.request.ContainerOperationProcessor in project databus by linkedin.
the class SimpleFileLoggingConsumer method mainFunction.
public void mainFunction(String[] args) throws Exception {
String[] leftOverArgs = processLocalArgs(args);
Properties startupProps = DatabusHttpClientImpl.processCommandLineArgs(leftOverArgs);
DatabusHttpClientImpl.Config clientConfigBuilder = new DatabusHttpClientImpl.Config();
clientConfigBuilder.getContainer().setIdFromName(MODULE + ".localhost");
if (_enableBootStrap) {
clientConfigBuilder.getRuntime().getBootstrap().setEnabled(true);
}
ConfigLoader<DatabusHttpClientImpl.StaticConfig> configLoader = new ConfigLoader<DatabusHttpClientImpl.StaticConfig>("databus.client.", clientConfigBuilder);
String[] sources = addSources();
StringBuilder sourcesString = new StringBuilder();
boolean firstSrc = true;
for (String source : sources) {
if (!firstSrc)
sourcesString.append(",");
firstSrc = false;
sourcesString.append(source);
}
if (_httpPort != null) {
startupProps.put("databus.client.container.httpPort", _httpPort);
}
if (_jmxServicePort != null) {
startupProps.put("databus.client.container.jmx.jmxServicePort", _jmxServicePort);
}
if (_checkpointFileRootDir != null) {
startupProps.put("databus.client.checkpointPersistence.fileSystem.rootDirectory", _checkpointFileRootDir);
}
DatabusHttpClientImpl.StaticConfig clientConfig = configLoader.loadConfig(startupProps);
// set up relay
ServerInfoBuilder relayBuilder = clientConfig.getRuntime().getRelay("1");
relayBuilder.setName("DefaultRelay");
if (_relayHost != null) {
relayBuilder.setHost(_relayHost);
}
if (_relayPort != null) {
relayBuilder.setPort(Integer.parseInt(_relayPort));
}
relayBuilder.setSources(sourcesString.toString());
// set up bootstrap
if (_enableBootStrap) {
ServerInfoBuilder bootstrapBuilder = clientConfig.getRuntime().getBootstrap().getService("2");
bootstrapBuilder.setName("DefaultBootstrapServices");
if (_bootstrapHost != null) {
bootstrapBuilder.setHost(_bootstrapHost);
}
if (_bootstrapPort != null) {
bootstrapBuilder.setPort(Integer.parseInt(_bootstrapPort));
}
bootstrapBuilder.setSources(sourcesString.toString());
}
// handler server side filtering, can either pass a config file or set from command line
DbusKeyCompositeFilterConfig filterConfig = createServerSideFilterConfig(_filterConfFile, startupProps);
// set up listeners
DatabusHttpClientImpl client = new DatabusHttpClientImpl(clientConfig);
// dump decoded payload values and raw (undecoded) events
DatabusFileLoggingConsumer consumer = createTypedConsumer(_valueDumpFile, _eventDumpFile);
if (_eventPattern != null) {
consumer.setEventPattern(_eventPattern);
}
DatabusRegistration reg = client.register(consumer, sources);
if (!(reg instanceof DatabusV2RegistrationImpl)) {
throw new RuntimeException("Unexpected type for registration Object !!");
}
if (null != filterConfig)
reg.withServerSideFilter(filterConfig);
// add pause processor
try {
client.getProcessorRegistry().register(ConsumerPauseRequestProcessor.COMMAND_NAME, new ConsumerPauseRequestProcessor(null, consumer));
client.getProcessorRegistry().register(ContainerOperationProcessor.COMMAND_NAME, new ContainerOperationProcessor(null, client));
} catch (ProcessorRegistrationConflictException e) {
LOG.error("Failed to register " + ConsumerPauseRequestProcessor.COMMAND_NAME);
}
DatabusClientShutdownThread shutdownThread = new DatabusClientShutdownThread(client);
Runtime.getRuntime().addShutdownHook(shutdownThread);
//this should automatically start the registration
client.startAndBlock();
}
use of com.linkedin.databus2.core.container.request.ContainerOperationProcessor in project databus by linkedin.
the class BootstrapHttpServer method initializeBootstrapServerCommandProcessors.
protected void initializeBootstrapServerCommandProcessors() throws DatabusException {
LOG.info("Initializing Bootstrap HTTP Server");
LOG.info("Config=" + _bootstrapServerConfig);
try {
RequestProcessorRegistry processorRegistry = getProcessorRegistry();
processorRegistry.register(ConfigRequestProcessor.COMMAND_NAME, new ConfigRequestProcessor(null, this));
processorRegistry.register(BootstrapRequestProcessor.COMMAND_NAME, new BootstrapRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(StartSCNRequestProcessor.COMMAND_NAME, new StartSCNRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(TargetSCNRequestProcessor.COMMAND_NAME, new TargetSCNRequestProcessor(null, _bootstrapServerConfig, this));
processorRegistry.register(ContainerOperationProcessor.COMMAND_NAME, new ContainerOperationProcessor(null, this));
} catch (SQLException sqle) {
throw new DatabusException("command registration failed", sqle);
} catch (InstantiationException e) {
throw new DatabusException("command registration failed", e);
} catch (IllegalAccessException e) {
throw new DatabusException("command registration failed", e);
} catch (ClassNotFoundException e) {
throw new DatabusException("command registration failed", e);
}
LOG.info("Done Initializing Bootstrap HTTP Server");
}
Aggregations