Search in sources :

Example 16 with ActionStatus

use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.

the class TestWriteFileAction method writeFile.

protected void writeFile(String filePath, int length) throws IOException {
    String[] args = { filePath, String.valueOf(length) };
    WriteFileAction writeFileAction = new WriteFileAction();
    writeFileAction.setDfsClient(dfsClient);
    writeFileAction.setContext(smartContext);
    writeFileAction.init(args);
    writeFileAction.run();
    // check results
    ActionStatus actionStatus = writeFileAction.getActionStatus();
    Assert.assertTrue(actionStatus.isFinished());
    Assert.assertTrue(actionStatus.isSuccessful());
    System.out.println("Write file action running time : " + StringUtils.formatTime(actionStatus.getRunningTime()));
    Assert.assertEquals(1.0f, actionStatus.getPercentage(), 0.00001f);
}
Also used : ActionStatus(org.smartdata.actions.ActionStatus)

Example 17 with ActionStatus

use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.

the class TestSetStoragePolicyAction method setStoragePolicy.

private byte setStoragePolicy(String file, String storagePolicy) throws IOException {
    SetStoragePolicyAction action = new SetStoragePolicyAction();
    action.setDfsClient(dfsClient);
    action.setContext(smartContext);
    action.init(new String[] { file, storagePolicy });
    action.run();
    ActionStatus status = action.getActionStatus();
    // check results
    System.out.println("Action running time = " + StringUtils.formatTime(status.getRunningTime()));
    Assert.assertTrue(status.isFinished());
    Assert.assertTrue(status.isSuccessful());
    Assert.assertEquals(1.0f, status.getPercentage(), 0.00001f);
    HdfsFileStatus fileStatus = dfsClient.getFileInfo(file);
    return fileStatus.getStoragePolicy();
}
Also used : HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) ActionStatus(org.smartdata.actions.ActionStatus)

Aggregations

ActionStatus (org.smartdata.actions.ActionStatus)17 Test (org.junit.Test)7 Path (org.apache.hadoop.fs.Path)5 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)4 IOException (java.io.IOException)3 StorageType (org.apache.hadoop.fs.StorageType)3 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)3 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)3 OutputStream (java.io.OutputStream)2 SmartAction (org.smartdata.actions.SmartAction)2 ActionInfo (org.smartdata.common.actions.ActionInfo)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 BlockLocation (org.apache.hadoop.fs.BlockLocation)1 DFSInputStream (org.apache.hadoop.hdfs.DFSInputStream)1 MoverStatus (org.smartdata.actions.hdfs.move.MoverStatus)1 ActionInfoComparator (org.smartdata.common.actions.ActionInfoComparator)1