Search in sources :

Example 11 with DatabusClientException

use of com.linkedin.databus.client.pub.DatabusClientException in project databus by linkedin.

the class DatabusV2RegistrationImpl method withRegId.

@Override
public synchronized DatabusRegistration withRegId(RegistrationId regId) throws DatabusClientException, IllegalStateException {
    if ((_id != null) && (_id.equals(regId)))
        return this;
    if (!RegistrationIdGenerator.isIdValid(regId))
        throw new DatabusClientException("Another registration with the same regId (" + regId + ") already present !!");
    if (_state.isRunning())
        throw new IllegalStateException("Cannot update regId when registration is in running state. RegId :" + _id + ", State :" + _state);
    _id = regId;
    // Component Status should use the correct component name
    _status = new Status();
    return this;
}
Also used : DatabusComponentStatus(com.linkedin.databus.core.DatabusComponentStatus) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException)

Example 12 with DatabusClientException

use of com.linkedin.databus.client.pub.DatabusClientException in project databus by linkedin.

the class DatabusHttpClientImpl method doStart.

@Override
protected void doStart() {
    super.doStart();
    LOG.info("relay consumers: " + getRelayGroupStreamConsumers().size());
    LOG.info("bootstrap consumers: " + getRelayGroupBootstrapConsumers().size());
    if (_clientNode != null && _clientNode.isEnabled()) {
        if (!waitForLeadership()) {
            LOG.error("Error acquiring leadership! Not starting client");
            return;
        }
    }
    _httpStatsCollector.registerMastershipStatus(1);
    if (!getClientStaticConfig().usesDynamicRelayConfiguration()) {
        initializeRelayConnections();
        for (DatabusRegistration r : _regList) {
            if (!r.getState().isRunning()) {
                try {
                    LOG.info("Registration (" + r.getRegistrationId() + ") has not been started yet !! Starting !!");
                    r.start();
                } catch (DatabusClientException e) {
                    LOG.error("Got exception while starting registration !!", e);
                    throw new RuntimeException(e);
                }
            }
        }
    } else {
        // The connections are made during registerDatabusListener call and not when the client is started
        LOG.info("Client with dynamically configured relays: relay connections will be initialized during register call");
    }
    if ((_dscUpdater != null) && _dscUpdater.isRunning()) {
        _dscUpdater.stop();
    }
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException)

Example 13 with DatabusClientException

use of com.linkedin.databus.client.pub.DatabusClientException in project databus by linkedin.

the class DatabusHttpClientImpl method getRandomRelay.

/**
   *
   * @throws DatabusClientException
   */
protected ServerInfo getRandomRelay(Map<List<DatabusSubscription>, Set<ServerInfo>> groupsServers, List<DatabusSubscription> sources) throws DatabusClientException {
    List<ServerInfo> candidateServers = findServers(groupsServers, sources);
    if (0 == candidateServers.size()) {
        throw new DatabusClientException("Unable to find servers to support sources: " + sources);
    }
    Random rng = new Random();
    ServerInfo randomRelay = candidateServers.get(rng.nextInt(candidateServers.size()));
    return randomRelay;
}
Also used : Random(java.util.Random) ServerInfo(com.linkedin.databus.client.pub.ServerInfo) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException)

Example 14 with DatabusClientException

use of com.linkedin.databus.client.pub.DatabusClientException in project databus by linkedin.

the class DatabusHttpClientImpl method register.

@Override
public DatabusRegistration register(Collection<DatabusCombinedConsumer> consumers, String... sources) throws DatabusClientException {
    if ((null == consumers) || (consumers.isEmpty()))
        throw new DatabusClientException("No consumer callbacks have been specified.");
    if ((null == sources) || (sources.length == 0))
        throw new DatabusClientException("Please specify Databus sources to be consumed: register(consumer, source1, source2, ...");
    RegistrationId regId = RegistrationIdGenerator.generateNewId(consumers.iterator().next().getClass().getSimpleName(), DatabusSubscription.createSubscriptionList(Arrays.asList(sources)));
    DatabusV2RegistrationImpl reg = new DatabusV2RegistrationImpl(regId, this, getCheckpointPersistenceProvider());
    reg.addDatabusConsumers(consumers);
    reg.addSubscriptions(sources);
    _regList.add(reg);
    reg.onRegister();
    return reg;
}
Also used : RegistrationId(com.linkedin.databus.client.pub.RegistrationId) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) DatabusV2RegistrationImpl(com.linkedin.databus.client.registration.DatabusV2RegistrationImpl)

Aggregations

DatabusClientException (com.linkedin.databus.client.pub.DatabusClientException)14 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)4 DatabusCombinedConsumer (com.linkedin.databus.client.pub.DatabusCombinedConsumer)3 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)3 ServerInfo (com.linkedin.databus.client.pub.ServerInfo)3 DatabusException (com.linkedin.databus2.core.DatabusException)3 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)2 AbstractDatabusCombinedConsumer (com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer)2 DatabusV2ConsumerRegistration (com.linkedin.databus.client.consumer.DatabusV2ConsumerRegistration)2 ClusterCheckpointPersistenceProvider (com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider)2 ClusterCheckpointException (com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider.ClusterCheckpointException)2 DatabusV2RegistrationImpl (com.linkedin.databus.client.registration.DatabusV2RegistrationImpl)2 DatabusComponentStatus (com.linkedin.databus.core.DatabusComponentStatus)2 DatabusSubscription (com.linkedin.databus.core.data_model.DatabusSubscription)2 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)2 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)2 Test (org.testng.annotations.Test)2 DatabusSourcesConnection (com.linkedin.databus.client.DatabusSourcesConnection)1 StaticConfig (com.linkedin.databus.client.DatabusSourcesConnection.StaticConfig)1