Search in sources :

Example 1 with DatabusV2ClusterRegistrationImpl

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;
}
Also used : DatabusV2ClusterRegistrationImpl(com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl) ClusterCheckpointPersistenceProvider(com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider) DbusClusterInfo(com.linkedin.databus.client.pub.DbusClusterInfo) RegistrationId(com.linkedin.databus.client.pub.RegistrationId) ClusterRegistrationStaticConfig(com.linkedin.databus.client.registration.ClusterRegistrationStaticConfig) ClusterRegistrationStaticConfig(com.linkedin.databus.client.registration.ClusterRegistrationStaticConfig) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException)

Example 2 with DatabusV2ClusterRegistrationImpl

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());
}
Also used : DatabusV2ClusterRegistrationImpl(com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl) DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) DbusPartitionInfoImpl(com.linkedin.databus.client.DbusPartitionInfoImpl) RequestProcessingException(com.linkedin.databus2.core.container.request.RequestProcessingException) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo)

Example 3 with DatabusV2ClusterRegistrationImpl

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;
}
Also used : DatabusV2ClusterRegistrationImpl(com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl) DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) ArrayList(java.util.ArrayList) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo) DbusPartitionInfo(com.linkedin.databus.client.pub.DbusPartitionInfo)

Example 4 with DatabusV2ClusterRegistrationImpl

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;
}
Also used : DatabusV2ClusterRegistrationImpl(com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl) DbusClusterInfo(com.linkedin.databus.client.pub.DbusClusterInfo) HashMap(java.util.HashMap) DatabusMultiPartitionRegistration(com.linkedin.databus.client.registration.DatabusMultiPartitionRegistration) RegistrationId(com.linkedin.databus.client.pub.RegistrationId)

Aggregations

DatabusV2ClusterRegistrationImpl (com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl)4 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)2 DbusClusterInfo (com.linkedin.databus.client.pub.DbusClusterInfo)2 DbusPartitionInfo (com.linkedin.databus.client.pub.DbusPartitionInfo)2 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)2 DbusPartitionInfoImpl (com.linkedin.databus.client.DbusPartitionInfoImpl)1 ClusterCheckpointPersistenceProvider (com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider)1 DatabusClientException (com.linkedin.databus.client.pub.DatabusClientException)1 ClusterRegistrationStaticConfig (com.linkedin.databus.client.registration.ClusterRegistrationStaticConfig)1 DatabusMultiPartitionRegistration (com.linkedin.databus.client.registration.DatabusMultiPartitionRegistration)1 RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1