Tabnine Logo
LastRunConstraint
Code IndexAdd Tabnine to your IDE (free)

How to use
LastRunConstraint
in
co.cask.cdap.internal.app.runtime.schedule.constraint

Best Java code snippets using co.cask.cdap.internal.app.runtime.schedule.constraint.LastRunConstraint (Showing top 6 results out of 315)

origin: cdapio/cdap

@Override
public ConstraintProgramScheduleBuilder withDurationSinceLastRun(long duration, TimeUnit unit) {
 constraints.add(new LastRunConstraint(duration, unit));
 return this;
}
origin: cdapio/cdap

LastRunConstraint lastRunConstraint = new LastRunConstraint(1, TimeUnit.HOURS);
ConstraintContext constraintContext = new ConstraintContext(job, now, store);
assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext));
Map<String, String> systemArgs = ImmutableMap.of(ProgramOptionConstants.SCHEDULE_NAME, schedule.getName());
setStartAndRunning(store, pid1, EMPTY_MAP, systemArgs);
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
store.setResume(pid1, AppFabricTestHelper.createSourceId(++sourceId), -1);
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
store.setStop(pid3, nowSec - TimeUnit.MINUTES.toSeconds(1), ProgramRunStatus.KILLED,
       AppFabricTestHelper.createSourceId(++sourceId));
assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext));
origin: cdapio/cdap

@Override
public ConstraintResult check(ProgramSchedule schedule, ConstraintContext context) {
 long startTime = TimeUnit.MILLISECONDS.toSeconds(context.getCheckTimeMillis() - millisSinceLastRun);
 // We only need to check program runs within recent history, adding a buffer of 1 day, because the time range
 // is for the start time of the program. It may start before `millisSinceLastRun`, but complete after it.
 // Note: this will miss out on active workflow runs that started more than ~1day ago (suspended/lengthy workflows)
 Iterable<RunRecordMeta> runRecords =
  context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.ALL,
              startTime - TimeUnit.DAYS.toSeconds(1), Long.MAX_VALUE, 100).values();
 // We can limit to 100, since just 1 program in the recent history is enough to make the constraint fail.
 // We want use 100 as the limit instead of 1, because we want to attempt to get the latest completed run,
 // instead of just the first (in order to more accurately compute a next runtime
 if (Iterables.isEmpty(filter(runRecords, startTime))) {
  return ConstraintResult.SATISFIED;
 }
 if (!waitUntilMet) {
  return ConstraintResult.NEVER_SATISFIED;
 }
 return new ConstraintResult(ConstraintResult.SatisfiedState.NOT_SATISFIED,
               context.getCheckTimeMillis() + TimeUnit.SECONDS.toMillis(10));
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public ConstraintResult check(ProgramSchedule schedule, ConstraintContext context) {
 long startTime = TimeUnit.MILLISECONDS.toSeconds(context.getCheckTimeMillis() - millisSinceLastRun);
 // We only need to check program runs within recent history, adding a buffer of 1 day, because the time range
 // is for the start time of the program. It may start before `millisSinceLastRun`, but complete after it.
 // Note: this will miss out on active workflow runs that started more than ~1day ago (suspended/lengthy workflows)
 Iterable<RunRecordMeta> runRecords =
  context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.ALL,
              startTime - TimeUnit.DAYS.toSeconds(1), Long.MAX_VALUE, 100).values();
 // We can limit to 100, since just 1 program in the recent history is enough to make the constraint fail.
 // We want use 100 as the limit instead of 1, because we want to attempt to get the latest completed run,
 // instead of just the first (in order to more accurately compute a next runtime
 if (Iterables.isEmpty(filter(runRecords, startTime))) {
  return ConstraintResult.SATISFIED;
 }
 if (!waitUntilMet) {
  return ConstraintResult.NEVER_SATISFIED;
 }
 return new ConstraintResult(ConstraintResult.SatisfiedState.NOT_SATISFIED,
               context.getCheckTimeMillis() + TimeUnit.SECONDS.toMillis(10));
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public ConstraintProgramScheduleBuilder withDurationSinceLastRun(long duration, TimeUnit unit) {
 constraints.add(new LastRunConstraint(duration, unit));
 return this;
}
origin: cdapio/cdap

@Test
public void testConstraintCodec() {
 testSerDeser(new ProtoConstraint.ConcurrencyConstraint(3), new ConcurrencyConstraint(3));
 testSerDeser(new ProtoConstraint.DelayConstraint(300000L, TimeUnit.MILLISECONDS),
        new DelayConstraint(300000L, TimeUnit.MILLISECONDS));
 testSerDeser(new ProtoConstraint.LastRunConstraint(3600000L, TimeUnit.MILLISECONDS),
        new LastRunConstraint(3600000L, TimeUnit.MILLISECONDS));
 testSerDeser(new ProtoConstraint.TimeRangeConstraint("02:00", "06:00", TimeZone.getDefault()),
        new TimeRangeConstraint("02:00", "06:00", TimeZone.getDefault()));
}
co.cask.cdap.internal.app.runtime.schedule.constraintLastRunConstraint

Javadoc

A Constraint which requires a certain duration pass since the last execution of the schedule.

Most used methods

  • <init>
  • check
  • filter

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getContentResolver (Context)
  • setScale (BigDecimal)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top plugins for Android Studio
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