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;
}
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();
}
}
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;
}
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;
}
Aggregations