Esempio n. 1
0
  public static void runTopologies(AuraClient auraClient, List<Topology.AuraTopology> topologies) {
    SubmissionHandler handler = new SubmissionHandler(auraClient, topologies, 1);
    TopologyFinishedHandler finishedHandler = new TopologyFinishedHandler();

    auraClient.ioManager.addEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, handler);
    auraClient.ioManager.addEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, finishedHandler);

    handler.handleTopologyFinished(null);
    auraClient.awaitSubmissionResult(topologies.size());

    auraClient.ioManager.removeEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, handler);
    auraClient.ioManager.removeEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, finishedHandler);
  }
Esempio n. 2
0
  public static void runTopologiesInParallel(
      final AuraClient auraClient, final List<Topology.AuraTopology> topologies) {
    TopologyFinishedHandler handler = new TopologyFinishedHandler();

    auraClient.ioManager.addEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, handler);

    for (int i = 0; i < topologies.size(); i++) {
      final int jobIndex = i;

      new Thread() {

        public void run() {
          LOG.info("Submit: {}", topologies.get(jobIndex).name);
          auraClient.submitTopology(topologies.get(jobIndex), null);
        }
      }.start();
    }

    auraClient.awaitSubmissionResult(topologies.size());
    auraClient.ioManager.removeEventListener(
        IOEvents.ControlEventType.CONTROL_EVENT_TOPOLOGY_FINISHED, handler);
  }