Tabnine Logo
JobInfo.getJobId
Code IndexAdd Tabnine to your IDE (free)

How to use
getJobId
method
in
de.otto.edison.jobs.domain.JobInfo

Best Java code snippets using de.otto.edison.jobs.domain.JobInfo.getJobId (Showing top 20 results out of 315)

origin: de.otto.edison/edison-mongo

@Override
protected final String keyOf(final JobInfo value) {
  return value.getJobId();
}
origin: otto-de/edison-microservice

@Override
protected final String keyOf(final JobInfo value) {
  return value.getJobId();
}
origin: otto-de/edison-microservice

@Override
public JobInfo createOrUpdate(final JobInfo job) {
  jobs.put(job.getJobId(), job);
  return job;
}
origin: otto-de/edison-microservice

public void deleteJobs(final Optional<String> type) {
  if (type.isPresent()) {
    jobRepository.findByType(type.get()).forEach((j) -> jobRepository.removeIfStopped(j.getJobId()));
  } else {
    jobRepository.findAll().forEach((j) -> jobRepository.removeIfStopped(j.getJobId()));
  }
}
origin: otto-de/edison-microservice

/**
 * Execute the cleanup of the given repository.
 */
@Scheduled(fixedRate = KEEP_LAST_JOBS_CLEANUP_INTERVAL)
public void doCleanUp() {
  final List<JobInfo> jobs = jobRepository.findAllJobInfoWithoutMessages();
  findJobsToDelete(jobs)
      .forEach(jobInfo -> jobRepository.removeIfStopped(jobInfo.getJobId()));
}
origin: otto-de/edison-microservice

/**
 * Execute the cleanup of the given repository.
 */
@Scheduled(fixedRate = KEEP_LAST_JOBS_CLEANUP_INTERVAL)
public void doCleanUp() {
  final List<JobInfo> jobs = jobRepository.findAllJobInfoWithoutMessages();
  findJobsToDelete(jobs)
      .forEach(jobInfo -> jobRepository.removeIfStopped(jobInfo.getJobId()));
}
origin: otto-de/edison-microservice

public List<Link> getLinks() {
  final String jobUri = String.format("%s%s/jobs/%s", baseUri, edisonManagementBasePath, job.getJobId());
  return asList(
      link("self", jobUri, "Self"),
      link("http://github.com/otto-de/edison/link-relations/job/definition", String.format("%s%s/jobdefinitions/%s", baseUri, edisonManagementBasePath, job.getJobType()), "Job Definition"),
      link("collection", jobUri.substring(0, jobUri.lastIndexOf("/")), "All Jobs"),
      link("collection/" + getJobType(), jobUri.substring(0, jobUri.lastIndexOf("/")) + "?type=" + getJobType(), "All " + getJobType() + " Jobs")
  );
}
origin: otto-de/edison-microservice

public void killJobsDeadSince(final int seconds) {
  final OffsetDateTime timeToMarkJobAsStopped = now(clock).minusSeconds(seconds);
  LOG.info(format("JobCleanup: Looking for jobs older than %s ", timeToMarkJobAsStopped));
  final List<JobInfo> deadJobs = jobRepository.findRunningWithoutUpdateSince(timeToMarkJobAsStopped);
  deadJobs.forEach(deadJob -> killJob(deadJob.getJobId()));
  clearRunLocks();
}
origin: otto-de/edison-microservice

  private JobInfo someRunningJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) {
    OffsetDateTime now = now();
    JobInfo someJob = mock(JobInfo.class);
    when(someJob.getJobType()).thenReturn("someJobType");
    when(someJob.getJobId()).thenReturn("someJobId");
    when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo));
    when(someJob.getStopped()).thenReturn(empty());
    when(someJob.getStatus()).thenReturn(jobStatus);
    return someJob;
  }
}
origin: otto-de/edison-microservice

@Test
public void shouldFindAll() {
  // given
  repository.createOrUpdate(newJobInfo("oldest", "FOO", fixed(Instant.now().minusSeconds(1), systemDefault()), "localhost"));
  repository.createOrUpdate(newJobInfo("youngest", "FOO", fixed(Instant.now(), systemDefault()), "localhost"));
  // when
  final List<JobInfo> jobInfos = repository.findAll();
  // then
  assertThat(jobInfos.size(), is(2));
  assertThat(jobInfos.get(0).getJobId(), is("youngest"));
  assertThat(jobInfos.get(1).getJobId(), is("oldest"));
}
origin: otto-de/edison-microservice

private JobInfo someStoppedJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) {
  OffsetDateTime now = now();
  JobInfo someJob = mock(JobInfo.class);
  when(someJob.getJobType()).thenReturn("someJobType");
  when(someJob.getJobId()).thenReturn("someId");
  when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo));
  when(someJob.getStopped()).thenReturn(of(now.minusSeconds(startedSecondsAgo-1)));
  when(someJob.getStatus()).thenReturn(jobStatus);
  return someJob;
}
origin: otto-de/edison-microservice

@Test
public void shouldKillDeadJobsSince() {
  JobInfo someJobInfo = defaultJobInfo().setJobType("jobType").build();
  when(jobRepository.findRunningWithoutUpdateSince(any())).thenReturn(singletonList(someJobInfo));
  when(jobRepository.findOne(someJobInfo.getJobId())).thenReturn(Optional.of(someJobInfo));
  jobService.killJobsDeadSince(60);
  verify(jobMetaService).releaseRunLock("jobType");
}
origin: otto-de/edison-microservice

