Package com.spotify.helios.common.descriptors

Examples of com.spotify.helios.common.descriptors.JobId


        }

        boolean jobRemovalFailed = false;
        // Iterate over jobs, looking for ones with a matching prefix.
        for (Map.Entry<JobId, Job> entry : jobs.entrySet()) {
          final JobId jobId = entry.getKey();
          // Skip over job if the id doesn't start with current filename.
          if (!jobId.getName().startsWith(prefixFile.prefix())) {
            continue;
          }
          // Get list of all hosts where this job is deployed, and undeploy
          final JobStatus status = client.jobStatus(entry.getKey()).get();
          final List<String> hosts = ImmutableList.copyOf(status.getDeployments().keySet());
View Full Code Here


  }

  @Override
  protected void runOneIteration() {
    for (Entry<JobId, Job> entry : masterModel.getJobs().entrySet()) {
      final JobId jobId = entry.getKey();
      final Job job = entry.getValue();

      if (job.getExpires() == null) {
        continue;
      } else if (job.getExpires().getTime() <= clock.now().getMillis()) {
View Full Code Here

    // If too many "globally", toss them
    while (count.get() >= MAX_TOTAL_SIZE) {
      getNext();
    }

    final JobId key = item.getStatus().getJob().getId();
    final Deque<TaskStatusEvent> deque = getDeque(key);

    synchronized (deque) {
      // if too many in the particular deque, toss them
      while (deque.size() >= MAX_QUEUE_SIZE) {
View Full Code Here

      // Didn't find anything that needed processing?
      if (current == null) {
        return null;
      }

      final JobId id = current.getStatus().getJob().getId();
      final Deque<TaskStatusEvent> deque = items.get(id);
      if (deque == null) {
        // shouldn't happen because we should be the only one pulling items off, but....
        continue;
      }
View Full Code Here

  public boolean isEmpty() {
    return count.get() == 0;
  }

  private void putBack(TaskStatusEvent event) {
    final JobId key = event.getStatus().getJob().getId();
    final Deque<TaskStatusEvent> queue = getDeque(key);
    synchronized (queue) {
      if (queue.size() >= MAX_QUEUE_SIZE) {
        // already full, just toss the event
        return;
View Full Code Here

      if (item == null) {
        return;
      }

      try {
        final JobId jobId = item.getStatus().getJob().getId();
        final String historyPath = Paths.historyJobHostEventsTimestamp(
            jobId, hostname, item.getTimestamp());
        log.debug("writing queued item to zookeeper {} {}", item.getStatus().getJob().getId(),
            item.getTimestamp());
        client.ensurePath(historyPath, true);
View Full Code Here

    //         be undeployed and deleted.
    //  job4 - Created, not deployed, not locked. Simulates an old job no longer in use, which
    //         should be deleted.

    // job1 - create and deploy
    final JobId jobId1 = createJob(testJobName + "_1", testJobVersion, BUSYBOX, IDLE_COMMAND);
    deployJob(jobId1, testHost1);
    // job2 - create
    final JobId jobId2 = createJob(testJobName + "_2", testJobVersion, BUSYBOX, IDLE_COMMAND);
    // job3 - create and deploy
    final JobId jobId3 = createJob(testJobName + "_3", testJobVersion, BUSYBOX, IDLE_COMMAND);
    deployJob(jobId3, testHost1);
    // job4 - create
    final JobId jobId4 = createJob(testJobName + "_4", testJobVersion, BUSYBOX, IDLE_COMMAND);

    try (
        // Create prefix files for all four jobs. They will be locked by default.
        JobPrefixFile file1 = JobPrefixFile.create(jobId1.getName(), prefixDirectory);
        JobPrefixFile file2 = JobPrefixFile.create(jobId2.getName(), prefixDirectory);
        JobPrefixFile file3 = JobPrefixFile.create(jobId3.getName(), prefixDirectory);
        JobPrefixFile file4 = JobPrefixFile.create(jobId4.getName(), prefixDirectory)
    ) {
      // Release the locks of jobs 3 and 4 so they can be cleaned up
      file3.release();
      file4.release();

      assertThat(testResult(JobNamePrefixTestImpl.class), isSuccessful());

      final Map<JobId, Job> jobs = client.jobs().get();

      // Verify job1 is still deployed and the prefix file has not been deleted.
      assertThat(jobs, hasKey(jobId1));
      final JobStatus status1 = client.jobStatus(jobId1).get();
      assertThat(status1.getDeployments().size(), is(1));
      assertTrue(fileExists(prefixDirectory, jobId1.getName()));

      // Verify job2 still exists, is not deployed, and the prefix file is still there.
      assertThat(jobs, hasKey(jobId2));
      final JobStatus status2 = client.jobStatus(jobId2).get();
      assertThat(status2.getDeployments().size(), is(0));
      assertTrue(fileExists(prefixDirectory, jobId2.getName()));

      // Verify that job3 has been deleted (which means it has also been undeployed), and
      // the prefix file has been deleted.
      assertThat(jobs, not(hasKey(jobId3)));
      assertFalse(fileExists(prefixDirectory, jobId3.getName()));

      // Verify that job4 and its prefix file have been deleted.
      assertThat(jobs, not(hasKey(jobId4)));
      assertFalse(fileExists(prefixDirectory, jobId4.getName()));

      // Verify the prefix file created during the run of JobNamePrefixTest was deleted
      assertFalse(fileExists(prefixDirectory, jobPrefixFile.prefix()));
    }
  }
View Full Code Here

                                          "echo role: $SPOTIFY_ROLE; " +
                                          "echo foo: $FOO; " +
                                          "echo bar: $BAR");

      // Create job
      final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, command,
                                    ImmutableMap.of("FOO", "4711",
                                                    "BAR", "deadbeef"));

      // deploy
      deployJob(jobId, testHost());
View Full Code Here

  @Test
  public void testClient() throws Exception {
    final CreateJobResponse created = client.createJob(job).get();
    assertEquals(CreateJobResponse.Status.OK, created.getStatus());

    JobId jobId = job.getId();
    // Wait for agent to come up
    awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS);
    awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);

    // Deploy the job on the agent
View Full Code Here

    final String server2 = "127.0.0.2";
    startDefaultMaster();
    startDefaultAgent(testHost(), "--dns", server1, "--dns", server2);
    awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);

    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX,
                                  asList("cat", "/etc/resolv.conf"));

    deployJob(jobId, testHost());

    final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
View Full Code Here

TOP

Related Classes of com.spotify.helios.common.descriptors.JobId

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.