Ejemplo n.º 1
0
 @Override
 protected void doStop() throws Exception {
   LOG.info("Stopping flowlet: " + flowletContext);
   try {
     driver.stopAndWait();
   } finally {
     // Close all consumers
     for (ConsumerSupplier consumerSupplier : consumerSuppliers) {
       Closeables.closeQuietly(consumerSupplier);
     }
     flowletContext.close();
   }
   LOG.info("Flowlet stopped: " + flowletContext);
 }
Ejemplo n.º 2
0
 /** Constructs an instance. The instance must be constructed before the flowlet driver starts. */
 FlowletProgramController(
     String programName,
     String flowletName,
     BasicFlowletContext flowletContext,
     FlowletRuntimeService driver,
     Collection<ProducerSupplier> producerSuppliers,
     Collection<ConsumerSupplier<?>> consumerSuppliers) {
   super(programName + ":" + flowletName, flowletContext.getRunId());
   this.flowletContext = flowletContext;
   this.driver = driver;
   this.producerSuppliers = producerSuppliers;
   this.consumerSuppliers = consumerSuppliers;
   listenDriveState(driver);
 }
Ejemplo n.º 3
0
 @Override
 protected void doResume() throws Exception {
   LOG.info("Resuming flowlet: " + flowletContext);
   // Open producers
   for (ProducerSupplier producerSupplier : producerSuppliers) {
     producerSupplier.open();
   }
   // Open consumers
   for (ConsumerSupplier consumerSupplier : consumerSuppliers) {
     consumerSupplier.open(flowletContext.getInstanceCount());
   }
   driver.resume();
   LOG.info("Flowlet resumed: " + flowletContext);
 }
Ejemplo n.º 4
0
 private void changeInstanceCount(BasicFlowletContext flowletContext, int instanceCount) {
   Preconditions.checkState(
       getState() == State.SUSPENDED,
       "Cannot change instance count of a flowlet without suspension.");
   flowletContext.setInstanceCount(instanceCount);
 }