Package com.linkedin.databus.client.pub

Examples of com.linkedin.databus.client.pub.DatabusClientException


  public DatabusRegistration register(DatabusCombinedConsumer consumer,
                                      String... sources)
               throws DatabusClientException
  {
    if ((null == consumer))
      throw new DatabusClientException("No consumer callback has been specified.");

    if ((null == sources) || (sources.length == 0))
      throw new DatabusClientException("Please specify Databus sources to be consumed: register(consumer, source1, source2, ...");

    RegistrationId regId =
        RegistrationIdGenerator.generateNewId(consumer.getClass().getSimpleName(),
                                              DatabusSubscription.createSubscriptionList(Arrays.asList(sources)));
    DatabusV2RegistrationImpl reg = new DatabusV2RegistrationImpl(regId,
View Full Code Here


               Collection<DatabusCombinedConsumer> consumers,
               String... sources)
        throws DatabusClientException
  {
    if ((null == consumers|| (consumers.isEmpty()))
      throw new DatabusClientException("No consumer callbacks have been specified.");

    if ((null == sources) || (sources.length == 0))
      throw new DatabusClientException("Please specify Databus sources to be consumed: register(consumer, source1, source2, ...");

    RegistrationId regId =
        RegistrationIdGenerator.generateNewId(consumers.iterator().next().getClass().getSimpleName(),
                                              DatabusSubscription.createSubscriptionList(Arrays.asList(sources)));
    DatabusV2RegistrationImpl reg = new DatabusV2RegistrationImpl(regId,
View Full Code Here

                                             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());
View Full Code Here

  {
    List<ServerInfo> candidateServers = findServers(groupsServers, sources);
    if (0 == candidateServers.size())
    {

      throw new DatabusClientException("Unable to find servers to support sources: " + sources);
    }
    Random rng = new Random();
    ServerInfo randomRelay = candidateServers.get(rng.nextInt(candidateServers.size()));
    return randomRelay;
  }
View Full Code Here

      {
        subsSources = DatabusSubscription.createFromUriList(randomRelay.getSources());
      }
      catch (DatabusException e)
      {
        throw new DatabusClientException("source list decode error:" + e.getMessage(), e);
      }
      catch (URISyntaxException e)
      {
        throw new DatabusClientException("source list decode error:" + e.getMessage(), e);
      }
    }
    List<DatabusV2ConsumerRegistration> consumers = getListOfConsumerRegsFromSubList(groupsListeners, subsSources);
    if (null == consumers)
    {
View Full Code Here

    if ( _state != RegistrationState.REGISTERED)
      throw new IllegalStateException("Registration (" + _id + ") not in startable state !! Current State is :" + _state);

    if ( (null == _sources) || (_sources.isEmpty()))
      throw new DatabusClientException("Registration (" + _id + ") does not have any sources to start !!");

    if ( (null == _consumers) || (_consumers.isEmpty()))
      throw new DatabusClientException("Registration (" + _id + ") does not have any consumers to start !!");

    List<ServerInfo> relays = _client.getRelays();
    List<ServerInfo> bootstrapServers = _client.getBootstrapServices();

    List<DatabusCombinedConsumer> streamConsumers = new ArrayList<DatabusCombinedConsumer>();
    List<DatabusCombinedConsumer> bootstrapConsumers = new ArrayList<DatabusCombinedConsumer>();

    if ( (null == relays) || ( relays.isEmpty()))
      throw new DatabusClientException("No configured relays in the client to start");

    Set<ServerInfo> candidateRelays = new HashSet<ServerInfo>();

    for (ServerInfo s : relays)
    {
      if (canServe(s, _sources))
        candidateRelays.add(s);
    }

    if (candidateRelays.isEmpty())
      throw new DatabusClientException("No candidate relays for source : " + _sources);

    streamConsumers.addAll(_consumers);

    boolean canConsumerBootstrap = false;
    _streamConsumerRawRegistrations = new ArrayList<DatabusV2ConsumerRegistration>();
    _streamConsumerRawRegistrations.add(new DatabusV2ConsumerRegistration(streamConsumers, _sources, _filterConfig));

    for (DatabusCombinedConsumer c : _consumers)
    {
      if ( c.canBootstrap())
      {
        canConsumerBootstrap = true;
        bootstrapConsumers.add(c);
      }
    }

    boolean enableBootstrap = _client.getClientStaticConfig().getRuntime().getBootstrap().isEnabled();
    Set<ServerInfo> candidateBootstrapServers = new HashSet<ServerInfo>();

    if (enableBootstrap && canConsumerBootstrap)
    {
      if ( (null == bootstrapServers) || ( bootstrapServers.isEmpty()))
        throw new DatabusClientException("No configured bootstrap servers in the client to start");

      for (ServerInfo s : bootstrapServers)
      {
        if (canServe(s,_sources))
          candidateBootstrapServers.add(s);
      }

      if (candidateBootstrapServers.isEmpty())
        throw new DatabusClientException("No candidate bootstrap servers for source : " + _sources);

      _bootstrapConsumerRawRegistrations = new ArrayList<DatabusV2ConsumerRegistration>();;
      _bootstrapConsumerRawRegistrations.add(new DatabusV2ConsumerRegistration(bootstrapConsumers, _sources, _filterConfig));
    }
View Full Code Here

    try
    {
      subs = DatabusSubscription.createFromUriList(sources);
    } catch (Exception ex) {
      throw new DatabusClientException(ex);
    }
    return subs;
  }
View Full Code Here

  {
    if ( (_id != null) && (_id.equals(regId)))
      return this;

    if (! RegistrationIdGenerator.isIdValid(regId))
      throw new DatabusClientException("Another registration with the same regId (" + regId + ") already present !!");

    if (_state.isRunning())
      throw new IllegalStateException("Cannot update regId when registration is in running state. RegId :" + _id + ", State :" + _state);

    _id = regId;
View Full Code Here

    try {
      _cluster = createCluster();
      _cluster.start();
    } catch (Exception e) {
      _log.fatal("Got exception while trying to create the cluster with id (" + id + ")", e);
      throw new DatabusClientException(e);
    }

    initializeStatsCollectors();

    _log.info("Dabatus cluster object created : " + _cluster + " with id :" + id);

    _clusterMember = _cluster.addMember(id,this);

    boolean joined = _clusterMember.join();

    if ( ! joined )
    {
      _log.fatal("Unable to join the cluster "  + _clusterInfo);
      throw new DatabusClientException("Unable to join the cluster :" + _clusterInfo);
    }
    _state =RegistrationState.STARTED;
    activatePartitions();
    return true;
  }
View Full Code Here

  {
    if ( (_id != null) && (_id.equals(regId)))
      return this;

    if (! RegistrationIdGenerator.isIdValid(regId))
      throw new DatabusClientException("Another registration with the same regId (" + regId + ") already present !!");

    if (_state.isRunning())
      throw new IllegalStateException("Cannot update regId when registration is in running state. RegId :" + _id + ", State :" + _state);

    _id = regId;
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.DatabusClientException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.