|
@@ -19,19 +19,13 @@ package org.apache.hadoop.yarn.server.timeline;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
-import org.apache.hadoop.fs.FileSystem;
|
|
|
|
-import org.apache.hadoop.fs.Path;
|
|
|
|
import org.apache.hadoop.util.Time;
|
|
import org.apache.hadoop.util.Time;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
|
|
import org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager;
|
|
import org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager;
|
|
-import org.codehaus.jackson.JsonFactory;
|
|
|
|
-import org.codehaus.jackson.map.ObjectMapper;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,15 +41,12 @@ public class EntityCacheItem {
|
|
private EntityGroupFSTimelineStore.AppLogs appLogs;
|
|
private EntityGroupFSTimelineStore.AppLogs appLogs;
|
|
private long lastRefresh;
|
|
private long lastRefresh;
|
|
private Configuration config;
|
|
private Configuration config;
|
|
- private FileSystem fs;
|
|
|
|
private int refCount = 0;
|
|
private int refCount = 0;
|
|
private static AtomicInteger activeStores = new AtomicInteger(0);
|
|
private static AtomicInteger activeStores = new AtomicInteger(0);
|
|
|
|
|
|
- public EntityCacheItem(TimelineEntityGroupId gId, Configuration config,
|
|
|
|
- FileSystem fs) {
|
|
|
|
|
|
+ public EntityCacheItem(TimelineEntityGroupId gId, Configuration config) {
|
|
this.groupId = gId;
|
|
this.groupId = gId;
|
|
this.config = config;
|
|
this.config = config;
|
|
- this.fs = fs;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -97,15 +88,12 @@ public class EntityCacheItem {
|
|
* other operations on the same cache item.
|
|
* other operations on the same cache item.
|
|
*
|
|
*
|
|
* @param aclManager ACL manager for the timeline storage
|
|
* @param aclManager ACL manager for the timeline storage
|
|
- * @param jsonFactory JSON factory for the storage
|
|
|
|
- * @param objMapper Object mapper for the storage
|
|
|
|
* @param metrics Metrics to trace the status of the entity group store
|
|
* @param metrics Metrics to trace the status of the entity group store
|
|
* @return a {@link org.apache.hadoop.yarn.server.timeline.TimelineStore}
|
|
* @return a {@link org.apache.hadoop.yarn.server.timeline.TimelineStore}
|
|
* object filled with all entities in the group.
|
|
* object filled with all entities in the group.
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
public synchronized TimelineStore refreshCache(TimelineACLsManager aclManager,
|
|
public synchronized TimelineStore refreshCache(TimelineACLsManager aclManager,
|
|
- JsonFactory jsonFactory, ObjectMapper objMapper,
|
|
|
|
EntityGroupFSTimelineStoreMetrics metrics) throws IOException {
|
|
EntityGroupFSTimelineStoreMetrics metrics) throws IOException {
|
|
if (needRefresh()) {
|
|
if (needRefresh()) {
|
|
long startTime = Time.monotonicNow();
|
|
long startTime = Time.monotonicNow();
|
|
@@ -128,30 +116,13 @@ public class EntityCacheItem {
|
|
// Store is not null, the refresh is triggered by stale storage.
|
|
// Store is not null, the refresh is triggered by stale storage.
|
|
metrics.incrCacheStaleRefreshes();
|
|
metrics.incrCacheStaleRefreshes();
|
|
}
|
|
}
|
|
- List<LogInfo> removeList = new ArrayList<>();
|
|
|
|
try (TimelineDataManager tdm =
|
|
try (TimelineDataManager tdm =
|
|
new TimelineDataManager(store, aclManager)) {
|
|
new TimelineDataManager(store, aclManager)) {
|
|
tdm.init(config);
|
|
tdm.init(config);
|
|
tdm.start();
|
|
tdm.start();
|
|
- for (LogInfo log : appLogs.getDetailLogs()) {
|
|
|
|
- LOG.debug("Try refresh logs for {}", log.getFilename());
|
|
|
|
- // Only refresh the log that matches the cache id
|
|
|
|
- if (log.matchesGroupId(groupId)) {
|
|
|
|
- Path appDirPath = appLogs.getAppDirPath();
|
|
|
|
- if (fs.exists(log.getPath(appDirPath))) {
|
|
|
|
- LOG.debug("Refresh logs for cache id {}", groupId);
|
|
|
|
- log.parseForStore(tdm, appDirPath, appLogs.isDone(),
|
|
|
|
- jsonFactory, objMapper, fs);
|
|
|
|
- } else {
|
|
|
|
- // The log may have been removed, remove the log
|
|
|
|
- removeList.add(log);
|
|
|
|
- LOG.info("File {} no longer exists, removing it from log list",
|
|
|
|
- log.getPath(appDirPath));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // Load data from appLogs to tdm
|
|
|
|
+ appLogs.loadDetailLog(tdm, groupId);
|
|
}
|
|
}
|
|
- appLogs.getDetailLogs().removeAll(removeList);
|
|
|
|
}
|
|
}
|
|
updateRefreshTimeToNow();
|
|
updateRefreshTimeToNow();
|
|
metrics.addCacheRefreshTime(Time.monotonicNow() - startTime);
|
|
metrics.addCacheRefreshTime(Time.monotonicNow() - startTime);
|