Package org.apache.twill.discovery

Examples of org.apache.twill.discovery.Discoverable


    return new InetSocketAddress(address, port);
  }

  @Override
  protected void run() throws Exception {
    serviceCancellable = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.EXTERNAL_AUTHENTICATION;
      }
View Full Code Here


    LOG.info("Starting {}...", ExploreExecutorService.class.getSimpleName());

    exploreService.startAndWait();

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

    this.picker = new RandomEndpointStrategy(discoverables);
  }

  @Override
  public Discoverable pick() {
    Discoverable lastPick = this.lastPick;
    if (lastPick == null || !isValid(lastPick)) {
      this.lastPick = lastPick = picker.pick();
    }
    return lastPick;
  }
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

    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

      JsonArray entryJson = element.getAsJsonArray();
      if (entryJson.size() != 2) {
        throw new JsonParseException("Expect json array of size = 2, got " + entryJson.size());
      }
      Discoverable key = context.deserialize(entryJson.get(0), Discoverable.class);
      PartitionReplica value = context.deserialize(entryJson.get(1), PartitionReplica.class);
      assignments.put(key, value);
    }

    return new ResourceAssignment(name, assignments);
View Full Code Here

    final String service = jsonObj.get("service").getAsString();
    String hostname = jsonObj.get("hostname").getAsString();
    int port = jsonObj.get("port").getAsInt();
    final InetSocketAddress address = new InetSocketAddress(hostname, port);

    return new Discoverable() {
      @Override
      public String getName() {
        return service;
      }
View Full Code Here

      this.discoveryService = discoveryService;
    }

    @Override
    public Cancellable announce(final String serviceName, final int port) {
      return discoveryService.register(new Discoverable() {
        @Override
        public String getName() {
          return serviceName;
        }
View Full Code Here

      public void running() {
        final InetSocketAddress socketAddress = httpService.getBindAddress();
        LOG.info("AppFabric HTTP Service started at {}", socketAddress);

        // When it is running, register it with service discovery
        cancellable = discoveryService.register(new Discoverable() {

          @Override
          public String getName() {
            return Constants.Service.APP_FABRIC_HTTP;
          }
View Full Code Here

    return cancel;
  }

  @Override
  public Cancellable announce(final String serviceName, final int port) {
    return 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.