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;
}
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);
}
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;
}
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);
}
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);
}
Aggregations