use of com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl in project databus by linkedin.
the class DatabusHttpClientImpl method registerCluster.
@Override
public DatabusRegistration registerCluster(String cluster, DbusClusterConsumerFactory consumerFactory, DbusServerSideFilterFactory filterFactory, DbusPartitionListener partitionListener, String... sources) throws DatabusClientException {
if ((null == sources) || (sources.length == 0))
throw new DatabusClientException("Sources is empty !!");
if (_activeClusters.contains(cluster))
throw new DatabusClientException("Cluster :" + cluster + " has already been registed to this client instance." + " Only one registration per cluster is allowed for a databus client instance !!");
ClusterRegistrationStaticConfig c = _clientStaticConfig.getClientCluster(cluster);
if (null == c)
throw new DatabusClientException("Cluster Configuration for cluster (" + cluster + ") not provided !!");
if (null == consumerFactory)
throw new DatabusClientException("Consumer Factory is null !!");
ClusterCheckpointPersistenceProvider.StaticConfig ckptPersistenceProviderConfig = new ClusterCheckpointPersistenceProvider.StaticConfig(c.getZkAddr(), c.getClusterName(), c.getMaxCkptWritesSkipped(), c.getCheckpointIntervalMs());
DbusClusterInfo clusterInfo = new DbusClusterInfo(c.getClusterName(), c.getNumPartitions(), c.getQuorum());
RegistrationId regId = RegistrationIdGenerator.generateNewId(c.getClusterName());
DatabusV2ClusterRegistrationImpl reg = new DatabusV2ClusterRegistrationImpl(regId, this, ckptPersistenceProviderConfig, clusterInfo, consumerFactory, filterFactory, partitionListener, sources);
_regList.add(reg);
reg.onRegister();
_activeClusters.add(cluster);
return reg;
}
use of com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl in project databus by linkedin.
the class ClientStateRequestProcessor method getV2PartitionRegistration.
/**
* Helper method to get partition registration information for a given V2 Cluster
* partition
*
* @param cluster
* V2 Cluster
* @param partition
* Partition in the cluster.
* @return
* @throws RequestProcessingException
* When cluster or partition is not hosted in this instance.
*/
private RegInfo getV2PartitionRegistration(String cluster, long partition) throws RequestProcessingException {
DatabusV2ClusterRegistrationImpl reg = getV2ClusterRegistration(cluster);
DbusPartitionInfo p = new DbusPartitionInfoImpl(partition);
DatabusRegistration r = reg.getPartitionRegs().get(p);
if (null == r)
throw new RequestProcessingException("Partition(" + partition + ") for cluster (" + cluster + ") not found !!");
return new RegInfo(r.getState().name(), r.getRegistrationId(), r.getStatus(), r.getFilterConfig(), r.getSubscriptions());
}
use of com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl in project databus by linkedin.
the class ClientStateRequestProcessor method getV2ClusterPartitions.
/**
* Get the list of partitions hosted by this client for the V2 cluster.
*
* @param cluster
* V2 CLuster for which we need to find out the partitions.
* @return
* @throws RequestProcessingException
* when unable to find the cluster.
*/
private Collection<PartitionInfo> getV2ClusterPartitions(String cluster) throws RequestProcessingException {
DatabusV2ClusterRegistrationImpl reg = getV2ClusterRegistration(cluster);
List<PartitionInfo> partitions = new ArrayList<PartitionInfo>();
Map<DbusPartitionInfo, DatabusRegistration> regMap = reg.getPartitionRegs();
for (Entry<DbusPartitionInfo, DatabusRegistration> e : regMap.entrySet()) {
PartitionInfo p = new PartitionInfo(e.getKey().getPartitionId(), e.getValue().getRegistrationId());
partitions.add(p);
}
return partitions;
}
use of com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl 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;
}
Aggregations