Search in sources :

Example 6 with DbusPartitionInfo

use of com.linkedin.databus.client.pub.DbusPartitionInfo 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();
    }
}
Also used : DbusPartitionInfoImpl(com.linkedin.databus.client.DbusPartitionInfoImpl) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException)

Example 7 with DbusPartitionInfo

use of com.linkedin.databus.client.pub.DbusPartitionInfo 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();
    }
}
Also used : DatabusException(com.linkedin.databus2.core.DatabusException) DbusPartitionInfoImpl(com.linkedin.databus.client.DbusPartitionInfoImpl) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo)

Example 8 with DbusPartitionInfo

use of com.linkedin.databus.client.pub.DbusPartitionInfo 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();
}
Also used : DatabusV3MultiPartitionRegistration(com.linkedin.databus.client.pub.DatabusV3MultiPartitionRegistration) HashMap(java.util.HashMap) RegistrationId(com.linkedin.databus.client.pub.RegistrationId) DatabusV3Registration(com.linkedin.databus.client.pub.DatabusV3Registration) DbusPartitionInfoImpl(com.linkedin.databus.client.DbusPartitionInfoImpl) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo) PhysicalPartition(com.linkedin.databus.core.data_model.PhysicalPartition)

Example 9 with DbusPartitionInfo

use of com.linkedin.databus.client.pub.DbusPartitionInfo in project databus by linkedin.

the class ClientStatsRequestProcessor method findRegistration.

private DatabusRegistration findRegistration(DatabusRequest request, String prefix) throws RequestProcessingException {
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    String registrationIdStr = category.substring(prefix.length());
    RegistrationId regId = new RegistrationId(registrationIdStr);
    Collection<DatabusRegistration> regs = _client.getAllRegistrations();
    for (DatabusRegistration r : regs) {
        if (regId.equals(r.getRegistrationId()))
            return r;
        if (r instanceof DatabusMultiPartitionRegistration) {
            Map<DbusPartitionInfo, DatabusRegistration> childRegs = ((DatabusMultiPartitionRegistration) r).getPartitionRegs();
            for (Entry<DbusPartitionInfo, DatabusRegistration> e : childRegs.entrySet()) if (regId.equals(e.getValue().getRegistrationId()))
                return e.getValue();
        }
    }
    throw new RequestProcessingException("Unable to find registration (" + regId + ") ");
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) DatabusMultiPartitionRegistration(com.linkedin.databus.client.registration.DatabusMultiPartitionRegistration) RegistrationId(com.linkedin.databus.client.pub.RegistrationId) RequestProcessingException(com.linkedin.databus2.core.container.request.RequestProcessingException) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo)

Example 10 with DbusPartitionInfo

use of com.linkedin.databus.client.pub.DbusPartitionInfo in project databus by linkedin.

the class MockRemoteExceptionHandler method createFakeFilter.

private static DbusKeyCompositeFilterConfig createFakeFilter() throws DatabusException {
    DbusModPartitionedFilterFactory filterFactory = new DbusModPartitionedFilterFactory("source1");
    DbusClusterInfo cluster = new DbusClusterInfo("cluster", 2, 2);
    DbusPartitionInfo partition = new DbusPartitionInfo() {

        @Override
        public long getPartitionId() {
            return 1;
        }

        @Override
        public boolean equalsPartition(DbusPartitionInfo other) {
            return true;
        }
    };
    return filterFactory.createServerSideFilter(cluster, partition);
}
Also used : DbusClusterInfo(com.linkedin.databus.client.pub.DbusClusterInfo) DbusModPartitionedFilterFactory(com.linkedin.databus.client.pub.DbusModPartitionedFilterFactory) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo)

Aggregations

DbusPartitionInfo (com.linkedin.databus.client.pub.DbusPartitionInfo)10 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)5 DbusPartitionInfoImpl (com.linkedin.databus.client.DbusPartitionInfoImpl)4 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)3 DatabusMultiPartitionRegistration (com.linkedin.databus.client.registration.DatabusMultiPartitionRegistration)3 RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DbusClusterInfo (com.linkedin.databus.client.pub.DbusClusterInfo)2 DatabusV2ClusterRegistrationImpl (com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl)2 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)1 StaticConfig (com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider.StaticConfig)1 DatabusClientException (com.linkedin.databus.client.pub.DatabusClientException)1 DatabusV3MultiPartitionRegistration (com.linkedin.databus.client.pub.DatabusV3MultiPartitionRegistration)1 DatabusV3Registration (com.linkedin.databus.client.pub.DatabusV3Registration)1 DbusModPartitionedFilterFactory (com.linkedin.databus.client.pub.DbusModPartitionedFilterFactory)1 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)1 DatabusException (com.linkedin.databus2.core.DatabusException)1 DbusKeyCompositeFilterConfig (com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig)1 InetSocketAddress (java.net.InetSocketAddress)1