Package com.vmware.bdd.software.mgmt.plugin.monitor

Examples of com.vmware.bdd.software.mgmt.plugin.monitor.ClusterReport


      // TODO
   }

   @Test(groups = { "TestAmbariImpl" }, dependsOnMethods = { "testCreateCluster" })
   public void testStatusQuery() {
      ClusterReport report = provider.queryClusterStatus(blueprint);
      Assert.assertTrue(report.getStatus().equals(ServiceStatus.STARTED), "Should get started cluster status");
   }
View Full Code Here


      spy.setApiManager(backup);
   }

   @Test(groups = { "TestAmbariImpl" })
   public void testDoSoftwareOperation() {
      ClusterReport clusterReport = new ClusterReport(blueprint);
      AmbariImpl spy = Mockito.spy(provider);
      ApiManager apiManager = new FakeApiManager(makeClientBuilder());
      ApiManager backup = spy.getApiManager();
      spy.setApiManager(apiManager);
      ApiRequest request = new ApiRequest();
View Full Code Here

@MockClass(realClass = SoftwareManager.class)
public class MockSoftwareManager implements SoftwareManager {
   @Mock
   public boolean createCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reports) throws SoftwareManagementPluginException {
      ClusterReport report = new ClusterReport();
      report.setName(blueprint.getName());
      report.setAction("testing 1");
      report.setFinished(false);
      report.setProgress(30);
      reports.addClusterReport(report.clone());
      try {
         Thread.sleep(5000);
      } catch (Exception e) {
         e.printStackTrace();
         return false;
      }

      report.setAction("testing 2");
      report.setProgress(60);
      reports.addClusterReport(report.clone());
      try {
         Thread.sleep(15000);
      } catch (Exception e) {
         e.printStackTrace();
         return false;
      }
      report.setAction("testing 3");
      report.setProgress(90);
      reports.addClusterReport(report.clone());
      try {
         Thread.sleep(3000);
      } catch (Exception e) {
         e.printStackTrace();
         return false;
      }
      report.setAction("testing finished");
      report.setProgress(100);
      report.setFinished(true);
      reports.addClusterReport(report.clone());
      return true;
   }
View Full Code Here

         List<ClusterReport> reports = queue.pollClusterReport();
         if (reports.isEmpty()) {
            logger.debug("No reports found. Waiting ...");
            continue;
         }
         ClusterReport lastestReport = reports.get(reports.size() - 1);
         lastestReport.getProgress();
         logger.info("progress finished? " + lastestReport.isFinished());
         if (!lastestReport.isFinished()) {
            int progress = lastestReport.getProgress();
            if (statusUpdater != null) {
               statusUpdater.setProgress(((double) progress) / 100);
            }
         }

         setLastErrorMsg(lastestReport.getErrMsg());
         clusterEntityMgr.handleOperationStatus(targetName.split("-")[0], lastestReport, exit);
      }
   }
View Full Code Here

                  }
               }
               success = softwareManager.startNodes(clusterBlueprint.getName(), nodes, queue);
               break;
            case QUERY:
               ClusterReport report = softwareManager.queryClusterStatus(clusterBlueprint);
               queue.addClusterReport(report);
               success = true;
               break;
            case RESIZE:
               AuAssert.check(chunkContext != null);
