use of com.linkedin.databus.client.pub.DatabusV3Registration in project databus by linkedin.
the class ClientStateRequestProcessor method processMPRegistrations.
/**
* Exposes the mapping between a mpRegistration -> Set of individual registrations
*
*/
private void processMPRegistrations(DatabusRequest request) throws IOException, RequestProcessingException {
Map<RegistrationId, DatabusV3Registration> registrationIdMap = _client.getRegistrationIdMap();
if (null == registrationIdMap)
throw new InvalidRequestParamValueException(request.getName(), REGISTRATIONS_KEY, "Present only for Databus V3 clients");
Map<String, List<String>> ridList = new TreeMap<String, List<String>>();
for (Map.Entry<RegistrationId, DatabusV3Registration> entry : registrationIdMap.entrySet()) {
DatabusV3Registration reg = entry.getValue();
if (reg instanceof DatabusV3MultiPartitionRegistration) {
Collection<DatabusV3Registration> dvrList = ((DatabusV3MultiPartitionRegistration) reg).getPartionRegs().values();
List<String> mpRegList = new ArrayList<String>();
for (DatabusV3Registration dvr : dvrList) {
mpRegList.add(dvr.getRegistrationId().getId());
}
ridList.put(entry.getKey().getId(), mpRegList);
}
}
writeJsonObjectToResponse(ridList, request);
return;
}
use of com.linkedin.databus.client.pub.DatabusV3Registration in project databus by linkedin.
the class ClientStateRequestProcessor method processRegistrations.
/**
* Displays all top-level registrations registered to the client (both V2 and V3).
* 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, V2/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.
*
* @param request
* DatabusRequest corresponding to the REST API.
* @throws IOException
* when unable to write to ourput channel
*/
private void processRegistrations(DatabusRequest request) throws IOException {
Map<String, Collection<DatabusSubscription>> regIds = new TreeMap<String, Collection<DatabusSubscription>>();
// V2 Registration
Collection<RegInfo> regs = getAllTopLevelV2Registrations();
if (null != regs) {
for (RegInfo r : regs) {
regIds.put(r.getRegId().getId(), r.getSubs());
}
}
Map<RegistrationId, DatabusV3Registration> registrationIdMap = _client.getRegistrationIdMap();
// V3 Registration
if (null != registrationIdMap) {
for (Map.Entry<RegistrationId, DatabusV3Registration> entry : registrationIdMap.entrySet()) {
DatabusV3Registration reg = entry.getValue();
List<DatabusSubscription> dsl = reg.getSubscriptions();
regIds.put(entry.getKey().getId(), dsl);
}
}
writeJsonObjectToResponse(regIds, request);
}
use of com.linkedin.databus.client.pub.DatabusV3Registration in project databus by linkedin.
the class ClientStatsRequestProcessor method processBootstrapEventsRegistrationV3.
private void processBootstrapEventsRegistrationV3(DatabusRequest request) throws IOException, RequestProcessingException {
DatabusV3Registration reg = findV3Registration(request, BOOTSTRAP_EVENTS_REG_KEY_PREFIX);
writeJsonObjectToResponse(reg.getBootstrapEventStats().getTotalStats(), request);
}
use of com.linkedin.databus.client.pub.DatabusV3Registration in project databus by linkedin.
the class ClientStateRequestProcessor method getV3ClusterPartitions.
/**
* Get the list of partitions hosted by this client for the V3 cluster.
*
* @param cluster
* V3 CLuster for which we need to find out the partitions.
* @return
* @throws RequestProcessingException
* when unable to find the cluster.
*/
private Collection<PartitionInfo> getV3ClusterPartitions(String cluster) throws RequestProcessingException {
DatabusV3MultiPartitionRegistration reg = getV3ClusterRegistration(cluster);
List<PartitionInfo> partitions = new ArrayList<PartitionInfo>();
Map<PhysicalPartition, DatabusV3Registration> regMap = reg.getPartionRegs();
for (Entry<PhysicalPartition, DatabusV3Registration> e : regMap.entrySet()) {
PartitionInfo p = new PartitionInfo(e.getKey().getId(), e.getValue().getRegistrationId());
partitions.add(p);
}
return partitions;
}
use of com.linkedin.databus.client.pub.DatabusV3Registration 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