Package com.google.common.eventbus

Examples of com.google.common.eventbus.EventBus$EventWithSubscriber


      mockMonitor(null, null, new Function<Object, MonitorStatus>() {
         @Override
         public MonitorStatus apply(final Object input) {
            return MonitorStatus.DONE;
         }
      }, new EventBus());
   }
View Full Code Here


      }, new EventBus());
   }

   @Test(expectedExceptions = NullPointerException.class)
   public void testCreateMonitorWithNullFunction() {
      mockMonitor(null, new Object(), null, new EventBus());
   }
View Full Code Here

    binder.install(new PubsubEventModule());
  }

  @Override
  protected void configure() {
    final EventBus eventBus = new EventBus("TaskEvents");
    eventBus.register(new Object() {
      @Subscribe public void logDeadEvent(DeadEvent event) {
        LOG.warning("Captured dead event " + event.getEvent());
      }
    });

    bind(EventBus.class).toInstance(eventBus);

    EventSink eventSink = new EventSink() {
      @Override
      public void post(PubsubEvent event) {
        eventBus.post(event);
      }
    };
    bind(EventSink.class).toInstance(eventSink);

    // Ensure at least an empty binding is present.
View Full Code Here

            }
        } catch (ApplicationSettingsException e) {
            e.printStackTrace();
        }
        try {
            publisher = new MonitorPublisher(new EventBus());
            BetterGfacImpl.setMonitorPublisher(publisher);
            registry = RegistryFactory.getDefaultRegistry();
            setGatewayProperties();
            BetterGfacImpl.startDaemonHandlers();
            BetterGfacImpl.startStatusUpdators(registry,zk,publisher);
View Full Code Here

        this.registry = registry;
        this.airavataAPI = airavataAPI;
        this.airavataRegistry2 = airavataRegistry2;
        daemonHandlers = new ArrayList<ThreadedHandler>();
        activityListeners = new ArrayList<AbstractActivityListener>();
        monitorPublisher = new MonitorPublisher(new EventBus());     // This is a EventBus common for gfac
        startStatusUpdators();
        startDaemonHandlers();
    }
View Full Code Here

    @Test
    public void testLocalProvider() throws GFacException,GFacProviderException {
        LocalDirectorySetupHandler localDirectorySetupHandler = new LocalDirectorySetupHandler();
        localDirectorySetupHandler.invoke(jobExecutionContext);
        LocalProvider localProvider = new LocalProvider();
        localProvider.setMonitorPublisher(new MonitorPublisher(new EventBus()));
        localProvider.initialize(jobExecutionContext);
        localProvider.execute(jobExecutionContext);
        localProvider.dispose(jobExecutionContext);
    }
View Full Code Here

    private AuthenticationInfo authenticationInfo;

    public HPCPullMonitor() {
        connections = new HashMap<String, ResourceConnection>();
        this.queue = new LinkedBlockingDeque<UserMonitorData>();
        publisher = new MonitorPublisher(new EventBus());
    }
View Full Code Here

    * Provides asynchronous {@link EventBus}.
    */
   @Provides
   @Singleton
   EventBus provideSyncEventBus(DeadEventLoggingHandler deadEventsHandler) { // NO_UCD
      EventBus syncBus = new EventBus("jclouds-sync-event-bus");
      syncBus.register(deadEventsHandler);
      return syncBus;
   }
View Full Code Here

    }

    @Override
    protected void setUp() throws Exception {
      subscriber = createSubscriber();
      EventBus bus = new EventBus();
      bus.register(subscriber);
      bus.post(EVENT);
    }
View Full Code Here

    // Process test classes and resources.
    long start = System.currentTimeMillis();   
    final List<String> testClassNames = processTestResources();

    final EventBus aggregatedBus = new EventBus("aggregated");
    final TestsSummaryEventListener summaryListener = new TestsSummaryEventListener();
    aggregatedBus.register(summaryListener);
   
    for (Object o : listeners) {
      if (o instanceof ProjectComponent) {
        ((ProjectComponent) o).setProject(getProject());
      }
      if (o instanceof AggregatedEventListener) {
        ((AggregatedEventListener) o).setOuter(this);
      }
      aggregatedBus.register(o);
    }

    if (testClassNames.isEmpty()) {
      aggregatedBus.post(new AggregatedQuitEvent());
    } else {
      start = System.currentTimeMillis();
     
      final int slaveCount = determineSlaveCount(testClassNames.size());
      final List<SlaveInfo> slaveInfos = Lists.newArrayList();
      for (int slave = 0; slave < slaveCount; slave++) {
        final SlaveInfo slaveInfo = new SlaveInfo(slave, slaveCount);
        slaveInfos.add(slaveInfo);
      }

      // Order test class names identically for balancers.
      Collections.sort(testClassNames);
     
      // Prepare a pool of suites dynamically dispatched to slaves as they become idle.
      final Deque<String> stealingQueue =
          new ArrayDeque<String>(loadBalanceSuites(slaveInfos, testClassNames, balancers));
      aggregatedBus.register(new Object() {
        @Subscribe @SuppressWarnings("unused")
        public void onSlaveIdle(SlaveIdle slave) {
          if (stealingQueue.isEmpty()) {
            slave.finished();
          } else {
            String suiteName = stealingQueue.pop();
            slave.newSuite(suiteName);
          }
        }
      });

      // Create callables for the executor.
      final List<Callable<Void>> slaves = Lists.newArrayList();
      for (int slave = 0; slave < slaveCount; slave++) {
        final SlaveInfo slaveInfo = slaveInfos.get(slave);
        slaves.add(new Callable<Void>() {
          @Override
          public Void call() throws Exception {
            executeSlave(slaveInfo, aggregatedBus);
            return null;
          }
        });
      }

      ExecutorService executor = Executors.newCachedThreadPool();
      aggregatedBus.post(new AggregatedStartEvent(slaves.size(), testClassNames.size()));

      try {
        List<Future<Void>> all = executor.invokeAll(slaves);
        executor.shutdown();

        for (int i = 0; i < slaves.size(); i++) {
          Future<Void> f = all.get(i);
          try {
            f.get();
          } catch (ExecutionException e) {
            slaveInfos.get(i).executionError = e.getCause();
          }
        }
      } catch (InterruptedException e) {
        log("Master interrupted? Weird.", Project.MSG_ERR);
      }
      aggregatedBus.post(new AggregatedQuitEvent());

      for (SlaveInfo si : slaveInfos) {
        if (si.start > 0 && si.end > 0) {
          log(String.format(Locale.ENGLISH, "JVM J%d: %8.2f .. %8.2f = %8.2fs",
              si.id,
View Full Code Here

TOP

Related Classes of com.google.common.eventbus.EventBus$EventWithSubscriber

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.