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

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

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

origin: otto-de/edison-microservice

@Override
public List<JobInfo> findAllJobInfoWithoutMessages() {
  return jobs.values().stream()
        .sorted(STARTED_TIME_DESC_COMPARATOR)
        .map(job->job.copy().setMessages(emptyList()).build())
        .collect(toList());
}
origin: otto-de/edison-microservice

@Override
public void setJobStatus(String jobId, JobStatus jobStatus) {
  JobInfo jobInfo = jobs.get(jobId);
  jobs.replace(jobId, jobInfo.copy().setStatus(jobStatus).build());
}
origin: otto-de/edison-microservice

@Override
public void setLastUpdate(String jobId, OffsetDateTime lastUpdate) {
  JobInfo jobInfo = jobs.get(jobId);
  jobs.replace(jobId, jobInfo.copy().setLastUpdated(lastUpdate).build());
}
origin: otto-de/edison-microservice

@Override
public void appendMessage(String jobId, JobMessage jobMessage) {
  JobInfo jobInfo = jobs.get(jobId);
  jobs.replace(jobId, jobInfo.copy().setLastUpdated(jobMessage.getTimestamp()).addMessage(jobMessage).build());
}
origin: otto-de/edison-microservice

private JobInfo.Builder defaultJobInfo() {
  return newJobInfo(JOB_ID, JOB_TYPE, clock, HOSTNAME).copy();
}
origin: otto-de/edison-microservice

@Test
public void shouldStoreAndRetrieveAllJobInfoWithoutMessages() {
  // given
  final JobInfo job1 = someJobInfo("http://localhost/foo");
  final JobInfo job2 = someJobInfo("http://localhost/bar");
  repo.createOrUpdate(job1);
  repo.createOrUpdate(job2);
  // when
  final List<JobInfo> jobInfos = repo.findAllJobInfoWithoutMessages();
  // then
  assertThat(jobInfos, hasSize(2));
  assertThat(jobInfos.get(0), is(job1.copy().setMessages(emptyList()).build()));
  assertThat(jobInfos.get(1), is(job2.copy().setMessages(emptyList()).build()));
}
origin: otto-de/edison-microservice

private void stopJob(final String jobId,
           final JobStatus status) {
  jobRepository.findOne(jobId).ifPresent((JobInfo jobInfo) -> {
    jobMetaService.releaseRunLock(jobInfo.getJobType());
    final OffsetDateTime now = now(clock);
    final Builder builder = jobInfo.copy()
        .setStopped(now)
        .setLastUpdated(now);
    if (status != null) {
      builder.setStatus(status);
    }
    jobRepository.createOrUpdate(builder.build());
  });
}
origin: otto-de/edison-microservice

@Test
public void shouldKillJob() {
  OffsetDateTime now = OffsetDateTime.now(clock);
  JobInfo jobInfo = JobInfo.newJobInfo("superId", "superType", clock, HOSTNAME);
  when(jobRepository.findOne("superId")).thenReturn(Optional.of(jobInfo));
  jobService.killJob("superId");
  JobInfo expected = jobInfo.copy().setStatus(JobInfo.JobStatus.DEAD).setStopped(now).setLastUpdated(now).build();
  verify(jobMetaService).releaseRunLock("superType");
  verify(jobRepository).createOrUpdate(expected);
}
origin: otto-de/edison-microservice

@Test
public void shouldStopJob() {
  OffsetDateTime now = OffsetDateTime.now(clock);
  Clock earlierClock = offset(clock, Duration.of(-1, MINUTES));
  JobInfo jobInfo = JobInfo.newJobInfo("superId", "superType", earlierClock, HOSTNAME);
  when(jobRepository.findOne("superId")).thenReturn(Optional.of(jobInfo));
  jobService.stopJob("superId");
  JobInfo expected = jobInfo.copy().setStatus(JobInfo.JobStatus.OK).setStopped(now).setLastUpdated(now).build();
  verify(jobMetaService).releaseRunLock("superType");
  verify(jobRepository).createOrUpdate(expected);
}
origin: otto-de/edison-microservice

