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

How to use
JobControl
in
com.emc.ecs.sync.rest

Best Java code snippets using com.emc.ecs.sync.rest.JobControl (Showing top 16 results out of 315)

origin: EMCECS/ecs-sync

public JobControl getJobControl(int jobId) {
  EcsSync sync = syncCache.get(jobId);
  if (sync == null) return null;
  JobControl jobControl = new JobControl();
  jobControl.setStatus(getJobStatus(sync));
  jobControl.setThreadCount(sync.getSyncConfig().getOptions().getThreadCount());
  return jobControl;
}
origin: EMCECS/ecs-sync

public void setJobControl(int jobId, JobControl jobControl) {
  EcsSync sync = syncCache.get(jobId);
  if (sync == null) throw new JobNotFoundException("the specified job ID does not exist");
  if (jobControl.getThreadCount() > 0) {
    sync.setThreadCount(jobControl.getThreadCount());
  }
  if (jobControl.getStatus() != null) {
    switch (jobControl.getStatus()) {
      case Stopped:
        sync.terminate();
        break;
      case Paused:
        sync.pause();
        break;
      case Running:
        sync.resume();
        break;
    }
  }
}
origin: EMCECS/ecs-sync

private void setThreadCount(int jobId, Integer threadCount) {
  JobControl control = new JobControl();
  if (threadCount != null) {
    control.setThreadCount(threadCount);
  }
  controlJob(jobId, control);
}
origin: EMCECS/ecs-sync

private void stop(int jobId) {
  JobControl control = new JobControl();
  control.setStatus(JobControlStatus.Stopped);
  controlJob(jobId, control);
}
origin: EMCECS/ecs-sync

  while (client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus() == JobControlStatus.Initializing) {
    Thread.sleep(500);
  client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Stopped, 4));
  Assert.assertEquals(JobControlStatus.Stopped, jobControl.getStatus());
} finally {
origin: EMCECS/ecs-sync

while (client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus() == JobControlStatus.Initializing) {
  Thread.sleep(200);
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Paused, 0));
Assert.assertEquals(JobControlStatus.Paused, jobControl.getStatus());
Assert.assertEquals(2, jobControl.getThreadCount());
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 0));
Assert.assertEquals(JobControlStatus.Running, jobControl.getStatus());
Assert.assertEquals(2, jobControl.getThreadCount());
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 32));
while (!client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus().isFinalState()) {
  Thread.sleep(1000);
Assert.assertEquals(JobControlStatus.Complete, jobControl.getStatus());
origin: EMCECS/ecs-sync

@After
public void stopRestServer() throws InterruptedException {
  if (restServer != null) restServer.stop(0);
  restServer = null;
  // wait for all jobs to stop to prevent leakage into other tests
  for (JobInfo jobInfo : SyncJobService.getInstance().getAllJobs().getJobs()) {
    while (!SyncJobService.getInstance().getJobControl(jobInfo.getJobId()).getStatus().isFinalState())
      Thread.sleep(500);
    SyncJobService.getInstance().deleteJob(jobInfo.getJobId(), false);
  }
}
origin: EMCECS/ecs-sync

while (client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus() == JobControlStatus.Initializing) {
  Thread.sleep(500);
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Paused, 4));
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Stopped, 4));
Assert.assertEquals(JobControlStatus.Stopped, jobControl.getStatus());
origin: EMCECS/ecs-sync

private void resume(int jobId) {
  JobControl control = new JobControl();
  control.setStatus(JobControlStatus.Running);
  controlJob(jobId, control);
}
origin: EMCECS/ecs-sync

