Search in sources :

Example 1 with EventProducer

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;
}
Also used : DatabusException(com.linkedin.databus2.core.DatabusException) ArrayList(java.util.ArrayList) LogicalSourceStaticConfig(com.linkedin.databus2.relay.config.LogicalSourceStaticConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) UnsupportedKeyException(com.linkedin.databus.core.UnsupportedKeyException) NoSuchSchemaException(com.linkedin.databus2.schemas.NoSuchSchemaException)

Example 2 with EventProducer

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);
    }
}
Also used : GGParserStatistics(com.linkedin.databus.monitoring.mbean.GGParserStatistics) DatabusRelayMain(com.linkedin.databus2.relay.DatabusRelayMain) ArrayList(java.util.ArrayList) EventProducer(com.linkedin.databus2.producers.EventProducer) GoldenGateEventProducer(com.linkedin.databus2.relay.GoldenGateEventProducer) InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException) GoldenGateEventProducer(com.linkedin.databus2.relay.GoldenGateEventProducer)

Example 3 with EventProducer

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()));
        }
    }
}
Also used : EventProducer(com.linkedin.databus2.producers.EventProducer)

Example 4 with EventProducer

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);
}
Also used : EventProducer(com.linkedin.databus2.producers.EventProducer)

Example 5 with EventProducer

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()));
        }
    }
}
Also used : EventProducer(com.linkedin.databus2.producers.EventProducer) RequestProcessingException(com.linkedin.databus2.core.container.request.RequestProcessingException)

Aggregations

EventProducer (com.linkedin.databus2.producers.EventProducer)14 ArrayList (java.util.ArrayList)13 Checkpoint (com.linkedin.databus.core.Checkpoint)9 DatabusV2ConsumerRegistration (com.linkedin.databus.client.consumer.DatabusV2ConsumerRegistration)8 MultiConsumerCallback (com.linkedin.databus.client.consumer.MultiConsumerCallback)8 StreamConsumerCallbackFactory (com.linkedin.databus.client.consumer.StreamConsumerCallbackFactory)8 DbusEvent (com.linkedin.databus.core.DbusEvent)8 DatabusSubscription (com.linkedin.databus.core.data_model.DatabusSubscription)8 DbusEventAppender (com.linkedin.databus.core.test.DbusEventAppender)8 DbusEventGenerator (com.linkedin.databus.core.test.DbusEventGenerator)8 IdNamePair (com.linkedin.databus.core.util.IdNamePair)8 UncaughtExceptionTrackingThread (com.linkedin.databus.core.util.UncaughtExceptionTrackingThread)8 SelectingDatabusCombinedConsumer (com.linkedin.databus.client.consumer.SelectingDatabusCombinedConsumer)7 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)7 RegisterResponseEntry (com.linkedin.databus2.core.container.request.RegisterResponseEntry)7 RelayEventProducer (com.linkedin.databus2.producers.RelayEventProducer)7 OracleEventProducer (com.linkedin.databus2.producers.db.OracleEventProducer)7 HashMap (java.util.HashMap)7 List (java.util.List)7 Vector (java.util.Vector)7