View Full Code Here

               if (softMgr == null) {
                  logger.error("No software manager for cluster " + clusterName
                        + " available.");
                  continue;
               }
               ClusterReport report = softMgr.queryClusterStatus(blueprint);
               if (report == null) {
                  logger.debug("No service status got from software manager, ignore it.");
                  continue;
               }
               logger.debug("Got cluster status: " + report.getStatus());
               lockedEntityManager.getClusterEntityMgr().setClusterStatus(
                     clusterName, report);
            } catch (Throwable e) {
               logger.error("Failed to syncup status for cluster "
                     + clusterName + ". Error message: " + e.getMessage(), e);
View Full Code Here

      }
   }

   @Override
   public boolean poll() {
      ClusterReport toReport = null;
      synchronized (currentReport) {
         if (!reported) {
            if (leftStepsNum == 0) {
               currentReport.setProgress(endProgress);
            } else {
               int currentProgress = currentReport.getProgress();
               int toProgress = currentProgress + (endProgress - currentProgress) / leftStepsNum;
               currentReport.setProgress(toProgress > endProgress ? endProgress : toProgress );
               leftStepsNum -= 1;
            }
            toReport = currentReport.clone();
            reported = true;
         }
      }
      if (toReport != null) {
         // free the "currentReport" lock before adding to reportQueue to avoid blocking
         logger.info("report status progress=" + toReport.getProgress() + ", action=" + toReport.getAction());
         reportQueue.addClusterReport(toReport);
      }
      if (rootResource.getCommandsResource().readCommand(parentCmdId).getEndTime() != null) {
         running = false;
         executor.shutdown();
View Full Code Here

            "cluster " + CLUSTER_NAME + " should be deleted");
   }

   @Test
   public void testHandleExternalOperationStatus() {
      ClusterReport report = new ClusterReport();
      report.setAction("Installing agent...");
      report.setFinished(false);
      report.setName(CLUSTER_NAME);
      report.setProgress(80);
      report.setNodeReports(new HashMap<String, NodeReport>());
      NodeReport node = new NodeReport();
      node.setAction("Installing node agent...");
      node.setName(HDFS_NODE_0);
      report.getNodeReports().put(HDFS_NODE_0, node);

      node = new NodeReport();
      node.setName(HDFS_NODE_1);
      node.setUseClusterMsg(true);
      report.getNodeReports().put(HDFS_NODE_1, node);

      boolean result = clusterEntityMgr.handleOperationStatus(CLUSTER_NAME, report, false);
      Assert.assertFalse(result,
            "cluster " + CLUSTER_NAME + " operation should not be finished");
      List<NodeEntity> nodes = clusterEntityMgr.findAllNodes(CLUSTER_NAME);
View Full Code Here

      }
      if (!isClusterProvisionedByBDE(clusterDef)) {
         throw SoftwareManagementPluginException.START_CLUSTER_FAILED_NOT_PROV_BY_BDE(clusterName);
      }

      ClusterReport clusterReport = clusterDef.getCurrentReport();
      clusterReport.setAction("Ambari is starting services");
      clusterReport.setProgress(ProgressSplit.OPERATION_BEGIN.getProgress());
      reportStatus(clusterReport, reports);
      boolean success = false;
      //when start services, some tasks will fail with error msg "Host Role in invalid state".
      // The failed task are random(I had saw NodeManager, ResourceManager, NAGOIS failed), and the
      // root cause is not clear by now. Each time, when I retry, it succeed. So just add retry logic to make a
      // a temp fix for it.
      //TODO(qjin): find out the root cause of failure in startting services
      Exception resultException = null;
      try {
         ReflectionUtils.getPreStartServicesHook().preStartServices(clusterName, 120);
         for (int i = 0; i < getRequestMaxRetryTimes(); i++) {
            ApiRequest apiRequestSummary;
            try {
               apiRequestSummary = apiManager.startAllServicesInCluster(clusterName);
               //when reach here, command is succeed. If ApiRequestInfo is null, it means the command has been
               //finished successfully, otherwise we need to wait for it using doSoftwareOperation
               if (apiRequestSummary == null || apiRequestSummary.getApiRequestInfo() == null) {
                  success = true;
                  return true;
               }
               success = doSoftwareOperation(clusterBlueprint.getName(), apiRequestSummary, clusterReport, reports);
            } catch (Exception e) {
               resultException = e;
               logger.warn("Failed to start cluster services, retrying after 5 seconds...", e);
               try {
                  Thread.sleep(5000);
               } catch (InterruptedException interrupt) {
                  logger.info("interrupted when sleeping, trying to start cluster services immediately");
               }
            }
         }
      } finally {
         if (!success) {
            logger.error("Failed to start all services: ", resultException);
            throw SoftwareManagementPluginException.START_CLUSTER_FAILED(resultException, Constants.AMBARI_PLUGIN_NAME, clusterName);
         }

         clusterReport.setClusterAndNodesServiceStatus(ServiceStatus.STARTED);
         clusterReport.setClusterAndNodesAction("");
         clusterReport.clearAllNodesErrorMsg();
         reportStatus(clusterReport.clone(), reports);
         return true;
      }
   }
View Full Code Here

            roleRef.setRoleName(role.getName());
            roleRefs.add(roleRef);
         }
      }
      hosts.get(2).setRoleRefs(roleRefs);
      ClusterReport report = provider.queryClusterStatus(blueprint);
      Assert.assertTrue(report.getStatus() != null
            && report.getStatus() == ServiceStatus.STOPPED,
            "Status should be stopped, but got " + report.getStatus());
      System.out.println("Status: " + report.getStatus());
   }
View Full Code Here

TOP

Related Classes of com.vmware.bdd.software.mgmt.plugin.monitor.ClusterReport

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.