MAPREDUCE-6473. Job submission can take a long time during Cluster initialization. Contributed by Kuhu Shukla

This commit is contained in:
Jason Lowe 2016-01-12 23:56:23 +00:00
parent 126705f67e
commit f657b54281
2 changed files with 44 additions and 28 deletions

View File

@ -468,6 +468,9 @@ Release 2.8.0 - UNRELEASED
MAPREDUCE-6394. Speed up Task processing loop in HsTasksBlock#render() MAPREDUCE-6394. Speed up Task processing loop in HsTasksBlock#render()
(Ray Chiang via jlowe) (Ray Chiang via jlowe)
MAPREDUCE-6473. Job submission can take a long time during Cluster
initialization (Kuhu Shukla via jlowe)
BUG FIXES BUG FIXES
MAPREDUCE-6314. TestPipeApplication fails on trunk. MAPREDUCE-6314. TestPipeApplication fails on trunk.

View File

@ -66,6 +66,22 @@ public class Cluster {
private static ServiceLoader<ClientProtocolProvider> frameworkLoader = private static ServiceLoader<ClientProtocolProvider> frameworkLoader =
ServiceLoader.load(ClientProtocolProvider.class); ServiceLoader.load(ClientProtocolProvider.class);
private volatile List<ClientProtocolProvider> providerList = null;
private void initProviderList() {
if (providerList == null) {
synchronized (frameworkLoader) {
if (providerList == null) {
List<ClientProtocolProvider> localProviderList =
new ArrayList<ClientProtocolProvider>();
for (ClientProtocolProvider provider : frameworkLoader) {
localProviderList.add(provider);
}
providerList = localProviderList;
}
}
}
}
static { static {
ConfigUtil.loadResources(); ConfigUtil.loadResources();
@ -85,8 +101,8 @@ public class Cluster {
private void initialize(InetSocketAddress jobTrackAddr, Configuration conf) private void initialize(InetSocketAddress jobTrackAddr, Configuration conf)
throws IOException { throws IOException {
synchronized (frameworkLoader) { initProviderList();
for (ClientProtocolProvider provider : frameworkLoader) { for (ClientProtocolProvider provider : providerList) {
LOG.debug("Trying ClientProtocolProvider : " LOG.debug("Trying ClientProtocolProvider : "
+ provider.getClass().getName()); + provider.getClass().getName());
ClientProtocol clientProtocol = null; ClientProtocol clientProtocol = null;
@ -103,18 +119,15 @@ public class Cluster {
LOG.debug("Picked " + provider.getClass().getName() LOG.debug("Picked " + provider.getClass().getName()
+ " as the ClientProtocolProvider"); + " as the ClientProtocolProvider");
break; break;
} } else {
else {
LOG.debug("Cannot pick " + provider.getClass().getName() LOG.debug("Cannot pick " + provider.getClass().getName()
+ " as the ClientProtocolProvider - returned null protocol"); + " as the ClientProtocolProvider - returned null protocol");
} }
} } catch (Exception e) {
catch (Exception e) {
LOG.info("Failed to use " + provider.getClass().getName() LOG.info("Failed to use " + provider.getClass().getName()
+ " due to error: ", e); + " due to error: ", e);
} }
} }
}
if (null == clientProtocolProvider || null == client) { if (null == clientProtocolProvider || null == client) {
throw new IOException( throw new IOException(