Search in sources :

Example 1 with CmdletState

use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.

the class TestCompressDecompress method waitTillActionDone.

private void waitTillActionDone(long cmdId) throws Exception {
    int n = 0;
    while (true) {
        Thread.sleep(1000);
        CmdletManager cmdletManager = ssm.getCmdletManager();
        CmdletInfo info = cmdletManager.getCmdletInfo(cmdId);
        if (info == null) {
            continue;
        }
        CmdletState state = info.getState();
        if (state == CmdletState.DONE) {
            return;
        } else if (state == CmdletState.FAILED) {
            // Reasonably assume that there is only one action wrapped by a given cmdlet.
            long aid = cmdletManager.getCmdletInfo(cmdId).getAids().get(0);
            Assert.fail("Action failed. " + cmdletManager.getActionInfo(aid).getLog());
        } else {
            System.out.println(state);
        }
        // Wait for 20s.
        if (++n == 20) {
            throw new Exception("Time out in waiting for cmdlet: " + cmdletManager.getCmdletInfo(cmdId).toString());
        }
    }
}
Also used : CmdletManager(org.smartdata.server.engine.CmdletManager) CmdletState(org.smartdata.model.CmdletState) CmdletInfo(org.smartdata.model.CmdletInfo) IOException(java.io.IOException)

Example 2 with CmdletState

use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.

the class TestMoverScheduler method testScheduler.

@Test(timeout = 40000)
public void testScheduler() throws Exception {
    waitTillSSMExitSafeMode();
    String file = "/testfile";
    Path filePath = new Path(file);
    int numBlocks = 2;
    DistributedFileSystem fs = cluster.getFileSystem();
    DFSTestUtil.createFile(fs, filePath, numBlocks * DEFAULT_BLOCK_SIZE, (short) 3, 100);
    fs.setStoragePolicy(filePath, "ALL_SSD");
    CmdletManager cmdletManager = ssm.getCmdletManager();
    long cmdId = cmdletManager.submitCmdlet("allssd -file /testfile");
    while (true) {
        Thread.sleep(1000);
        CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
        if (state == CmdletState.DONE) {
            return;
        } else if (state == CmdletState.FAILED) {
            Assert.fail("Mover failed.");
        } else {
            System.out.println(state);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) CmdletManager(org.smartdata.server.engine.CmdletManager) CmdletState(org.smartdata.model.CmdletState) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) Test(org.junit.Test)

Example 3 with CmdletState

use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.

the class CmdletManager method onCmdletStatusUpdate.

public void onCmdletStatusUpdate(CmdletStatus status) throws IOException {
    if (status == null) {
        return;
    }
    long cmdletId = status.getCmdletId();
    CmdletInfo cmdletInfo = idToCmdlets.get(cmdletId);
    if (cmdletInfo != null) {
        synchronized (cmdletInfo) {
            if (CmdletState.isTerminalState(cmdletInfo.getState())) {
                return;
            }
            CmdletState state = status.getCurrentState();
            cmdletInfo.setState(state);
            cmdletInfo.setStateChangedTime(status.getStateUpdateTime());
            if (CmdletState.isTerminalState(state)) {
                cmdletFinished(cmdletId);
            } else if (state == CmdletState.DISPATCHED) {
                flushCmdletInfo(cmdletInfo);
            }
        }
    }
}
Also used : CmdletState(org.smartdata.model.CmdletState) CmdletInfo(org.smartdata.model.CmdletInfo)

Example 4 with CmdletState

use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.

the class TestSmallFileScheduler method testScheduler.

@Test(timeout = 180000)
public void testScheduler() throws Exception {
    waitTillSSMExitSafeMode();
    Thread.sleep(2000);
    CmdletManager cmdletManager = ssm.getCmdletManager();
    long cmdId = cmdletManager.submitCmdlet("compact -file " + "['/test/small_files/file_0','/test/small_files/file_1'] " + "-containerFile /test/small_files/container_file_2");
    while (true) {
        Thread.sleep(3000);
        CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
        if (state == CmdletState.DONE) {
            long containerFileLen = dfsClient.getFileInfo("/test/small_files/container_file_2").getLen();
            Assert.assertEquals(sumFileLen, containerFileLen);
            Assert.assertEquals(0, dfsClient.getFileInfo("/test/small_files/file_1").getLen());
            return;
        } else if (state == CmdletState.FAILED) {
            Assert.fail("Compact failed.");
        } else {
            System.out.println(state);
        }
    }
}
Also used : CmdletManager(org.smartdata.server.engine.CmdletManager) CmdletState(org.smartdata.model.CmdletState) Test(org.junit.Test)

Example 5 with CmdletState

use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.

the class TestCmdletManager method testSubmitAPI.

@Test
public void testSubmitAPI() throws Exception {
    waitTillSSMExitSafeMode();
    DistributedFileSystem dfs = cluster.getFileSystem();
    Path dir = new Path("/testMoveFile");
    dfs.mkdirs(dir);
    // Move to SSD
    dfs.setStoragePolicy(dir, "HOT");
    FSDataOutputStream out1 = dfs.create(new Path("/testMoveFile/file1"), true, 1024);
    out1.writeChars("/testMoveFile/file1");
    out1.close();
    Path dir3 = new Path("/testCacheFile");
    dfs.mkdirs(dir3);
    Assert.assertTrue(ActionRegistry.supportedActions().size() > 0);
    CmdletManager cmdletManager = ssm.getCmdletManager();
    long cmdId = cmdletManager.submitCmdlet("allssd -file /testMoveFile/file1 ; cache -file /testCacheFile ; " + "write -file /test -length 1024");
    Thread.sleep(1200);
    List<ActionInfo> actionInfos = cmdletManager.listNewCreatedActions(10);
    Assert.assertTrue(actionInfos.size() > 0);
    while (true) {
        CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
        if (state == CmdletState.DONE) {
            break;
        }
        Assert.assertFalse(CmdletState.isTerminalState(state));
        System.out.printf("Cmdlet still running.\n");
        Thread.sleep(1000);
    }
    List<CmdletInfo> com = ssm.getMetaStore().getCmdlets(null, null, CmdletState.DONE);
    Assert.assertTrue(com.size() >= 1);
    List<ActionInfo> result = ssm.getMetaStore().getActions(null, null);
    Assert.assertTrue(result.size() == 3);
}
Also used : Path(org.apache.hadoop.fs.Path) CmdletState(org.smartdata.model.CmdletState) ActionInfo(org.smartdata.model.ActionInfo) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) CmdletInfo(org.smartdata.model.CmdletInfo) Test(org.junit.Test)

Aggregations

CmdletState (org.smartdata.model.CmdletState)5 Test (org.junit.Test)3 CmdletInfo (org.smartdata.model.CmdletInfo)3 CmdletManager (org.smartdata.server.engine.CmdletManager)3 Path (org.apache.hadoop.fs.Path)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 IOException (java.io.IOException)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 ActionInfo (org.smartdata.model.ActionInfo)1