Package org.apache.twill.discovery

Examples of org.apache.twill.discovery.Discoverable


    LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Constants.Logging.SYSTEM_NAME,
                                                                       Constants.Logging.COMPONENT_NAME,
                                                                       Constants.Service.LOGSAVER));
    httpService.startAndWait();

    cancellable = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.LOGSAVER;
      }
View Full Code Here


    LOG.info("Starting Metrics Service...");
    httpService.startAndWait();
    LOG.info("Started Metrics HTTP Service...");
    // Register the service
    cancelDiscovery = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.METRICS;
      }
View Full Code Here

                                                                       Constants.Logging.COMPONENT_NAME,
                                                                       Constants.Service.METRICS_PROCESSOR));
    httpService.startAndWait();
    LOG.info("MetricsProcessor Service started");

    cancellable = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.METRICS_PROCESSOR;
      }
View Full Code Here

                                  TxConstants.Service.DEFAULT_DATA_TX_BIND_ADDRESS);
      port = configuration.getInt(TxConstants.Service.CFG_DATA_TX_BIND_PORT,
                                  TxConstants.Service.DEFAULT_DATA_TX_BIND_PORT);
      LOG.info("Service assumed at " + address + ":" + port);
    } else {
      Discoverable endpoint = endpointStrategy.pick();
      if (endpoint == null) {
        LOG.error("Unable to discover tx service.");
        throw new TException("Unable to discover tx service.");
      }
      address = endpoint.getSocketAddress().getHostName();
      port = endpoint.getSocketAddress().getPort();
      LOG.info("Service discovered at " + address + ":" + port);
    }

    // now we have an address and port, try to connect a client
    if (timeout < 0) {
View Full Code Here

      this.timeoutUnit = timeoutUnit;
    }

    @Override
    public Discoverable pick() {
      Discoverable pick = delegate.pick();
      try {
        long count = 0;
        while (pick == null && count++ < timeout) {
          timeoutUnit.sleep(1);
          pick = delegate.pick();
View Full Code Here

    }

    @Override
    public Discoverable pick() {
      // Reservoir sampling
      Discoverable result = null;
      Iterator<Discoverable> itor = endpoints.iterator();
      Random random = new Random();
      int count = 0;
      while (itor.hasNext()) {
        Discoverable next = itor.next();
        if (random.nextInt(++count) == 0) {
          result = next;
        }
      }
      return result;
View Full Code Here

      cancelDiscovery.cancel();
    }
  }

  protected void doRegister() {
    cancelDiscovery = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return serviceName;
      }
View Full Code Here

TOP

Related Classes of org.apache.twill.discovery.Discoverable

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.