/* (non-Javadoc)
@see net.timewalker.ffmq4.local.LocalEngineListener#engineDeployed()
339751
@Override
	public void engineDeployed()
    {
        try
        {
            if (jmxAgent != null)
            {
                jmxAgent.register(new ObjectName(JMXAgent.JMX_DOMAIN+":type=Engines,engine="+engine.getName()+",children=async-managers,name=notification"), engine.getNotificationAsyncTaskManager());
                jmxAgent.register(new ObjectName(JMXAgent.JMX_DOMAIN+":type=Engines,engine="+engine.getName()+",children=async-managers,name=delivery"), engine.getDeliveryAsyncTaskManager());
                jmxAgent.register(new ObjectName(JMXAgent.JMX_DOMAIN+":type=Engines,engine="+engine.getName()+",children=async-managers,name=disk-io"), engine.getDiskIOAsyncTaskManager());
            }
        }
        catch (Exception e)
        {
            log.error("Cannot register local engine async managers from JMX agent",e);
        }
    }
1339683
public synchronized void pauseDeployment(final String deployment, ServerActivityCallback listener) {
        final List<ControlPoint> eps = new ArrayList<ControlPoint>();
        for (ControlPoint ep : entryPoints.values()) {
            if (ep.getDeployment().equals(deployment)) {
                if(!ep.isPaused()) {
                    eps.add(ep);
                }
            }
        }
        CountingRequestCountCallback realListener = new CountingRequestCountCallback(eps.size(), listener);
        for (ControlPoint ep : eps) {
            ep.pause(realListener);
        }
    }
1620
public void blockGenerateDeploymentWhenNeeded(@Observes EventContext<GenerateDeployment> eventContext) {
        if (!extensionEnabled()) {
            eventContext.proceed();
        }
        else if (suiteDeploymentGenerated) {
            // Do nothing with event.
            debug("Blocking GenerateDeployment event {0}", eventContext.getEvent().toString());
        } else {
            suiteDeploymentGenerated = true;
            debug("NOT Blocking GenerateDeployment event {0}", eventContext.getEvent().toString());
            eventContext.proceed();
        }
    }
206032
void forcedUndeployScan() {

        if (acquireScanLock()) {
            try {
                ROOT_LOGGER.tracef("Performing a post-boot forced undeploy scan for scan directory %s", deploymentDir.getAbsolutePath());
                ScanContext scanContext = new ScanContext(deploymentOperations);

                // Add remove actions to the plan for anything we count as
                // deployed that we didn't find on the scan
                for (Map.Entry<String, DeploymentMarker> missing : scanContext.toRemove.entrySet()) {
                    // remove successful deployment and left will be removed
                    if (scanContext.registeredDeployments.containsKey(missing.getKey())) {
                        scanContext.registeredDeployments.remove(missing.getKey());
                    }
                }
                Set<String> scannedDeployments = new HashSet<String>(scanContext.registeredDeployments.keySet());
                scannedDeployments.removeAll(scanContext.persistentDeployments);

                List<ScannerTask> scannerTasks = scanContext.scannerTasks;
                for (String toUndeploy : scannedDeployments) {
                    scannerTasks.add(new UndeployTask(toUndeploy, deploymentDir, scanContext.scanStartTime, true));
                }
                try {
                    executeScannerTasks(scannerTasks, deploymentOperations, true);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }

                ROOT_LOGGER.tracef("Forced undeploy scan complete");
            } catch (Exception e) {
                ROOT_LOGGER.scanException(e, deploymentDir.getAbsolutePath());
            } finally {
                releaseScanLock();
            }
        }
    }
1296437
private void doDeployVerticle(final Message<JsonObject> message) {
    String main = message.body().getString("main");
    if (main == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No verticle main specified."));
      return;
    }

    JsonObject config = message.body().getObject("config");
    if (config == null) {
      config = new JsonObject();
    }
    int instances = message.body().getInteger("instances", 1);
    boolean worker = message.body().getBoolean("worker", false);
    if (worker) {
      boolean multiThreaded = message.body().getBoolean("multi-threaded", false);
      platform.deployWorkerVerticle(main, config, instances, multiThreaded, createDeploymentHandler(message));
    } else {
      platform.deployVerticle(main, config, instances, createDeploymentHandler(message));
    }
  }
1058200
@Override
    public void artifactDeployed(RepositoryEvent event) {
        log.fine("Deployed " + event.getArtifact() + " to " + event.getRepository());
    }
266458
private static void addRedeployOperationStep(final CompositeOperationBuilder builder, final DeploymentDescription deployment) {
        final String deploymentName = deployment.getName();
        final Set<String> serverGroups = deployment.getServerGroups();
        if (serverGroups.isEmpty()) {
            builder.addStep(createOperation(DEPLOYMENT_REDEPLOY_OPERATION, createAddress(DEPLOYMENT, deploymentName)));
        } else {
            for (String serverGroup : serverGroups) {
                builder.addStep(createOperation(DEPLOYMENT_REDEPLOY_OPERATION, createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, deploymentName)));
            }
        }
    }
748992
@Override
	public void topicUndeployed(LocalTopic topic)
    {
    	try
    	{
    		if (jmxAgent != null)
    			jmxAgent.unregister(new ObjectName(JMXAgent.JMX_DOMAIN+":type=Engines,engine="+engine.getName()+",children=topics,name="+topic.getName()));
    	}
    	catch (Exception e)
    	{
    		log.error("Cannot unregister local topic from JMX agent",e);
    	}
    }
772470
private void doDeployModule(final Message<JsonObject> message) {
    String moduleName = message.body().getString("module");
    if (moduleName == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No module name specified."));
      return;
    }

    JsonObject config = message.body().getObject("config");
    if (config == null) {
      config = new JsonObject();
    }
    int instances = message.body().getInteger("instances", 1);
    platform.deployModule(moduleName, config, instances, new Handler<AsyncResult<String>>() {
      @Override
      public void handle(AsyncResult<String> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          final String deploymentID = result.result();
          context.execute(new Action<String>() {
            @Override
            public String perform() {
              deployments.put(node, message.body().copy().putString("id", deploymentID).encode());
              return deploymentID;
            }
          }, new Handler<AsyncResult<String>>() {
            @Override
            public void handle(AsyncResult<String> result) {
              message.reply(new JsonObject().putString("status", "ok").putString("id", deploymentID));
            }
          });
        }
      }
    });
  }
824298
public void setUndeploy(java.util.Collection<String> undeploy) {
        if (undeploy == null) {
            this.undeploy = null;
            return;
        }

        this.undeploy = new com.amazonaws.internal.SdkInternalList<String>(undeploy);
    }
896121
private void doUndeployModule(final Message<JsonObject> message) {
    final String deploymentID = message.body().getString("id");
    if (deploymentID == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No deployment ID specified."));
    } else {
      removeDeployment(deploymentID, new Handler<AsyncResult<Void>>() {
        @Override
        public void handle(AsyncResult<Void> result) {
          platform.undeployModule(deploymentID, new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              if (result.failed()) {
                message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
              } else {
                message.reply(new JsonObject().putString("status", "ok"));
              }
            }
          });
        }
      });
    }
  }
684018
public final void undeploy() {
        synchronized (TinyPlugzConfigurator.DEPLOY_LOCK) {
            Require.state(isDeployed(),
                    "Can not undeploy TinyPlugz: no instance deployed");
            final TinyPlugz plugz = instance;
            Require.state(plugz == this,
                    "Undeploy called on an instance which was not the deployed one");
            instance = null;
            plugz.dispose();
        }
    }
436089
public void undeployVM(String vrpId, VirtualMachine vm, ClusterComputeResource cluster) throws InvalidState, NotFound, RuntimeFault, RemoteException {
        getVimService().undeployVM(getMOR(), vrpId, vm.getMOR(), cluster.getMOR());
    }
861972
private void undeployModule(final InstanceContext instance, final CountingCompletionHandler<Void> counter) {
    deploymentIDs.remove(instance.address(), new Handler<AsyncResult<String>>() {
      @Override
      public void handle(AsyncResult<String> result) {
        if (result.failed()) {
          counter.fail(result.cause());
        } else if (result.result() != null) {
          cluster.undeployModule(result.result(), new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              unwatchInstance(instance, counter);
            }
          });
        } else {
          unwatchInstance(instance, counter);
        }
      }
    });
  }
1218837
private void doRedeploy(final JsonObject deploymentInfo) {
    if (deploymentInfo.getString("type").equals("module")) {
      log.info(String.format("%s - redeploying module %s", DefaultGroupManager.this, deploymentInfo.getString("module")));
      final CountDownLatch latch = new CountDownLatch(1);
      platform.deployModule(deploymentInfo.getString("module"), deploymentInfo.getObject("config", new JsonObject()), deploymentInfo.getInteger("instances", 1), createRedeployHandler(deploymentInfo, latch));
      try {
        latch.await(10, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
      }
    } else if (deploymentInfo.getString("type").equals("verticle")) {
      log.info(String.format("%s - redeploying verticle %s", DefaultGroupManager.this, deploymentInfo.getString("main")));
      final CountDownLatch latch = new CountDownLatch(1);
      if (deploymentInfo.getBoolean("worker", false)) {
        platform.deployWorkerVerticle(deploymentInfo.getString("main"), deploymentInfo.getObject("config", new JsonObject()), deploymentInfo.getInteger("instances", 1), deploymentInfo.getBoolean("multi-threaded"), createRedeployHandler(deploymentInfo, latch));
      } else {
        platform.deployVerticle(deploymentInfo.getString("main"), deploymentInfo.getObject("config", new JsonObject()), deploymentInfo.getInteger("instances", 1), createRedeployHandler(deploymentInfo, latch));
      }
      try {
        latch.await(10, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
      }
    }
  }
990251
public void putBeanDeployments(BeanDeploymentArchiveMapping bdaMapping) {
        for (Entry<BeanDeploymentArchive, BeanManagerImpl> entry : bdaMapping.getBdaToBeanManagerMap().entrySet()) {
            beanDeploymentArchives.put(entry.getKey(), entry.getValue());
            addBeanManager(entry.getValue());
        }
    }
581707
private void doDeployNetwork(final NetworkContext context, final Message<JsonObject> message) {
    final WrappedWatchableMap<String, String> data = new WrappedWatchableMap<String, String>(context.address(), this.data.<String, String>getMap(context.address()), vertx);

    // When the context is set in the cluster, the network's manager will be notified
    // via a cluster event. The manager will then unset the network's status key and
    // update the network. Once the network has been updated (components are deployed
    // and undeployed and connections are created or removed as necessary) the manager
    // will reset the network's status key to the updated version. We can use this fact
    // to determine when the configuration change is complete by watching the network's
    // status key for the new context version.
    data.watch(context.status(), null, new Handler<MapEvent<String, String>>() {
      @Override
      public void handle(MapEvent<String, String> event) {
        // Once the network has been updated we can stop watching the network's status key.
        // Once the status key is unwatched trigger the async handler indicating that the
        // update is complete.
        if (event.type().equals(MapEvent.Type.CREATE) && event.value().equals(context.version())) {
          data.unwatch(context.status(), null, this, new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              message.reply(new JsonObject().putString("status", "ok").putObject("context", Contexts.serialize(context)));
            }
          });
        }
      }
    }, new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> result) {
        // Once the network's status key is being watched, set the new configuration in
        // the cluster. This change will be recognized by the network's manager which will
        // then update the running network's configuration.
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          try {
            data.put(context.address(), Contexts.serialize(context).encode());
          } catch (Exception e) {
            message.reply(new JsonObject().putString("status", "error").putString("message", e.getMessage()));
          }
        }
      }
    });
  }