Search in sources :

Example 1 with JobId

use of org.apache.hyracks.api.job.JobId in project asterixdb by apache.

the class JobUtils method runJob.

public static JobId runJob(IHyracksClientConnection hcc, JobSpecification spec, boolean waitForCompletion) throws Exception {
    spec.setMaxReattempts(0);
    final JobId jobId = hcc.startJob(spec);
    if (waitForCompletion) {
        hcc.waitForCompletion(jobId);
    }
    return jobId;
}
Also used : JobId(org.apache.hyracks.api.job.JobId)

Example 2 with JobId

use of org.apache.hyracks.api.job.JobId in project asterixdb by apache.

the class AbstractIntegrationTest method runTestAndStoreResult.

protected void runTestAndStoreResult(JobSpecification spec, File file) throws Exception {
    JobId jobId = executeTest(spec);
    BufferedWriter output = new BufferedWriter(new FileWriter(file));
    List<String> results;
    for (int i = 0; i < spec.getResultSetIds().size(); i++) {
        results = readResults(spec, jobId, spec.getResultSetIds().get(i));
        for (String str : results) {
            output.write(str);
        }
    }
    output.close();
    hcc.waitForCompletion(jobId);
}
Also used : FileWriter(java.io.FileWriter) JobId(org.apache.hyracks.api.job.JobId) BufferedWriter(java.io.BufferedWriter)

Example 3 with JobId

use of org.apache.hyracks.api.job.JobId in project asterixdb by apache.

the class AbstractIntegrationTest method runTestAndCompareResults.

protected boolean runTestAndCompareResults(JobSpecification spec, String[] expectedFileNames) throws Exception {
    JobId jobId = executeTest(spec);
    List<String> results;
    for (int i = 0; i < expectedFileNames.length; i++) {
        results = readResults(spec, jobId, spec.getResultSetIds().get(i));
        BufferedReader expectedFile = new BufferedReader(new FileReader(expectedFileNames[i]));
        //We're expecting some sort of result.
        Assert.assertTrue(results != null);
        Assert.assertTrue(results.size() > 0);
        String expectedLine, actualLine;
        int j = 0;
        while ((expectedLine = expectedFile.readLine()) != null) {
            actualLine = results.get(j).trim();
            Assert.assertEquals(expectedLine, actualLine);
            j++;
        }
        //We also expect the same amount of results.
        Assert.assertEquals(j, results.size());
        expectedFile.close();
    }
    hcc.waitForCompletion(jobId);
    return true;
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) JobId(org.apache.hyracks.api.job.JobId)

Example 4 with JobId

use of org.apache.hyracks.api.job.JobId in project asterixdb by apache.

the class QueryCancellationServletTest method testDelete.

@Test
public void testDelete() throws Exception {
    // Creates a query cancellation servlet.
    QueryCancellationServlet cancellationServlet = new QueryCancellationServlet(new ConcurrentHashMap<>(), new String[] { "/" });
    // Adds mocked Hyracks client connection into the servlet context.
    IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
    cancellationServlet.ctx().put(ServletConstants.HYRACKS_CONNECTION_ATTR, mockHcc);
    // Adds a query context into the servlet context.
    IStatementExecutorContext queryCtx = new StatementExecutorContext();
    cancellationServlet.ctx().put(ServletConstants.RUNNING_QUERIES_ATTR, queryCtx);
    // Tests the case that query is not in the map.
    IServletRequest mockRequest = mockRequest("1");
    IServletResponse mockResponse = mock(IServletResponse.class);
    cancellationServlet.handle(mockRequest, mockResponse);
    verify(mockResponse, times(1)).setStatus(HttpResponseStatus.NOT_FOUND);
    // Tests the case that query is in the map.
    queryCtx.put("1", new JobId(1));
    cancellationServlet.handle(mockRequest, mockResponse);
    verify(mockResponse, times(1)).setStatus(HttpResponseStatus.OK);
    // Tests the case the client_context_id is not provided.
    mockRequest = mockRequest(null);
    cancellationServlet.handle(mockRequest, mockResponse);
    verify(mockResponse, times(1)).setStatus(HttpResponseStatus.BAD_REQUEST);
    // Tests the case that the job cancellation hit some exception from Hyracks.
    queryCtx.put("2", new JobId(2));
    Mockito.doThrow(new Exception()).when(mockHcc).cancelJob(any());
    mockRequest = mockRequest("2");
    cancellationServlet.handle(mockRequest, mockResponse);
    verify(mockResponse, times(1)).setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
Also used : StatementExecutorContext(org.apache.asterix.api.http.ctx.StatementExecutorContext) IStatementExecutorContext(org.apache.asterix.translator.IStatementExecutorContext) IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) QueryCancellationServlet(org.apache.asterix.api.http.server.QueryCancellationServlet) IStatementExecutorContext(org.apache.asterix.translator.IStatementExecutorContext) IServletResponse(org.apache.hyracks.http.api.IServletResponse) JobId(org.apache.hyracks.api.job.JobId) IServletRequest(org.apache.hyracks.http.api.IServletRequest) Test(org.junit.Test)

Example 5 with JobId

use of org.apache.hyracks.api.job.JobId in project asterixdb by apache.

the class AlgebricksHyracksIntegrationUtil method runJob.

public static void runJob(JobSpecification spec) throws Exception {
    AlgebricksConfig.ALGEBRICKS_LOGGER.info(spec.toJSON().toString());
    JobId jobId = hcc.startJob(spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
    AlgebricksConfig.ALGEBRICKS_LOGGER.info(jobId.toString());
    hcc.waitForCompletion(jobId);
}
Also used : JobId(org.apache.hyracks.api.job.JobId)

Aggregations

JobId (org.apache.hyracks.api.job.JobId)57 JobSpecification (org.apache.hyracks.api.job.JobSpecification)17 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)13 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)11 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)10 CmdLineParser (org.kohsuke.args4j.CmdLineParser)9 Test (org.junit.Test)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)4 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)4 Joblet (org.apache.hyracks.control.nc.Joblet)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 HashMap (java.util.HashMap)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 RemoteException (java.rmi.RemoteException)2