Package com.vmware.bdd.entity

Examples of com.vmware.bdd.entity.ClusterEntity


      if (cluster != null)
         clusterEntityMgr.delete(cluster);
   }

   public static ClusterEntity assembleClusterEntity(String clusterName) {
      ClusterEntity cluster = new ClusterEntity(clusterName);
      cluster.setDistro("bigtop");
      cluster.setDistroVendor(Constants.DEFAULT_VENDOR);
      cluster.setTopologyPolicy(TopologyType.NONE);
      cluster.setStatus(ClusterStatus.PROVISIONING);
      cluster.setAutomationEnable(false);
      cluster.setAppManager(Constants.IRONFAN);

      List<NodeGroupEntity> nodeGroups = new LinkedList<NodeGroupEntity>();
      NodeGroupEntity hdfsGroup = new NodeGroupEntity(HDFS_GROUP);

      // add hdfs node group
      hdfsGroup.setCluster(cluster);
      hdfsGroup.setCpuNum(1);
      hdfsGroup.setMemorySize(2048);
      hdfsGroup.setStorageSize(20);
      hdfsGroup.setStorageType(DatastoreType.LOCAL);
      hdfsGroup.setDefineInstanceNum(1);
      hdfsGroup.setHaFlag("on");

      ArrayList<String> roleStr = new ArrayList<String>();
      roleStr.add(HadoopRole.HADOOP_DATANODE.toString());
      hdfsGroup.setRoles((new Gson()).toJson(roleStr));

      // add a hdfs node
      List<NodeEntity> nodes = new LinkedList<NodeEntity>();
      NodeEntity node0 = new NodeEntity();
      node0.setVmName(HDFS_NODE_0);
      node0.setNodeGroup(hdfsGroup);
      nodes.add(node0);

      NodeEntity node1 = new NodeEntity();
      node1.setVmName(HDFS_NODE_1);
      node1.setNodeGroup(hdfsGroup);
      nodes.add(node1);

      hdfsGroup.setNodes(nodes);

      nodeGroups.add(hdfsGroup);

      // add compute node group
      NodeGroupEntity computeGroup = new NodeGroupEntity(COMPUTE_GROUP);

      computeGroup.setCluster(cluster);
      computeGroup.setCpuNum(1);
      computeGroup.setMemorySize(2048);
      computeGroup.setStorageSize(20);
      computeGroup.setStorageType(DatastoreType.SHARED);
      computeGroup.setDefineInstanceNum(1);
      computeGroup.setHaFlag("on");

      roleStr.clear();
      roleStr.add(HadoopRole.HADOOP_TASKTRACKER.toString());
      computeGroup.setRoles((new Gson()).toJson(roleStr));

      Set<NodeGroupAssociation> associations =
            new HashSet<NodeGroupAssociation>();
      NodeGroupAssociation association = new NodeGroupAssociation();

      association.setReferencedGroup(HDFS_GROUP);
      association.setAssociationType(GroupAssociationType.STRICT);
      association.setNodeGroup(computeGroup);

      associations.add(association);

      computeGroup.setGroupAssociations(associations);
      computeGroup.setNodes(new LinkedList<NodeEntity>());

      nodeGroups.add(computeGroup);

      cluster.setNodeGroups(nodeGroups);

      return cluster;
   }
