Package com.cloudera.api.v6

Examples of com.cloudera.api.v6.DashboardsResource


   @Test (groups = { "TestClouderaManagerImpl" }, dependsOnMethods = { "testStartStoppedCluster" })
   public void testStopClusterGotException() {
      setupMocks();
      blueprint.getHadoopStack().setDistro("CDH-5.0.1");
      ClustersResourceV6 resourceV6 = Mockito.mock(FakeClustersResource.class);
      Mockito.when(resourceV6.stopCommand(blueprint.getName())).thenThrow(
            SoftwareManagementPluginException.STOP_CLUSTER_FAILED(null, null, blueprint.getName()));
      ServicesResourceV6 servicesResourceV6 = Mockito.mock(ServicesResourceV6.class);
      List<ApiService> serviceList = new ArrayList<>();
      ApiService hdfs = new ApiService();
      hdfs.setName("HDFS");
      hdfs.setServiceState(ApiServiceState.STARTED);
      serviceList.add(hdfs);
      ApiServiceList apiServiceList = new ApiServiceList();
      apiServiceList.setServices(serviceList);
      Mockito.when(servicesResourceV6.readServices((DataView) anyObject())).thenReturn(apiServiceList);

      List<ApiRole> roleList = new ArrayList<>();
      ApiRole role = new ApiRole();
      role.setName("NAMENODE");
      role.setRoleState(ApiRoleState.STARTED);
      role.setType(role.getName());
      ApiHostRef hostRef = new ApiHostRef("host1");
      role.setHostRef(hostRef);
      roleList.add(role);
      RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
      Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
      Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);

      ApiClusterList apiClusterList = new ApiClusterList();
      ApiCluster apiCluster = new ApiCluster();
      apiCluster.setName(blueprint.getName());
      apiClusterList.add(apiCluster);
      Mockito.when(resourceV6.readClusters((DataView) anyObject())).thenReturn(apiClusterList);

      RootResourceV6 fakeRootResourceV6 = Mockito.mock(FakeRootResource.class);
      Mockito.when(fakeRootResourceV6.getClustersResource()).thenReturn(resourceV6);

      FakeHostsResource fakeHostsResource = Mockito.mock(FakeHostsResource.class);
View Full Code Here


      setupMocks();
      blueprint.getHadoopStack().setDistro("CDH-5.0.1");
      provider.onStopCluster(blueprint, reportQueue);

      blueprint.getHadoopStack().setDistro("CDH-5.0.1");
      ClustersResourceV6 resourceV6 = Mockito.mock(FakeClustersResource.class);
      Mockito.when(resourceV6.startCommand(blueprint.getName())).thenThrow(
            SoftwareManagementPluginException.START_CLUSTER_FAILED(null, null, blueprint.getName()));
      ServicesResourceV6 servicesResourceV6 = Mockito.mock(ServicesResourceV6.class);
      List<ApiService> serviceList = new ArrayList<>();
      ApiService hdfs = new ApiService();
      hdfs.setName("HDFS");
      hdfs.setServiceState(ApiServiceState.STOPPED);
      serviceList.add(hdfs);
      ApiServiceList apiServiceList = new ApiServiceList();
      apiServiceList.setServices(serviceList);
      Mockito.when(servicesResourceV6.readServices((DataView) anyObject())).thenReturn(apiServiceList);

      List<ApiRole> roleList = new ArrayList<>();
      ApiRole role = new ApiRole();
      role.setName("NAMENODE");
      role.setRoleState(ApiRoleState.STOPPED);
      role.setType(role.getName());
      ApiHostRef hostRef = new ApiHostRef("host1");
      role.setHostRef(hostRef);
      roleList.add(role);
      RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
      Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
      Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);

      ApiClusterList apiClusterList = new ApiClusterList();
      ApiCluster apiCluster = new ApiCluster();
      apiCluster.setName(blueprint.getName());
      apiClusterList.add(apiCluster);
      Mockito.when(resourceV6.readClusters((DataView) anyObject())).thenReturn(apiClusterList);

      RootResourceV6 fakeRootResourceV6 = Mockito.mock(FakeRootResource.class);
      Mockito.when(fakeRootResourceV6.getClustersResource()).thenReturn(resourceV6);

      FakeHostsResource fakeHostsResource = Mockito.mock(FakeHostsResource.class);
