use of com.linkedin.databus2.producers.EventProducer in project databus by linkedin.
the class OpenReplicatorEventProducerServiceProvider method createProducer.
@Override
public EventProducer createProducer(PhysicalSourceStaticConfig physicalSourceConfig, SchemaRegistryService schemaRegistryService, DbusEventBufferAppendable eventBuffer, DbusEventsStatisticsCollector statsCollector, MaxSCNReaderWriter checkpointWriter) throws InvalidConfigException {
// Parse each one of the logical sources
List<OpenReplicatorAvroEventFactory> eventFactories = new ArrayList<OpenReplicatorAvroEventFactory>();
for (LogicalSourceStaticConfig sourceConfig : physicalSourceConfig.getSources()) {
OpenReplicatorAvroEventFactory factory = null;
try {
factory = buildEventFactory(sourceConfig, physicalSourceConfig, schemaRegistryService);
} catch (Exception ex) {
LOG.error("Got exception while building monitored sources for config :" + sourceConfig, ex);
throw new InvalidConfigException(ex);
}
eventFactories.add(factory);
}
EventProducer producer = null;
try {
producer = new OpenReplicatorEventProducer(eventFactories, eventBuffer, checkpointWriter, physicalSourceConfig, statsCollector, null, null, schemaRegistryService, JMX_DOMAIN);
} catch (DatabusException e) {
LOG.error("Got databus exception when instantiating Open Replicator event producer for source : " + physicalSourceConfig.getName(), e);
throw new InvalidConfigException(e);
}
return producer;
}
use of com.linkedin.databus2.producers.EventProducer in project databus by linkedin.
the class RelayStatsRequestProcessor method processInboundGGStats.
private void processInboundGGStats(DatabusRequest request, String category) throws IOException, RequestProcessingException {
if (!(_relay instanceof DatabusRelayMain)) {
throw new IllegalArgumentException(category + " for relay which is not DatabusRelayMain");
}
String psourceName = null;
if (category.startsWith(INBOUND_GG_PSOURCE_PREFIX)) {
psourceName = category.substring(INBOUND_GG_PSOURCE_PREFIX.length());
if (psourceName == null || psourceName.length() <= 0) {
throw new InvalidRequestParamValueException(request.getName(), INBOUND_GG_PSOURCE_PREFIX, null);
}
LOG.info("get parser stats for source " + psourceName);
}
List<String> phSourceNames = new ArrayList<String>();
EventProducer[] prods = ((DatabusRelayMain) _relay).getProducers();
GGParserStatistics stat = null;
for (EventProducer prod : prods) {
if (prod != null && (prod instanceof GoldenGateEventProducer)) {
GoldenGateEventProducer ggProducer = (GoldenGateEventProducer) prod;
String pSrcName = ggProducer.getParserStats().getPhysicalSourceName();
phSourceNames.add(pSrcName);
if (// remember the stats object
psourceName != null && psourceName.equals(pSrcName))
stat = ggProducer.getParserStats();
}
}
if (psourceName != null) {
if (stat == null)
throw new InvalidRequestParamValueException(request.getName(), INBOUND_GG_PSOURCE_PREFIX, psourceName);
writeJsonObjectToResponse(stat, request);
} else {
writeJsonObjectToResponse(phSourceNames, request);
}
}
use of com.linkedin.databus2.producers.EventProducer in project databus by linkedin.
the class ControlSourceEventsRequestProcessor method doStatus.
private void doStatus(DatabusRequest request) throws IOException {
Set<String> sources = getSourcesParam(request);
for (EventProducer producer : _eventProducers) {
if (sources == null || sources.contains(producer.getName())) {
String state;
if (producer.isRunning()) {
state = "running";
} else if (producer.isPaused()) {
state = "paused";
} else {
state = "shutdown";
}
write(request, String.format("{\"name\" : \"%s\", \"status\" : \"%s\", \"SCN\" : %d}", producer.getName(), state, producer.getSCN()));
}
}
}
use of com.linkedin.databus2.producers.EventProducer in project databus by linkedin.
the class ControlSourceEventsRequestProcessor method doShutdown.
private void doShutdown(DatabusRequest request) throws IOException {
Set<String> sources = getSourcesParam(request);
for (EventProducer producer : _eventProducers) {
if (sources == null || sources.contains(producer.getName())) {
producer.shutdown();
}
}
doStatus(request);
}
use of com.linkedin.databus2.producers.EventProducer in project databus by linkedin.
the class ControlSourceEventsRequestProcessor method doStart.
private void doStart(DatabusRequest request) throws IOException, RequestProcessingException {
Set<String> sources = getSourcesParam(request);
if (sources == null || sources.size() != 1) {
throw new RequestProcessingException("start requires exactly one source be specified");
}
long scn = request.getOptionalLongParam(PARAM_SCN, -1L);
for (EventProducer producer : _eventProducers) {
if (sources.contains(producer.getName())) {
producer.start(scn);
write(request, String.format("{\"name\" : \"%s\", \"status\" : \"%s\", \"SCN\" : %d}", producer.getName(), "running", producer.getSCN()));
}
}
}
Aggregations