YARN-6811. [ATS1.5] All history logs should be kept under its own User Directory. Contributed by Rohith Sharma K S.
This commit is contained in:
parent
bbc6d254c8
commit
f44b349b81
|
@ -2069,6 +2069,10 @@ public class YarnConfiguration extends Configuration {
|
||||||
= TIMELINE_SERVICE_PREFIX
|
= TIMELINE_SERVICE_PREFIX
|
||||||
+ "entity-file.fs-support-append";
|
+ "entity-file.fs-support-append";
|
||||||
|
|
||||||
|
public static final String
|
||||||
|
TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR =
|
||||||
|
TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_PREFIX + "with-user-dir";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for timeline service v2.0
|
* Settings for timeline service v2.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -145,10 +145,13 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
new LogFDsCache(flushIntervalSecs, cleanIntervalSecs, ttl,
|
new LogFDsCache(flushIntervalSecs, cleanIntervalSecs, ttl,
|
||||||
timerTaskTTL);
|
timerTaskTTL);
|
||||||
|
|
||||||
this.isAppendSupported =
|
this.isAppendSupported = conf.getBoolean(
|
||||||
conf.getBoolean(
|
|
||||||
YarnConfiguration.TIMELINE_SERVICE_ENTITYFILE_FS_SUPPORT_APPEND, true);
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYFILE_FS_SUPPORT_APPEND, true);
|
||||||
|
|
||||||
|
boolean storeInsideUserDir = conf.getBoolean(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
|
||||||
|
false);
|
||||||
|
|
||||||
objMapper = createObjectMapper();
|
objMapper = createObjectMapper();
|
||||||
|
|
||||||
int attemptDirCacheSize = conf.getInt(
|
int attemptDirCacheSize = conf.getInt(
|
||||||
|
@ -157,8 +160,8 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
YarnConfiguration
|
YarnConfiguration
|
||||||
.DEFAULT_TIMELINE_SERVICE_CLIENT_INTERNAL_ATTEMPT_DIR_CACHE_SIZE);
|
.DEFAULT_TIMELINE_SERVICE_CLIENT_INTERNAL_ATTEMPT_DIR_CACHE_SIZE);
|
||||||
|
|
||||||
attemptDirCache =
|
attemptDirCache = new AttemptDirCache(attemptDirCacheSize, fs, activePath,
|
||||||
new AttemptDirCache(attemptDirCacheSize, fs, activePath);
|
authUgi, storeInsideUserDir);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
StringBuilder debugMSG = new StringBuilder();
|
StringBuilder debugMSG = new StringBuilder();
|
||||||
|
@ -171,6 +174,8 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
+ "=" + ttl + ", " +
|
+ "=" + ttl + ", " +
|
||||||
YarnConfiguration.TIMELINE_SERVICE_ENTITYFILE_FS_SUPPORT_APPEND
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYFILE_FS_SUPPORT_APPEND
|
||||||
+ "=" + isAppendSupported + ", " +
|
+ "=" + isAppendSupported + ", " +
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR
|
||||||
|
+ "=" + storeInsideUserDir + ", " +
|
||||||
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_ACTIVE_DIR
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_ACTIVE_DIR
|
||||||
+ "=" + activePath);
|
+ "=" + activePath);
|
||||||
|
|
||||||
|
@ -946,8 +951,11 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
private final Map<ApplicationAttemptId, Path> attemptDirCache;
|
private final Map<ApplicationAttemptId, Path> attemptDirCache;
|
||||||
private final FileSystem fs;
|
private final FileSystem fs;
|
||||||
private final Path activePath;
|
private final Path activePath;
|
||||||
|
private final UserGroupInformation authUgi;
|
||||||
|
private final boolean storeInsideUserDir;
|
||||||
|
|
||||||
public AttemptDirCache(int cacheSize, FileSystem fs, Path activePath) {
|
public AttemptDirCache(int cacheSize, FileSystem fs, Path activePath,
|
||||||
|
UserGroupInformation ugi, boolean storeInsideUserDir) {
|
||||||
this.attemptDirCacheSize = cacheSize;
|
this.attemptDirCacheSize = cacheSize;
|
||||||
this.attemptDirCache =
|
this.attemptDirCache =
|
||||||
new LinkedHashMap<ApplicationAttemptId, Path>(
|
new LinkedHashMap<ApplicationAttemptId, Path>(
|
||||||
|
@ -961,6 +969,8 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
};
|
};
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
this.activePath = activePath;
|
this.activePath = activePath;
|
||||||
|
this.authUgi = ugi;
|
||||||
|
this.storeInsideUserDir = storeInsideUserDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path getAppAttemptDir(ApplicationAttemptId attemptId)
|
public Path getAppAttemptDir(ApplicationAttemptId attemptId)
|
||||||
|
@ -993,8 +1003,8 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path createApplicationDir(ApplicationId appId) throws IOException {
|
private Path createApplicationDir(ApplicationId appId) throws IOException {
|
||||||
Path appDir =
|
Path appRootDir = getAppRootDir(authUgi.getShortUserName());
|
||||||
new Path(activePath, appId.toString());
|
Path appDir = new Path(appRootDir, appId.toString());
|
||||||
if (FileSystem.mkdirs(fs, appDir,
|
if (FileSystem.mkdirs(fs, appDir,
|
||||||
new FsPermission(APP_LOG_DIR_PERMISSIONS))) {
|
new FsPermission(APP_LOG_DIR_PERMISSIONS))) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
|
@ -1003,5 +1013,19 @@ public class FileSystemTimelineWriter extends TimelineWriter{
|
||||||
}
|
}
|
||||||
return appDir;
|
return appDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Path getAppRootDir(String user) throws IOException {
|
||||||
|
if (!storeInsideUserDir) {
|
||||||
|
return activePath;
|
||||||
|
}
|
||||||
|
Path userDir = new Path(activePath, user);
|
||||||
|
if (FileSystem.mkdirs(fs, userDir,
|
||||||
|
new FsPermission(APP_LOG_DIR_PERMISSIONS))) {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("New user directory created - " + userDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userDir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3244,4 +3244,14 @@
|
||||||
<value>0.0.0.0:8091</value>
|
<value>0.0.0.0:8091</value>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<property>
|
||||||
|
<description>
|
||||||
|
It is TimelineClient 1.5 configuration whether to store active
|
||||||
|
application’s timeline data with in user directory i.e
|
||||||
|
${yarn.timeline-service.entity-group-fs-store.active-dir}/${user.name}
|
||||||
|
</description>
|
||||||
|
<name>yarn.timeline-service.entity-group-fs-store.with-user-dir</name>
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class TestTimelineClientForATS1_5 {
|
||||||
private static FileContext localFS;
|
private static FileContext localFS;
|
||||||
private static File localActiveDir;
|
private static File localActiveDir;
|
||||||
private TimelineWriter spyTimelineWriter;
|
private TimelineWriter spyTimelineWriter;
|
||||||
|
private UserGroupInformation authUgi;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
|
@ -69,6 +70,10 @@ public class TestTimelineClientForATS1_5 {
|
||||||
localFS.delete(new Path(localActiveDir.getAbsolutePath()), true);
|
localFS.delete(new Path(localActiveDir.getAbsolutePath()), true);
|
||||||
localActiveDir.mkdir();
|
localActiveDir.mkdir();
|
||||||
LOG.info("Created activeDir in " + localActiveDir.getAbsolutePath());
|
LOG.info("Created activeDir in " + localActiveDir.getAbsolutePath());
|
||||||
|
authUgi = UserGroupInformation.getCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
private YarnConfiguration getConfigurations() {
|
||||||
YarnConfiguration conf = new YarnConfiguration();
|
YarnConfiguration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||||
conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 1.5f);
|
conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 1.5f);
|
||||||
|
@ -77,7 +82,7 @@ public class TestTimelineClientForATS1_5 {
|
||||||
conf.set(
|
conf.set(
|
||||||
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SUMMARY_ENTITY_TYPES,
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SUMMARY_ENTITY_TYPES,
|
||||||
"summary_type");
|
"summary_type");
|
||||||
client = createTimelineClient(conf);
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -90,6 +95,21 @@ public class TestTimelineClientForATS1_5 {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostEntities() throws Exception {
|
public void testPostEntities() throws Exception {
|
||||||
|
client = createTimelineClient(getConfigurations());
|
||||||
|
verifyForPostEntities(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPostEntitiesToKeepUnderUserDir() throws Exception {
|
||||||
|
YarnConfiguration conf = getConfigurations();
|
||||||
|
conf.setBoolean(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
|
||||||
|
true);
|
||||||
|
client = createTimelineClient(conf);
|
||||||
|
verifyForPostEntities(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyForPostEntities(boolean storeInsideUserDir) {
|
||||||
ApplicationId appId =
|
ApplicationId appId =
|
||||||
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
||||||
TimelineEntityGroupId groupId =
|
TimelineEntityGroupId groupId =
|
||||||
|
@ -118,7 +138,8 @@ public class TestTimelineClientForATS1_5 {
|
||||||
entityTDB[0] = entities[0];
|
entityTDB[0] = entities[0];
|
||||||
verify(spyTimelineWriter, times(1)).putEntities(entityTDB);
|
verify(spyTimelineWriter, times(1)).putEntities(entityTDB);
|
||||||
Assert.assertTrue(localFS.util().exists(
|
Assert.assertTrue(localFS.util().exists(
|
||||||
new Path(getAppAttemptDir(attemptId1), "summarylog-"
|
new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
|
||||||
|
"summarylog-"
|
||||||
+ attemptId1.toString())));
|
+ attemptId1.toString())));
|
||||||
reset(spyTimelineWriter);
|
reset(spyTimelineWriter);
|
||||||
|
|
||||||
|
@ -132,13 +153,16 @@ public class TestTimelineClientForATS1_5 {
|
||||||
verify(spyTimelineWriter, times(0)).putEntities(
|
verify(spyTimelineWriter, times(0)).putEntities(
|
||||||
any(TimelineEntity[].class));
|
any(TimelineEntity[].class));
|
||||||
Assert.assertTrue(localFS.util().exists(
|
Assert.assertTrue(localFS.util().exists(
|
||||||
new Path(getAppAttemptDir(attemptId2), "summarylog-"
|
new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
|
||||||
|
"summarylog-"
|
||||||
+ attemptId2.toString())));
|
+ attemptId2.toString())));
|
||||||
Assert.assertTrue(localFS.util().exists(
|
Assert.assertTrue(localFS.util().exists(
|
||||||
new Path(getAppAttemptDir(attemptId2), "entitylog-"
|
new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
|
||||||
|
"entitylog-"
|
||||||
+ groupId.toString())));
|
+ groupId.toString())));
|
||||||
Assert.assertTrue(localFS.util().exists(
|
Assert.assertTrue(localFS.util().exists(
|
||||||
new Path(getAppAttemptDir(attemptId2), "entitylog-"
|
new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
|
||||||
|
"entitylog-"
|
||||||
+ groupId2.toString())));
|
+ groupId2.toString())));
|
||||||
reset(spyTimelineWriter);
|
reset(spyTimelineWriter);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -148,6 +172,21 @@ public class TestTimelineClientForATS1_5 {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPutDomain() {
|
public void testPutDomain() {
|
||||||
|
client = createTimelineClient(getConfigurations());
|
||||||
|
verifyForPutDomain(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPutDomainToKeepUnderUserDir() {
|
||||||
|
YarnConfiguration conf = getConfigurations();
|
||||||
|
conf.setBoolean(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
|
||||||
|
true);
|
||||||
|
client = createTimelineClient(conf);
|
||||||
|
verifyForPutDomain(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyForPutDomain(boolean storeInsideUserDir) {
|
||||||
ApplicationId appId =
|
ApplicationId appId =
|
||||||
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
||||||
ApplicationAttemptId attemptId1 =
|
ApplicationAttemptId attemptId1 =
|
||||||
|
@ -161,23 +200,33 @@ public class TestTimelineClientForATS1_5 {
|
||||||
|
|
||||||
client.putDomain(attemptId1, domain);
|
client.putDomain(attemptId1, domain);
|
||||||
verify(spyTimelineWriter, times(0)).putDomain(domain);
|
verify(spyTimelineWriter, times(0)).putDomain(domain);
|
||||||
Assert.assertTrue(localFS.util().exists(
|
Assert.assertTrue(localFS.util()
|
||||||
new Path(getAppAttemptDir(attemptId1), "domainlog-"
|
.exists(new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
|
||||||
+ attemptId1.toString())));
|
"domainlog-" + attemptId1.toString())));
|
||||||
reset(spyTimelineWriter);
|
reset(spyTimelineWriter);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Assert.fail("Exception is not expected." + e);
|
Assert.fail("Exception is not expected." + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path getAppAttemptDir(ApplicationAttemptId appAttemptId) {
|
private Path getAppAttemptDir(ApplicationAttemptId appAttemptId,
|
||||||
Path appDir =
|
boolean storeInsideUserDir) {
|
||||||
new Path(localActiveDir.getAbsolutePath(), appAttemptId
|
Path userDir = getUserDir(appAttemptId, storeInsideUserDir);
|
||||||
.getApplicationId().toString());
|
Path appDir = new Path(userDir, appAttemptId.getApplicationId().toString());
|
||||||
Path attemptDir = new Path(appDir, appAttemptId.toString());
|
Path attemptDir = new Path(appDir, appAttemptId.toString());
|
||||||
return attemptDir;
|
return attemptDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Path getUserDir(ApplicationAttemptId appAttemptId,
|
||||||
|
boolean storeInsideUserDir) {
|
||||||
|
if (!storeInsideUserDir) {
|
||||||
|
return new Path(localActiveDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
Path userDir =
|
||||||
|
new Path(localActiveDir.getAbsolutePath(), authUgi.getShortUserName());
|
||||||
|
return userDir;
|
||||||
|
}
|
||||||
|
|
||||||
private static TimelineEntity generateEntity(String type) {
|
private static TimelineEntity generateEntity(String type) {
|
||||||
TimelineEntity entity = new TimelineEntity();
|
TimelineEntity entity = new TimelineEntity();
|
||||||
entity.setEntityId("entity id");
|
entity.setEntityId("entity id");
|
||||||
|
|
|
@ -356,7 +356,13 @@ public class EntityGroupFSTimelineStore extends CompositeService
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
int scanActiveLogs() throws IOException {
|
int scanActiveLogs() throws IOException {
|
||||||
long startTime = Time.monotonicNow();
|
long startTime = Time.monotonicNow();
|
||||||
RemoteIterator<FileStatus> iter = list(activeRootPath);
|
int logsToScanCount = scanActiveLogs(activeRootPath);
|
||||||
|
metrics.addActiveLogDirScanTime(Time.monotonicNow() - startTime);
|
||||||
|
return logsToScanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int scanActiveLogs(Path dir) throws IOException {
|
||||||
|
RemoteIterator<FileStatus> iter = list(dir);
|
||||||
int logsToScanCount = 0;
|
int logsToScanCount = 0;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
FileStatus stat = iter.next();
|
FileStatus stat = iter.next();
|
||||||
|
@ -368,10 +374,9 @@ public class EntityGroupFSTimelineStore extends CompositeService
|
||||||
AppLogs logs = getAndSetActiveLog(appId, stat.getPath());
|
AppLogs logs = getAndSetActiveLog(appId, stat.getPath());
|
||||||
executor.execute(new ActiveLogParser(logs));
|
executor.execute(new ActiveLogParser(logs));
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Unable to parse entry {}", name);
|
logsToScanCount += scanActiveLogs(stat.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metrics.addActiveLogDirScanTime(Time.monotonicNow() - startTime);
|
|
||||||
return logsToScanCount;
|
return logsToScanCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,6 +423,18 @@ public class EntityGroupFSTimelineStore extends CompositeService
|
||||||
appDirPath = getActiveAppPath(applicationId);
|
appDirPath = getActiveAppPath(applicationId);
|
||||||
if (fs.exists(appDirPath)) {
|
if (fs.exists(appDirPath)) {
|
||||||
appState = AppState.ACTIVE;
|
appState = AppState.ACTIVE;
|
||||||
|
} else {
|
||||||
|
// check for user directory inside active path
|
||||||
|
RemoteIterator<FileStatus> iter = list(activeRootPath);
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Path child = new Path(iter.next().getPath().getName(),
|
||||||
|
applicationId.toString());
|
||||||
|
appDirPath = new Path(activeRootPath, child);
|
||||||
|
if (fs.exists(appDirPath)) {
|
||||||
|
appState = AppState.ACTIVE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (appState != AppState.UNKNOWN) {
|
if (appState != AppState.UNKNOWN) {
|
||||||
|
|
|
@ -37,6 +37,8 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
||||||
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
|
import org.apache.hadoop.yarn.server.timeline.EntityGroupFSTimelineStore.AppState;
|
||||||
|
import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -58,7 +60,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.server.timeline.EntityGroupFSTimelineStore.AppState;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -91,6 +92,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
private static ApplicationId mainTestAppId;
|
private static ApplicationId mainTestAppId;
|
||||||
private static Path mainTestAppDirPath;
|
private static Path mainTestAppDirPath;
|
||||||
private static Path testDoneDirPath;
|
private static Path testDoneDirPath;
|
||||||
|
private static Path testActiveDirPath;
|
||||||
private static String mainEntityLogFileName;
|
private static String mainEntityLogFileName;
|
||||||
|
|
||||||
private EntityGroupFSTimelineStore store;
|
private EntityGroupFSTimelineStore store;
|
||||||
|
@ -125,22 +127,27 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
+ i);
|
+ i);
|
||||||
sampleAppIds.add(appId);
|
sampleAppIds.add(appId);
|
||||||
}
|
}
|
||||||
|
testActiveDirPath = getTestRootPath("active");
|
||||||
// Among all sample applicationIds, choose the first one for most of the
|
// Among all sample applicationIds, choose the first one for most of the
|
||||||
// tests.
|
// tests.
|
||||||
mainTestAppId = sampleAppIds.get(0);
|
mainTestAppId = sampleAppIds.get(0);
|
||||||
mainTestAppDirPath = getTestRootPath(mainTestAppId.toString());
|
mainTestAppDirPath = new Path(testActiveDirPath, mainTestAppId.toString());
|
||||||
mainEntityLogFileName = EntityGroupFSTimelineStore.ENTITY_LOG_PREFIX
|
mainEntityLogFileName = EntityGroupFSTimelineStore.ENTITY_LOG_PREFIX
|
||||||
+ EntityGroupPlugInForTest.getStandardTimelineGroupId(mainTestAppId);
|
+ EntityGroupPlugInForTest.getStandardTimelineGroupId(mainTestAppId);
|
||||||
|
|
||||||
testDoneDirPath = getTestRootPath("done");
|
testDoneDirPath = getTestRootPath("done");
|
||||||
config.set(YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_DONE_DIR,
|
config.set(YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_DONE_DIR,
|
||||||
testDoneDirPath.toString());
|
testDoneDirPath.toString());
|
||||||
|
config.set(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_ACTIVE_DIR,
|
||||||
|
testActiveDirPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
for (ApplicationId appId : sampleAppIds) {
|
for (ApplicationId appId : sampleAppIds) {
|
||||||
Path attemotDirPath = new Path(getTestRootPath(appId.toString()),
|
Path attemotDirPath =
|
||||||
|
new Path(new Path(testActiveDirPath, appId.toString()),
|
||||||
getAttemptDirName(appId));
|
getAttemptDirName(appId));
|
||||||
createTestFiles(appId, attemotDirPath);
|
createTestFiles(appId, attemotDirPath);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +185,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
store.stop();
|
store.stop();
|
||||||
for (ApplicationId appId : sampleAppIds) {
|
for (ApplicationId appId : sampleAppIds) {
|
||||||
fs.delete(getTestRootPath(appId.toString()), true);
|
fs.delete(new Path(testActiveDirPath,appId.toString()), true);
|
||||||
}
|
}
|
||||||
if (testJar != null) {
|
if (testJar != null) {
|
||||||
testJar.delete();
|
testJar.delete();
|
||||||
|
@ -414,8 +421,88 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
private void createTestFiles(ApplicationId appId, Path attemptDirPath)
|
private void createTestFiles(ApplicationId appId, Path attemptDirPath)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
createTestFiles(appId, attemptDirPath, mainEntityLogFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTestFiles(ApplicationId appId, Path attemptDirPath,
|
||||||
|
String logPath) throws IOException {
|
||||||
TimelineEntities entities = PluginStoreTestUtils.generateTestEntities();
|
TimelineEntities entities = PluginStoreTestUtils.generateTestEntities();
|
||||||
PluginStoreTestUtils.writeEntities(entities,
|
PluginStoreTestUtils.writeEntities(entities,
|
||||||
new Path(attemptDirPath, TEST_SUMMARY_LOG_FILE_NAME), fs);
|
new Path(attemptDirPath, TEST_SUMMARY_LOG_FILE_NAME), fs);
|
||||||
|
@ -429,7 +516,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
TimelineEntities entityList = new TimelineEntities();
|
TimelineEntities entityList = new TimelineEntities();
|
||||||
entityList.addEntity(entityNew);
|
entityList.addEntity(entityNew);
|
||||||
PluginStoreTestUtils.writeEntities(entityList,
|
PluginStoreTestUtils.writeEntities(entityList,
|
||||||
new Path(attemptDirPath, mainEntityLogFileName), fs);
|
new Path(attemptDirPath, logPath), fs);
|
||||||
|
|
||||||
FSDataOutputStream out = fs.create(
|
FSDataOutputStream out = fs.create(
|
||||||
new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME));
|
new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME));
|
||||||
|
|
Loading…
Reference in New Issue