Search in sources :

Example 21 with FileInfo

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);
}
Also used : FileInfo(org.smartdata.model.FileInfo)

Example 22 with 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));
}
Also used : FileInfo(org.smartdata.model.FileInfo) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 23 with 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);
}
Also used : FileInfo(org.smartdata.model.FileInfo) HashMap(java.util.HashMap) BackUpInfo(org.smartdata.model.BackUpInfo) ActionInfo(org.smartdata.model.ActionInfo) RuleInfo(org.smartdata.model.RuleInfo) CmdletInfo(org.smartdata.model.CmdletInfo) Test(org.junit.Test)

Example 24 with FileInfo

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) FileInfo(org.smartdata.model.FileInfo) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) HashMap(java.util.HashMap)

Example 25 with FileInfo

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) FileInfo(org.smartdata.model.FileInfo) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) HashMap(java.util.HashMap)

Aggregations

FileInfo (org.smartdata.model.FileInfo)51 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)15 FileDiff (org.smartdata.model.FileDiff)12 AlluxioURI (alluxio.AlluxioURI)10 HashMap (java.util.HashMap)10 URIStatus (alluxio.client.file.URIStatus)9 MetaStoreException (org.smartdata.metastore.MetaStoreException)9 BackUpInfo (org.smartdata.model.BackUpInfo)7 FileSystem (alluxio.client.file.FileSystem)6 JournalEntry (alluxio.proto.journal.Journal.JournalEntry)6 AlluxioEntryApplier (org.smartdata.alluxio.metric.fetcher.AlluxioEntryApplier)6 SmartFilePermission (org.smartdata.SmartFilePermission)5 Gson (com.google.gson.Gson)4 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 ActionInfo (org.smartdata.model.ActionInfo)4 AlluxioException (alluxio.exception.AlluxioException)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3