Package com.vmware.bdd.entity

Examples of com.vmware.bdd.entity.ClusterEntity


      node.setHostName(vcVm.getHost().getName());
      update(node);
   }

   public ClusterBlueprint toClusterBluePrint(String clusterName) {
      ClusterEntity clusterEntity = findByName(clusterName);
      ClusterBlueprint blueprint = new ClusterBlueprint();
      Gson gson = new Gson();

      blueprint.setName(clusterEntity.getName());
      blueprint.setInstanceNum(clusterEntity.getRealInstanceNum(true));
      // TODO: topology
      if (clusterEntity.getHadoopConfig() != null) {
         Map<String, Object> clusterConfigs =
               gson.fromJson(clusterEntity.getHadoopConfig(), Map.class);
         blueprint.setConfiguration(clusterConfigs);
      }

      // set HadoopStack
      HadoopStack hadoopStack = new HadoopStack();
      hadoopStack.setDistro(clusterEntity.getDistro());
      hadoopStack.setVendor(clusterEntity.getDistroVendor());
      hadoopStack.setFullVersion(clusterEntity.getDistroVersion());
      blueprint.setHadoopStack(hadoopStack);

      // set nodes/nodegroups
      List<NodeGroupInfo> nodeGroupInfos = new ArrayList<NodeGroupInfo>();
      for (NodeGroupEntity group : clusterEntity.getNodeGroups()) {
         NodeGroupInfo nodeGroupInfo = toNodeGroupInfo(group);
         nodeGroupInfos.add(nodeGroupInfo);
      }
      blueprint.setNodeGroups(nodeGroupInfos);
      return blueprint;
View Full Code Here


      }
      return channel.isConnected();
   }

   private void updateVhmMasterMoid(String clusterName) {
      ClusterEntity cluster = getClusterEntityMgr().findByName(clusterName);
      if (cluster.getVhmMasterMoid() == null) {
         List<NodeEntity> nodes =
               getClusterEntityMgr().findAllNodes(clusterName);
         for (NodeEntity node : nodes) {
            if (node.getMoId() != null
                  && node.getNodeGroup().getRoles() != null) {
               @SuppressWarnings("unchecked")
               List<String> roles =
                     new Gson().fromJson(node.getNodeGroup().getRoles(),
                           List.class);
               if (cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
                  if (roles
                        .contains(HadoopRole.MAPR_JOBTRACKER_ROLE.toString())) {
                     String thisJtIp = node.getPrimaryMgtIpV4();
                     String activeJtIp;
                     try {
                        activeJtIp =
                              getMaprActiveJobTrackerIp(thisJtIp, clusterName);
                        logger.info("fetched active JT Ip: " + activeJtIp);
                     } catch (Exception e) {
                        continue;
                     }

                     /*
                      * TODO: in multiple NICs env, if portgroups are isolated,
                      * may not able to retrieve active IP.
                      */
                     AuAssert.check(!CommonUtil.isBlank(thisJtIp),
                           "falied to query active JobTracker Ip");
                     for (NodeEntity jt : nodes) {
                        boolean isActiveJt = false;
                        for (NicEntity nicEntity : jt.getNics()) {
                           if (nicEntity.getIpv4Address() != null
                                 && activeJtIp.equals(nicEntity
                                       .getIpv4Address())) {
                              isActiveJt = true;
                              break;
                           }
                        }

                        if (isActiveJt) {
                           cluster.setVhmMasterMoid(jt.getMoId());
                           break;
                        }
                     }
                     break;
                  }
               } else {
                  if (roles.contains(HadoopRole.HADOOP_JOBTRACKER_ROLE
                        .toString())) {
                     cluster.setVhmMasterMoid(node.getMoId());
                     break;
                  }
               }
            }
         }
View Full Code Here

   @SuppressWarnings("unchecked")
   public boolean setAutoElasticity(String clusterName, boolean refreshAllNodes) {
      logger.info("set auto elasticity for cluster " + clusterName);

      ClusterEntity cluster = getClusterEntityMgr().findByName(clusterName);
      List<NodeEntity> nodes = clusterEntityMgr.findAllNodes(clusterName);

      Boolean enableAutoElasticity = cluster.getAutomationEnable();
      if (enableAutoElasticity == null) {
         return true;
      }

      String masterMoId = cluster.getVhmMasterMoid();
      if (masterMoId == null) {
         // this will only occurs when creating cluster
         updateVhmMasterMoid(clusterName);
         cluster = getClusterEntityMgr().findByName(clusterName);
         masterMoId = cluster.getVhmMasterMoid();
         if (masterMoId == null) {
            logger.error("masterMoId missed.");
            throw ClusteringServiceException.SET_AUTO_ELASTICITY_FAILED(cluster
                  .getName());
         }
      }

      String serengetiUUID = ConfigInfo.getSerengetiRootFolder();
      int minComputeNodeNum = cluster.getVhmMinNum();
      int maxComputeNodeNum = cluster.getVhmMaxNum();
      String jobTrackerPort = cluster.getVhmJobTrackerPort();

      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(masterMoId);
      if (vcVm == null) {
         logger.error("cannot find vhm master node");
         return false;
      }
      String masterUUID = vcVm.getConfig().getUuid();

      Callable<Void>[] storeProcedures = new Callable[nodes.size()];
      int i = 0;
      for (NodeEntity node : nodes) {
         VcVirtualMachine vm = VcCache.getIgnoreMissing(node.getMoId());
         if (vm == null) {
            logger.error("cannot find node: " + node.getVmName());
            continue;
         }
         if (!refreshAllNodes && !vm.getId().equalsIgnoreCase(masterMoId)) {
            continue;
         }
         List<String> roles =
               new Gson().fromJson(node.getNodeGroup().getRoles(), List.class);
         SoftwareManager softMgr =
            softwareManagerCollector.getSoftwareManager(cluster.getAppManager());

         boolean isComputeOnlyNode =
            softMgr.isComputeOnlyRoles(roles);
         SetAutoElasticitySP sp =
               new SetAutoElasticitySP(clusterName, vm, serengetiUUID,
View Full Code Here

   }

   @SuppressWarnings("rawtypes")
   public ClusterRead toClusterRead(String clusterName,
         boolean ignoreObsoleteNode) {
      ClusterEntity cluster = findByName(clusterName);
      if (cluster == null) {
         throw BddException.NOT_FOUND("Cluster", clusterName);
      }
      ClusterStatus clusterStatus = cluster.getStatus();
      ClusterRead clusterRead = new ClusterRead();
      clusterRead
            .setInstanceNum(cluster.getRealInstanceNum(ignoreObsoleteNode));
      clusterRead.setName(cluster.getName());
      clusterRead.setStatus(clusterStatus);
      clusterRead.setAppManager(cluster.getAppManager());
      clusterRead.setDistro(cluster.getDistro());
      clusterRead.setDistroVendor(cluster.getDistroVendor());
      clusterRead.setTopologyPolicy(cluster.getTopologyPolicy());
      clusterRead.setAutomationEnable(cluster.getAutomationEnable());
      clusterRead.setVhmMinNum(cluster.getVhmMinNum());
      clusterRead.setVhmMaxNum(cluster.getVhmMaxNum());
      clusterRead.setVhmTargetNum(cluster.getVhmTargetNum());
      clusterRead.setIoShares(cluster.getIoShares());
      clusterRead.setVersion(cluster.getVersion());
      if (!CommonUtil.isBlank(cluster.getAdvancedProperties())) {
         Gson gson = new Gson();
         Map<String, String> advancedProperties =
               gson.fromJson(cluster.getAdvancedProperties(), Map.class);
         clusterRead.setExternalHDFS(advancedProperties.get("ExternalHDFS"));
         clusterRead.setExternalMapReduce(advancedProperties
               .get("ExternalMapReduce"));
         clusterRead.setLocalRepoURL(advancedProperties.get("LocalRepoURL"));
      }

      SoftwareManager softMgr = null;
      try {
         softMgr =
               softwareManagerCollector.getSoftwareManager(cluster
                     .getAppManager());
      } catch (Exception e) {
         logger.error("Failed to get softwareManger.");
         // do not throw exception for exporting cluster info
      }

      List<NodeGroupRead> groupList = new ArrayList<NodeGroupRead>();
      for (NodeGroupEntity group : cluster.getNodeGroups()) {
         NodeGroupRead groupRead = group.toNodeGroupRead(ignoreObsoleteNode);
         groupRead.setComputeOnly(false);
         try {
            groupRead.setComputeOnly(softMgr.isComputeOnlyRoles(groupRead
                  .getRoles()));
         } catch (Exception e) {
         }
         groupList.add(groupRead);
      }

      clusterRead.setNodeGroups(groupList);

      Set<VcResourcePoolEntity> rps = cluster.getUsedRps();
      List<ResourcePoolRead> rpReads =
            new ArrayList<ResourcePoolRead>(rps.size());
      for (VcResourcePoolEntity rp : rps) {
         ResourcePoolRead rpRead = rp.toRest();
         rpRead.setNodes(null);
View Full Code Here

      if (persistentDiskMode) {
         setPersistentDiskMode(vNode);
      }

      ClusterEntity clusterEntity =
            getClusterEntityMgr().findByName(vNode.getClusterName());
      CreateVmPrePowerOn prePowerOn =
            new CreateVmPrePowerOn(reserveRawDisks, vNode.getVmSchema().diskSchema.getDisks(),
                  ha, ft, clusterEntity.getIoShares());

      return prePowerOn;
   }
View Full Code Here

      return initialized;
   }

   @Override
   public boolean isSupportVHM(String clusterName) {
      ClusterEntity cluster = getClusterEntityMgr().findByName(clusterName);
      SoftwareManager softMgr =
            softwareManagerCollector
                  .getSoftwareManagerByClusterName(clusterName);
      if (!softMgr.hasComputeMasterGroup(getClusterEntityMgr()
            .toClusterBluePrint(clusterName))) {
View Full Code Here

   }

   @Transactional
   @RetryTransaction
   public void updateClusterTaskId(String clusterName, Long taskId) {
      ClusterEntity cluster = clusterDao.findByName(clusterName);
      cluster.setLatestTaskId(taskId);
      clusterDao.update(cluster);
   }
View Full Code Here

      spec.setDistroVendor(Constants.DEFAULT_VENDOR);
      spec.setType(ClusterType.HDFS_MAPRED);
      spec = ClusterSpecFactory.getCustomizedSpec(spec, null);
      clusterConfigMgr.createClusterConfig(spec);

      ClusterEntity cluster = clusterEntityMgr.findClusterById(1l);
      List<ClusterEntity> cs = clusterEntityMgr.findAllClusters();
      for (ClusterEntity c : cs) {
         System.out.println(c.getId());
      }
      cluster = clusterEntityMgr.findByName("my-cluster");
View Full Code Here

      NodeGroupCreate[] ngs = new NodeGroupCreate[] { ng0, ng1, ng2 };
      spec.setNodeGroups(ngs);
      spec = ClusterSpecFactory.getCustomizedSpec(spec, null);
      clusterConfigMgr.createClusterConfig(spec);

      ClusterEntity cluster = clusterEntityMgr.findClusterById(1l);
      List<ClusterEntity> cs = clusterEntityMgr.findAllClusters();
      for (ClusterEntity c : cs) {
         System.out.println(c.getId());
      }
      cluster = clusterEntityMgr.findByName("my-cluster-external-hdfs");
      Assert.assertTrue(cluster != null);
      Assert.assertEquals(cluster.getAdvancedProperties(), "{\"ExternalHDFS\":\"hdfs://168.192.0.70:8020\"}");
      ClusterRead clusterRead = clusterEntityMgr.toClusterRead("my-cluster-external-hdfs");
      Assert.assertEquals(clusterRead.getExternalHDFS(), "hdfs://168.192.0.70:8020");

      ClusterCreate attrs =
            clusterConfigMgr.getClusterConfig("my-cluster-external-hdfs");
View Full Code Here

      worker.setStorage(storage);
      spec.setNodeGroups(new NodeGroupCreate[] { worker });

      spec = ClusterSpecFactory.getCustomizedSpec(spec, null);
      clusterConfigMgr.createClusterConfig(spec);
      ClusterEntity cluster =
            clusterEntityMgr.findByName("my-cluster-external-mr");

      Assert.assertTrue(cluster != null);
      Assert.assertEquals(
            cluster.getAdvancedProperties(),
            "{\"ExternalMapReduce\":\"192.168.0.1:8021\",\"ExternalHDFS\":\"hdfs://192.168.0.2:8020\"}");
      ClusterRead clusterRead =
            clusterEntityMgr.toClusterRead("my-cluster-external-mr");
      Assert.assertEquals(clusterRead.getExternalHDFS(),
            "hdfs://192.168.0.2:8020");
View Full Code Here

TOP

Related Classes of com.vmware.bdd.entity.ClusterEntity

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.