Examples of watchChanges()


Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

      getContext().announce(SERVICE_NAME, port);

      final CountDownLatch discoveredLatch = new CountDownLatch(1);

      ServiceDiscovered serviceDiscovered = getContext().discover(SERVICE_NAME);
      serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() {
        @Override
        public void onChange(ServiceDiscovered serviceDiscovered) {
          // Try to find a discoverable that is not this instance
          for (Discoverable discoverable : serviceDiscovered) {
            int discoveredPort = discoverable.getSocketAddress().getPort();
View Full Code Here

Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

      getContext().announce(SERVICE_NAME, port);

      final CountDownLatch discoveredLatch = new CountDownLatch(1);

      ServiceDiscovered serviceDiscovered = getContext().discover(SERVICE_NAME);
      serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() {
        @Override
        public void onChange(ServiceDiscovered serviceDiscovered) {
          // Try to find a discoverable that is not this instance
          for (Discoverable discoverable : serviceDiscovered) {
            int discoveredPort = discoverable.getSocketAddress().getPort();
View Full Code Here

Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

    if (discoverable != null) {
      return createURL(discoverable, applicationId, serviceName);
    }

    final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
    Cancellable discoveryCancel = serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() {
      @Override
      public void onChange(ServiceDiscovered serviceDiscovered) {
        try {
          URL url = createURL(serviceDiscovered.iterator().next(), applicationId, serviceName);
          discoverableQueue.offer(url);
View Full Code Here

Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

    httpService.startAndWait();

    // setting watch for ops executor service that we need to be running to operate correctly
    ServiceDiscovered discover = discoveryServiceClient.discover(Constants.Service.DATASET_EXECUTOR);
    opExecutorDiscovered = SettableFuture.create();
    opExecutorServiceWatch = discover.watchChanges(
      new ServiceDiscovered.ChangeListener() {
        @Override
        public void onChange(ServiceDiscovered serviceDiscovered) {
          if (!Iterables.isEmpty(serviceDiscovered)) {
            LOG.info("Discovered {} service", Constants.Service.DATASET_EXECUTOR);
View Full Code Here

Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

    if (discoverable != null) {
      return createURL(discoverable, applicationId, serviceId);
    }

    final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
    Cancellable discoveryCancel = serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() {
      @Override
      public void onChange(ServiceDiscovered serviceDiscovered) {
        try {
          URL url = createURL(serviceDiscovered.iterator().next(), applicationId, serviceId);
          discoverableQueue.offer(url);
View Full Code Here

Examples of org.apache.twill.discovery.ServiceDiscovered.watchChanges()

  @Override
  protected void startUp() throws Exception {
    // Wait till DatasetService is discovered then start the scheduler.
    ServiceDiscovered discover = discoveryServiceClient.discover(Constants.Service.DATASET_MANAGER);
    cancellable = discover.watchChanges(
      new ServiceDiscovered.ChangeListener() {
        @Override
        public void onChange(ServiceDiscovered serviceDiscovered) {
          if (!Iterables.isEmpty(serviceDiscovered) && !schedulerStarted.get()) {
            LOG.info("Starting scheduler, Discovered {} dataset service(s)",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.