View Full Code Here

            newRole.setRoleState(ApiRoleState.STOPPED);
            newRoles.add(newRole);
         }
         newService.setRoles(newRoles);
         services.add(newService);
         RolesResourceV6 rolesResourceV6 = new FakeRolesResource(newRoles);
         rolesResources.put(service.getName(), rolesResourceV6);
      }

      return services;
   }
View Full Code Here

      role.setRoleState(ApiRoleState.STARTED);
      role.setType(role.getName());
      ApiHostRef hostRef = new ApiHostRef("host1");
      role.setHostRef(hostRef);
      roleList.add(role);
      RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
      Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
      Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);

      ApiClusterList apiClusterList = new ApiClusterList();
      ApiCluster apiCluster = new ApiCluster();
View Full Code Here

      role.setRoleState(ApiRoleState.STOPPED);
      role.setType(role.getName());
      ApiHostRef hostRef = new ApiHostRef("host1");
      role.setHostRef(hostRef);
      roleList.add(role);
      RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
      Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
      Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);

      ApiClusterList apiClusterList = new ApiClusterList();
      ApiCluster apiCluster = new ApiCluster();
View Full Code Here

      ApiCluster apiCluster = new ApiCluster();
      apiCluster.setName(blueprint.getName());
      apiClusterList.add(apiCluster);
      Mockito.when(resourceV6.readClusters((DataView) anyObject())).thenReturn(apiClusterList);

      RootResourceV6 fakeRootResourceV6 = Mockito.mock(FakeRootResource.class);
      Mockito.when(fakeRootResourceV6.getClustersResource()).thenReturn(resourceV6);

      FakeHostsResource fakeHostsResource = Mockito.mock(FakeHostsResource.class);
      ApiHost apiHost = Mockito.mock(ApiHost.class);
      Mockito.when(apiHost.getIpAddress()).thenReturn("127.0.0.1");
      Mockito.when(fakeHostsResource.readHost(anyString())).thenReturn(apiHost);
      Mockito.when(fakeRootResourceV6.getHostsResource()).thenReturn(fakeHostsResource);

      Mockito.when(apiRootResource.getRootV6()).thenReturn(fakeRootResourceV6);

      boolean exceptionExist = false;
      try {
View Full Code Here

      ApiCluster apiCluster = new ApiCluster();
      apiCluster.setName(blueprint.getName());
      apiClusterList.add(apiCluster);
      Mockito.when(resourceV6.readClusters((DataView) anyObject())).thenReturn(apiClusterList);

      RootResourceV6 fakeRootResourceV6 = Mockito.mock(FakeRootResource.class);
      Mockito.when(fakeRootResourceV6.getClustersResource()).thenReturn(resourceV6);

      FakeHostsResource fakeHostsResource = Mockito.mock(FakeHostsResource.class);
      ApiHost apiHost = Mockito.mock(ApiHost.class);
      Mockito.when(apiHost.getIpAddress()).thenReturn("127.0.0.1");
      Mockito.when(fakeHostsResource.readHost(anyString())).thenReturn(apiHost);
      Mockito.when(fakeRootResourceV6.getHostsResource()).thenReturn(fakeHostsResource);

      Mockito.when(apiRootResource.getRootV6()).thenReturn(fakeRootResourceV6);

      boolean exceptionExist = false;
      try {
View Full Code Here

            @Override
            public ApiCommand abortCommand(long commandId) {
               return null;
            }
         };
         RootResourceV6 mockRootResourceV6 = Mockito.mock(RootResourceV6.class);
         Mockito.when(mockRootResourceV6.getCommandsResource()).thenReturn(fakeCommandResource);
         Mockito.when(apiRootResource.getRootV6()).thenReturn(mockRootResourceV6);
         ClouderaManagerImpl localProvider = new ClouderaManagerImpl("127.0.0.1", 7180, "admin", "admin", "RSA_CERT");
         Object errMsg = method.invoke(localProvider, apiCommand, "http://domain");
         Assert.assertTrue(errMsg instanceof String);
         Assert.assertEquals(errMsg, "TestGetSummaryErrorMsg. Please refer to http://domain/cmf/command/1/details for details");
View Full Code Here

      setupMocks();
      blueprint.getHadoopStack().setDistro("CDH-5.0.1");
      ClustersResourceV6 resourceV6 = Mockito.mock(FakeClustersResource.class);
      Mockito.when(resourceV6.stopCommand(blueprint.getName())).thenThrow(
            SoftwareManagementPluginException.STOP_CLUSTER_FAILED(null, null, blueprint.getName()));
      ServicesResourceV6 servicesResourceV6 = Mockito.mock(ServicesResourceV6.class);
      List<ApiService> serviceList = new ArrayList<>();
      ApiService hdfs = new ApiService();
      hdfs.setName("HDFS");
      hdfs.setServiceState(ApiServiceState.STARTED);
      serviceList.add(hdfs);
      ApiServiceList apiServiceList = new ApiServiceList();
      apiServiceList.setServices(serviceList);
      Mockito.when(servicesResourceV6.readServices((DataView) anyObject())).thenReturn(apiServiceList);

      List<ApiRole> roleList = new ArrayList<>();
      ApiRole role = new ApiRole();
      role.setName("NAMENODE");
      role.setRoleState(ApiRoleState.STARTED);
      role.setType(role.getName());
      ApiHostRef hostRef = new ApiHostRef("host1");
      role.setHostRef(hostRef);
      roleList.add(role);
      RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
      Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
      Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);

      ApiClusterList apiClusterList = new ApiClusterList();
      ApiCluster apiCluster = new ApiCluster();
      apiCluster.setName(blueprint.getName());
