use of com.linkedin.databus.client.DbusPartitionInfoImpl 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.DbusPartitionInfoImpl in project databus by linkedin.
the class DatabusV2ClusterRegistrationImpl method onGainedPartitionOwnership.
@Override
public synchronized void onGainedPartitionOwnership(int partition) {
_log.info("Partition (" + partition + ") getting added !!");
DbusPartitionInfo partitionInfo = new DbusPartitionInfoImpl(partition);
try {
addPartition(partitionInfo);
} catch (DatabusClientException e) {
_log.error("Unable to add partition. Shutting down the cluster !!", e);
deregister();
}
}
use of com.linkedin.databus.client.DbusPartitionInfoImpl in project databus by linkedin.
the class DatabusV2ClusterRegistrationImpl method onLostPartitionOwnership.
@Override
public synchronized void onLostPartitionOwnership(int partition) {
_log.info("Partition (" + partition + ") getting removed !!");
DbusPartitionInfo partitionInfo = new DbusPartitionInfoImpl(partition);
try {
dropOnePartition(partitionInfo);
} catch (DatabusException e) {
_log.error("Unable to drop partition. Shutting down the cluster !!", e);
deregister();
}
}
use of com.linkedin.databus.client.DbusPartitionInfoImpl in project databus by linkedin.
the class ClientStateRequestProcessor method getAllTopLevelV3Registrations.
/**
* Returns all the top-level V3 registrations. Top-level registrations are those that
* were created as a result of one of "registerXXX()" calls on databus-client. In the
* case of multi-partition registrations (like MPRegistration, V3 CLB), only the parent
* registration is considered the top-level registration. Per-partition (child)
* registrations which were created as part of partition migration are NOT top-level
* registrations.
*
* @return collection of top-level registrations (V3)
*/
private Collection<RegInfo> getAllTopLevelV3Registrations() {
/**
* Important Note: There is an important implementation difference on which
* registrations are stored in the global registration data-structure maintained by
* the client (DatabusHttp[V3]ClientImpls) between V2 and V3.
*
* 1. In the case of V2, only top-level registrations are stored in the global
* data-structure (DatabusHttpClientImpl.regList 2. In the case of V3, all
* registrations are stored in the global data-structure.
*
* In the case of V3, this is needed so that all registrations can act on the relay
* external view change. This can be refactored in the future by moving the
* relay-external view change to registration impl ( reduce the complexity in
* ClientImpl ). The V2 implementation did not have this logic and was following a
* more intuitive structure of preserving the hierarchy.
*/
Map<RegistrationId, RegInfo> regListMap = new HashMap<RegistrationId, RegInfo>();
/**
* The _client.getRegistrationIdMap() has all registrations in one place. Top-Level
* Registrations = Only those registrations whose getParent() == null.
*/
Map<RegistrationId, DatabusV3Registration> regMap = _client.getRegistrationIdMap();
for (Entry<RegistrationId, DatabusV3Registration> e : regMap.entrySet()) {
RegInfo regInfo = null;
DatabusV3Registration r = e.getValue();
// If not top-level, skip
if (null != r.getParentRegistration()) {
continue;
}
Map<DbusPartitionInfo, RegInfo> childR = null;
if (r instanceof DatabusV3MultiPartitionRegistration) {
// ass the children regs to parent.
Map<PhysicalPartition, DatabusV3Registration> childRegs = ((DatabusV3MultiPartitionRegistration) r).getPartionRegs();
childR = new HashMap<DbusPartitionInfo, RegInfo>();
for (Entry<PhysicalPartition, DatabusV3Registration> e2 : childRegs.entrySet()) {
childR.put(new DbusPartitionInfoImpl(e2.getKey().getId()), new RegInfo(e.getValue().getState().name(), e.getValue().getRegistrationId(), e.getValue().getStatus(), null, e.getValue().getSubscriptions()));
}
}
regInfo = new RegInfo(r.getState().name(), r.getRegistrationId(), r.getStatus(), null, r.getSubscriptions(), true, childR);
regListMap.put(e.getKey(), regInfo);
}
return regListMap.values();
}
Aggregations