@After public void tearDown() throws Exception { store.stop(); for (ApplicationId appId : sampleAppIds) { fs.delete(new Path(testActiveDirPath,appId.toString()), true); } if (testJar != null) { testJar.delete(); rootDir.delete(); } }
private EntityGroupFSTimelineStore createAndStartTimelineStore( AppState appstate) { // stop before creating new store to get the lock store.stop(); EntityGroupFSTimelineStore newStore = new EntityGroupFSTimelineStore() { @Override protected AppState getAppState(ApplicationId appId) throws IOException { return appstate; } }; newStore.init(config); newStore.setFs(fs); newStore.start(); return newStore; }
@Test public void testGetEntityPluginRead() throws Exception { EntityGroupFSTimelineStore store = null; ApplicationId appId = ApplicationId.fromString("application_1501509265053_0001"); String user = UserGroupInformation.getCurrentUser().getShortUserName(); Path userBase = new Path(testActiveDirPath, user); Path userAppRoot = new Path(userBase, appId.toString()); Path attemotDirPath = new Path(userAppRoot, getAttemptDirName(appId)); try { store = createAndStartTimelineStore(AppState.ACTIVE); String logFileName = EntityGroupFSTimelineStore.ENTITY_LOG_PREFIX + EntityGroupPlugInForTest.getStandardTimelineGroupId(appId); createTestFiles(appId, attemotDirPath, logFileName); TimelineEntity entity = store.getEntity(entityNew.getEntityId(), entityNew.getEntityType(), EnumSet.allOf(Field.class)); assertNotNull(entity); assertEquals(entityNew.getEntityId(), entity.getEntityId()); assertEquals(entityNew.getEntityType(), entity.getEntityType()); } finally { if (store != null) { store.stop(); } fs.delete(userBase, true); } }
@Test public void testScanActiveLogsAndMoveToDonePluginRead() throws Exception { EntityGroupFSTimelineStore store = null; ApplicationId appId = ApplicationId.fromString("application_1501509265053_0002"); String user = UserGroupInformation.getCurrentUser().getShortUserName(); Path userBase = new Path(testActiveDirPath, user); Path userAppRoot = new Path(userBase, appId.toString()); Path attemotDirPath = new Path(userAppRoot, getAttemptDirName(appId)); try { store = createAndStartTimelineStore(AppState.COMPLETED); String logFileName = EntityGroupFSTimelineStore.ENTITY_LOG_PREFIX + EntityGroupPlugInForTest.getStandardTimelineGroupId(appId); createTestFiles(appId, attemotDirPath, logFileName); store.scanActiveLogs(); TimelineEntity entity = store.getEntity(entityNew.getEntityId(), entityNew.getEntityType(), EnumSet.allOf(Field.class)); assertNotNull(entity); assertEquals(entityNew.getEntityId(), entity.getEntityId()); assertEquals(entityNew.getEntityType(), entity.getEntityType()); } finally { if (store != null) { store.stop(); } fs.delete(userBase, true); } }