if ( _state != RegistrationState.REGISTERED)
throw new IllegalStateException("Registration (" + _id + ") not in startable state !! Current State is :" + _state);
if ( (null == _sources) || (_sources.isEmpty()))
throw new DatabusClientException("Registration (" + _id + ") does not have any sources to start !!");
if ( (null == _consumers) || (_consumers.isEmpty()))
throw new DatabusClientException("Registration (" + _id + ") does not have any consumers to start !!");
List<ServerInfo> relays = _client.getRelays();
List<ServerInfo> bootstrapServers = _client.getBootstrapServices();
List<DatabusCombinedConsumer> streamConsumers = new ArrayList<DatabusCombinedConsumer>();
List<DatabusCombinedConsumer> bootstrapConsumers = new ArrayList<DatabusCombinedConsumer>();
if ( (null == relays) || ( relays.isEmpty()))
throw new DatabusClientException("No configured relays in the client to start");
Set<ServerInfo> candidateRelays = new HashSet<ServerInfo>();
for (ServerInfo s : relays)
{
if (canServe(s, _sources))
candidateRelays.add(s);
}
if (candidateRelays.isEmpty())
throw new DatabusClientException("No candidate relays for source : " + _sources);
streamConsumers.addAll(_consumers);
boolean canConsumerBootstrap = false;
_streamConsumerRawRegistrations = new ArrayList<DatabusV2ConsumerRegistration>();
_streamConsumerRawRegistrations.add(new DatabusV2ConsumerRegistration(streamConsumers, _sources, _filterConfig));
for (DatabusCombinedConsumer c : _consumers)
{
if ( c.canBootstrap())
{
canConsumerBootstrap = true;
bootstrapConsumers.add(c);
}
}
boolean enableBootstrap = _client.getClientStaticConfig().getRuntime().getBootstrap().isEnabled();
Set<ServerInfo> candidateBootstrapServers = new HashSet<ServerInfo>();
if (enableBootstrap && canConsumerBootstrap)
{
if ( (null == bootstrapServers) || ( bootstrapServers.isEmpty()))
throw new DatabusClientException("No configured bootstrap servers in the client to start");
for (ServerInfo s : bootstrapServers)
{
if (canServe(s,_sources))
candidateBootstrapServers.add(s);
}
if (candidateBootstrapServers.isEmpty())
throw new DatabusClientException("No candidate bootstrap servers for source : " + _sources);
_bootstrapConsumerRawRegistrations = new ArrayList<DatabusV2ConsumerRegistration>();;
_bootstrapConsumerRawRegistrations.add(new DatabusV2ConsumerRegistration(bootstrapConsumers, _sources, _filterConfig));
}