use of com.linkedin.databus.client.pub.RegistrationId in project databus by linkedin.
the class DatabusHttpClientImpl method register.
@Override
public DatabusRegistration register(DatabusCombinedConsumer consumer, String... sources) throws DatabusClientException {
if ((null == consumer))
throw new DatabusClientException("No consumer callback has 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(consumer.getClass().getSimpleName(), DatabusSubscription.createSubscriptionList(Arrays.asList(sources)));
DatabusV2RegistrationImpl reg = new DatabusV2RegistrationImpl(regId, this, getCheckpointPersistenceProvider());
List<DatabusCombinedConsumer> consumers = new ArrayList<DatabusCombinedConsumer>();
consumers.add(consumer);
reg.addDatabusConsumers(consumers);
reg.addSubscriptions(sources);
_regList.add(reg);
reg.onRegister();
return reg;
}
use of com.linkedin.databus.client.pub.RegistrationId in project databus by linkedin.
the class DatabusHttpClientImpl method getAllClientClusters.
/**
* Fetch all the client clusters which have been registered in this client instance keyed by their
* registrationIds. This has been overridden by V3 client to provide both V2 and V3 clusters.
*
* Only a copy of the registration ids are returned. Hence modifying the registration ids should not
* affect the global Registration Id map.
* @return Client clusters registered in this client instance keyed by their registration ids.
*/
public Map<RegistrationId, DbusClusterInfo> getAllClientClusters() {
Map<RegistrationId, DbusClusterInfo> clusters = new HashMap<RegistrationId, DbusClusterInfo>();
Collection<DatabusMultiPartitionRegistration> regs = getAllClientClusterRegistrations();
for (DatabusMultiPartitionRegistration reg : regs) {
if (reg instanceof DatabusV2ClusterRegistrationImpl) {
DatabusV2ClusterRegistrationImpl r = (DatabusV2ClusterRegistrationImpl) reg;
clusters.put(new RegistrationId(r.getRegistrationId().getId()), r.getClusterInfo());
}
}
return clusters;
}
use of com.linkedin.databus.client.pub.RegistrationId 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;
}
use of com.linkedin.databus.client.pub.RegistrationId in project databus by linkedin.
the class RegistrationIdGenerator method generateNewId.
/**
* Queries the existing database of registrations inside the client and generates a new id different from
* any of them
*
* @param prefix : A String prefix which can be specified to precede the id to be generated. Typically this
* is the name of the Consumer class
* @param subsSources : List of subscriptions the consumer is interested in
* @return RegistrationId : Generated based on the prefix _ 8 byte md5 hash ( subscriptions ) _ count
*/
public static RegistrationId generateNewId(String prefix, Collection<DatabusSubscription> subsSources) {
StringBuilder subscription = new StringBuilder();
for (DatabusSubscription ds : subsSources) {
if (ds != null)
subscription.append(ds.generateSubscriptionString());
}
String id = generateUniqueString(prefix, subscription.toString());
RegistrationId rid = new RegistrationId(id);
return rid;
}
use of com.linkedin.databus.client.pub.RegistrationId in project databus by linkedin.
the class RegistrationIdGenerator method generateNewId.
/**
* For a given regId , this API queries the existing database of registrations inside the client.
* If the id is available, it is returned as a registration id, otherwise a running counter
* is appended to the suggested regId.
*
* @param id : A suggested name by the caller to be used as regId. If the id is not available, a running counter
* is appended
* @return RegistrationId : Generated based on the id _count
*/
public static RegistrationId generateNewId(String id) {
String r = generateUniqueString(id);
RegistrationId rid = new RegistrationId(r);
return rid;
}
Aggregations