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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations