Search in sources :

Example 21 with MetaStore

use of org.smartdata.metastore.MetaStore in project SSM by Intel-bigdata.

the class TestAlluxioEntryApplier method setUp.

@Before
public void setUp() throws Exception {
    initDao();
    metaStore = new MetaStore(druidPool);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) Before(org.junit.Before)

Example 22 with MetaStore

use of org.smartdata.metastore.MetaStore in project SSM by Intel-bigdata.

the class TestCompressDecompress method testSubmitCompressionAction.

@Test
public void testSubmitCompressionAction() throws Exception {
    // if (!loadedNative()) {
    // return;
    // }
    waitTillSSMExitSafeMode();
    // initDB();
    int arraySize = 1024 * 1024 * 80;
    String fileName = "/ssm/compression/file1";
    byte[] bytes = prepareFile(fileName, arraySize);
    MetaStore metaStore = ssm.getMetaStore();
    int bufSize = 1024 * 1024 * 10;
    CmdletManager cmdletManager = ssm.getCmdletManager();
    long cmdId = cmdletManager.submitCmdlet("compress -file " + fileName + " -bufSize " + bufSize + " -codec " + codec);
    waitTillActionDone(cmdId);
    FileState fileState = null;
    // metastore  test
    int n = 0;
    while (true) {
        fileState = metaStore.getFileState(fileName);
        if (FileState.FileType.COMPRESSION.equals(fileState.getFileType())) {
            break;
        }
        Thread.sleep(1000);
        if (n++ >= 20) {
            throw new Exception("Time out in waiting for getting expect file state.");
        }
    }
    Assert.assertEquals(FileState.FileStage.DONE, fileState.getFileStage());
    Assert.assertTrue(fileState instanceof CompressionFileState);
    CompressionFileState compressionFileState = (CompressionFileState) fileState;
    Assert.assertEquals(fileName, compressionFileState.getPath());
    Assert.assertEquals(bufSize, compressionFileState.getBufferSize());
    Assert.assertEquals(codec, compressionFileState.getCompressionImpl());
    Assert.assertEquals(arraySize, compressionFileState.getOriginalLength());
    Assert.assertTrue(compressionFileState.getCompressedLength() > 0);
    Assert.assertTrue(compressionFileState.getCompressedLength() < compressionFileState.getOriginalLength());
    // data accuracy test
    byte[] input = new byte[arraySize];
    DFSInputStream dfsInputStream = smartDFSClient.open(fileName);
    int offset = 0;
    while (true) {
        int len = dfsInputStream.read(input, offset, arraySize - offset);
        if (len <= 0) {
            break;
        }
        offset += len;
    }
    Assert.assertArrayEquals("original array not equals compress/decompressed array", input, bytes);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) CmdletManager(org.smartdata.server.engine.CmdletManager) CompressionFileState(org.smartdata.model.CompressionFileState) DFSInputStream(org.apache.hadoop.hdfs.DFSInputStream) IOException(java.io.IOException) Test(org.junit.Test)

Example 23 with MetaStore

use of org.smartdata.metastore.MetaStore in project SSM by Intel-bigdata.

the class TestSmartClient method testGetFileState.

@Test
public void testGetFileState() throws Exception {
    waitTillSSMExitSafeMode();
    MetaStore metaStore = ssm.getMetaStore();
    String path = "/file1";
    FileState fileState = new NormalFileState(path);
    SmartClient client = new SmartClient(smartContext.getConf());
    FileState fileState1;
    // No entry in file_state table (Normal type as default)
    fileState1 = client.getFileState(path);
    Assert.assertEquals(fileState, fileState1);
    metaStore.insertUpdateFileState(fileState);
    fileState1 = client.getFileState(path);
    Assert.assertEquals(fileState, fileState1);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) FileState(org.smartdata.model.FileState) NormalFileState(org.smartdata.model.NormalFileState) NormalFileState(org.smartdata.model.NormalFileState) SmartClient(org.smartdata.client.SmartClient) Test(org.junit.Test)

Example 24 with MetaStore

use of org.smartdata.metastore.MetaStore in project SSM by Intel-bigdata.

the class TestCopy2S3Scheduler method testZeroLength.

@Test(timeout = 45000)
public void testZeroLength() throws Exception {
    waitTillSSMExitSafeMode();
    MetaStore metaStore = ssm.getMetaStore();
    SmartAdmin admin = new SmartAdmin(smartContext.getConf());
    DistributedFileSystem dfs = cluster.getFileSystem();
    final String srcPath = "/src/";
    dfs.mkdirs(new Path(srcPath));
    // Write to src
    for (int i = 0; i < 3; i++) {
        // Create test files
        DFSTestUtil.createFile(dfs, new Path(srcPath + i), 0, (short) 1, 1);
    }
    long ruleId = admin.submitRule("file: path matches \"/src/*\"| copy2s3 -dest s3a://xxxctest/dest/", RuleState.ACTIVE);
    Thread.sleep(2500);
    List<ActionInfo> actions = metaStore.getActions(ruleId, 0);
    Assert.assertEquals(actions.size(), 0);
}
Also used : Path(org.apache.hadoop.fs.Path) MetaStore(org.smartdata.metastore.MetaStore) SmartAdmin(org.smartdata.admin.SmartAdmin) ActionInfo(org.smartdata.model.ActionInfo) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) Test(org.junit.Test)

Example 25 with MetaStore

use of org.smartdata.metastore.MetaStore in project SSM by Intel-bigdata.

the class TestAccessCountTableManager method initTestEnvironment.

private AccessCountTableManager initTestEnvironment() throws Exception {
    MetaStore metaStore = new MetaStore(druidPool);
    createTables(databaseTester.getConnection().getConnection());
    IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("files.xml"));
    databaseTester.setDataSet(dataSet);
    databaseTester.onSetup();
    prepareFiles(metaStore);
    return new AccessCountTableManager(metaStore);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) IDataSet(org.dbunit.dataset.IDataSet) XmlDataSet(org.dbunit.dataset.xml.XmlDataSet)

Aggregations

MetaStore (org.smartdata.metastore.MetaStore)29 Test (org.junit.Test)17 Before (org.junit.Before)7 DBTest (org.smartdata.metastore.DBTest)7 Path (org.apache.hadoop.fs.Path)5 ActionInfo (org.smartdata.model.ActionInfo)5 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)4 SmartConf (org.smartdata.conf.SmartConf)4 TimeGranularity (org.smartdata.metastore.utils.TimeGranularity)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 IDataSet (org.dbunit.dataset.IDataSet)3 XmlDataSet (org.dbunit.dataset.xml.XmlDataSet)3 SmartAdmin (org.smartdata.admin.SmartAdmin)3 CmdletInfo (org.smartdata.model.CmdletInfo)3 LocalAlluxioCluster (alluxio.master.LocalAlluxioCluster)2 ArrayList (java.util.ArrayList)2 FsPermission (org.apache.hadoop.fs.permission.FsPermission)2 DFSClient (org.apache.hadoop.hdfs.DFSClient)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2