Codota Logo
ProgramController$State
Code IndexAdd Codota to your IDE (free)

How to use
ProgramController$State
in
co.cask.cdap.app.runtime

Best Java code snippets using co.cask.cdap.app.runtime.ProgramController$State (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: co.cask.cdap/cdap-app-fabric

protected void complete(final State completionState) {
 LOG.trace("Program {} completed with state {}", programId, completionState);
 if (!state.compareAndSet(State.STARTING, completionState)
  && !state.compareAndSet(State.ALIVE, completionState)
  && !state.compareAndSet(State.SUSPENDED, completionState)) {
  LOG.warn("Cannot transit to COMPLETED state from {} state: {}", state.get(), name);
  return;
 }
 executor.execute(() -> {
  state.set(completionState);
  if (State.KILLED.equals(completionState)) {
   caller.killed();
  } else {
   caller.completed();
  }
 });
}
origin: cdapio/cdap

@Override
public List<RuntimeInfo> listAll(ProgramType... types) {
 List<RuntimeInfo> runningPrograms = new ArrayList<>();
 for (ProgramType type : types) {
  for (Map.Entry<RunId, RuntimeInfo> entry : list(type).entrySet()) {
   ProgramController.State programState = entry.getValue().getController().getState();
   if (programState.isDone()) {
    continue;
   }
   runningPrograms.add(entry.getValue());
  }
 }
 return runningPrograms;
}
origin: cdapio/cdap

@Test
public void testStopBeforeStart() throws RuntimeException {
 ProgramId programId = new ProgramId("account1", "invalidApp", ProgramType.MAPREDUCE, "InvalidMR");
 long now = System.currentTimeMillis();
 String pid = RunIds.generate().getId();
 store.setStop(programId.run(pid), now, ProgramController.State.ERROR.getRunStatus(),
        ByteBuffer.allocate(0).array());
 Assert.assertNull(store.getRun(programId.run(pid)));
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public List<RuntimeInfo> listAll(ProgramType... types) {
 List<RuntimeInfo> runningPrograms = new ArrayList<>();
 for (ProgramType type : types) {
  for (Map.Entry<RunId, RuntimeInfo> entry : list(type).entrySet()) {
   ProgramController.State programState = entry.getValue().getController().getState();
   if (programState.isDone()) {
    continue;
   }
   runningPrograms.add(entry.getValue());
  }
 }
 return runningPrograms;
}
origin: co.cask.cdap/cdap-app-fabric

private Predicate<RunRecordMeta> getPredicate(final ProgramController.State state) {
 return (record) -> record.getStatus().equals(state.getRunStatus());
}
origin: cdapio/cdap

@Test
public void testConcurrentStopStart() {
 // Two programs that start/stop at same time
 // Should have two run history.
 ProgramId programId = new ProgramId("account1", "concurrentApp", ProgramType.MAPREDUCE, "concurrentMR");
 long now = System.currentTimeMillis();
 long nowSecs = TimeUnit.MILLISECONDS.toSeconds(now);
 RunId run1 = RunIds.generate(now - 10000);
 ArtifactId artifactId = programId.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();
 setStartAndRunning(programId.run(run1.getId()), artifactId);
 RunId run2 = RunIds.generate(now - 10000);
 setStartAndRunning(programId.run(run2.getId()), artifactId);
 store.setStop(programId.run(run1.getId()), nowSecs, ProgramController.State.COMPLETED.getRunStatus(),
        AppFabricTestHelper.createSourceId(++sourceId));
 store.setStop(programId.run(run2.getId()), nowSecs, ProgramController.State.COMPLETED.getRunStatus(),
        AppFabricTestHelper.createSourceId(++sourceId));
 Map<ProgramRunId, RunRecordMeta> historymap = store.getRuns(programId, ProgramRunStatus.ALL,
                               0, Long.MAX_VALUE, Integer.MAX_VALUE);
 Assert.assertEquals(2, historymap.size());
}
origin: cdapio/cdap

@Test
public void testRunsLimit() {
 ApplicationSpecification spec = Specifications.from(new AllProgramsApp());
 ApplicationId appId = new ApplicationId("testRunsLimit", spec.getName());
 store.addApplication(appId, spec);
 ProgramId mapreduceProgramId = new ApplicationId("testRunsLimit", spec.getName())
  .mr(AllProgramsApp.NoOpMR.class.getSimpleName());
 ArtifactId artifactId = appId.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();
 Assert.assertNotNull(store.getApplication(appId));
 long now = System.currentTimeMillis();
 ProgramRunId programRunId = mapreduceProgramId.run(RunIds.generate(now - 3000));
 setStartAndRunning(programRunId, artifactId);
 store.setStop(programRunId, now - 100, ProgramController.State.COMPLETED.getRunStatus(),
        AppFabricTestHelper.createSourceId(++sourceId));
 setStartAndRunning(mapreduceProgramId.run(RunIds.generate(now - 2000)), artifactId);
 // even though there's two separate run records (one that's complete and one that's active), only one should be
 // returned by the query, because the limit parameter of 1 is being passed in.
 Map<ProgramRunId, RunRecordMeta> historymap = store.getRuns(mapreduceProgramId, ProgramRunStatus.ALL,
                               0, Long.MAX_VALUE, 1);
 Assert.assertEquals(1, historymap.size());
}
origin: cdapio/cdap

store.setStop(mapreduceProgramRunId1, now, ProgramController.State.COMPLETED.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
store.setStop(workflowProgramId1.run(runId.getId()), now, ProgramController.State.COMPLETED.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
store.setStop(serviceRunId, now, ProgramController.State.COMPLETED.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
origin: cdapio/cdap

ProgramController.State.ERROR.getRunStatus(), AppFabricTestHelper.createSourceId(++sourceId));
origin: cdapio/cdap

while (!controller.getState().equals(ProgramController.State.COMPLETED)) {
 TimeUnit.MILLISECONDS.sleep(100);
origin: cdapio/cdap

private Predicate<RunRecordMeta> getPredicate(final ProgramController.State state) {
 return (record) -> record.getStatus().equals(state.getRunStatus());
}
origin: cdapio/cdap

ArtifactId artifactId = programId.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();
setStartAndRunning(programId.run(run1.getId()), artifactId);
store.setStop(programId.run(run1.getId()), startTimeSecs - 10, ProgramController.State.ERROR.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
store.setStop(programId.run(run2.getId()), startTimeSecs - 5, ProgramController.State.COMPLETED.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
RunId run4 = RunIds.generate(now - 5000);
setStartAndRunning(programId2.run(run4.getId()), artifactId);
store.setStop(programId2.run(run4.getId()), startTimeSecs - 4, ProgramController.State.COMPLETED.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
Assert.assertEquals(startTimeSecs - 10, run.getStartTs());
Assert.assertEquals(Long.valueOf(startTimeSecs - 5), run.getStopTs());
Assert.assertEquals(ProgramController.State.COMPLETED.getRunStatus(), run.getStatus());
Assert.assertEquals(ProgramController.State.ERROR.getRunStatus(), run.getStatus());
Assert.assertEquals(ProgramController.State.SUSPENDED.getRunStatus(), run.getStatus());
Map<String, String> emptyArgs = ImmutableMap.of();
setStart(programId.run(run7.getId()), emptyArgs, emptyArgs, artifactId);
store.setStop(programId.run(run7.getId()), startTimeSecs + 1, ProgramController.State.ERROR.getRunStatus(),
       AppFabricTestHelper.createSourceId(++sourceId));
RunRecordMeta expectedRunRecord7 = RunRecordMeta.builder()
origin: cdapio/cdap

protected void complete(final State completionState) {
 LOG.trace("Program {} completed with state {}", programId, completionState);
 if (!state.compareAndSet(State.STARTING, completionState)
  && !state.compareAndSet(State.ALIVE, completionState)
  && !state.compareAndSet(State.SUSPENDED, completionState)) {
  LOG.warn("Cannot transit to COMPLETED state from {} state: {}", state.get(), name);
  return;
 }
 executor.execute(() -> {
  state.set(completionState);
  if (State.KILLED.equals(completionState)) {
   caller.killed();
  } else {
   caller.completed();
  }
 });
}
co.cask.cdap.app.runtimeProgramController$State

Javadoc

All possible state transitions.

 
|------------------------------------| 
|                                    | 
|        |-----------------------|   | 
v        v                       |   | 
ALIVE ---------------> COMPLETED   |   | 
|   -> STOPPING ---> KILLED      |   | 
|                                |   | 
|----> SUSPENDING -> SUSPENDED --|   | 
|           | 
|------> RESUMING 

Any error during state transitions would end up in ERROR state.

Any unrecoverable error in ALIVE state would also end up in ERROR state.

Most used methods

  • equals
  • getRunStatus
  • isDone

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JList (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now