|
@@ -110,8 +110,9 @@ public class AuxServices extends AbstractService
|
|
|
private Path stateStoreRoot = null;
|
|
|
private FileSystem stateStoreFs = null;
|
|
|
|
|
|
- private Path manifest;
|
|
|
- private FileSystem manifestFS;
|
|
|
+ private volatile boolean manifestEnabled = false;
|
|
|
+ private volatile Path manifest;
|
|
|
+ private volatile FileSystem manifestFS;
|
|
|
private Timer manifestReloadTimer;
|
|
|
private TimerTask manifestReloadTask;
|
|
|
private long manifestReloadInterval;
|
|
@@ -139,6 +140,13 @@ public class AuxServices extends AbstractService
|
|
|
// Obtain services from configuration in init()
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns whether aux services manifest / dynamic loading is enabled.
|
|
|
+ */
|
|
|
+ public boolean isManifestEnabled() {
|
|
|
+ return manifestEnabled;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Adds a service to the service map.
|
|
|
*
|
|
@@ -480,7 +488,8 @@ public class AuxServices extends AbstractService
|
|
|
*
|
|
|
* @throws IOException if manifest can't be loaded
|
|
|
*/
|
|
|
- private void reloadManifest() throws IOException {
|
|
|
+ @VisibleForTesting
|
|
|
+ protected void reloadManifest() throws IOException {
|
|
|
loadManifest(getConfig(), true);
|
|
|
}
|
|
|
|
|
@@ -488,9 +497,15 @@ public class AuxServices extends AbstractService
|
|
|
* Reloads auxiliary services. Must be called after service init.
|
|
|
*
|
|
|
* @param services a list of auxiliary services
|
|
|
- * @throws IOException if aux services have not been started yet
|
|
|
+ * @throws IOException if aux services have not been started yet or dynamic
|
|
|
+ * reloading is not enabled
|
|
|
*/
|
|
|
- public void reload(AuxServiceRecords services) throws IOException {
|
|
|
+ public synchronized void reload(AuxServiceRecords services) throws
|
|
|
+ IOException {
|
|
|
+ if (!manifestEnabled) {
|
|
|
+ throw new IOException("Dynamic reloading is not enabled via " +
|
|
|
+ YarnConfiguration.NM_AUX_SERVICES_MANIFEST_ENABLED);
|
|
|
+ }
|
|
|
if (getServiceState() != Service.STATE.STARTED) {
|
|
|
throw new IOException("Auxiliary services have not been started yet, " +
|
|
|
"please retry later");
|
|
@@ -578,6 +593,10 @@ public class AuxServices extends AbstractService
|
|
|
@VisibleForTesting
|
|
|
protected synchronized void loadManifest(Configuration conf, boolean
|
|
|
startServices) throws IOException {
|
|
|
+ if (!manifestEnabled) {
|
|
|
+ throw new IOException("Dynamic reloading is not enabled via " +
|
|
|
+ YarnConfiguration.NM_AUX_SERVICES_MANIFEST_ENABLED);
|
|
|
+ }
|
|
|
if (manifest == null) {
|
|
|
return;
|
|
|
}
|
|
@@ -730,8 +749,10 @@ public class AuxServices extends AbstractService
|
|
|
STATE_STORE_ROOT_NAME);
|
|
|
stateStoreFs = FileSystem.getLocal(conf);
|
|
|
}
|
|
|
- String manifestStr = conf.get(YarnConfiguration.NM_AUX_SERVICES_MANIFEST);
|
|
|
- if (manifestStr == null) {
|
|
|
+ manifestEnabled = conf.getBoolean(
|
|
|
+ YarnConfiguration.NM_AUX_SERVICES_MANIFEST_ENABLED,
|
|
|
+ YarnConfiguration.DEFAULT_NM_AUX_SERVICES_MANIFEST_ENABLED);
|
|
|
+ if (!manifestEnabled) {
|
|
|
Collection<String> auxNames = conf.getStringCollection(
|
|
|
YarnConfiguration.NM_AUX_SERVICES);
|
|
|
for (final String sName : auxNames) {
|
|
@@ -742,14 +763,20 @@ public class AuxServices extends AbstractService
|
|
|
addService(sName, s, service);
|
|
|
}
|
|
|
} else {
|
|
|
- manifest = new Path(manifestStr);
|
|
|
- manifestFS = FileSystem.get(new URI(manifestStr), conf);
|
|
|
- loadManifest(conf, false);
|
|
|
+ String manifestStr = conf.get(YarnConfiguration.NM_AUX_SERVICES_MANIFEST);
|
|
|
+ if (manifestStr != null) {
|
|
|
+ manifest = new Path(manifestStr);
|
|
|
+ manifestFS = FileSystem.get(new URI(manifestStr), conf);
|
|
|
+ loadManifest(conf, false);
|
|
|
+ manifestReloadInterval = conf.getLong(
|
|
|
+ YarnConfiguration.NM_AUX_SERVICES_MANIFEST_RELOAD_MS,
|
|
|
+ YarnConfiguration.DEFAULT_NM_AUX_SERVICES_MANIFEST_RELOAD_MS);
|
|
|
+ manifestReloadTask = new ManifestReloadTask();
|
|
|
+ } else {
|
|
|
+ LOG.info("Auxiliary services manifest is enabled, but no manifest " +
|
|
|
+ "file is specified in the configuration.");
|
|
|
+ }
|
|
|
}
|
|
|
- manifestReloadInterval = conf.getLong(
|
|
|
- YarnConfiguration.NM_AUX_SERVICES_MANIFEST_RELOAD_MS,
|
|
|
- YarnConfiguration.DEFAULT_NM_AUX_SERVICES_MANIFEST_RELOAD_MS);
|
|
|
- manifestReloadTask = new ManifestReloadTask();
|
|
|
|
|
|
super.serviceInit(conf);
|
|
|
}
|
|
@@ -781,8 +808,10 @@ public class AuxServices extends AbstractService
|
|
|
String name = entry.getKey();
|
|
|
startAuxService(name, service, serviceRecordMap.get(name));
|
|
|
}
|
|
|
- if (manifest != null && manifestReloadInterval > 0) {
|
|
|
- manifestReloadTimer = new Timer("AuxServicesManifestRelaod-Timer",
|
|
|
+ if (manifestEnabled && manifest != null && manifestReloadInterval > 0) {
|
|
|
+ LOG.info("Scheduling reloading auxiliary services manifest file at " +
|
|
|
+ "interval " + manifestReloadInterval + " ms");
|
|
|
+ manifestReloadTimer = new Timer("AuxServicesManifestReload-Timer",
|
|
|
true);
|
|
|
manifestReloadTimer.schedule(manifestReloadTask,
|
|
|
manifestReloadInterval, manifestReloadInterval);
|