@Test
public void testCreateDelete() throws Exception {
  SyncConfig syncConfig = new SyncConfig();
  syncConfig.setSource(new TestConfig().withObjectCount(10).withMaxSize(10240).withDiscardData(false));
  syncConfig.setTarget(new TestConfig().withReadData(true).withDiscardData(false));
  // create sync job
  ClientResponse response = client.resource(endpoint).path("/job").put(ClientResponse.class, syncConfig);
  String jobIdStr = response.getHeaders().getFirst("x-emc-job-id");
  try {
    Assert.assertEquals(response.getEntity(String.class), 201, response.getStatus());
    response.close(); // must close all responses
    Assert.assertNotNull(jobIdStr);
    int jobId = Integer.parseInt(jobIdStr);
    // wait for job to complete
    while (!client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus().isFinalState()) {
      Thread.sleep(1000);
    }
    // get status (should be complete)
    JobControl jobControl = client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class);
    Assert.assertNotNull(jobControl);
    Assert.assertEquals(JobControlStatus.Complete, jobControl.getStatus());
  } finally {
    // delete job
    response = client.resource(endpoint).path("/job/" + jobIdStr).delete(ClientResponse.class);
    if (response.getStatus() != 200)
      log.warn("could not delete job: {}", response.getEntity(String.class));
    response.close(); // must close all responses
  }
}
origin: EMCECS/ecs-sync

  client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 10));
  client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 2));
  Thread.sleep(300);
  totalCount = client.resource(endpoint).path("/job/" + jobId + "/progress").get(SyncProgress.class).getObjectsComplete();
  client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 32));
  while (!client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus().isFinalState()) {
    Thread.sleep(1000);
  Assert.assertEquals(JobControlStatus.Complete, jobControl.getStatus());
} finally {
origin: EMCECS/ecs-sync

private void pause(int jobId) {
  JobControl control = new JobControl();
  control.setStatus(JobControlStatus.Paused);
  controlJob(jobId, control);
}
origin: EMCECS/ecs-sync

while (!client.resource(endpoint).path("/job/" + jobId1 + "/control").get(JobControl.class).getStatus().isFinalState()
    && !client.resource(endpoint).path("/job/" + jobId2 + "/control").get(JobControl.class).getStatus().isFinalState()
    && !client.resource(endpoint).path("/job/" + jobId3 + "/control").get(JobControl.class).getStatus().isFinalState()) {
  Thread.sleep(1000);
origin: EMCECS/ecs-sync

while (client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus() == JobControlStatus.Initializing) {
  Thread.sleep(500);
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Stopped, 20));
origin: EMCECS/ecs-sync

@Test
public void testGetJob() throws Exception {
  SyncConfig syncConfig = new SyncConfig();
  syncConfig.setSource(new TestConfig().withObjectCount(10).withMaxSize(10240).withDiscardData(false));
  syncConfig.setTarget(new TestConfig().withReadData(true).withDiscardData(false));
  // create sync job
  ClientResponse response = client.resource(endpoint).path("/job").put(ClientResponse.class, syncConfig);
  String jobId = response.getHeaders().getFirst("x-emc-job-id");
  try {
    Assert.assertEquals(response.getEntity(String.class), 201, response.getStatus());
    response.close(); // must close all responses
    // get job
    SyncConfig syncConfig2 = client.resource(endpoint).path("/job/" + jobId).get(SyncConfig.class);
    Assert.assertNotNull(syncConfig2);
    Assert.assertEquals(syncConfig, syncConfig2);
    // wait for job to complete
    while (!client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus().isFinalState()) {
      Thread.sleep(1000);
    }
  } finally {
    // delete job
    response = client.resource(endpoint).path("/job/" + jobId).delete(ClientResponse.class);
    if (response.getStatus() != 200)
      log.warn("could not delete job: {}", response.getEntity(String.class));
    response.close(); // must close all responses
  }
}
origin: EMCECS/ecs-sync

while (client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus() == JobControlStatus.Initializing) {
  Thread.sleep(500);
client.resource(endpoint).path("/job/" + jobId + "/control").post(new JobControl(JobControlStatus.Running, 32));
while (!client.resource(endpoint).path("/job/" + jobId + "/control").get(JobControl.class).getStatus().isFinalState()) {
  Thread.sleep(1000);
Assert.assertEquals(JobControlStatus.Complete, jobControl.getStatus());
com.emc.ecs.sync.restJobControl

Most used methods

  • <init>
  • getStatus
  • getThreadCount
  • setStatus
  • setThreadCount

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • 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
  • JOptionPane (javax.swing)
  • 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