Example usage for java.lang Process.Builder Process.Builder

List of usage examples for java.lang Process.Builder Process.Builder

Introduction

In this page you can find the example usage for java.lang Process.Builder Process.Builder.

Prototype

Process.Builder

Source Link

Usage

From source file:org.apache.falcon.adfservice.ADFJob.java

protected void startProcess(Feed inputFeed, Feed outputFeed, String engineType, String scriptPath)
        throws FalconException {
    // submit input/output feeds
    LOG.info("submitting input feed {} for {} process", inputFeed.getName(), engineType);
    jobManager.submitJob(EntityType.FEED.name(), inputFeed.getEntityxml());

    LOG.info("submitting output feed {} for {} process", outputFeed.getName(), engineType);
    jobManager.submitJob(EntityType.FEED.name(), outputFeed.getEntityxml());

    // submit and schedule process
    String processRequest = new Process.Builder().withProcessName(jobEntityName()).withFrequency(frequency)
            .withStartTime(startTime).withEndTime(endTime).withClusterName(getClusterNameToRunProcessOn())
            .withInputFeedName(inputFeed.getName()).withOutputFeedName(outputFeed.getName())
            .withEngineType(engineType).withWFPath(scriptPath).withAclOwner(proxyUser).build().getEntityxml();

    LOG.info("submitting/scheduling {} process: {}", engineType, processRequest);
    submitAndScheduleJob(EntityType.PROCESS.name(), processRequest);
    LOG.info("submitted and scheduled {} process: {}", engineType, jobEntityName());
}

From source file:piecework.content.concrete.FileSystemContentProviderTest.java

@Before
public void setup() throws IOException {
    deployment = new ProcessDeployment.Builder().deploymentId("123").base("abc").build();
    process = new Process.Builder().processDefinitionKey("TEST")
            .deploy(new ProcessDeploymentVersion(deployment), deployment).build();

    String tempFilesystem = System.getProperty("java.io.tmpdir");
    rootDirectory = new File(tempFilesystem, UUID.randomUUID().toString());
    processDirectory = new File(rootDirectory, "abc");
    processDirectory.mkdirs();/*  w w w  .  j  a  va  2s.  co  m*/
    temporaryFile = File.createTempFile("fsTestGeneric", ".test", processDirectory);
    temporaryCssFile = File.createTempFile("fsTest", ".css", processDirectory);
    temporaryJsFile = File.createTempFile("fsTest", ".js", processDirectory);
    temporaryHtmlFile = File.createTempFile("fsTest", ".html", processDirectory);
    temporaryFileName = temporaryFile.getName();
    FileWriter writer = null;
    try {
        writer = new FileWriter(temporaryFile);
        IOUtils.write(testData, writer);
    } finally {
        IOUtils.closeQuietly(writer);
    }
    contentProvider.setFilesystemRoot(rootDirectory.getAbsolutePath());
    contentProvider.init();

    principal = new User.Builder().userId("testuser").build();

    ContentProfile contentProfile = new ContentProfile.Builder()
            .baseDirectory(processDirectory.getAbsolutePath()).build();
    this.modelProvider = new ProcessDeploymentProviderStub(process, deployment, contentProfile, principal);
    contentProvider.accessTracker = Mockito.mock(AccessTracker.class);
}

From source file:piecework.model.Process.java

private Process() {
    this(new Process.Builder(), new ViewContext());
}

From source file:piecework.persistence.concrete.AllowedTaskRepositoryProviderTest.java

@Before
public void setup() throws Exception {
    Process process = new Process.Builder().processDefinitionKey("TEST").build();

    ProcessInstance instance = new ProcessInstance.Builder().processDefinitionKey("TEST")
            .processInstanceId("334222")
            .task(new Task.Builder().taskInstanceId("1000").candidateAssigneeId("testuser").build())
            .task(new Task.Builder().taskInstanceId(TESTUSER_ACTIVE_TASK_ID).candidateAssigneeId("testuser")
                    .active().build())// ww w  . j a  v a2s  .  c  o  m
            .task(new Task.Builder().taskInstanceId("998").candidateAssigneeId("testuser").build())
            .task(new Task.Builder().taskInstanceId(ANOTHER_ACTIVE_TASK_ID).candidateAssigneeId("another")
                    .active().build())
            .formValue("SomeFile", new File.Builder().id("877").contentType("text/html")
                    .location("/TEST/some/other/path/test.html").name("Test.html").fieldName("SomeFile")
                    .processDefinitionKey("TEST").description("A quick description of the sample file").build())
            .attachmentId("233").build();

    ContentResource attachmentContentResource = new BasicContentResource.Builder()
            .inputStream(new ByteArrayInputStream("This is some test data from an input stream".getBytes()))
            .build();

    ContentResource valueContentResource = new BasicContentResource.Builder()
            .inputStream(new ByteArrayInputStream("<html><body>Hello World</body></html>".getBytes())).build();

    Attachment att1 = new Attachment.Builder().contentType("text/plain").location("/TEST/some/path/file.txt")
            .attachmentId("233").build();

    Mockito.doReturn(Collections.singletonList(att1)).when(attachmentRepository).findAll(any(Iterable.class));

    Mockito.doReturn("testuser").when(principal).getEntityId();
    Mockito.doReturn(Boolean.TRUE).when(principal).hasRole(eq(process), eq(AuthorizationRole.USER));

    Mockito.doReturn(process).when(processRepository).findOne(eq("TEST"));
    Mockito.doReturn(instance).when(processInstanceRepository).findOne(eq("1234"));

    ProcessProvider processProvider = new ProcessRepositoryProvider(processRepository, "TEST", principal);
    this.allowedTaskProvider = allowedTaskProvider(processProvider);

    Mockito.doReturn(attachmentContentResource).when(contentRepository).findByLocation(eq(allowedTaskProvider),
            eq("/TEST/some/path/file.txt"));
    Mockito.doReturn(valueContentResource).when(contentRepository).findByLocation(eq(allowedTaskProvider),
            eq("/TEST/some/other/path/test.html"));
}

From source file:piecework.util.UserInterfaceUtilityTest.java

@Test
public void testScriptNameForm() throws Exception {
    Process process = new Process.Builder().build();
    ProcessDeployment deployment = new ProcessDeployment.Builder().build();
    Container container = null;//ww w  .j  a v a  2s .c  o  m
    String location = null;
    DataInjectionStrategy strategy = DataInjectionStrategy.NONE;
    Action action = new Action(container, location, strategy);
    ViewContext context = new ViewContext();
    Form form = new Form.Builder()
            .disposition(FormDisposition.Builder.build(process, deployment, action, context)).build();

    Assert.assertEquals("Form.js", UserInterfaceUtility.scriptName(Form.class, form));
}

From source file:piecework.util.UserInterfaceUtilityTest.java

@Test
public void testScriptNameFormRemote() throws Exception {
    Process process = new Process.Builder().processDefinitionKey("TEST").build();
    ProcessDeployment deployment = new ProcessDeployment.Builder().build();
    Container container = null;/*  ww  w  . j  av a 2 s . c  om*/
    String location = null;
    DataInjectionStrategy strategy = DataInjectionStrategy.REMOTE;
    Action action = new Action(container, location, strategy);
    ViewContext context = new ViewContext();
    Form form = new Form.Builder().process(process)
            .disposition(FormDisposition.Builder.build(process, deployment, action, context)).build();

    Assert.assertEquals("TEST.js", UserInterfaceUtility.scriptName(Form.class, form));
}