Package com.vmware.bdd.software.mgmt.impl

Examples of com.vmware.bdd.software.mgmt.impl.SoftwareManagementClient


   public void doWork() throws Exception {
      boolean exit = false;

      logger.info("start monitor operation progress for target " + targetName);
      OperationStatusWithDetail detailedStatus = null;
      SoftwareManagementClient monitorClient = new SoftwareManagementClient();
      monitorClient.init();

      while (!exit) {
         try {
            Thread.sleep(queryInterval);
         } catch (InterruptedException e) {
            logger.info("monitor thread is waked up by caller to stop monitoring");
            stop = true;
         }
         if (stop) {
            logger.info("received stop signal, will do one more query then exit, so as to retrieve the final progress after Ironfan exits.");
            exit = true;
         }

         logger.info("progress query started");
         detailedStatus = monitorClient.getOperationStatusWithDetail(targetName);
         if (null == detailedStatus) {
            logger.error("Failed to query progress. Something wrong with the Monitor Service?");
            break;
         }
         logger.info("progress finished? " + detailedStatus.getOperationStatus().isFinished());
         logger.debug(detailedStatus.toString());
         logger.info("progress query completed");
         if (detailedStatus.getOperationStatus().getProgress() < 100) {
            int progress = detailedStatus.getOperationStatus().getProgress();
            if (statusUpdater != null) {
               statusUpdater.setProgress(((double) progress) / 100);
            }
         }
         setLastErrorMsg(detailedStatus.getOperationStatus().getErrorMsg());
         clusterEntityMgr.handleOperationStatus(targetName.split("-")[0], detailedStatus, exit);

         // for large scale cluster (100+ nodes), don't need to query too frequent which will cause too much overhead on Chef Server
         if (queryInterval == QUERY_INTERVAL_DEFAULT) {
            int size = detailedStatus.getClusterData().getClusterSize();
            if (size > BIG_CLUSTER_NODES_COUNT) {
               queryInterval = Math.min(QUERY_INTERVAL_MAX, QUERY_INTERVAL_LONG * (size / BIG_CLUSTER_NODES_COUNT));
               logger.info("progress query interval set to " + queryInterval / 1000 + "s because this cluster has " + size + " nodes");
            }
         }
      }
      if (monitorClient != null) {
         monitorClient.close();
      }
   }
View Full Code Here


      if (Configuration.getBoolean("management.thrift.mock", false)) {
         result.put("succeed", true);
         result.put("exitCode", 0);
         return result;
      }
      final SoftwareManagementClient client = new SoftwareManagementClient();
      client.init();

      if (clusterOperation.getAction().ordinal() != ClusterAction.QUERY.ordinal()) {
         //Reset node's provision attribute
         client.resetNodeProvisionAttribute(clusterOperation.getTargetName());
      }

      // start monitor thread
      Thread progressThread = null;
      ThriftProgressMonitor monitor = null;
      monitor = new ThriftProgressMonitor(clusterOperation.getTargetName(), statusUpdater, clusterEntityMgr);
      progressThread = new Thread(monitor, "ProgressMonitor-" + clusterOperation.getTargetName());
      progressThread.setDaemon(true);
      progressThread.start();

      // start cluster operation
      int exitCode = -1;
      try {
         exitCode = client.runClusterOperation(clusterOperation);
      } catch (Throwable t) {
         logger.error(" operation : " + clusterOperation.getAction()
               + " failed on cluster: " + clusterOperation.getTargetName(), t);
      } finally {
         if (progressThread != null) {
            if (monitor != null) {
               monitor.setStop(true); // tell monitor to stop monitoring then the thread will exit
               progressThread.interrupt(); // wake it up to stop immediately if it's sleeping
               progressThread.join();
            }
         }

         if (client != null) {
            client.close();
         }
      }

      // handle operation result
      boolean succeed = true;
View Full Code Here

TOP

Related Classes of com.vmware.bdd.software.mgmt.impl.SoftwareManagementClient

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.