@Test
public void shouldUpdateJobInfo() {
  // given
  final JobInfo foo = someJobInfo("http://localhost/foo/B");
  repo.createOrUpdate(foo);
  final JobInfo writtenFoo = repo.createOrUpdate(foo.copy().addMessage(jobMessage(Level.INFO, "some message", now(foo.getClock()))).build());
  // when
  final Optional<JobInfo> jobInfo = repo.findOne("http://localhost/foo/B");
  // then
  assertThat(jobInfo.orElse(null), is(writtenFoo));
}
origin: otto-de/edison-microservice

@Test
public void shouldKeepAtLeastOneSuccessfulJob() {
  // given
  JobInfo job = builder()
      .setJobId("foobar")
      .setJobType("TYPE")
      .setStarted(now(muchEarlier))
      .setStopped(now(now))
      .setHostname("localhost")
      .setStatus(ERROR)
      .build();
  JobRepository repository = new InMemJobRepository() {{
    createOrUpdate(job.copy().setStatus(OK).build());
    createOrUpdate(job.copy().setStarted(now(now)).setJobId("foo").build());
    createOrUpdate(job.copy().setJobId("bar").setStarted(now(earlier)).build());
    createOrUpdate(job.copy().setJobId("barzig").setStarted(now(evenEarlier)).build());
    createOrUpdate(job.copy().setJobId("foozification").setStarted(now(evenEarlier)).build());
  }};
  KeepLastJobs strategy = new KeepLastJobs(repository, 2);
  // when
  strategy.doCleanUp();
  // then
  assertThat(repository.size(), is(3L));
  assertThat(repository.findOne("foo"), isPresent());
  assertThat(repository.findOne("bar"), isPresent());
  assertThat(repository.findOne("barzig"), isAbsent());
  assertThat(repository.findOne("foobar"), isPresent());
  assertThat(repository.findOne("foozification"), isAbsent());
}
origin: otto-de/edison-microservice

@Test
public void shouldOnlyRemoveStoppedJobs() {
  // given
  JobInfo job = builder()
      .setJobId("foo")
      .setJobType("TYPE")
      .setHostname("localhost")
      .setStatus(OK)
      .build();
  JobRepository repository = new InMemJobRepository() {{
    createOrUpdate(job.copy().setStarted(now(now)).setStopped(now(now)).build());
    createOrUpdate(job.copy().setStarted(now(earlier)).setJobId("foobar").setStarted(now(earlier)).build());
    createOrUpdate(job.copy().setStarted(now(muchEarlier)).setJobId("bar").setStopped(now(now)).build());
  }};
  KeepLastJobs strategy = new KeepLastJobs(repository, 1);
  // when
  strategy.doCleanUp();
  // then
  assertThat(repository.findOne("foo"), isPresent());
  assertThat(repository.findOne("foobar"), isPresent());
  assertThat(repository.findOne("bar"), isAbsent());
  assertThat(repository.size(), is(2L));
}
origin: otto-de/edison-microservice

  @Test
  public void shouldOnlyRemoveStoppedJobs() {
    // given
    JobInfo job = builder()
        .setJobId("foo")
        .setJobType("TYPE")
        .setHostname("localhost")
        .setStatus(SKIPPED)
        .build();

    JobRepository repository = new InMemJobRepository() {{
      createOrUpdate(job.copy().setStarted(now(now)).setStopped(now(now)).build());
      createOrUpdate(job.copy().setStarted(now(earlier)).setJobId("foobar").setStarted(now(earlier)).build());
      createOrUpdate(job.copy().setStarted(now(muchEarlier)).setJobId("bar").setStopped(now(now)).build());
    }};
    KeepLastJobs strategy = new KeepLastJobs(repository, 1);

    // when
    strategy.doCleanUp();
    // then
    assertThat(repository.findOne("foo"), isPresent());
    assertThat(repository.findOne("foobar"), isPresent());
    assertThat(repository.findOne("bar"), isAbsent());

    assertThat(repository.size(), is(2L));
  }
}
origin: otto-de/edison-microservice

