Search in sources :

Example 1 with HdfsAction

use of org.smartdata.hdfs.action.HdfsAction in project SSM by Intel-bigdata.

the class TestCmdlet method runHelper.

private Cmdlet runHelper() throws IOException {
    SmartAction[] actions = new SmartAction[4];
    // New action
    // actions[0] = new AllSsdFileAction();
    // actions[0].setDfsClient(client);
    // actions[0].setContext(new SmartContext(smartConf));
    // actions[0].getDNStorageReports(new String[]{"/testMoveFile/file1"});
    // actions[1] = new MoveFileAction();
    // actions[1].setDfsClient(client);
    // actions[1].setContext(new SmartContext(smartConf));
    // actions[1].getDNStorageReports(new String[]{"/testMoveFile/file2", "COLD"});
    actions[2] = new CacheFileAction();
    ((HdfsAction) actions[2]).setDfsClient(dfsClient);
    actions[2].setContext(smartContext);
    Map<String, String> args = new HashMap();
    args.put(CacheFileAction.FILE_PATH, "/testCacheFile");
    actions[2].init(args);
    // New Cmdlet
    Cmdlet cmd = new Cmdlet(Arrays.asList(actions));
    cmd.setId(1);
    cmd.setRuleId(1);
    cmd.setState(CmdletState.PENDING);
    return cmd;
}
Also used : CacheFileAction(org.smartdata.hdfs.action.CacheFileAction) HdfsAction(org.smartdata.hdfs.action.HdfsAction) HashMap(java.util.HashMap) SmartAction(org.smartdata.action.SmartAction)

Example 2 with HdfsAction

use of org.smartdata.hdfs.action.HdfsAction in project SSM by Intel-bigdata.

the class CmdletFactory method createAction.

public SmartAction createAction(long cmdletId, boolean isLastAction, LaunchAction launchAction) throws ActionException {
    SmartAction smartAction = ActionRegistry.createAction(launchAction.getActionType());
    smartAction.setContext(smartContext);
    smartAction.setCmdletId(cmdletId);
    smartAction.setLastAction(isLastAction);
    smartAction.init(launchAction.getArgs());
    smartAction.setActionId(launchAction.getActionId());
    if (smartAction instanceof HdfsAction) {
        try {
            ((HdfsAction) smartAction).setDfsClient(new SmartDFSClient(HadoopUtil.getNameNodeUri(smartContext.getConf()), smartContext.getConf(), getRpcServerAddress()));
        } catch (IOException e) {
            LOG.error("smartAction aid={} setDfsClient error", launchAction.getActionId(), e);
            throw new ActionException(e);
        }
    }
    /*
    else if (smartAction instanceof AlluxioAction) {
      FileSystem fs;
      try {
        fs =  AlluxioUtil.getAlluxioFs(smartContext);
      } catch (Exception e) {
        LOG.error("smartAction aid={} alluxio filesystem error", launchAction.getActionId(), e);
        throw new ActionException(e);
      }
      ((AlluxioAction) smartAction).setFileSystem(fs);
    }
    */
    return smartAction;
}
Also used : HdfsAction(org.smartdata.hdfs.action.HdfsAction) SmartAction(org.smartdata.action.SmartAction) ActionException(org.smartdata.action.ActionException) IOException(java.io.IOException) SmartDFSClient(org.smartdata.hdfs.client.SmartDFSClient)

Aggregations

SmartAction (org.smartdata.action.SmartAction)2 HdfsAction (org.smartdata.hdfs.action.HdfsAction)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ActionException (org.smartdata.action.ActionException)1 CacheFileAction (org.smartdata.hdfs.action.CacheFileAction)1 SmartDFSClient (org.smartdata.hdfs.client.SmartDFSClient)1