@Test public void testCreateAction() throws ActionException { SmartContext smartContext = mock(SmartContext.class); SmartConf conf = new SmartConf(); conf.set(DFS_NAMENODE_HTTP_ADDRESS_KEY, "http: conf.set(SmartConfKeys.SMART_DFS_NAMENODE_RPCSERVER_KEY, "hdfs: when(smartContext.getConf()).thenReturn(conf); CmdletFactory cmdletFactory = new CmdletFactory(smartContext); LaunchAction launchAction1 = new LaunchAction(10, "allssd", new HashMap<String, String>()); }
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); } } return smartAction; }
CmdletFactory { 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); } } return smartAction; } }
CmdletFactory { 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); } } return smartAction; } CmdletFactory(SmartContext smartContext);  CmdletFactory(SmartContext smartContext, StatusReporter reporter); }
CmdletFactory { 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); } } return smartAction; } CmdletFactory(SmartContext smartContext);  CmdletFactory(SmartContext smartContext, StatusReporter reporter); Cmdlet createCmdlet(LaunchCmdlet launchCmdlet); SmartAction createAction(long cmdletId, boolean isLastAction, LaunchAction launchAction); }
CmdletFactory { 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); } } return smartAction; } CmdletFactory(SmartContext smartContext);  CmdletFactory(SmartContext smartContext, StatusReporter reporter); Cmdlet createCmdlet(LaunchCmdlet launchCmdlet); SmartAction createAction(long cmdletId, boolean isLastAction, LaunchAction launchAction);  }