@Test
public void shouldRunJob() {
  // given:
  String jobType = "bar";
  when(jobRunnable.getJobDefinition()).thenReturn(someJobDefinition(jobType));
  // when:
  Optional<String> optionalJobId = jobService.startAsyncJob(jobType);
  // then:
  final JobInfo expectedJobInfo = JobInfo.newJobInfo(optionalJobId.get(), jobType, clock, systemInfo.hostname);
  verify(executorService).execute(any(Runnable.class));
  verify(jobRepository).createOrUpdate(expectedJobInfo);
  verify(jobRunnable).execute();
  verify(jobMetaService).aquireRunLock(expectedJobInfo.getJobId(), expectedJobInfo.getJobType());
}
origin: otto-de/edison-microservice

@Test
public void shouldKillJobsWithoutUpdateSince() {
  JobInfo toBeKilled = defaultJobInfo("toBeKilled", 75);
  jobRepository.createOrUpdate(toBeKilled);
  jobService.killJobsDeadSince(60);
  Optional<JobInfo> expectedKilledJob = jobRepository.findOne(toBeKilled.getJobId());
  assertThat(expectedKilledJob.get().isStopped(), is(true));
  assertThat(expectedKilledJob.get().getStatus(), is(DEAD));
}
origin: otto-de/edison-microservice

@Test
public void shouldNotKillJobsThatHaveRecentlyBeenUpdated() {
  JobInfo notToBeKilled = defaultJobInfo("notToBeKilled", 45);
  jobRepository.createOrUpdate(notToBeKilled);
  jobService.killJobsDeadSince(60);
  Optional<JobInfo> expectedRunningJob = jobRepository.findOne(notToBeKilled.getJobId());
  assertThat(expectedRunningJob.get().isStopped(), is(false));
  assertThat(expectedRunningJob.get().getStatus(), is(OK));
}
origin: otto-de/edison-microservice

@Test
public void shouldUpdateJobLastUpdateTime() {
  //Given
  final JobInfo foo = jobInfo("http://localhost/foo", "T_FOO");
  repo.createOrUpdate(foo);
  final OffsetDateTime myTestTime = OffsetDateTime.of(1979, 2, 5, 1, 2, 3, 4, ZoneOffset.UTC);
  //When
  repo.setLastUpdate(foo.getJobId(), myTestTime);
  final Optional<JobInfo> jobInfo = repo.findOne(foo.getJobId());
  //Then
  assertThat(jobInfo, OptionalMatchers.isPresent());
  assertThat(Date.from(jobInfo.get().getLastUpdated().toInstant()), is(Date.from(myTestTime.toInstant())));
}
origin: otto-de/edison-microservice

@Test
public void shouldFindRunningJobsWithoutUpdatedSinceSpecificDate() throws Exception {
  // given
  repository.createOrUpdate(newJobInfo("deadJob", "FOO", fixed(Instant.now().minusSeconds(10), systemDefault()), "localhost"));
  repository.createOrUpdate(newJobInfo("running", "FOO", fixed(Instant.now(), systemDefault()), "localhost"));
  // when
  final List<JobInfo> jobInfos = repository.findRunningWithoutUpdateSince(now().minus(5, ChronoUnit.SECONDS));
  // then
  assertThat(jobInfos, IsCollectionWithSize.hasSize(1));
  assertThat(jobInfos.get(0).getJobId(), is("deadJob"));
}
origin: otto-de/edison-microservice

@Test
public void shouldFindJobInfoByUri() {
  // given
  InMemJobRepository repository = new InMemJobRepository();
  // when
  JobInfo job = newJobInfo(randomUUID().toString(), "MYJOB", clock, "localhost");
  repository.createOrUpdate(job);
  // then
  assertThat(repository.findOne(job.getJobId()), isPresent());
}
origin: otto-de/edison-microservice

@Test
public void shouldUpdateJobStatus() {
  //Given
  final JobInfo foo = jobInfo("http://localhost/foo", "T_FOO"); //default jobStatus is 'OK'
  repository.createOrUpdate(foo);
  //When
  repository.setJobStatus(foo.getJobId(), ERROR);
  JobStatus status = repository.findStatus("http://localhost/foo");
  //Then
  assertThat(status, is(ERROR));
}
origin: otto-de/edison-microservice

@Test
public void shouldUpdateJobStatus() {
  //Given
  final JobInfo foo = jobInfo("http://localhost/foo", "T_FOO"); //default jobStatus is 'OK'
  repo.createOrUpdate(foo);
  //When
  repo.setJobStatus(foo.getJobId(), ERROR);
  final JobStatus status = repo.findStatus("http://localhost/foo");
  //Then
  assertThat(status, is(ERROR));
}
de.otto.edison.jobs.domainJobInfogetJobId

Popular methods of JobInfo

  • getJobType
  • getLastUpdated
  • getMessages
  • getStarted
  • getStatus
  • getStopped
  • isStopped
  • newJobInfo
  • copy
  • getHostname
  • <init>
  • builder
  • <init>,
  • builder,
  • equals,
  • getClock,
  • hashCode

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • findViewById (Activity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Collectors (java.util.stream)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now