|
@@ -49,6 +49,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -107,6 +108,7 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Cont
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerResourceFailedEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ApplicationLocalizationEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ApplicationLocalizationEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationCleanupEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationCleanupEvent;
|
|
|
|
+import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationRequestEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationRequestEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEventType;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEventType;
|
|
@@ -388,6 +390,9 @@ public class ResourceLocalizationService extends CompositeService
|
|
case INIT_CONTAINER_RESOURCES:
|
|
case INIT_CONTAINER_RESOURCES:
|
|
handleInitContainerResources((ContainerLocalizationRequestEvent) event);
|
|
handleInitContainerResources((ContainerLocalizationRequestEvent) event);
|
|
break;
|
|
break;
|
|
|
|
+ case CONTAINER_RESOURCES_LOCALIZED:
|
|
|
|
+ handleContainerResourcesLocalized((ContainerLocalizationEvent) event);
|
|
|
|
+ break;
|
|
case CACHE_CLEANUP:
|
|
case CACHE_CLEANUP:
|
|
handleCacheCleanup(event);
|
|
handleCacheCleanup(event);
|
|
break;
|
|
break;
|
|
@@ -450,7 +455,18 @@ public class ResourceLocalizationService extends CompositeService
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Once a container's resources are localized, kill the corresponding
|
|
|
|
+ * {@link ContainerLocalizer}
|
|
|
|
+ */
|
|
|
|
+ private void handleContainerResourcesLocalized(
|
|
|
|
+ ContainerLocalizationEvent event) {
|
|
|
|
+ Container c = event.getContainer();
|
|
|
|
+ String locId = ConverterUtils.toString(c.getContainerId());
|
|
|
|
+ localizerTracker.endContainerLocalization(locId);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void handleCacheCleanup(LocalizationEvent event) {
|
|
private void handleCacheCleanup(LocalizationEvent event) {
|
|
ResourceRetentionSet retain =
|
|
ResourceRetentionSet retain =
|
|
new ResourceRetentionSet(delService, cacheTargetSize);
|
|
new ResourceRetentionSet(delService, cacheTargetSize);
|
|
@@ -661,7 +677,7 @@ public class ResourceLocalizationService extends CompositeService
|
|
response.setLocalizerAction(LocalizerAction.DIE);
|
|
response.setLocalizerAction(LocalizerAction.DIE);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
- return localizer.update(status.getResources());
|
|
|
|
|
|
+ return localizer.processHeartbeat(status.getResources());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -715,6 +731,17 @@ public class ResourceLocalizationService extends CompositeService
|
|
localizer.interrupt();
|
|
localizer.interrupt();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void endContainerLocalization(String locId) {
|
|
|
|
+ LocalizerRunner localizer;
|
|
|
|
+ synchronized (privLocalizers) {
|
|
|
|
+ localizer = privLocalizers.get(locId);
|
|
|
|
+ if (null == localizer) {
|
|
|
|
+ return; // ignore
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ localizer.endContainerLocalization();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -863,6 +890,7 @@ public class ResourceLocalizationService extends CompositeService
|
|
final Map<LocalResourceRequest,LocalizerResourceRequestEvent> scheduled;
|
|
final Map<LocalResourceRequest,LocalizerResourceRequestEvent> scheduled;
|
|
// Its a shared list between Private Localizer and dispatcher thread.
|
|
// Its a shared list between Private Localizer and dispatcher thread.
|
|
final List<LocalizerResourceRequestEvent> pending;
|
|
final List<LocalizerResourceRequestEvent> pending;
|
|
|
|
+ private AtomicBoolean killContainerLocalizer = new AtomicBoolean(false);
|
|
|
|
|
|
// TODO: threadsafe, use outer?
|
|
// TODO: threadsafe, use outer?
|
|
private final RecordFactory recordFactory =
|
|
private final RecordFactory recordFactory =
|
|
@@ -883,6 +911,10 @@ public class ResourceLocalizationService extends CompositeService
|
|
pending.add(request);
|
|
pending.add(request);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void endContainerLocalization() {
|
|
|
|
+ killContainerLocalizer.set(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Find next resource to be given to a spawned localizer.
|
|
* Find next resource to be given to a spawned localizer.
|
|
*
|
|
*
|
|
@@ -929,7 +961,7 @@ public class ResourceLocalizationService extends CompositeService
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- LocalizerHeartbeatResponse update(
|
|
|
|
|
|
+ LocalizerHeartbeatResponse processHeartbeat(
|
|
List<LocalResourceStatus> remoteResourceStatuses) {
|
|
List<LocalResourceStatus> remoteResourceStatuses) {
|
|
LocalizerHeartbeatResponse response =
|
|
LocalizerHeartbeatResponse response =
|
|
recordFactory.newRecordInstance(LocalizerHeartbeatResponse.class);
|
|
recordFactory.newRecordInstance(LocalizerHeartbeatResponse.class);
|
|
@@ -938,7 +970,7 @@ public class ResourceLocalizationService extends CompositeService
|
|
ApplicationId applicationId =
|
|
ApplicationId applicationId =
|
|
context.getContainerId().getApplicationAttemptId().getApplicationId();
|
|
context.getContainerId().getApplicationAttemptId().getApplicationId();
|
|
|
|
|
|
- LocalizerAction action = LocalizerAction.LIVE;
|
|
|
|
|
|
+ boolean fetchFailed = false;
|
|
// Update resource statuses.
|
|
// Update resource statuses.
|
|
for (LocalResourceStatus stat : remoteResourceStatuses) {
|
|
for (LocalResourceStatus stat : remoteResourceStatuses) {
|
|
LocalResource rsrc = stat.getResource();
|
|
LocalResource rsrc = stat.getResource();
|
|
@@ -974,7 +1006,7 @@ public class ResourceLocalizationService extends CompositeService
|
|
case FETCH_FAILURE:
|
|
case FETCH_FAILURE:
|
|
final String diagnostics = stat.getException().toString();
|
|
final String diagnostics = stat.getException().toString();
|
|
LOG.warn(req + " failed: " + diagnostics);
|
|
LOG.warn(req + " failed: " + diagnostics);
|
|
- response.setLocalizerAction(LocalizerAction.DIE);
|
|
|
|
|
|
+ fetchFailed = true;
|
|
getLocalResourcesTracker(req.getVisibility(), user, applicationId)
|
|
getLocalResourcesTracker(req.getVisibility(), user, applicationId)
|
|
.handle(new ResourceFailedLocalizationEvent(
|
|
.handle(new ResourceFailedLocalizationEvent(
|
|
req, diagnostics));
|
|
req, diagnostics));
|
|
@@ -986,15 +1018,15 @@ public class ResourceLocalizationService extends CompositeService
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
LOG.info("Unknown status: " + stat.getStatus());
|
|
LOG.info("Unknown status: " + stat.getStatus());
|
|
- action = LocalizerAction.DIE;
|
|
|
|
|
|
+ fetchFailed = true;
|
|
getLocalResourcesTracker(req.getVisibility(), user, applicationId)
|
|
getLocalResourcesTracker(req.getVisibility(), user, applicationId)
|
|
.handle(new ResourceFailedLocalizationEvent(
|
|
.handle(new ResourceFailedLocalizationEvent(
|
|
req, stat.getException().getMessage()));
|
|
req, stat.getException().getMessage()));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (action == LocalizerAction.DIE) {
|
|
|
|
- response.setLocalizerAction(action);
|
|
|
|
|
|
+ if (fetchFailed || killContainerLocalizer.get()) {
|
|
|
|
+ response.setLocalizerAction(LocalizerAction.DIE);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1022,12 +1054,9 @@ public class ResourceLocalizationService extends CompositeService
|
|
} catch (URISyntaxException e) {
|
|
} catch (URISyntaxException e) {
|
|
//TODO fail? Already translated several times...
|
|
//TODO fail? Already translated several times...
|
|
}
|
|
}
|
|
- } else if (pending.isEmpty()) {
|
|
|
|
- // TODO: Synchronization
|
|
|
|
- action = LocalizerAction.DIE;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- response.setLocalizerAction(action);
|
|
|
|
|
|
+ response.setLocalizerAction(LocalizerAction.LIVE);
|
|
response.setResourceSpecs(rsrcs);
|
|
response.setResourceSpecs(rsrcs);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|