Search in sources :

Example 11 with MetaStore

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

the class SmartServer method initWith.

public void initWith() throws Exception {
    LOG.info("Start Init Smart Server");
    HadoopUtil.setSmartConfByHadoop(conf);
    MetaStore metaStore = MetaStoreUtils.getDBAdapter(conf);
    context = new ServerContext(conf, metaStore);
    initServiceMode(conf);
    engine = new SmartEngine(context);
    rpcServer = new SmartRpcServer(this, conf);
    zeppelinServer = new SmartZeppelinServer(conf, engine);
    LOG.info("Finish Init Smart Server");
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) SmartZeppelinServer(org.apache.zeppelin.server.SmartZeppelinServer) ServerContext(org.smartdata.server.engine.ServerContext)

Example 12 with MetaStore

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

the class TestCopy2S3Scheduler method testDir.

@Test(timeout = 45000)
public void testDir() 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), 1024, (short) 1, 1);
    }
    long ruleId = admin.submitRule("file: path matches \"/src/*\"| copy2s3 -dest s3a://xxxctest/dest/", RuleState.ACTIVE);
    List<ActionInfo> actions;
    do {
        actions = metaStore.getActions(ruleId, 0);
        Thread.sleep(1000);
    } while (actions.size() < 3);
}
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 13 with MetaStore

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

the class TestCopy2S3Scheduler method testOnS3.

@Test(timeout = 45000)
public void testOnS3() 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));
    List<String> sps = new ArrayList<>();
    // Write to src
    for (int i = 0; i < 3; i++) {
        // Create test files
        // Not 0 because this file may be not be truncated yet
        sps.add(srcPath + i);
        DFSTestUtil.createFile(dfs, new Path(srcPath + i), 10, (short) 1, 1);
    }
    do {
        Thread.sleep(1000);
        if (metaStore.getFilesByPaths(sps).size() == sps.size()) {
            break;
        }
    } while (true);
    for (String p : sps) {
        metaStore.insertUpdateFileState(new S3FileState(p));
    }
    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(0, actions.size());
}
Also used : Path(org.apache.hadoop.fs.Path) MetaStore(org.smartdata.metastore.MetaStore) SmartAdmin(org.smartdata.admin.SmartAdmin) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) S3FileState(org.smartdata.model.S3FileState) Test(org.junit.Test)

Example 14 with MetaStore

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

the class TestAccessEventAggregator method testAccessEventAggregator.

@Test
public void testAccessEventAggregator() throws MetaStoreException {
    MetaStore adapter = mock(MetaStore.class);
    AccessCountTableManager manager = mock(AccessCountTableManager.class);
    AccessEventAggregator aggregator = new AccessEventAggregator(adapter, manager);
    aggregator.addAccessEvents(Lists.newArrayList(new FileAccessEvent("", 3000)));
    verify(adapter, never()).execute(anyString());
    aggregator.addAccessEvents(Lists.newArrayList(new FileAccessEvent("", 6000)));
    verify(adapter, times(1)).execute(anyString());
    verify(manager, times(1)).addTable(any(AccessCountTable.class));
    aggregator.addAccessEvents(Lists.newArrayList(new FileAccessEvent("abc", 8000), new FileAccessEvent("def", 14000), new FileAccessEvent("", 18000)));
    verify(adapter, times(3)).execute(anyString());
    verify(manager, times(3)).addTable(any(AccessCountTable.class));
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) FileAccessEvent(org.smartdata.metrics.FileAccessEvent) Test(org.junit.Test)

Example 15 with MetaStore

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

the class TestAlluxioEntryFetcher method setUp.

@Before
public void setUp() throws Exception {
    localAlluxioCluster = new LocalAlluxioCluster(2);
    localAlluxioCluster.initConfiguration();
    Configuration.set(PropertyKey.WEB_RESOURCES, PathUtils.concatPath(System.getProperty("user.dir"), "src/test/webapp"));
    localAlluxioCluster.start();
    fs = localAlluxioCluster.getClient();
    initDao();
    metaStore = new MetaStore(druidPool);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) LocalAlluxioCluster(alluxio.master.LocalAlluxioCluster)

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