use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class SmallFilePlugin method updateContainerFileInfoCache.
/**
* Update container file info cache based on containerFileSizeThreshold
* and cmdlet.
*/
private void updateContainerFileInfoCache(RuleInfo ruleInfo, Map<String, FileInfo> containerFileInfoMap) {
if (!containerFileInfoMap.isEmpty()) {
// Remove container file whose size is greater than containerFileSizeThreshold
for (Map.Entry<String, FileInfo> entry : containerFileInfoMap.entrySet()) {
if (entry.getValue().getLength() >= containerFileSizeThreshold) {
containerFileInfoMap.remove(entry.getKey());
}
}
// Remove container file which is being used
try {
List<Long> aids = new ArrayList<>();
List<CmdletInfo> list = cmdletManager.listCmdletsInfo(ruleInfo.getId());
for (CmdletInfo cmdletInfo : list) {
if (!CmdletState.isTerminalState(cmdletInfo.getState())) {
aids.addAll(cmdletInfo.getAids());
}
}
List<ActionInfo> actionInfos = cmdletManager.getActions(aids);
for (ActionInfo actionInfo : actionInfos) {
Map<String, String> args = actionInfo.getArgs();
if (args.containsKey(SmallFileCompactAction.CONTAINER_FILE)) {
containerFileInfoMap.remove(args.get(SmallFileCompactAction.CONTAINER_FILE));
}
}
} catch (IOException e) {
LOG.error("Failed to get cmdlet and action info.", e);
}
}
containerFileInfoCache.put(ruleInfo, containerFileInfoMap);
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class MetaStore method listFileActions.
public List<DetailedFileAction> listFileActions(long rid, int size) throws MetaStoreException {
if (mapStoragePolicyIdName == null) {
updateCache();
}
List<ActionInfo> actionInfos = getActions(rid, size);
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 getActions.
public List<ActionInfo> getActions(long rid, long start, long offset) throws MetaStoreException {
long mark = 0;
long count = 0;
List<CmdletInfo> cmdletInfos = cmdletDao.getByRid(rid);
List<ActionInfo> totalActions = new ArrayList<>();
for (CmdletInfo cmdletInfo : cmdletInfos) {
List<Long> aids = cmdletInfo.getAids();
if (mark + aids.size() >= start + 1) {
long gap;
gap = start - mark;
for (Long aid : aids) {
if (gap > 0) {
gap--;
mark++;
continue;
}
if (count < offset) {
ActionInfo actionInfo = getActionById(aid);
totalActions.add(actionInfo);
count++;
mark++;
} else {
return totalActions;
}
}
} else {
mark += aids.size();
}
}
return totalActions;
}
Aggregations