use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class MetaDataAction method execute.
@Override
protected void execute() throws Exception {
if (srcPath == null) {
throw new IllegalArgumentException("File src is missing.");
}
FileInfo fileInfo = new FileInfo(srcPath, 0, 0, false, replication, 0, mTime, aTime, permission, ownerName, groupName, (byte) 1, (byte) 0);
changeFileMetaData(srcPath, fileInfo);
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestFileInfoDao method testInsertUpdateFiles.
@Test
public void testInsertUpdateFiles() throws Exception {
String path = "/testFile";
long length = 123L;
boolean isDir = false;
short blockReplication = 1;
long blockSize = 128 * 1024L;
long modTime = 123123123L;
long accessTime = 123123120L;
short permission = 1;
String owner = "root";
String group = "admin";
long fileId = 312321L;
byte storagePolicy = 0;
byte erasureCodingPolicy = 0;
Map<Integer, String> mapOwnerIdName = new HashMap<>();
mapOwnerIdName.put(1, "root");
Map<Integer, String> mapGroupIdName = new HashMap<>();
mapGroupIdName.put(1, "admin");
FileInfo fileInfo = new FileInfo(path, fileId, length, isDir, blockReplication, blockSize, modTime, accessTime, permission, owner, group, storagePolicy, erasureCodingPolicy);
fileInfoDao.insert(fileInfo);
fileInfoDao.update(path, 10);
FileInfo file = fileInfoDao.getById(fileId);
fileInfo.setStoragePolicy((byte) 10);
Assert.assertTrue(file.equals(fileInfo));
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testMoveSyncRules.
@Test
public void testMoveSyncRules() throws Exception {
String pathString = "/src/1";
long length = 123L;
boolean isDir = false;
int blockReplication = 1;
long blockSize = 128 * 1024L;
long modTime = 123123123L;
long accessTime = 123123120L;
String owner = "root";
String group = "admin";
long fileId = 56L;
byte storagePolicy = 0;
byte erasureCodingPolicy = 0;
FileInfo fileInfo = new FileInfo(pathString, fileId, length, isDir, (short) blockReplication, blockSize, modTime, accessTime, (short) 1, owner, group, storagePolicy, erasureCodingPolicy);
metaStore.insertFile(fileInfo);
Map<String, String> args = new HashMap();
args.put("-file", "/src/1");
String rule = "file : accessCount(10m) > 20 \n\n" + "and length() > 3 | ";
long submitTime = System.currentTimeMillis();
RuleInfo ruleInfo = new RuleInfo(0, submitTime, rule + "sync -dest /dest/", RuleState.ACTIVE, 0, 0, 0);
metaStore.insertNewRule(ruleInfo);
metaStore.insertBackUpInfo(new BackUpInfo(ruleInfo.getId(), "/src/", "/dest/", 100));
metaStore.insertNewRule(new RuleInfo(1, submitTime, rule + "allssd", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "archive", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "onessd", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "cache", RuleState.ACTIVE, 0, 0, 0));
Assert.assertTrue(metaStore.listMoveRules().size() == 3);
Assert.assertTrue(metaStore.listSyncRules().size() == 1);
CmdletInfo cmdletInfo = new CmdletInfo(1, ruleInfo.getId(), CmdletState.EXECUTING, "test", 123123333L, 232444444L);
cmdletInfo.setAids(Collections.singletonList(1L));
metaStore.insertCmdlet(cmdletInfo);
metaStore.insertAction(new ActionInfo(1, 1, "allssd", args, "Test", "Test", true, 123213213L, true, 123123L, 100));
Assert.assertTrue(metaStore.listFileActions(ruleInfo.getId(), 0).size() >= 0);
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class FileInfoDao method getFidPaths.
public Map<Long, String> getFidPaths(Collection<Long> ids) throws SQLException {
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
Map<Long, String> idToPath = new HashMap<>();
String sql = "SELECT * FROM file WHERE fid IN (:ids)";
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
parameterSource.addValue("ids", ids);
List<FileInfo> files = namedParameterJdbcTemplate.query(sql, parameterSource, new FileInfoRowMapper());
for (FileInfo file : files) {
idToPath.put(file.getFileId(), file.getPath());
}
return idToPath;
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class FileInfoDao method getPathFids.
public Map<String, Long> getPathFids(Collection<String> paths) throws SQLException {
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
Map<String, Long> pathToId = new HashMap<>();
String sql = "SELECT * FROM file WHERE path IN (:paths)";
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
parameterSource.addValue("paths", paths);
List<FileInfo> files = namedParameterJdbcTemplate.query(sql, parameterSource, new FileInfoRowMapper());
for (FileInfo file : files) {
pathToId.put(file.getPath(), file.getFileId());
}
return pathToId;
}
Aggregations