|
@@ -108,6 +108,8 @@ public class AMRMProxyService extends CompositeService implements
|
|
private Map<ApplicationId, RequestInterceptorChainWrapper> applPipelineMap;
|
|
private Map<ApplicationId, RequestInterceptorChainWrapper> applPipelineMap;
|
|
private RegistryOperations registry;
|
|
private RegistryOperations registry;
|
|
private AMRMProxyMetrics metrics;
|
|
private AMRMProxyMetrics metrics;
|
|
|
|
+ private FederationStateStoreFacade federationFacade;
|
|
|
|
+ private boolean federationEnabled = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates an instance of the service.
|
|
* Creates an instance of the service.
|
|
@@ -144,7 +146,10 @@ public class AMRMProxyService extends CompositeService implements
|
|
RegistryOperations.class);
|
|
RegistryOperations.class);
|
|
addService(this.registry);
|
|
addService(this.registry);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ this.federationFacade = FederationStateStoreFacade.getInstance();
|
|
|
|
+ this.federationEnabled =
|
|
|
|
+ conf.getBoolean(YarnConfiguration.FEDERATION_ENABLED,
|
|
|
|
+ YarnConfiguration.DEFAULT_FEDERATION_ENABLED);
|
|
super.serviceInit(conf);
|
|
super.serviceInit(conf);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -389,13 +394,22 @@ public class AMRMProxyService extends CompositeService implements
|
|
throws IOException, YarnException {
|
|
throws IOException, YarnException {
|
|
long startTime = clock.getTime();
|
|
long startTime = clock.getTime();
|
|
try {
|
|
try {
|
|
- LOG.info("Callback received for initializing request "
|
|
|
|
- + "processing pipeline for an AM");
|
|
|
|
ContainerTokenIdentifier containerTokenIdentifierForKey =
|
|
ContainerTokenIdentifier containerTokenIdentifierForKey =
|
|
BuilderUtils.newContainerTokenIdentifier(request.getContainerToken());
|
|
BuilderUtils.newContainerTokenIdentifier(request.getContainerToken());
|
|
ApplicationAttemptId appAttemptId =
|
|
ApplicationAttemptId appAttemptId =
|
|
containerTokenIdentifierForKey.getContainerID()
|
|
containerTokenIdentifierForKey.getContainerID()
|
|
.getApplicationAttemptId();
|
|
.getApplicationAttemptId();
|
|
|
|
+ ApplicationId applicationID = appAttemptId.getApplicationId();
|
|
|
|
+ // Checking if application is there in federation state store only
|
|
|
|
+ // if federation is enabled. If
|
|
|
|
+ // application is submitted to router then it adds it in statestore.
|
|
|
|
+ // if application is not found in statestore that means its
|
|
|
|
+ // submitted to RM
|
|
|
|
+ if (!checkIfAppExistsInStateStore(applicationID)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ LOG.info("Callback received for initializing request "
|
|
|
|
+ + "processing pipeline for an AM");
|
|
Credentials credentials = YarnServerSecurityUtils
|
|
Credentials credentials = YarnServerSecurityUtils
|
|
.parseCredentials(request.getContainerLaunchContext());
|
|
.parseCredentials(request.getContainerLaunchContext());
|
|
|
|
|
|
@@ -772,6 +786,21 @@ public class AMRMProxyService extends CompositeService implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ boolean checkIfAppExistsInStateStore(ApplicationId applicationID) {
|
|
|
|
+ if (!federationEnabled) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // Check if app is there in state store. If app is not there then it
|
|
|
|
+ // throws Exception
|
|
|
|
+ this.federationFacade.getApplicationHomeSubCluster(applicationID);
|
|
|
|
+ } catch (YarnException ex) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
private Token<AMRMTokenIdentifier> getFirstAMRMToken(
|
|
private Token<AMRMTokenIdentifier> getFirstAMRMToken(
|
|
Collection<Token<? extends TokenIdentifier>> allTokens) {
|
|
Collection<Token<? extends TokenIdentifier>> allTokens) {
|