View Full Code Here

   private void updateRoleConfigGroups(String clusterName) throws IOException {
      Map<String, String> nameMap = AvailableServiceRoleContainer.nameToDisplayName();
      if (nameMap == null || nameMap.isEmpty()) {
         return;
      }
      ServicesResourceV6 servicesResource = apiResourceRootV6.getClustersResource().getServicesResource(clusterName);
      for (ApiService service : servicesResource.readServices(DataView.SUMMARY)) {
         for (ApiRoleConfigGroup roleConfigGroup : servicesResource.getRoleConfigGroupsResource(service.getName())
               .readRoleConfigGroups()) {
            if (roleConfigGroup == null || !nameMap.containsKey(roleConfigGroup.getRoleType())) {
               continue;
            }

            String roleDisplayName = nameMap.get(roleConfigGroup.getRoleType());
            ApiConfigList configList = new ApiConfigList();
            boolean needUpdate = true;
            switch (roleDisplayName) {
               case "HDFS_NAMENODE":
                  configList.add(new ApiConfig(Constants.CONFIG_DFS_NAME_DIR_LIST, "/tmp/dfs/nn"));
                  break;
               case "HDFS_DATANODE":
                  configList.add(new ApiConfig(Constants.CONFIG_DFS_DATA_DIR_LIST, "/tmp/dfs/dn"));
                  break;
               case "HDFS_SECONDARY_NAMENODE":
                  configList.add(new ApiConfig(Constants.CONFIG_FS_CHECKPOINT_DIR_LIST, "/tmp/dfs/snn"));
                  break;
               case "HDFS_JOURNALNODE":
                  configList.add(new ApiConfig(Constants.CONFIG_DFS_JOURNALNODE_EDITS_DIR, "/tmp/dfs/jn"));
                  break;
               case "YARN_NODE_MANAGER":
                  configList.add(new ApiConfig(Constants.CONFIG_NM_LOCAL_DIRS, "/tmp/yarn/nm"));
                  break;
               case "MAPREDUCE_JOBTRACKER":
                  configList.add(new ApiConfig(Constants.CONFIG_MAPRED_JT_LOCAL_DIR_LIST, "/tmp/mapred/jt"));
                  break;
               case "MAPREDUCE_TASKTRACKER":
                  configList.add(new ApiConfig(Constants.CONFIG_MAPRED_TT_LOCAL_DIR_LIST, "/tmp/mapred/tt"));
                  break;
               default:
                  needUpdate = false;
                  break;
            }

            if (needUpdate) {
               logger.info("Updating base role config group of type: " + roleDisplayName);
               roleConfigGroup.setConfig(configList);
               servicesResource.getRoleConfigGroupsResource(service.getName()).updateRoleConfigGroup(roleConfigGroup.getName(),
                     roleConfigGroup, Constants.ROLE_CONFIG_GROUP_UPDATE_NOTES);
            }
         }
      }
   }
View Full Code Here

TOP

Related Classes of com.cloudera.api.v6.DashboardsResource

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.