Search in sources :

Example 1 with PersistConfig

use of alluxio.job.plan.persist.PersistConfig in project alluxio by Alluxio.

the class BatchedJobDefinitionTest method batchPersist.

@Test
public void batchPersist() throws Exception {
    AlluxioURI uri = new AlluxioURI("/test");
    PersistConfig config = new PersistConfig(uri.getPath(), -1, true, "");
    HashSet<Map<String, String>> configs = Sets.newHashSet();
    ObjectMapper oMapper = new ObjectMapper();
    Map<String, String> map = oMapper.convertValue(config, Map.class);
    configs.add(map);
    BatchedJobConfig batchedJobConfig = new BatchedJobConfig("Persist", configs);
    WorkerNetAddress workerNetAddress = new WorkerNetAddress().setDataPort(10);
    WorkerInfo workerInfo = new WorkerInfo().setAddress(workerNetAddress);
    long blockId = 1;
    BlockInfo blockInfo = new BlockInfo().setBlockId(blockId);
    FileBlockInfo fileBlockInfo = new FileBlockInfo().setBlockInfo(blockInfo);
    BlockLocation location = new BlockLocation();
    location.setWorkerAddress(workerNetAddress);
    blockInfo.setLocations(Lists.newArrayList(location));
    FileInfo testFileInfo = new FileInfo();
    testFileInfo.setFileBlockInfos(Lists.newArrayList(fileBlockInfo));
    Mockito.when(mMockFileSystem.getStatus(uri)).thenReturn(new URIStatus(testFileInfo));
    Set<Pair<WorkerInfo, BatchedJobDefinition.BatchedJobTask>> result = new BatchedJobDefinition().selectExecutors(batchedJobConfig, Lists.newArrayList(workerInfo), new SelectExecutorsContext(1, mJobServerContext));
    System.out.println(result);
    Assert.assertNull(result.iterator().next().getSecond().getJobTaskArgs());
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(workerInfo, result.iterator().next().getFirst());
}
Also used : BatchedJobDefinition(alluxio.job.plan.batch.BatchedJobDefinition) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) WorkerInfo(alluxio.wire.WorkerInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) URIStatus(alluxio.client.file.URIStatus) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) FileInfo(alluxio.wire.FileInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) PersistConfig(alluxio.job.plan.persist.PersistConfig) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AlluxioURI(alluxio.AlluxioURI) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with PersistConfig

use of alluxio.job.plan.persist.PersistConfig in project alluxio by Alluxio.

the class JobShellTest method runPersistJob.

protected long runPersistJob(String pathStr) throws Exception {
    // write a file in alluxio only
    AlluxioURI filePath = new AlluxioURI(pathStr);
    FileOutStream os = sFileSystem.createFile(filePath, CreateFilePOptions.newBuilder().setWriteType(WritePType.MUST_CACHE).build());
    os.write((byte) 0);
    os.write((byte) 1);
    os.close();
    // persist the file
    URIStatus status = sFileSystem.getStatus(filePath);
    return sJobMaster.run(new PersistConfig(pathStr, 1, true, status.getUfsPath()));
}
Also used : FileOutStream(alluxio.client.file.FileOutStream) PersistConfig(alluxio.job.plan.persist.PersistConfig) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 3 with PersistConfig

use of alluxio.job.plan.persist.PersistConfig in project alluxio by Alluxio.

the class DistributedCommandsStatsTest method testAsyncPersistCancelStats.

@Test
public void testAsyncPersistCancelStats() throws Exception {
    FileSystemTestUtils.createByteFile(sFileSystem, "/testFile", WritePType.THROUGH, 10);
    long jobId = sJobMaster.run(new PersistConfig("/testFile", 0, false, "/testUfsPath"));
    sJobShell.run("cancel", Long.toString(jobId));
    JobTestUtils.waitForJobStatus(sJobMaster, jobId, Sets.newHashSet(Status.CANCELED), TEST_TIMEOUT);
    sJobShell.run("stat", "-v", Long.toString(jobId));
    String[] output = mOutput.toString().split("\n");
    assertEquals(String.format("ID: %s", jobId), output[0]);
    assertEquals(String.format("Name: Persist"), output[1]);
    assertTrue(output[2].contains("Description: PersistConfig"));
    assertTrue(output[2].contains("/testFile"));
    assertEquals("Status: CANCELED", output[3]);
    assertEquals("Task 0", output[4]);
    assertTrue(output[5].contains("\tWorker: "));
    assertEquals("\tStatus: CANCELED", output[6]);
    double cancelledCount = MetricsSystem.getMetricValue(MetricKey.MASTER_ASYNC_PERSIST_CANCEL.getName()).getValue();
    double failedCount = MetricsSystem.getMetricValue(MetricKey.MASTER_ASYNC_PERSIST_FAIL.getName()).getValue();
    double completedCount = MetricsSystem.getMetricValue(MetricKey.MASTER_ASYNC_PERSIST_SUCCESS.getName()).getValue();
    assertEquals(cancelledCount, 1, 0);
    assertEquals(failedCount, 0, 0);
    assertEquals(completedCount, 0, 0);
}
Also used : PersistConfig(alluxio.job.plan.persist.PersistConfig) Test(org.junit.Test)

Aggregations

PersistConfig (alluxio.job.plan.persist.PersistConfig)3 AlluxioURI (alluxio.AlluxioURI)2 URIStatus (alluxio.client.file.URIStatus)2 Test (org.junit.Test)2 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)1 FileOutStream (alluxio.client.file.FileOutStream)1 Pair (alluxio.collections.Pair)1 SelectExecutorsContext (alluxio.job.SelectExecutorsContext)1 BatchedJobDefinition (alluxio.job.plan.batch.BatchedJobDefinition)1 BlockInfo (alluxio.wire.BlockInfo)1 BlockLocation (alluxio.wire.BlockLocation)1 FileBlockInfo (alluxio.wire.FileBlockInfo)1 FileInfo (alluxio.wire.FileInfo)1 WorkerInfo (alluxio.wire.WorkerInfo)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Map (java.util.Map)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1