public TaskId(JobId jobId, long taskNum) { this.jobId = jobId; this.taskNum = taskNum; this.id = String.format("%s-%03d", jobId.getId(), taskNum); }
/** * Create a cluster job with the given job id that represent the given action to perform on a cluster, for the given * services on the given nodes. Null values for services or nodes indicates that the job covers all cluster services * or all cluster nodes. * * @param jobId Id of the job. * @param clusterAction Action the job is carrying out. * @param plannedServices Services affected by the job, with null indicating all services. * @param plannedNodes Nodes affected by the job, with null indicating all nodes. */ public ClusterJob(JobId jobId, ClusterAction clusterAction, Set<String> plannedServices, Set<String> plannedNodes) { this.jobId = jobId.getId(); this.clusterId = jobId.getClusterId(); this.clusterAction = clusterAction; this.stagedTasks = Lists.newArrayList(); this.currentStageNumber = 0; this.jobStatus = Status.NOT_SUBMITTED; this.plannedServices = plannedServices; this.plannedNodes = plannedNodes; taskStatus = Maps.newHashMap(); }
public ClusterTask(ProvisionerAction taskName, TaskId taskId, String nodeId, String service, ClusterAction clusterAction, String clusterTemplateName, Account account) { this.taskId = taskId.getId(); this.jobId = String.valueOf(taskId.getJobId().getId()); this.clusterId = taskId.getClusterId(); this.taskName = taskName; this.clusterAction = clusterAction; this.nodeId = nodeId; this.service = service; this.attempts = Lists.newArrayList(); //TODO: populate clusterTemplateName and account field for existing tasks: https://issues.cask.co/browse/COOPR-593 this.clusterTemplateName = clusterTemplateName; this.account = account; addAttempt(); }
ClusterJob configureJob = new ClusterJob(configureJobId, action); configureJob.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(configureJobId.getId()); cluster.setStatus(Cluster.Status.PENDING);
ClusterJob deleteJob = new ClusterJob(deleteJobId, ClusterAction.CLUSTER_DELETE); deleteJob.setJobStatus(ClusterJob.Status.RUNNING); cluster.setLatestJobId(deleteJobId.getId()); cluster.setStatus(Cluster.Status.PENDING); prepareClusterForOperation(cluster, request);
@Test public void testGetStoreDeleteClusterAsSystem() throws Exception { Cluster cluster = Cluster.builder() .setID("104") .setAccount(tenant1_user1) .setName("example-hdfs-delete") .setProvider(Entities.ProviderExample.RACKSPACE) .setClusterTemplate(Entities.ClusterTemplateExample.HDFS) .setNodes(ImmutableSet.of("node1", "node2")) .setServices(ImmutableSet.of("s1", "s2")) .build(); cluster.setLatestJobId(new JobId(cluster.getId(), 1).getId()); assertGetStoreDeleteCluster(systemView, cluster); }
.setName("cluster1") .setID(cluster1ID) .setLatestJobID(jobid1.getId()) .setClusterTemplate(Entities.ClusterTemplateExample.HDFS) .setAccount(tenant1_admin) .setName("cluster2") .setID(cluster2ID) .setLatestJobID(jobid2.getId()) .setClusterTemplate(Entities.ClusterTemplateExample.HDFS) .setAccount(tenant1_admin)
private Cluster createActiveCluster() throws IOException, IllegalAccessException { // Simulates an active cluster. The existing cluster will have // some user fields already specified from the initial cluster create operation, but another user field will // not exist because it is a sensitive field and was thus never persisted. // create a provider that already has the 'keyname' user field specified. Provider provider1 = Provider.builder() .setProviderType(providerType.getName()) .setProvisionerFields(ImmutableMap.<String, Object>of( "region", "iad", "url", "http://abc.com/api", "keyname", "mykey")) .setName("provider") .build(); // write the cluster to the store String clusterId = "123"; Cluster cluster = Cluster.builder() .setName("cluster1") .setID(clusterId) .setProvider(provider1) .setClusterTemplate(basicTemplate) .setServices(ImmutableSet.of(service1.getName())) .setNodes(ImmutableSet.of("node1")) .setAccount(account) .setStatus(Cluster.Status.ACTIVE) .setLatestJobID(new JobId(clusterId, 1).getId()) .build(); clusterStore.writeCluster(cluster); return cluster; } }