YARN-2565. Fixed RM to not use FileSystemApplicationHistoryStore unless explicitly set. Contributed by Zhijie Shen

This commit is contained in:
Jian He 2014-09-19 11:26:29 -07:00
parent 25fd69a8f9
commit 444acf8ea7
4 changed files with 50 additions and 24 deletions

View File

@ -400,6 +400,9 @@ Release 2.6.0 - UNRELEASED
YARN-2568. Fixed the potential test failures due to race conditions when RM YARN-2568. Fixed the potential test failures due to race conditions when RM
work-preserving recovery is enabled. (Jian He via zjshen) work-preserving recovery is enabled. (Jian He via zjshen)
YARN-2565. Fixed RM to not use FileSystemApplicationHistoryStore unless
explicitly set. (Zhijie Shen via jianhe)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -182,7 +182,9 @@ public class ApplicationHistoryServer extends CompositeService {
// APPLICATION_HISTORY_STORE is neither null nor empty, it means that the // APPLICATION_HISTORY_STORE is neither null nor empty, it means that the
// user has enabled it explicitly. // user has enabled it explicitly.
if (conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE) == null || if (conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE) == null ||
conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE).length() == 0) { conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE).length() == 0 ||
conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE).equals(
NullApplicationHistoryStore.class.getName())) {
return new ApplicationHistoryManagerOnTimelineStore( return new ApplicationHistoryManagerOnTimelineStore(
timelineDataManager, aclsManager); timelineDataManager, aclsManager);
} else { } else {

View File

@ -52,6 +52,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer; import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
import com.google.common.annotations.VisibleForTesting;
/** /**
* <p> * <p>
* {@link ResourceManager} uses this class to write the information of * {@link ResourceManager} uses this class to write the information of
@ -71,8 +73,10 @@ public class RMApplicationHistoryWriter extends CompositeService {
.getLog(RMApplicationHistoryWriter.class); .getLog(RMApplicationHistoryWriter.class);
private Dispatcher dispatcher; private Dispatcher dispatcher;
private ApplicationHistoryWriter writer; @VisibleForTesting
private boolean historyServiceEnabled; ApplicationHistoryWriter writer;
@VisibleForTesting
boolean historyServiceEnabled;
public RMApplicationHistoryWriter() { public RMApplicationHistoryWriter() {
super(RMApplicationHistoryWriter.class.getName()); super(RMApplicationHistoryWriter.class.getName());
@ -80,13 +84,18 @@ public class RMApplicationHistoryWriter extends CompositeService {
@Override @Override
protected synchronized void serviceInit(Configuration conf) throws Exception { protected synchronized void serviceInit(Configuration conf) throws Exception {
historyServiceEnabled = historyServiceEnabled =
conf.getBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, conf.getBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
YarnConfiguration.DEFAULT_APPLICATION_HISTORY_ENABLED); YarnConfiguration.DEFAULT_APPLICATION_HISTORY_ENABLED);
if (conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE) == null ||
conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE).length() == 0 ||
conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE).equals(
NullApplicationHistoryStore.class.getName())) {
historyServiceEnabled = false;
}
// Only create the services when the history service is enabled, preventing // Only create the services when the history service is enabled and not
// wasting the system resources. // using the null store, preventing wasting the system resources.
if (historyServiceEnabled) { if (historyServiceEnabled) {
writer = createApplicationHistoryStore(conf); writer = createApplicationHistoryStore(conf);
addIfService(writer); addIfService(writer);
@ -112,25 +121,19 @@ public class RMApplicationHistoryWriter extends CompositeService {
protected ApplicationHistoryStore createApplicationHistoryStore( protected ApplicationHistoryStore createApplicationHistoryStore(
Configuration conf) { Configuration conf) {
// If the history writer is not enabled, a dummy store will be used to try {
// write nothing Class<? extends ApplicationHistoryStore> storeClass =
if (historyServiceEnabled) { conf.getClass(YarnConfiguration.APPLICATION_HISTORY_STORE,
try { NullApplicationHistoryStore.class,
Class<? extends ApplicationHistoryStore> storeClass =
conf.getClass(YarnConfiguration.APPLICATION_HISTORY_STORE,
FileSystemApplicationHistoryStore.class,
ApplicationHistoryStore.class); ApplicationHistoryStore.class);
return storeClass.newInstance(); return storeClass.newInstance();
} catch (Exception e) { } catch (Exception e) {
String msg = String msg =
"Could not instantiate ApplicationHistoryWriter: " "Could not instantiate ApplicationHistoryWriter: "
+ conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE, + conf.get(YarnConfiguration.APPLICATION_HISTORY_STORE,
FileSystemApplicationHistoryStore.class.getName()); NullApplicationHistoryStore.class.getName());
LOG.error(msg, e); LOG.error(msg, e);
throw new YarnRuntimeException(msg, e); throw new YarnRuntimeException(msg, e);
}
} else {
return new NullApplicationHistoryStore();
} }
} }

View File

@ -78,6 +78,8 @@ public class TestRMApplicationHistoryWriter {
store = new MemoryApplicationHistoryStore(); store = new MemoryApplicationHistoryStore();
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true); conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true);
conf.setClass(YarnConfiguration.APPLICATION_HISTORY_STORE,
MemoryApplicationHistoryStore.class, ApplicationHistoryStore.class);
writer = new RMApplicationHistoryWriter() { writer = new RMApplicationHistoryWriter() {
@Override @Override
@ -174,6 +176,22 @@ public class TestRMApplicationHistoryWriter {
return container; return container;
} }
@Test
public void testDefaultStoreSetup() throws Exception {
Configuration conf = new YarnConfiguration();
conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true);
RMApplicationHistoryWriter writer = new RMApplicationHistoryWriter();
writer.init(conf);
writer.start();
try {
Assert.assertFalse(writer.historyServiceEnabled);
Assert.assertNull(writer.writer);
} finally {
writer.stop();
writer.close();
}
}
@Test @Test
public void testWriteApplication() throws Exception { public void testWriteApplication() throws Exception {
RMApp app = createRMApp(ApplicationId.newInstance(0, 1)); RMApp app = createRMApp(ApplicationId.newInstance(0, 1));