Search in sources :

Example 11 with OozieClientException

use of org.apache.oozie.client.OozieClientException in project oozie by apache.

the class TestLocalOozieClientCoord method testReRun2.

public void testReRun2() {
    OozieClient client = LocalOozie.getCoordClient();
    try {
        client.reRun("foo-id", client.createConfiguration());
        fail("OozieClientException expected.");
    } catch (OozieClientException oce) {
        assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
    }
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) OozieClientException(org.apache.oozie.client.OozieClientException)

Example 12 with OozieClientException

use of org.apache.oozie.client.OozieClientException in project oozie by apache.

the class TestLocalOozieClientCoord method testGetJobsInfo.

public void testGetJobsInfo() {
    OozieClient client = LocalOozie.getCoordClient();
    try {
        client.getJobsInfo("foo");
        fail("OozieClientException expected.");
    } catch (OozieClientException oce) {
        assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
    }
    try {
        client.getJobsInfo("foo", 0, 5);
        fail("OozieClientException expected.");
    } catch (OozieClientException oce) {
        assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
    }
    try {
        client.getJobInfo("foo-id");
        fail("OozieClientException expected.");
    } catch (OozieClientException oce) {
        assertEquals(ErrorCode.E0301.toString(), oce.getErrorCode());
    }
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) OozieClientException(org.apache.oozie.client.OozieClientException)

Example 13 with OozieClientException

use of org.apache.oozie.client.OozieClientException in project oozie by apache.

the class TestWorkflow method runWorkflowFromFile.

private void runWorkflowFromFile(final String workflowFileName, final Properties additionalWorkflowProperties) throws IOException, OozieClientException {
    final FileSystem fs = getFileSystem();
    final Path appPath = new Path(getFsTestCaseDir(), "app");
    fs.mkdirs(appPath);
    fs.mkdirs(new Path(appPath, "lib"));
    final Reader reader = getResourceAsReader(workflowFileName, -1);
    final Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, "workflow.xml")));
    copyCharStream(reader, writer);
    writer.close();
    reader.close();
    final Path path = getFsTestCaseDir();
    final OozieClient oozieClient = LocalOozie.getClient();
    final Properties conf = oozieClient.createConfiguration();
    conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
    conf.setProperty(OozieClient.USER_NAME, getTestUser());
    conf.setProperty("nameNodeBasePath", path.toString());
    conf.setProperty("base", path.toUri().getPath());
    conf.setProperty("nameNode", getNameNodeUri());
    conf.setProperty("jobTracker", getJobTrackerUri());
    for (final String additionalKey : additionalWorkflowProperties.stringPropertyNames()) {
        conf.setProperty(additionalKey, additionalWorkflowProperties.getProperty(additionalKey));
    }
    final String jobId = oozieClient.submit(conf);
    assertNotNull(jobId);
    WorkflowJob wf = oozieClient.getJobInfo(jobId);
    assertNotNull(wf);
    assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
    oozieClient.start(jobId);
    waitFor(15 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            final WorkflowJob wf = oozieClient.getJobInfo(jobId);
            return wf.getStatus() == WorkflowJob.Status.SUCCEEDED;
        }
    });
    wf = oozieClient.getJobInfo(jobId);
    assertNotNull(wf);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wf.getStatus());
}
Also used : Path(org.apache.hadoop.fs.Path) OozieClient(org.apache.oozie.client.OozieClient) FileSystem(org.apache.hadoop.fs.FileSystem) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) OutputStreamWriter(java.io.OutputStreamWriter) Properties(java.util.Properties) WorkflowJob(org.apache.oozie.client.WorkflowJob) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) OozieClientException(org.apache.oozie.client.OozieClientException)

Example 14 with OozieClientException

use of org.apache.oozie.client.OozieClientException in project oozie by apache.

the class DiagOozieClient method saveThreadDumpPage.

// Oozie has a jsp page with a thread dump, and the Oozie client normally doesn't have a way of getting it,
// so we're doing that here; reusing all the fancy HTTP handling code in AuthOozieClient
void saveThreadDumpPage(File file) throws OozieClientException, IOException {
    final URL url = new URL(super.getOozieUrl() + "admin/jvminfo.jsp");
    final HttpURLConnection retryableConnection = createRetryableConnection(url, "GET");
    if ((retryableConnection.getResponseCode() == HttpURLConnection.HTTP_OK)) {
        try (InputStream is = retryableConnection.getInputStream();
            final FileOutputStream os = new FileOutputStream(file)) {
            IOUtils.copyStream(is, os);
        }
    } else {
        throw new OozieClientException("HTTP error", retryableConnection.getResponseMessage());
    }
}
Also used : OozieClientException(org.apache.oozie.client.OozieClientException) HttpURLConnection(java.net.HttpURLConnection) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) URL(java.net.URL)

Example 15 with OozieClientException

use of org.apache.oozie.client.OozieClientException in project oozie by apache.

the class ServerInfoCollector method storeThreadDump.

void storeThreadDump(final File outputDir) {
    try {
        System.out.print("Getting Thread Dump...");
        client.saveThreadDumpPage(new File(outputDir, "thread-dump.html"));
        System.out.println("Done");
    } catch (OozieClientException | IOException e) {
        System.err.printf("Exception occurred during the retrieval of Oozie server thread dump: %s%n", e.getMessage());
    }
}
Also used : OozieClientException(org.apache.oozie.client.OozieClientException) IOException(java.io.IOException) File(java.io.File)

Aggregations

OozieClientException (org.apache.oozie.client.OozieClientException)26 IOException (java.io.IOException)13 Properties (java.util.Properties)12 OozieClient (org.apache.oozie.client.OozieClient)11 File (java.io.File)10 XOozieClient (org.apache.oozie.client.XOozieClient)8 Reader (java.io.Reader)7 Writer (java.io.Writer)7 ArrayList (java.util.ArrayList)6 Path (org.apache.hadoop.fs.Path)6 FileWriter (java.io.FileWriter)5 Option (org.apache.commons.cli.Option)3 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)3 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Map (java.util.Map)2 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)2 WorkflowJob (org.apache.oozie.client.WorkflowJob)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1