View Full Code Here


   public static void setup() {
      clusterInitializerService = new ClusterInitializerService();

      List<ClusterEntity> clusters = new ArrayList<ClusterEntity>();

      ClusterEntity cluster01 = new ClusterEntity("cluster01");
      cluster01.setStatus(ClusterStatus.PROVISION_ERROR);
      clusters.add(cluster01);

      ClusterEntity cluster02 = new ClusterEntity("cluster02");
      cluster02.setStatus(ClusterStatus.DELETING);
      clusters.add(cluster02);

      IClusterEntityManager clusterEntityManager = Mockito.mock(IClusterEntityManager.class);
      Mockito.when(clusterEntityManager.findAllClusters()).thenReturn(clusters);
      Mockito.doNothing().when(clusterEntityManager).update(cluster01);
View Full Code Here

    * Otherwise, UT will fail sometimes.
    */
   @Test(groups = { "testClusterEntityManager" })
   @Transactional
   public void testClusterEntityManagerFuns() {
      ClusterEntity cluster = clusterEntityMgr.findByName(CLUSTER_NAME);
      if (cluster != null)
         clusterEntityMgr.delete(cluster);
      testInsertClusterEntity();
      testUpdateClusterEntity();
      testUpdateNodeGroupEntity();
View Full Code Here

      testUpdateNodeGroupEntity();
      testDeleteEntity();
   }

   private void testInsertClusterEntity() {
      ClusterEntity cluster = assembleClusterEntity(CLUSTER_NAME);

      clusterEntityMgr.insert(cluster);

      // start validation
      ClusterEntity read = clusterEntityMgr.findByName(CLUSTER_NAME);
      Assert.assertTrue(read != null, "cluster " + CLUSTER_NAME
            + " should exist");

      NodeGroupEntity hdfs = clusterEntityMgr.findByName(cluster, HDFS_GROUP);
      Assert.assertTrue(hdfs != null, "node group " + HDFS_GROUP
View Full Code Here

      Assert.assertTrue(hdfsNode != null, "node " + HDFS_NODE_0
            + " should exist");
   }

   private void testUpdateClusterEntity() {
      ClusterEntity cluster = clusterEntityMgr.findByName(CLUSTER_NAME);
      Assert.assertNotNull(cluster);
      Assert.assertEquals(cluster.getAutomationEnable().booleanValue(), false);
      cluster.setAutomationEnable(true);
      clusterEntityMgr.update(cluster);
      cluster = clusterEntityMgr.findByName(CLUSTER_NAME);
      Assert.assertEquals(cluster.getAutomationEnable().booleanValue(), true);
      cluster.setAutomationEnable(false);
      clusterEntityMgr.update(cluster);
   }
View Full Code Here

      Assert.assertTrue(
            clusterEntityMgr.findByName(CLUSTER_NAME, HDFS_GROUP, HDFS_NODE_0) == null,
            "node " + HDFS_NODE_0 + " should be deleted");

      ClusterEntity cluster = clusterEntityMgr.findByName(CLUSTER_NAME);
      clusterEntityMgr.delete(cluster);
      Assert.assertTrue(clusterEntityMgr.findByName(CLUSTER_NAME) == null,
            "cluster " + CLUSTER_NAME + " should be deleted");
   }
View Full Code Here

   }

   @Transactional
   @Test(groups = { "testClusterEntity" })
   public void testOperations() {
      ClusterEntity cluster = new ClusterEntity(CLUSTER_NAME);
      cluster.setDistro("apache");
      cluster.setTopologyPolicy(TopologyType.NONE);
      cluster.setStatus(ClusterStatus.PROVISIONING);

      List<NodeGroupEntity> nodeGroups = new LinkedList<NodeGroupEntity>();
      NodeGroupEntity hdfsGroup = new NodeGroupEntity(HDFS_GROUP);

      hdfsGroup.setCluster(cluster);
      hdfsGroup.setCpuNum(1);
      hdfsGroup.setMemorySize(2048);
      hdfsGroup.setStorageSize(20);
      hdfsGroup.setStorageType(DatastoreType.LOCAL);
      hdfsGroup.setDefineInstanceNum(2);
      hdfsGroup.setHaFlag("on");

      List<NodeEntity> hdfsNodes = new LinkedList<NodeEntity>();
      NodeEntity hdfsNode1 = new NodeEntity();
      NodeEntity hdfsNode2 = new NodeEntity();
      hdfsNode1.setVmName("hdfsNode1");
      hdfsNode2.setVmName("hdfsNode2");

      VcResourcePoolEntity vcRp1 = new VcResourcePoolEntity();
      vcRp1.setName("RP1");
      vcRp1.setVcCluster("Cluster1");
      vcRp1.setVcResourcePool("VcRp1");
      resourcePoolDao.insert(vcRp1);
      hdfsNode1.setVcRp(vcRp1);

      hdfsNodes.add(hdfsNode1);
      hdfsNodes.add(hdfsNode2);
      hdfsGroup.setNodes(hdfsNodes);

      ArrayList<String> roleStr = new ArrayList<String>();
      roleStr.add(HADOOP_ROLE);
      roleStr.add(DATA_NODE_ROLE);
      hdfsGroup.setRoles((new Gson()).toJson(roleStr));

      nodeGroups.add(hdfsGroup);

      NodeGroupEntity computeGroup = new NodeGroupEntity(COMPUTE_GROUP);

      computeGroup.setCluster(cluster);
      computeGroup.setCpuNum(1);
      computeGroup.setMemorySize(2048);
      computeGroup.setStorageSize(20);
      computeGroup.setStorageType(DatastoreType.SHARED);
      computeGroup.setDefineInstanceNum(1);
      computeGroup.setHaFlag("on");

      List<NodeEntity> computeNodes = new LinkedList<NodeEntity>();
      NodeEntity computeNode1 = new NodeEntity();
      computeNode1.setVmName("computeNode1");
      computeNodes.add(computeNode1);
      computeGroup.setNodes(computeNodes);

      roleStr.clear();
      roleStr.add(HADOOP_ROLE);
      roleStr.add(COMPUTE_NODE_ROLE);
      computeGroup.setRoles((new Gson()).toJson(roleStr));

      Set<NodeGroupAssociation> associations =
            new HashSet<NodeGroupAssociation>();
      NodeGroupAssociation association = new NodeGroupAssociation();

      association.setReferencedGroup(HDFS_GROUP);
      association.setAssociationType(GroupAssociationType.STRICT);
      association.setNodeGroup(computeGroup);

      associations.add(association);

      computeGroup.setGroupAssociations(associations);

      nodeGroups.add(computeGroup);

      cluster.setNodeGroups(nodeGroups);

      // test insert()
      clusterDao.insert(cluster);

      ClusterEntity clusterRead = clusterDao.findByName(CLUSTER_NAME);

      Assert.assertNotNull(clusterRead);
      Assert.assertTrue(clusterRead.getNodeGroups().size() == 2);

      NodeGroupEntity groupRead =
            nodeGroupDao.findByName(clusterRead, COMPUTE_GROUP);

      Assert.assertNotNull(groupRead);
      Assert.assertTrue(groupRead.getCpuNum() == 1);
      Assert.assertTrue(groupRead.getGroupAssociations().size() == 1);

      // test updateStatus()
      clusterDao.updateStatus(CLUSTER_NAME, ClusterStatus.VHM_RUNNING);
      clusterRead = clusterDao.findByName(CLUSTER_NAME);
      Assert.assertTrue(clusterRead.getStatus() == ClusterStatus.VHM_RUNNING);

      // test getAllNodes()
      List<NodeEntity> allNodes = clusterDao.getAllNodes(CLUSTER_NAME);
      logger.info(allNodes.size());
      Assert.assertTrue(allNodes.size() == 3);
View Full Code Here

   }

   @Override
   @Transactional
   public void updateStatus(String name, ClusterStatus status) {
      ClusterEntity cluster = findByName(name);
      AuAssert.check(cluster != null);
      cluster.setStatus(status);
   }
View Full Code Here

   @Override
   public List<NodeEntity> getAllNodes(String name) {
      List<NodeEntity> nodes = new ArrayList<NodeEntity>();

      ClusterEntity cluster = findByName(name);
      for (NodeGroupEntity group : cluster.getNodeGroups()) {
         nodes.addAll(group.getNodes());
      }
      return nodes;
   }
View Full Code Here

   }

   @Override
   @Transactional
   public ClusterStatus getStatus(String clusterName) {
      ClusterEntity cluster = findByName(clusterName);
      AuAssert.check(cluster != null);
      return cluster.getStatus();
   }
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.