Search in sources :

Example 96 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class PlanCoordinator method updateStatus.

/**
 * Updates the status of the job. When all the tasks are completed, run the join method in the
 * definition.
 */
private synchronized void updateStatus() {
    int completed = 0;
    List<TaskInfo> taskInfoList = mPlanInfo.getTaskInfoList();
    JobConfig config = mPlanInfo.getJobConfig();
    Preconditions.checkNotNull(config);
    FileSystem fileSystem = mJobServerContext.getFileSystem();
    for (TaskInfo info : taskInfoList) {
        Status status = info.getStatus();
        switch(status) {
            case FAILED:
                setJobAsFailed(info.getErrorType(), "Task execution failed: " + info.getErrorMessage());
                return;
            case CANCELED:
                if (mPlanInfo.getStatus() != Status.FAILED) {
                    mPlanInfo.setStatus(Status.CANCELED);
                    DistributedCmdMetrics.incrementForAllConfigsCancelStatus(config);
                }
                return;
            case RUNNING:
                if (mPlanInfo.getStatus() != Status.FAILED && mPlanInfo.getStatus() != Status.CANCELED) {
                    mPlanInfo.setStatus(Status.RUNNING);
                }
                break;
            case COMPLETED:
                completed++;
                break;
            case CREATED:
                // do nothing
                break;
            default:
                throw new IllegalArgumentException("Unsupported status " + info.getStatus());
        }
    }
    if (completed == taskInfoList.size()) {
        if (mPlanInfo.getStatus() == Status.COMPLETED) {
            return;
        }
        // all the tasks completed, run join
        try {
            // Try to join first, so that in case of failure we don't move to a completed state yet
            mPlanInfo.setResult(join(taskInfoList));
            mPlanInfo.setStatus(Status.COMPLETED);
            // Increment the counter for Complete status when all the tasks in a job are completed.
            DistributedCmdMetrics.incrementForAllConfigsCompleteStatus(config, fileSystem, new CountingRetry(5));
        } catch (Exception e) {
            LOG.warn("Job error when joining tasks Job Id={} Config={}", mPlanInfo.getId(), mPlanInfo.getJobConfig(), e);
            setJobAsFailed(ErrorUtils.getErrorType(e), e.getMessage());
        }
    }
}
Also used : TaskInfo(alluxio.job.wire.TaskInfo) Status(alluxio.job.wire.Status) CountingRetry(alluxio.retry.CountingRetry) FileSystem(alluxio.client.file.FileSystem) BatchedJobConfig(alluxio.job.plan.BatchedJobConfig) JobConfig(alluxio.job.JobConfig) JobDoesNotExistException(alluxio.exception.JobDoesNotExistException)

Example 97 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class DistributedLoadCommandTest method loadFileMultiCopy.

@Test
public void loadFileMultiCopy() throws IOException, AlluxioException {
    FileSystem fs = sResource.get().getClient();
    FileSystemTestUtils.createByteFile(fs, "/testFile", WritePType.THROUGH, 10);
    AlluxioURI uri = new AlluxioURI("/testFile");
    URIStatus status = fs.getStatus(uri);
    Assert.assertNotEquals(100, status.getInMemoryPercentage());
    // Testing loading of a single file
    sFsShell.run("distributedLoad", "/testFile", "--replication", "1");
    status = fs.getStatus(uri);
    Assert.assertEquals(100, status.getInMemoryPercentage());
    Assert.assertEquals(1, status.getFileBlockInfos().get(0).getBlockInfo().getLocations().size());
    sFsShell.run("distributedLoad", "/testFile", "--replication", "3");
    status = fs.getStatus(uri);
    Assert.assertEquals(3, status.getFileBlockInfos().get(0).getBlockInfo().getLocations().size());
}
Also used : FileSystem(alluxio.client.file.FileSystem) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 98 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class DistributedLoadCommandTest method loadDirWithLotsFilesInBatch.

@Test
public void loadDirWithLotsFilesInBatch() throws IOException, AlluxioException {
    FileSystem fs = sResource.get().getClient();
    int fileSize = 100;
    List<AlluxioURI> uris = new ArrayList<>(fileSize);
    for (int i = 0; i < fileSize; i++) {
        FileSystemTestUtils.createByteFile(fs, "/testBatchRoot/testBatchFile" + i, WritePType.THROUGH, 10);
        AlluxioURI uri = new AlluxioURI("/testBatchRoot/testBatchFile" + i);
        uris.add(uri);
        URIStatus status = fs.getStatus(uri);
        Assert.assertNotEquals(100, status.getInMemoryPercentage());
    }
    // Testing loading of a directory
    sFsShell.run("distributedLoad", "/testBatchRoot", "--batch-size", "3");
    for (AlluxioURI uri : uris) {
        URIStatus status = fs.getStatus(uri);
        Assert.assertEquals(100, status.getInMemoryPercentage());
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) ArrayList(java.util.ArrayList) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 99 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class DistributedLoadCommandTest method loadFile.

@Test
public void loadFile() throws IOException, AlluxioException {
    FileSystem fs = sResource.get().getClient();
    FileSystemTestUtils.createByteFile(fs, "/testFileNew", WritePType.THROUGH, 10);
    AlluxioURI uri = new AlluxioURI("/testFileNew");
    URIStatus status = fs.getStatus(uri);
    Assert.assertNotEquals(100, status.getInMemoryPercentage());
    // Testing loading of a single file
    sFsShell.run("distributedLoad", "/testFileNew");
    status = fs.getStatus(uri);
    Assert.assertEquals(100, status.getInMemoryPercentage());
}
Also used : FileSystem(alluxio.client.file.FileSystem) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 100 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class DistributedLoadCommandTest method loadDirWithPassiveCacheInBatch.

@Test
public void loadDirWithPassiveCacheInBatch() throws IOException, AlluxioException {
    FileSystem fs = sResource.get().getClient();
    int fileSize = 20;
    List<AlluxioURI> uris = new ArrayList<>(fileSize);
    for (int i = 0; i < fileSize; i++) {
        FileSystemTestUtils.createByteFile(fs, "/testBatchRoot/testBatchFilePassive" + i, WritePType.THROUGH, 10);
        AlluxioURI uri = new AlluxioURI("/testBatchRoot/testBatchFilePassive" + i);
        uris.add(uri);
        URIStatus status = fs.getStatus(uri);
        Assert.assertNotEquals(100, status.getInMemoryPercentage());
    }
    // Testing loading of a directory
    sFsShell.run("distributedLoad", "/testBatchRoot", "--batch-size", "3", "--passive-cache");
    for (AlluxioURI uri : uris) {
        URIStatus status = fs.getStatus(uri);
        Assert.assertEquals(100, status.getInMemoryPercentage());
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) ArrayList(java.util.ArrayList) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Aggregations

FileSystem (alluxio.client.file.FileSystem)122 AlluxioURI (alluxio.AlluxioURI)90 Test (org.junit.Test)75 URIStatus (alluxio.client.file.URIStatus)42 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)22 FileInStream (alluxio.client.file.FileInStream)13 IOException (java.io.IOException)12 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)11 ArrayList (java.util.ArrayList)11 FileOutStream (alluxio.client.file.FileOutStream)10 AlluxioException (alluxio.exception.AlluxioException)9 File (java.io.File)9 Path (javax.ws.rs.Path)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)8 HashMap (java.util.HashMap)8 FileSystemContext (alluxio.client.file.FileSystemContext)7 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)6 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)6 TestUserState (alluxio.security.user.TestUserState)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)5