@Test
public void shouldKeepNJobsOfEachTypePresentAndNotRemoveRunningJobs() {
  // given
  JobInfo stoppedJob = builder()
      .setJobId("foo1")
      .setJobType("TYPE1")
      .setStarted(now(now))
      .setStopped(now(now))
      .setHostname("localhost")
      .setStatus(OK)
      .build();
  JobRepository repository = new InMemJobRepository() {{
    createOrUpdate(stoppedJob);
    createOrUpdate(stoppedJob.copy().setJobId("foo2").setStopped(now(muchEarlier)).setStarted(now(muchEarlier)).build());
    createOrUpdate(stoppedJob.copy().setJobId("foo3").setStopped(now(evenEarlier)).setStarted(now(evenEarlier)).build());
    createOrUpdate(stoppedJob.copy().setJobId("bar1").setJobType("TYPE2").setStopped(now(earlier)).setStarted(now(earlier)).build());
    createOrUpdate(stoppedJob.copy().setJobId("bar2").setJobType("TYPE2").setStopped(now(muchEarlier)).setStarted(now(muchEarlier)).build());
    createOrUpdate(stoppedJob.copy().setJobId("bar3").setJobType("TYPE2").setStopped(now(evenEarlier)).setStarted(now(evenEarlier)).build());
  }};
  KeepLastJobs strategy = new KeepLastJobs(repository, 2);
  // when
  strategy.doCleanUp();
  // then
  assertThat(repository.size(), is(4L));
  assertThat(repository.findByType("TYPE1"), hasSize(2));
  assertThat(repository.findByType("TYPE2"), hasSize(2));
}
origin: otto-de/edison-microservice

@Test
public void shouldRemoveOldestJobs() {
  // given
  JobInfo job = builder()
      .setJobId("foo")
      .setJobType("TYPE")
      .setStarted(now(now))
      .setStopped(now(now))
      .setHostname("localhost")
      .setStatus(OK)
      .build();
  JobRepository repository = new InMemJobRepository() {{
    createOrUpdate(job);
    createOrUpdate(job.copy().setJobId("foobar").setStarted(now(earlier)).build());
    createOrUpdate(job.copy().setJobId("bar").setStarted(now(muchEarlier)).build());
  }};
  KeepLastJobs strategy = new KeepLastJobs(repository, 2);
  // when
  strategy.doCleanUp();
  // then
  assertThat(repository.size(), is(2L));
  assertThat(repository.findOne("bar"), isAbsent());
}
origin: otto-de/edison-microservice

@Test
public void shouldRemoveOldestJobs() {
  // given
  JobInfo job = builder()
      .setJobId("foo")
      .setJobType("TYPE")
      .setStarted(now(now))
      .setStopped(now(now))
      .setHostname("localhost")
      .setStatus(SKIPPED)
      .build();
  JobRepository repository = new InMemJobRepository() {{
    createOrUpdate(job);
    createOrUpdate(job.copy().setJobId("foobar").setStarted(now(earlier)).build());
    createOrUpdate(job.copy().setJobId("bar").setStarted(now(muchEarlier)).build());
  }};
  KeepLastJobs strategy = new KeepLastJobs(repository, 2);
  // when
  strategy.doCleanUp();
  // then
  assertThat(repository.size(), is(2L));
  assertThat(repository.findOne("bar"), isAbsent());
}
de.otto.edison.jobs.domainJobInfocopy

Popular methods of JobInfo

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

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • setContentView (Activity)
  • startActivity (Activity)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JLabel (javax.swing)
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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