use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class ServerProtocolsServerSideTranslator method listActionInfoOfLastActions.
@Override
public ListActionInfoOfLastActionsResponseProto listActionInfoOfLastActions(RpcController controller, ListActionInfoOfLastActionsRequestProto request) throws ServiceException {
try {
List<ActionInfo> list = server.listActionInfoOfLastActions(request.getMaxNumActions());
if (list == null) {
return ListActionInfoOfLastActionsResponseProto.newBuilder().build();
}
List<ActionInfoProto> protoList = new ArrayList<>();
for (ActionInfo a : list) {
protoList.add(ProtoBufferHelper.convert(a));
}
return ListActionInfoOfLastActionsResponseProto.newBuilder().addAllActionInfoList(protoList).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class MetaStore method listFileActions.
public List<DetailedFileAction> listFileActions(long rid, long start, long offset) throws MetaStoreException {
if (mapStoragePolicyIdName == null) {
updateCache();
}
List<ActionInfo> actionInfos = getActions(rid, start, offset);
List<DetailedFileAction> detailedFileActions = new ArrayList<>();
for (ActionInfo actionInfo : actionInfos) {
DetailedFileAction detailedFileAction = new DetailedFileAction(actionInfo);
String filePath = actionInfo.getArgs().get("-file");
FileInfo fileInfo = getFile(filePath);
if (fileInfo == null) {
// LOG.debug("Namespace is not sync! File {} not in file table!", filePath);
// Add a mock fileInfo
fileInfo = new FileInfo(filePath, 0L, 0L, false, (short) 0, 0L, 0L, 0L, (short) 0, "root", "root", (byte) 0, (byte) 0);
}
detailedFileAction.setFileLength(fileInfo.getLength());
detailedFileAction.setFilePath(filePath);
if (actionInfo.getActionName().contains("allssd") || actionInfo.getActionName().contains("onessd") || actionInfo.getActionName().contains("archive") || actionInfo.getActionName().contains("alldisk") || actionInfo.getActionName().contains("onedisk") || actionInfo.getActionName().contains("ramdisk")) {
detailedFileAction.setTarget(actionInfo.getActionName());
detailedFileAction.setSrc(mapStoragePolicyIdName.get((int) fileInfo.getStoragePolicy()));
} else {
detailedFileAction.setSrc(actionInfo.getArgs().get("-src"));
detailedFileAction.setTarget(actionInfo.getArgs().get("-dest"));
}
detailedFileActions.add(detailedFileAction);
}
return detailedFileActions;
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class MetaStore method markActionFailed.
/**
* Mark action {aid} as failed.
*
* @param aid
* @throws MetaStoreException
*/
public void markActionFailed(long aid) throws MetaStoreException {
ActionInfo actionInfo = getActionById(aid);
if (actionInfo != null) {
// Finished
actionInfo.setFinished(true);
// Failed
actionInfo.setSuccessful(false);
// 100 % progress
actionInfo.setProgress(1);
// Finish time equals to create time
actionInfo.setFinishTime(actionInfo.getCreateTime());
updateAction(actionInfo);
}
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class MetaStore method getActions.
public List<ActionInfo> getActions(long rid, int size) throws MetaStoreException {
if (size <= 0) {
size = Integer.MAX_VALUE;
}
List<CmdletInfo> cmdletInfos = cmdletDao.getByRid(rid);
List<ActionInfo> runningActions = new ArrayList<>();
List<ActionInfo> finishedActions = new ArrayList<>();
int total = 0;
for (CmdletInfo cmdletInfo : cmdletInfos) {
if (total >= size) {
break;
}
List<Long> aids = cmdletInfo.getAids();
for (Long aid : aids) {
if (total >= size) {
break;
}
ActionInfo actionInfo = getActionById(aid);
if (actionInfo != null && actionInfo.isFinished()) {
finishedActions.add(actionInfo);
} else {
runningActions.add(actionInfo);
}
total++;
}
}
runningActions.addAll(finishedActions);
return runningActions;
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestCmdletManager method testReloadCmdletsInDB.
@Test(timeout = 40000)
public void testReloadCmdletsInDB() throws Exception {
waitTillSSMExitSafeMode();
CmdletManager cmdletManager = ssm.getCmdletManager();
// Stop cmdletmanager
// cmdletManager.stop();
cmdletManager.setTimeout(1000);
MetaStore metaStore = ssm.getMetaStore();
String cmd = "write -file /test -length 1024; read -file /test";
CmdletDescriptor cmdletDescriptor = generateCmdletDescriptor(cmd);
long submitTime = System.currentTimeMillis();
CmdletInfo cmdletInfo0 = new CmdletInfo(0, cmdletDescriptor.getRuleId(), CmdletState.DISPATCHED, cmdletDescriptor.getCmdletString(), submitTime, submitTime);
CmdletInfo cmdletInfo1 = new CmdletInfo(1, cmdletDescriptor.getRuleId(), CmdletState.PENDING, cmdletDescriptor.getCmdletString(), submitTime, submitTime);
List<ActionInfo> actionInfos0 = cmdletManager.createActionInfos(cmdletDescriptor, cmdletInfo0.getCid());
flushToDB(metaStore, actionInfos0, cmdletInfo0);
List<ActionInfo> actionInfos1 = cmdletManager.createActionInfos(cmdletDescriptor, cmdletInfo1.getCid());
flushToDB(metaStore, actionInfos1, cmdletInfo1);
// init cmdletmanager
cmdletManager.init();
// cmdletManager.start();
CmdletInfo cmdlet0 = cmdletManager.getCmdletInfo(cmdletInfo0.getCid());
CmdletInfo cmdlet1 = cmdletManager.getCmdletInfo(cmdletInfo1.getCid());
while (cmdlet0.getState() != CmdletState.FAILED && cmdlet1.getState() != CmdletState.DONE) {
Thread.sleep(100);
}
}
Aggregations