http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/ConfigurationService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/ConfigurationService.java b/core/src/main/java/org/apache/oozie/service/ConfigurationService.java index 5e47081..d710744 100644 --- a/core/src/main/java/org/apache/oozie/service/ConfigurationService.java +++ b/core/src/main/java/org/apache/oozie/service/ConfigurationService.java @@ -19,6 +19,7 @@ package org.apache.oozie.service; import org.apache.hadoop.conf.Configuration; +import org.apache.oozie.util.ConfigUtils; import org.apache.oozie.util.Instrumentable; import org.apache.oozie.util.Instrumentation; import org.apache.oozie.util.XLog; @@ -30,6 +31,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -65,6 +67,8 @@ public class ConfigurationService implements Service, Instrumentable { public static final String CONF_IGNORE_SYS_PROPS = CONF_PREFIX + "ignore.system.properties"; + public static final String CONF_VERIFY_AVAILABLE_PROPS = CONF_PREFIX + "verify.available.properties"; + /** * System property that indicates the configuration directory. */ @@ -86,6 +90,7 @@ public class ConfigurationService implements Service, Instrumentable { private static final String IGNORE_TEST_SYS_PROPS = "oozie.test."; private static final Set<String> MASK_PROPS = new HashSet<String>(); + private static Map<String,String> defaultConfigs = new HashMap<String,String>(); static { @@ -139,6 +144,9 @@ public class ConfigurationService implements Service, Instrumentable { log.info("Oozie conf file [{0}]", configFile); configFile = new File(configDir, configFile).toString(); configuration = loadConf(); + if (configuration.getBoolean(CONF_VERIFY_AVAILABLE_PROPS, false)) { + verifyConfigurationName(); + } } public static String getConfigurationDirectory() throws ServiceException { @@ -203,14 +211,14 @@ public class ConfigurationService implements Service, Instrumentable { XConfiguration configuration; try { InputStream inputStream = getDefaultConfiguration(); - configuration = new XConfiguration(inputStream); + configuration = loadConfig(inputStream, true); File file = new File(configFile); if (!file.exists()) { log.info("Missing site configuration file [{0}]", configFile); } else { inputStream = new FileInputStream(configFile); - XConfiguration siteConfiguration = new XConfiguration(inputStream); + XConfiguration siteConfiguration = loadConfig(inputStream, false); XConfiguration.injectDefaults(configuration, siteConfiguration); configuration = siteConfiguration; } @@ -269,6 +277,20 @@ public class ConfigurationService implements Service, Instrumentable { return new LogChangesConfiguration(configuration); } + private XConfiguration loadConfig(InputStream inputStream, boolean defaultConfig) throws IOException, ServiceException { + XConfiguration configuration; + configuration = new XConfiguration(inputStream); + for(Map.Entry<String,String> entry: configuration) { + if (defaultConfig) { + defaultConfigs.put(entry.getKey(), entry.getValue()); + } + else { + log.debug("Overriding configuration with oozie-site, [{0}]", entry.getKey()); + } + } + return configuration; + } + private class LogChangesConfiguration extends XConfiguration { public LogChangesConfiguration(Configuration conf) { @@ -284,13 +306,22 @@ public class ConfigurationService implements Service, Instrumentable { return (s != null && s.trim().length() > 0) ? super.getStrings(name) : new String[0]; } + public String[] getStrings(String name, String[] defaultValue) { + String s = get(name); + if (s == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, + Arrays.asList(defaultValue).toString()); + } + return (s != null && s.trim().length() > 0) ? super.getStrings(name) : defaultValue; + } + public String get(String name, String defaultValue) { String value = get(name); if (value == null) { boolean maskValue = MASK_PROPS.contains(name); value = defaultValue; String logValue = (maskValue) ? "**MASKED**" : defaultValue; - log.warn(XLog.OPS, "Configuration property [{0}] not found, using default [{1}]", name, logValue); + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, logValue); } return value; } @@ -302,6 +333,59 @@ public class ConfigurationService implements Service, Instrumentable { log.info(XLog.OPS, "Programmatic configuration change, property[{0}]=[{1}]", name, value); } + public boolean getBoolean(String name, boolean defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + } + return super.getBoolean(name, defaultValue); + } + + public int getInt(String name, int defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + } + return super.getInt(name, defaultValue); + } + + public long getLong(String name, long defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + } + return super.getLong(name, defaultValue); + } + + public float getFloat(String name, float defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + } + return super.getFloat(name, defaultValue); + } + + public Class<?>[] getClasses(String name, Class<?> ... defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + } + return super.getClasses(name, defaultValue); + } + + public Class<?> getClass(String name, Class<?> defaultValue) { + String value = get(name); + if (value == null) { + log.debug(XLog.OPS, "Configuration property [{0}] not found, use given value [{1}]", name, defaultValue); + return defaultValue; + } + try { + return getClassByName(value); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + private void setValue(String name, String value) { super.set(name, value); } @@ -353,4 +437,89 @@ public class ConfigurationService implements Service, Instrumentable { } return value; } + + + /** + * Gets the oozie configuration value in oozie-default. + * @param name + * @return the configuration value of the <code>name</code> otherwise null + */ + private String getDefaultOozieConfig(String name) { + return defaultConfigs.get(name); + } + + /** + * Verify the configuration is in oozie-default + */ + public void verifyConfigurationName() { + for (Map.Entry<String, String> entry: configuration) { + if (getDefaultOozieConfig(entry.getKey()) == null) { + log.warn("Invalid configuration defined, [{0}] ", entry.getKey()); + } + } + } + + public static String get(String name) { + Configuration conf = Services.get().getConf(); + return get(conf, name); + } + + public static String get(Configuration conf, String name) { + return conf.get(name, ConfigUtils.STRING_DEFAULT); + } + + public static String[] getStrings(String name) { + Configuration conf = Services.get().getConf(); + return getStrings(conf, name); + } + + public static String[] getStrings(Configuration conf, String name) { + return conf.getStrings(name, new String[0]); + } + + public static boolean getBoolean(String name) { + Configuration conf = Services.get().getConf(); + return getBoolean(conf, name); + } + + public static boolean getBoolean(Configuration conf, String name) { + return conf.getBoolean(name, ConfigUtils.BOOLEAN_DEFAULT); + } + + public static int getInt(String name) { + Configuration conf = Services.get().getConf(); + return getInt(conf, name); + } + + public static int getInt(Configuration conf, String name) { + return conf.getInt(name, ConfigUtils.INT_DEFAULT); + } + + public static float getFloat(String name) { + Configuration conf = Services.get().getConf(); + return conf.getFloat(name, ConfigUtils.FLOAT_DEFAULT); + } + + public static long getLong(String name) { + Configuration conf = Services.get().getConf(); + return getLong(conf, name); + } + + public static long getLong(Configuration conf, String name) { + return conf.getLong(name, ConfigUtils.LONG_DEFAULT); + } + + public static Class<?>[] getClasses(String name) { + Configuration conf = Services.get().getConf(); + return getClasses(conf, name); + } + + public static Class<?>[] getClasses(Configuration conf, String name) { + return conf.getClasses(name); + } + + public static Class<?> getClass(Configuration conf, String name) { + return conf.getClass(name, Object.class); + } + }
http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/CoordMaterializeTriggerService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/CoordMaterializeTriggerService.java b/core/src/main/java/org/apache/oozie/service/CoordMaterializeTriggerService.java index ee1085a..fa16d1d 100644 --- a/core/src/main/java/org/apache/oozie/service/CoordMaterializeTriggerService.java +++ b/core/src/main/java/org/apache/oozie/service/CoordMaterializeTriggerService.java @@ -22,14 +22,12 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.apache.hadoop.conf.Configuration; import org.apache.oozie.CoordinatorJobBean; import org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand; import org.apache.oozie.executor.jpa.BatchQueryExecutor; import org.apache.oozie.executor.jpa.CoordJobQueryExecutor; import org.apache.oozie.executor.jpa.JPAExecutorException; import org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry; -import org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery; import org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery; import org.apache.oozie.lock.LockToken; import org.apache.oozie.util.XCallable; @@ -64,9 +62,6 @@ public class CoordMaterializeTriggerService implements Service { private static final String INSTRUMENTATION_GROUP = "coord_job_mat"; private static final String INSTR_MAT_JOBS_COUNTER = "jobs"; - public static final int CONF_LOOKUP_INTERVAL_DEFAULT = 300; - public static final int CONF_MATERIALIZATION_WINDOW_DEFAULT = 3600; - private static final int CONF_MATERIALIZATION_SYSTEM_LIMIT_DEFAULT = 50; /** * This runnable class will run in every "interval" to queue CoordMaterializeTransitionXCommand. @@ -149,8 +144,7 @@ public class CoordMaterializeTriggerService implements Service { // get current date Date currDate = new Date(new Date().getTime() + lookupInterval * 1000); // get list of all jobs that have actions that should be materialized. - int materializationLimit = Services.get().getConf() - .getInt(CONF_MATERIALIZATION_SYSTEM_LIMIT, CONF_MATERIALIZATION_SYSTEM_LIMIT_DEFAULT); + int materializationLimit = ConfigurationService.getInt(CONF_MATERIALIZATION_SYSTEM_LIMIT); materializeCoordJobs(currDate, materializationLimit, LOG, updateList); } @@ -195,7 +189,7 @@ public class CoordMaterializeTriggerService implements Service { callables = new ArrayList<XCallable<Void>>(); } callables.add(callable); - if (callables.size() == Services.get().getConf().getInt(CONF_CALLABLE_BATCH_SIZE, 10)) { + if (callables.size() == ConfigurationService.getInt(CONF_CALLABLE_BATCH_SIZE)) { boolean ret = Services.get().get(CallableQueueService.class).queueSerial(callables); if (ret == false) { XLog.getLog(getClass()).warn( @@ -211,11 +205,10 @@ public class CoordMaterializeTriggerService implements Service { @Override public void init(Services services) throws ServiceException { - Configuration conf = services.getConf(); // default is 3600sec (1hr) - int materializationWindow = conf.getInt(CONF_MATERIALIZATION_WINDOW, CONF_MATERIALIZATION_WINDOW_DEFAULT); + int materializationWindow = ConfigurationService.getInt(services.getConf(), CONF_MATERIALIZATION_WINDOW); // default is 300sec (5min) - int lookupInterval = Services.get().getConf().getInt(CONF_LOOKUP_INTERVAL, CONF_LOOKUP_INTERVAL_DEFAULT); + int lookupInterval = ConfigurationService.getInt(services.getConf(), CONF_LOOKUP_INTERVAL); // default is 300sec (5min) int schedulingInterval = Services.get().getConf().getInt(CONF_SCHEDULING_INTERVAL, lookupInterval); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/DBLiteWorkflowStoreService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/DBLiteWorkflowStoreService.java b/core/src/main/java/org/apache/oozie/service/DBLiteWorkflowStoreService.java index df83873..4f2c350 100644 --- a/core/src/main/java/org/apache/oozie/service/DBLiteWorkflowStoreService.java +++ b/core/src/main/java/org/apache/oozie/service/DBLiteWorkflowStoreService.java @@ -105,8 +105,8 @@ public class DBLiteWorkflowStoreService extends LiteWorkflowStoreService impleme public void init(Services services) throws ServiceException { Configuration conf = services.getConf(); - statusWindow = conf.getInt(CONF_METRICS_INTERVAL_WINDOW, 3600); - int statusMetricsCollectionInterval = conf.getInt(CONF_METRICS_INTERVAL_MINS, 5); + statusWindow = ConfigurationService.getInt(conf, CONF_METRICS_INTERVAL_WINDOW); + int statusMetricsCollectionInterval = ConfigurationService.getInt(conf, CONF_METRICS_INTERVAL_MINS); log = XLog.getLog(getClass()); selectForUpdate = false; http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/ELService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/ELService.java b/core/src/main/java/org/apache/oozie/service/ELService.java index 8406955..2506e99 100644 --- a/core/src/main/java/org/apache/oozie/service/ELService.java +++ b/core/src/main/java/org/apache/oozie/service/ELService.java @@ -87,7 +87,7 @@ public class ELService implements Service { private List<ELService.ELConstant> extractConstants(Configuration conf, String key) throws ServiceException { List<ELService.ELConstant> list = new ArrayList<ELService.ELConstant>(); if (conf.get(key, "").trim().length() > 0) { - for (String function : conf.getStrings(key)) { + for (String function : ConfigurationService.getStrings(conf, key)) { String[] parts = parseDefinition(function); list.add(new ELConstant(parts[0], parts[1], findConstant(parts[2], parts[3]))); log.trace("Registered prefix:constant[{0}:{1}] for class#field[{2}#{3}]", (Object[]) parts); @@ -99,7 +99,7 @@ public class ELService implements Service { private List<ELService.ELFunction> extractFunctions(Configuration conf, String key) throws ServiceException { List<ELService.ELFunction> list = new ArrayList<ELService.ELFunction>(); if (conf.get(key, "").trim().length() > 0) { - for (String function : conf.getStrings(key)) { + for (String function : ConfigurationService.getStrings(conf, key)) { String[] parts = parseDefinition(function); list.add(new ELFunction(parts[0], parts[1], findMethod(parts[2], parts[3]))); log.trace("Registered prefix:constant[{0}:{1}] for class#field[{2}#{3}]", (Object[]) parts); @@ -122,7 +122,7 @@ public class ELService implements Service { //Get the list of group names from configuration file // defined in the property tag: oozie.service.ELSerice.groups //String []groupList = services.getConf().get(CONF_GROUPS, "").trim().split(","); - String[] groupList = services.getConf().getStrings(CONF_GROUPS, ""); + String[] groupList = ConfigurationService.getStrings(services.getConf(), CONF_GROUPS); //For each group, collect the required functions and constants // and store it into HashMap for (String group : groupList) { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/EventHandlerService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/EventHandlerService.java b/core/src/main/java/org/apache/oozie/service/EventHandlerService.java index 244c048..7c0d3be 100644 --- a/core/src/main/java/org/apache/oozie/service/EventHandlerService.java +++ b/core/src/main/java/org/apache/oozie/service/EventHandlerService.java @@ -73,7 +73,8 @@ public class EventHandlerService implements Service { try { Configuration conf = services.getConf(); LOG = XLog.getLog(getClass()); - Class<? extends EventQueue> queueImpl = (Class<? extends EventQueue>) conf.getClass(CONF_EVENT_QUEUE, null); + Class<? extends EventQueue> queueImpl = (Class<? extends EventQueue>) ConfigurationService.getClass + (conf, CONF_EVENT_QUEUE); eventQueue = queueImpl == null ? new MemoryEventQueue() : (EventQueue) queueImpl.newInstance(); eventQueue.init(conf); // initialize app-types to switch on events for @@ -94,7 +95,7 @@ public class EventHandlerService implements Service { private void initApptypes(Configuration conf) { apptypes = new HashSet<String>(); - for (String jobtype : conf.getStringCollection(CONF_FILTER_APP_TYPES)) { + for (String jobtype : ConfigurationService.getStrings(conf, CONF_FILTER_APP_TYPES)) { String tmp = jobtype.trim().toLowerCase(); if (tmp.length() == 0) { continue; @@ -104,9 +105,7 @@ public class EventHandlerService implements Service { } private void initEventListeners(Configuration conf) throws Exception { - Class<?>[] listenerClass = conf.getClasses(CONF_LISTENERS, - org.apache.oozie.jms.JMSJobEventListener.class, - org.apache.oozie.sla.listener.SLAJobEventListener.class); + Class<?>[] listenerClass = ConfigurationService.getClasses(conf, CONF_LISTENERS); for (int i = 0; i < listenerClass.length; i++) { Object listener = null; try { @@ -152,8 +151,8 @@ public class EventHandlerService implements Service { } private void initWorkerThreads(Configuration conf, Services services) throws ServiceException { - numWorkers = conf.getInt(CONF_WORKER_THREADS, 3); - int interval = conf.getInt(CONF_WORKER_INTERVAL, 30); + numWorkers = ConfigurationService.getInt(conf, CONF_WORKER_THREADS); + int interval = ConfigurationService.getInt(conf, CONF_WORKER_INTERVAL); SchedulerService ss = services.get(SchedulerService.class); int available = ss.getSchedulableThreads(conf); if (numWorkers + 3 > available) { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/HCatAccessorService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/HCatAccessorService.java b/core/src/main/java/org/apache/oozie/service/HCatAccessorService.java index a645898..249b663 100644 --- a/core/src/main/java/org/apache/oozie/service/HCatAccessorService.java +++ b/core/src/main/java/org/apache/oozie/service/HCatAccessorService.java @@ -140,7 +140,7 @@ public class HCatAccessorService implements Service { } private void initializeMappingRules() { - String[] connections = conf.getStrings(JMS_CONNECTIONS_PROPERTIES); + String[] connections = ConfigurationService.getStrings(conf, JMS_CONNECTIONS_PROPERTIES); if (connections != null) { mappingRules = new ArrayList<MappingRule>(connections.length); for (String connection : connections) { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java b/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java index 0be840d..ed0bdc3 100644 --- a/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java +++ b/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java @@ -91,7 +91,6 @@ public class HadoopAccessorService implements Service { * Supported filesystem schemes for namespace federation */ public static final String SUPPORTED_FILESYSTEMS = CONF_PREFIX + "supported.filesystems"; - public static final String[] DEFAULT_SUPPORTED_SCHEMES = new String[]{"hdfs","hftp","webhdfs"}; private Set<String> supportedSchemes; private boolean allSchemesSupported; @@ -102,7 +101,7 @@ public class HadoopAccessorService implements Service { //for testing purposes, see XFsTestCase public void init(Configuration conf) throws ServiceException { - for (String name : conf.getStringCollection(JOB_TRACKER_WHITELIST)) { + for (String name : ConfigurationService.getStrings(conf, JOB_TRACKER_WHITELIST)) { String tmp = name.toLowerCase().trim(); if (tmp.length() == 0) { continue; @@ -110,9 +109,9 @@ public class HadoopAccessorService implements Service { jobTrackerWhitelist.add(tmp); } XLog.getLog(getClass()).info( - "JOB_TRACKER_WHITELIST :" + conf.getStringCollection(JOB_TRACKER_WHITELIST) + "JOB_TRACKER_WHITELIST :" + jobTrackerWhitelist.toString() + ", Total entries :" + jobTrackerWhitelist.size()); - for (String name : conf.getStringCollection(NAME_NODE_WHITELIST)) { + for (String name : ConfigurationService.getStrings(conf, NAME_NODE_WHITELIST)) { String tmp = name.toLowerCase().trim(); if (tmp.length() == 0) { continue; @@ -120,10 +119,10 @@ public class HadoopAccessorService implements Service { nameNodeWhitelist.add(tmp); } XLog.getLog(getClass()).info( - "NAME_NODE_WHITELIST :" + conf.getStringCollection(NAME_NODE_WHITELIST) + "NAME_NODE_WHITELIST :" + nameNodeWhitelist.toString() + ", Total entries :" + nameNodeWhitelist.size()); - boolean kerberosAuthOn = conf.getBoolean(KERBEROS_AUTH_ENABLED, true); + boolean kerberosAuthOn = ConfigurationService.getBoolean(conf, KERBEROS_AUTH_ENABLED); XLog.getLog(getClass()).info("Oozie Kerberos Authentication [{0}]", (kerberosAuthOn) ? "enabled" : "disabled"); if (kerberosAuthOn) { kerberosInit(conf); @@ -142,7 +141,7 @@ public class HadoopAccessorService implements Service { preLoadActionConfigs(conf); supportedSchemes = new HashSet<String>(); - String[] schemesFromConf = conf.getStrings(SUPPORTED_FILESYSTEMS, DEFAULT_SUPPORTED_SCHEMES); + String[] schemesFromConf = ConfigurationService.getStrings(conf, SUPPORTED_FILESYSTEMS); if(schemesFromConf != null) { for (String scheme: schemesFromConf) { scheme = scheme.trim(); @@ -161,12 +160,11 @@ public class HadoopAccessorService implements Service { private void kerberosInit(Configuration serviceConf) throws ServiceException { try { - String keytabFile = serviceConf.get(KERBEROS_KEYTAB, - System.getProperty("user.home") + "/oozie.keytab").trim(); + String keytabFile = ConfigurationService.get(serviceConf, KERBEROS_KEYTAB).trim(); if (keytabFile.length() == 0) { throw new ServiceException(ErrorCode.E0026, KERBEROS_KEYTAB); } - String principal = serviceConf.get(KERBEROS_PRINCIPAL, "oozie/localhost@LOCALHOST"); + String principal = ConfigurationService.get(serviceConf, KERBEROS_PRINCIPAL); if (principal.length() == 0) { throw new ServiceException(ErrorCode.E0026, KERBEROS_PRINCIPAL); } @@ -236,7 +234,8 @@ public class HadoopAccessorService implements Service { private void loadHadoopConfigs(Configuration serviceConf) throws ServiceException { try { - Map<String, File> map = parseConfigDirs(serviceConf.getStrings(HADOOP_CONFS, "*=hadoop-conf"), "hadoop"); + Map<String, File> map = parseConfigDirs(ConfigurationService.getStrings(serviceConf, HADOOP_CONFS), + "hadoop"); for (Map.Entry<String, File> entry : map.entrySet()) { hadoopConfigs.put(entry.getKey(), loadHadoopConf(entry.getValue())); } @@ -251,7 +250,7 @@ public class HadoopAccessorService implements Service { private void preLoadActionConfigs(Configuration serviceConf) throws ServiceException { try { - actionConfigDirs = parseConfigDirs(serviceConf.getStrings(ACTION_CONFS, "*=hadoop-conf"), "action"); + actionConfigDirs = parseConfigDirs(ConfigurationService.getStrings(serviceConf, ACTION_CONFS), "action"); for (String hostport : actionConfigDirs.keySet()) { actionConfigs.put(hostport, new ConcurrentHashMap<String, XConfiguration>()); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/InstrumentationService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/InstrumentationService.java b/core/src/main/java/org/apache/oozie/service/InstrumentationService.java index 093754e..0572f7f 100644 --- a/core/src/main/java/org/apache/oozie/service/InstrumentationService.java +++ b/core/src/main/java/org/apache/oozie/service/InstrumentationService.java @@ -51,7 +51,7 @@ public class InstrumentationService implements Service { @Override public void init(Services services) throws ServiceException { final Instrumentation instr = new Instrumentation(); - int interval = services.getConf().getInt(CONF_LOGGING_INTERVAL, 60); + int interval = ConfigurationService.getInt(services.getConf(), CONF_LOGGING_INTERVAL); initLogging(services, instr, interval); instr.addVariable(JVM_INSTRUMENTATION_GROUP, "free.memory", new Instrumentation.Variable<Long>() { @Override http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/JMSAccessorService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/JMSAccessorService.java b/core/src/main/java/org/apache/oozie/service/JMSAccessorService.java index a79ca7e..e6dc440 100644 --- a/core/src/main/java/org/apache/oozie/service/JMSAccessorService.java +++ b/core/src/main/java/org/apache/oozie/service/JMSAccessorService.java @@ -299,7 +299,7 @@ public class JMSAccessorService implements Service { } private ConnectionContext getConnectionContextImpl() { - Class<?> defaultClazz = conf.getClass(JMS_CONNECTION_CONTEXT_IMPL, DefaultConnectionContext.class); + Class<?> defaultClazz = ConfigurationService.getClass(conf, JMS_CONNECTION_CONTEXT_IMPL); ConnectionContext connCtx = null; if (defaultClazz == DefaultConnectionContext.class) { connCtx = new DefaultConnectionContext(); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/JMSTopicService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/JMSTopicService.java b/core/src/main/java/org/apache/oozie/service/JMSTopicService.java index e5cf1fe..35c82c3 100644 --- a/core/src/main/java/org/apache/oozie/service/JMSTopicService.java +++ b/core/src/main/java/org/apache/oozie/service/JMSTopicService.java @@ -103,7 +103,7 @@ public class JMSTopicService implements Service { } private void parseTopicConfiguration() throws ServiceException { - String topicName = conf.get(TOPIC_NAME, "default=" + TopicType.USER.value); + String topicName = ConfigurationService.get(conf, TOPIC_NAME); if (topicName == null) { throw new ServiceException(ErrorCode.E0100, getClass().getName(), "JMS topic cannot be null "); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/JPAService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/JPAService.java b/core/src/main/java/org/apache/oozie/service/JPAService.java index 8b9d1f5..906cb0f 100644 --- a/core/src/main/java/org/apache/oozie/service/JPAService.java +++ b/core/src/main/java/org/apache/oozie/service/JPAService.java @@ -137,18 +137,18 @@ public class JPAService implements Service, Instrumentable { public void init(Services services) throws ServiceException { LOG = XLog.getLog(JPAService.class); Configuration conf = services.getConf(); - String dbSchema = conf.get(CONF_DB_SCHEMA, "oozie"); - String url = conf.get(CONF_URL, "jdbc:derby:${oozie.home.dir}/${oozie.db.schema.name}-db;create=true"); - String driver = conf.get(CONF_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver"); - String user = conf.get(CONF_USERNAME, "sa"); - String password = conf.get(CONF_PASSWORD, "").trim(); - String maxConn = conf.get(CONF_MAX_ACTIVE_CONN, "10").trim(); - String dataSource = conf.get(CONF_CONN_DATA_SOURCE, "org.apache.commons.dbcp.BasicDataSource"); - String connPropsConfig = conf.get(CONF_CONN_PROPERTIES); - boolean autoSchemaCreation = conf.getBoolean(CONF_CREATE_DB_SCHEMA, false); - boolean validateDbConn = conf.getBoolean(CONF_VALIDATE_DB_CONN, true); - String evictionInterval = conf.get(CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL, "300000").trim(); - String evictionNum = conf.get(CONF_VALIDATE_DB_CONN_EVICTION_NUM, "10").trim(); + String dbSchema = ConfigurationService.get(conf, CONF_DB_SCHEMA); + String url = ConfigurationService.get(conf, CONF_URL); + String driver = ConfigurationService.get(conf, CONF_DRIVER); + String user = ConfigurationService.get(conf, CONF_USERNAME); + String password = ConfigurationService.get(conf, CONF_PASSWORD).trim(); + String maxConn = ConfigurationService.get(conf, CONF_MAX_ACTIVE_CONN).trim(); + String dataSource = ConfigurationService.get(conf, CONF_CONN_DATA_SOURCE); + String connPropsConfig = ConfigurationService.get(conf, CONF_CONN_PROPERTIES); + boolean autoSchemaCreation = ConfigurationService.getBoolean(conf, CONF_CREATE_DB_SCHEMA); + boolean validateDbConn = ConfigurationService.getBoolean(conf, CONF_VALIDATE_DB_CONN); + String evictionInterval = ConfigurationService.get(conf, CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL).trim(); + String evictionNum = ConfigurationService.get(conf, CONF_VALIDATE_DB_CONN_EVICTION_NUM).trim(); if (!url.startsWith("jdbc:")) { throw new ServiceException(ErrorCode.E0608, url, "invalid JDBC URL, must start with 'jdbc:'"); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/JvmPauseMonitorService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/JvmPauseMonitorService.java b/core/src/main/java/org/apache/oozie/service/JvmPauseMonitorService.java index 8bf9d1c..f0c72f3 100644 --- a/core/src/main/java/org/apache/oozie/service/JvmPauseMonitorService.java +++ b/core/src/main/java/org/apache/oozie/service/JvmPauseMonitorService.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.Daemon; +import org.apache.oozie.util.ConfigUtils; import org.apache.oozie.util.Instrumentation; import org.apache.oozie.util.XLog; @@ -56,15 +57,13 @@ public class JvmPauseMonitorService implements Service { * log WARN if we detect a pause longer than this threshold */ private long warnThresholdMs; - private static final String WARN_THRESHOLD_KEY = CONF_PREFIX + "warn-threshold.ms"; - private static final long WARN_THRESHOLD_DEFAULT = 10000; + public static final String WARN_THRESHOLD_KEY = CONF_PREFIX + "warn-threshold.ms"; /** * log INFO if we detect a pause longer than this threshold */ private long infoThresholdMs; - private static final String INFO_THRESHOLD_KEY = CONF_PREFIX + "info-threshold.ms"; - private static final long INFO_THRESHOLD_DEFAULT = 1000; + public static final String INFO_THRESHOLD_KEY = CONF_PREFIX + "info-threshold.ms"; private Thread monitorThread; private volatile boolean shouldRun = true; @@ -72,9 +71,8 @@ public class JvmPauseMonitorService implements Service { @Override public void init(Services services) throws ServiceException { - Configuration conf = services.getConf(); - warnThresholdMs = conf.getLong(WARN_THRESHOLD_KEY, WARN_THRESHOLD_DEFAULT); - infoThresholdMs = conf.getLong(INFO_THRESHOLD_KEY, INFO_THRESHOLD_DEFAULT); + warnThresholdMs = ConfigurationService.getLong(services.getConf(), WARN_THRESHOLD_KEY); + infoThresholdMs = ConfigurationService.getLong(services.getConf(), INFO_THRESHOLD_KEY); instrumentation = services.get(InstrumentationService.class).get(); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/LiteWorkflowStoreService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/LiteWorkflowStoreService.java b/core/src/main/java/org/apache/oozie/service/LiteWorkflowStoreService.java index 8a7017e..d661d08 100644 --- a/core/src/main/java/org/apache/oozie/service/LiteWorkflowStoreService.java +++ b/core/src/main/java/org/apache/oozie/service/LiteWorkflowStoreService.java @@ -138,8 +138,7 @@ public abstract class LiteWorkflowStoreService extends WorkflowStoreService { } private static int getUserRetryInterval(NodeHandler.Context context) throws WorkflowException { - Configuration conf = Services.get().get(ConfigurationService.class).getConf(); - int ret = conf.getInt(CONF_USER_RETRY_INTEVAL, 5); + int ret = ConfigurationService.getInt(CONF_USER_RETRY_INTEVAL); String userRetryInterval = context.getNodeDef().getUserRetryInterval(); if (!userRetryInterval.equals("null")) { @@ -155,8 +154,7 @@ public abstract class LiteWorkflowStoreService extends WorkflowStoreService { private static int getUserRetryMax(NodeHandler.Context context) throws WorkflowException { XLog log = XLog.getLog(LiteWorkflowStoreService.class); - Configuration conf = Services.get().get(ConfigurationService.class).getConf(); - int ret = conf.getInt(CONF_USER_RETRY_MAX, 0); + int ret = ConfigurationService.getInt(CONF_USER_RETRY_MAX); int max = ret; String userRetryMax = context.getNodeDef().getUserRetryMax(); @@ -184,11 +182,10 @@ public abstract class LiteWorkflowStoreService extends WorkflowStoreService { * @return set of error code user-retry is allowed for */ public static Set<String> getUserRetryErrorCode() { - Configuration conf = Services.get().get(ConfigurationService.class).getConf(); // eliminating whitespaces in the error codes value specification - String errorCodeString = conf.get(CONF_USER_RETRY_ERROR_CODE).replaceAll("\\s+", ""); + String errorCodeString = ConfigurationService.get(CONF_USER_RETRY_ERROR_CODE).replaceAll("\\s+", ""); Collection<String> strings = StringUtils.getStringCollection(errorCodeString); - String errorCodeExtString = conf.get(CONF_USER_RETRY_ERROR_CODE_EXT).replaceAll("\\s+", ""); + String errorCodeExtString = ConfigurationService.get(CONF_USER_RETRY_ERROR_CODE_EXT).replaceAll("\\s+", ""); Collection<String> extra = StringUtils.getStringCollection(errorCodeExtString); Set<String> set = new HashSet<String>(); set.addAll(strings); @@ -203,8 +200,7 @@ public abstract class LiteWorkflowStoreService extends WorkflowStoreService { * @throws WorkflowException thrown if there was an error parsing the action configuration. */ public static String getNodeDefDefaultVersion() throws WorkflowException { - Configuration conf = Services.get().get(ConfigurationService.class).getConf(); - String ret = conf.get(CONF_NODE_DEF_VERSION); + String ret = ConfigurationService.get(CONF_NODE_DEF_VERSION); if (ret == null) { ret = NODE_DEF_VERSION_1; } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/PauseTransitService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/PauseTransitService.java b/core/src/main/java/org/apache/oozie/service/PauseTransitService.java index dda5404..54865e8 100644 --- a/core/src/main/java/org/apache/oozie/service/PauseTransitService.java +++ b/core/src/main/java/org/apache/oozie/service/PauseTransitService.java @@ -38,6 +38,7 @@ import org.apache.oozie.service.SchedulerService; import org.apache.oozie.service.Service; import org.apache.oozie.service.Services; import org.apache.oozie.lock.LockToken; +import org.apache.oozie.util.ConfigUtils; import org.apache.oozie.util.XLog; import com.google.common.annotations.VisibleForTesting; @@ -147,8 +148,7 @@ public class PauseTransitService implements Service { private void updateCoord() { Date d = new Date(); // records the start time of this service run; List<CoordinatorJobBean> jobList = null; - Configuration conf = Services.get().getConf(); - boolean backwardSupportForCoordStatus = conf.getBoolean(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, false); + boolean backwardSupportForCoordStatus = ConfigUtils.isBackwardSupportForCoordStatus(); // pause coordinators as needed; try { @@ -200,10 +200,10 @@ public class PauseTransitService implements Service { */ @Override public void init(Services services) { - Configuration conf = services.getConf(); Runnable bundlePauseStartRunnable = new PauseTransitRunnable(); services.get(SchedulerService.class).schedule(bundlePauseStartRunnable, 10, - conf.getInt(CONF_BUNDLE_PAUSE_START_INTERVAL, 60), SchedulerService.Unit.SEC); + ConfigurationService.getInt(services.getConf(), CONF_BUNDLE_PAUSE_START_INTERVAL), + SchedulerService.Unit.SEC); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/PurgeService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/PurgeService.java b/core/src/main/java/org/apache/oozie/service/PurgeService.java index c370809..6e4a8e8 100644 --- a/core/src/main/java/org/apache/oozie/service/PurgeService.java +++ b/core/src/main/java/org/apache/oozie/service/PurgeService.java @@ -85,11 +85,13 @@ public class PurgeService implements Service { @Override public void init(Services services) { Configuration conf = services.getConf(); - Runnable purgeJobsRunnable = new PurgeRunnable(conf.getInt( - CONF_OLDER_THAN, 30), conf.getInt(COORD_CONF_OLDER_THAN, 7), conf.getInt(BUNDLE_CONF_OLDER_THAN, 7), - conf.getInt(PURGE_LIMIT, 100), conf.getBoolean(PURGE_OLD_COORD_ACTION, false)); - services.get(SchedulerService.class).schedule(purgeJobsRunnable, 10, conf.getInt(CONF_PURGE_INTERVAL, 3600), - SchedulerService.Unit.SEC); + Runnable purgeJobsRunnable = new PurgeRunnable(ConfigurationService.getInt(conf, CONF_OLDER_THAN), + ConfigurationService.getInt(conf, COORD_CONF_OLDER_THAN), + ConfigurationService.getInt(conf, BUNDLE_CONF_OLDER_THAN), + ConfigurationService.getInt(conf, PURGE_LIMIT), + ConfigurationService.getBoolean(conf, PURGE_OLD_COORD_ACTION)); + services.get(SchedulerService.class).schedule(purgeJobsRunnable, 10, + ConfigurationService.getInt(conf, CONF_PURGE_INTERVAL), SchedulerService.Unit.SEC); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/RecoveryService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/RecoveryService.java b/core/src/main/java/org/apache/oozie/service/RecoveryService.java index c47024d..21bfcfc 100644 --- a/core/src/main/java/org/apache/oozie/service/RecoveryService.java +++ b/core/src/main/java/org/apache/oozie/service/RecoveryService.java @@ -238,7 +238,7 @@ public class RecoveryService implements Service { private void runCoordActionRecovery() { XLog.Info.get().clear(); XLog log = XLog.getLog(getClass()); - long pushMissingDepInterval = Services.get().getConf().getLong(CONF_PUSH_DEPENDENCY_INTERVAL, 200); + long pushMissingDepInterval = ConfigurationService.getLong(CONF_PUSH_DEPENDENCY_INTERVAL); long pushMissingDepDelay = pushMissingDepInterval; List<CoordinatorActionBean> cactions = null; try { @@ -424,7 +424,7 @@ public class RecoveryService implements Service { } this.delay = Math.max(this.delay, delay); delayedCallables.add(callable); - if (delayedCallables.size() == Services.get().getConf().getInt(CONF_CALLABLE_BATCH_SIZE, 10)) { + if (delayedCallables.size() == ConfigurationService.getInt(CONF_CALLABLE_BATCH_SIZE)){ boolean ret = Services.get().get(CallableQueueService.class).queueSerial(delayedCallables, this.delay); if (ret == false) { XLog.getLog(getClass()).warn("Unable to queue the delayedCallables commands for RecoveryService. " @@ -445,14 +445,16 @@ public class RecoveryService implements Service { @Override public void init(Services services) { Configuration conf = services.getConf(); - Runnable recoveryRunnable = new RecoveryRunnable(conf.getInt(CONF_WF_ACTIONS_OLDER_THAN, 120), conf.getInt( - CONF_COORD_OLDER_THAN, 600),conf.getInt(CONF_BUNDLE_OLDER_THAN, 600)); + Runnable recoveryRunnable = new RecoveryRunnable( + ConfigurationService.getInt(conf, CONF_WF_ACTIONS_OLDER_THAN), + ConfigurationService.getInt(conf, CONF_COORD_OLDER_THAN), + ConfigurationService.getInt(conf, CONF_BUNDLE_OLDER_THAN)); services.get(SchedulerService.class).schedule(recoveryRunnable, 10, getRecoveryServiceInterval(conf), SchedulerService.Unit.SEC); } public int getRecoveryServiceInterval(Configuration conf){ - return conf.getInt(CONF_SERVICE_INTERVAL, 60); + return ConfigurationService.getInt(conf, CONF_SERVICE_INTERVAL); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/SchedulerService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/SchedulerService.java b/core/src/main/java/org/apache/oozie/service/SchedulerService.java index 7c7c0ff..b63a004 100644 --- a/core/src/main/java/org/apache/oozie/service/SchedulerService.java +++ b/core/src/main/java/org/apache/oozie/service/SchedulerService.java @@ -98,7 +98,7 @@ public class SchedulerService implements Service { * @return int num threads */ public int getSchedulableThreads(Configuration conf) { - return conf.getInt(SCHEDULER_THREADS, 10); + return ConfigurationService.getInt(conf, SCHEDULER_THREADS); } public enum Unit { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/SchemaService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/SchemaService.java b/core/src/main/java/org/apache/oozie/service/SchemaService.java index a696a97..3210585 100644 --- a/core/src/main/java/org/apache/oozie/service/SchemaService.java +++ b/core/src/main/java/org/apache/oozie/service/SchemaService.java @@ -82,7 +82,7 @@ public class SchemaService implements Service { for (String baseSchema : baseSchemas) { sources.add(new StreamSource(IOUtils.getResourceAsStream(baseSchema, -1))); } - String[] schemas = conf.getStrings(extSchema); + String[] schemas = ConfigurationService.getStrings(conf, extSchema); if (schemas != null) { for (String schema : schemas) { schema = schema.trim(); @@ -107,7 +107,6 @@ public class SchemaService implements Service { coordSchema = loadSchema(services.getConf(), OOZIE_COORDINATOR_XSD, COORD_CONF_EXT_SCHEMAS); bundleSchema = loadSchema(services.getConf(), OOZIE_BUNDLE_XSD, BUNDLE_CONF_EXT_SCHEMAS); slaSchema = loadSchema(services.getConf(), OOZIE_SLA_SEMANTIC_XSD, SLA_CONF_EXT_SCHEMAS); - bundleSchema = loadSchema(services.getConf(), OOZIE_BUNDLE_XSD, BUNDLE_CONF_EXT_SCHEMAS); } catch (SAXException ex) { throw new ServiceException(ErrorCode.E0130, ex.getMessage(), ex); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/Service.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/Service.java b/core/src/main/java/org/apache/oozie/service/Service.java index b7863ae..f3b1280 100644 --- a/core/src/main/java/org/apache/oozie/service/Service.java +++ b/core/src/main/java/org/apache/oozie/service/Service.java @@ -30,11 +30,6 @@ public interface Service { public static final String CONF_PREFIX = "oozie.service."; /** - * Constant for XCommand - */ - public static final String USE_XCOMMAND = "oozie.useXCommand"; - - /** * Initialize the service. <p/> Invoked by the {@link Service} singleton at start up time. * * @param services services singleton initializing the service. @@ -58,6 +53,6 @@ public interface Service { /** * Lock timeout value if service is only allowed to have one single running instance. */ - public static long lockTimeout = Services.get().getConf().getLong(DEFAULT_LOCK_TIMEOUT, 5 * 1000); + public static long lockTimeout = ConfigurationService.getLong(DEFAULT_LOCK_TIMEOUT); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/Services.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/Services.java b/core/src/main/java/org/apache/oozie/service/Services.java index eeba34f..5857055 100644 --- a/core/src/main/java/org/apache/oozie/service/Services.java +++ b/core/src/main/java/org/apache/oozie/service/Services.java @@ -116,13 +116,13 @@ public class Services { XLog.getLog(getClass()).warn("Oozie configured to work in a timezone other than UTC: {0}", DateUtils.getOozieProcessingTimeZone().getID()); } - systemId = conf.get(CONF_SYSTEM_ID, ("oozie-" + System.getProperty("user.name"))); + systemId = ConfigurationService.get(conf, CONF_SYSTEM_ID); if (systemId.length() > MAX_SYSTEM_ID_LEN) { systemId = systemId.substring(0, MAX_SYSTEM_ID_LEN); XLog.getLog(getClass()).warn("System ID [{0}] exceeds maximum length [{1}], trimming", systemId, MAX_SYSTEM_ID_LEN); } - setSystemMode(SYSTEM_MODE.valueOf(conf.get(CONF_SYSTEM_MODE, SYSTEM_MODE.NORMAL.toString()))); + setSystemMode(SYSTEM_MODE.valueOf(ConfigurationService.get(conf, CONF_SYSTEM_MODE))); runtimeDir = createRuntimeDir(); } @@ -191,8 +191,10 @@ public class Services { /** * Return the services configuration. * - * @return services configuraiton. + * @return services configuration. + * @deprecated Use {@link ConfigurationService#get(String)} to retrieve property from oozie configurations. */ + @Deprecated public Configuration getConf() { return conf; } @@ -283,9 +285,9 @@ public class Services { XLog log = new XLog(LogFactory.getLog(getClass())); try { Map<Class, Service> map = new LinkedHashMap<Class, Service>(); - Class[] classes = conf.getClasses(CONF_SERVICE_CLASSES); + Class[] classes = ConfigurationService.getClasses(conf, CONF_SERVICE_CLASSES); log.debug("Services list obtained from property '" + CONF_SERVICE_CLASSES + "'"); - Class[] classesExt = conf.getClasses(CONF_SERVICE_EXT_CLASSES); + Class[] classesExt = ConfigurationService.getClasses(conf, CONF_SERVICE_EXT_CLASSES); log.debug("Services list obtained from property '" + CONF_SERVICE_EXT_CLASSES + "'"); List<Service> list = new ArrayList<Service>(); loadServices(classes, list); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/ShareLibService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/ShareLibService.java b/core/src/main/java/org/apache/oozie/service/ShareLibService.java index ea500c5..5414e6b 100644 --- a/core/src/main/java/org/apache/oozie/service/ShareLibService.java +++ b/core/src/main/java/org/apache/oozie/service/ShareLibService.java @@ -98,14 +98,14 @@ public class ShareLibService implements Service, Instrumentable { FileSystem fs; - final long retentionTime = 1000 * 60 * 60 * 24 * Services.get().getConf().getInt(LAUNCHERJAR_LIB_RETENTION, 7); + final long retentionTime = 1000 * 60 * 60 * 24 * ConfigurationService.getInt(LAUNCHERJAR_LIB_RETENTION); @Override public void init(Services services) throws ServiceException { this.services = services; - sharelibMappingFile = services.getConf().get(SHARELIB_MAPPING_FILE, ""); - isShipLauncherEnabled = services.getConf().getBoolean(SHIP_LAUNCHER_JAR, false); - boolean failOnfailure = services.getConf().getBoolean(FAIL_FAST_ON_STARTUP, false); + sharelibMappingFile = ConfigurationService.get(services.getConf(), SHARELIB_MAPPING_FILE); + isShipLauncherEnabled = ConfigurationService.getBoolean(services.getConf(), SHIP_LAUNCHER_JAR); + boolean failOnfailure = ConfigurationService.getBoolean(services.getConf(), FAIL_FAST_ON_STARTUP); Path launcherlibPath = getLauncherlibPath(); HadoopAccessorService has = Services.get().get(HadoopAccessorService.class); URI uri = launcherlibPath.toUri(); @@ -145,7 +145,8 @@ public class ShareLibService implements Service, Instrumentable { } }; services.get(SchedulerService.class).schedule(purgeLibsRunnable, 10, - services.getConf().getInt(PURGE_INTERVAL, 1) * 60 * 60 * 24, SchedulerService.Unit.SEC); + ConfigurationService.getInt(services.getConf(), PURGE_INTERVAL) * 60 * 60 * 24, + SchedulerService.Unit.SEC); } /** @@ -460,7 +461,7 @@ public class ShareLibService implements Service, Instrumentable { Map<String, List<Path>> tempShareLibMap = new HashMap<String, List<Path>>(); - if (!StringUtils.isEmpty(sharelibMappingFile)) { + if (!StringUtils.isEmpty(sharelibMappingFile.trim())) { String sharelibMetaFileNewTimeStamp = JsonUtils.formatDateRfc822(new Date(fs.getFileStatus( new Path(sharelibMappingFile)).getModificationTime()),"GMT"); loadShareLibMetaFile(tempShareLibMap, sharelibMappingFile); @@ -624,7 +625,7 @@ public class ShareLibService implements Service, Instrumentable { instr.addVariable("libs", "sharelib.source", new Instrumentation.Variable<String>() { @Override public String getValue() { - if (!StringUtils.isEmpty(sharelibMappingFile)) { + if (!StringUtils.isEmpty(sharelibMappingFile.trim())) { return SHARELIB_MAPPING_FILE; } return WorkflowAppService.SYSTEM_LIB_PATH; @@ -633,7 +634,7 @@ public class ShareLibService implements Service, Instrumentable { instr.addVariable("libs", "sharelib.mapping.file", new Instrumentation.Variable<String>() { @Override public String getValue() { - if (!StringUtils.isEmpty(sharelibMappingFile)) { + if (!StringUtils.isEmpty(sharelibMappingFile.trim())) { return sharelibMappingFile; } return "(none)"; http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/StatusTransitService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/StatusTransitService.java b/core/src/main/java/org/apache/oozie/service/StatusTransitService.java index 77dcda9..85ab668 100644 --- a/core/src/main/java/org/apache/oozie/service/StatusTransitService.java +++ b/core/src/main/java/org/apache/oozie/service/StatusTransitService.java @@ -217,7 +217,7 @@ public class StatusTransitService implements Service { final Configuration conf = services.getConf(); Runnable stateTransitRunnable = new StatusTransitRunnable(); services.get(SchedulerService.class).schedule(stateTransitRunnable, 10, - conf.getInt(CONF_STATUSTRANSIT_INTERVAL, 60), SchedulerService.Unit.SEC); + ConfigurationService.getInt(conf, CONF_STATUSTRANSIT_INTERVAL), SchedulerService.Unit.SEC); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/URIHandlerService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/URIHandlerService.java b/core/src/main/java/org/apache/oozie/service/URIHandlerService.java index c0144b4..c4a3701 100644 --- a/core/src/main/java/org/apache/oozie/service/URIHandlerService.java +++ b/core/src/main/java/org/apache/oozie/service/URIHandlerService.java @@ -63,7 +63,7 @@ public class URIHandlerService implements Service { private void init(Configuration conf) throws ClassNotFoundException { cache = new HashMap<String, URIHandler>(); - String[] classes = conf.getStrings(URI_HANDLERS, FSURIHandler.class.getName()); + String[] classes = ConfigurationService.getStrings(conf, URI_HANDLERS); for (String classname : classes) { Class<?> clazz = Class.forName(classname.trim()); URIHandler uriHandler = (URIHandler) ReflectionUtils.newInstance(clazz, null); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/UUIDService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/UUIDService.java b/core/src/main/java/org/apache/oozie/service/UUIDService.java index 4d209b5..cd4ee2f 100644 --- a/core/src/main/java/org/apache/oozie/service/UUIDService.java +++ b/core/src/main/java/org/apache/oozie/service/UUIDService.java @@ -53,7 +53,7 @@ public class UUIDService implements Service { */ @Override public void init(Services services) throws ServiceException { - String genType = services.getConf().get(CONF_GENERATOR, "counter").trim(); + String genType = ConfigurationService.get(services.getConf(), CONF_GENERATOR).trim(); if (genType.equals("counter")) { counter = new AtomicLong(); resetStartTime(); @@ -208,4 +208,4 @@ public class UUIDService implements Service { return type; } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java b/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java index d07f374..6b6e97c 100644 --- a/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java +++ b/core/src/main/java/org/apache/oozie/service/WorkflowAppService.java @@ -77,7 +77,7 @@ public abstract class WorkflowAppService implements Service { public void init(Services services) { Configuration conf = services.getConf(); - String path = conf.get(SYSTEM_LIB_PATH, " "); + String path = ConfigurationService.get(conf, SYSTEM_LIB_PATH); if (path.trim().length() > 0) { systemLibPath = new Path(path.trim()); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/XLogStreamingService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/XLogStreamingService.java b/core/src/main/java/org/apache/oozie/service/XLogStreamingService.java index 721e76b..9a42f2f 100644 --- a/core/src/main/java/org/apache/oozie/service/XLogStreamingService.java +++ b/core/src/main/java/org/apache/oozie/service/XLogStreamingService.java @@ -44,7 +44,7 @@ public class XLogStreamingService implements Service, Instrumentable { * @throws ServiceException thrown if the log streaming service could not be initialized. */ public void init(Services services) throws ServiceException { - bufferLen = services.getConf().getInt(STREAM_BUFFER_LEN, 4096); + bufferLen = ConfigurationService.getInt(services.getConf(), STREAM_BUFFER_LEN); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/service/ZKLocksService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/ZKLocksService.java b/core/src/main/java/org/apache/oozie/service/ZKLocksService.java index 6f333c8..7fc4d17 100644 --- a/core/src/main/java/org/apache/oozie/service/ZKLocksService.java +++ b/core/src/main/java/org/apache/oozie/service/ZKLocksService.java @@ -54,7 +54,6 @@ public class ZKLocksService extends MemoryLocksService implements Service, Instr final private HashMap<String, InterProcessReadWriteLock> zkLocks = new HashMap<String, InterProcessReadWriteLock>(); private static final String REAPING_LEADER_PATH = ZKUtils.ZK_BASE_SERVICES_PATH + "/locksChildReaperLeaderPath"; - public static final int DEFAULT_REAPING_THRESHOLD = 300; // In sec public static final String REAPING_THRESHOLD = CONF_PREFIX + "ZKLocksService.locks.reaper.threshold"; public static final String REAPING_THREADS = CONF_PREFIX + "ZKLocksService.locks.reaper.threads"; private ChildReaper reaper = null; @@ -70,7 +69,7 @@ public class ZKLocksService extends MemoryLocksService implements Service, Instr try { zk = ZKUtils.register(this); reaper = new ChildReaper(zk.getClient(), LOCKS_NODE, Reaper.Mode.REAP_INDEFINITELY, getExecutorService(), - services.getConf().getInt(REAPING_THRESHOLD, DEFAULT_REAPING_THRESHOLD) * 1000, REAPING_LEADER_PATH); + ConfigurationService.getInt(services.getConf(), REAPING_THRESHOLD) * 1000, REAPING_LEADER_PATH); reaper.start(); } catch (Exception ex) { @@ -221,7 +220,7 @@ public class ZKLocksService extends MemoryLocksService implements Service, Instr } private static ScheduledExecutorService getExecutorService() { - return ThreadUtils.newFixedThreadScheduledPool(Services.get().getConf().getInt(REAPING_THREADS, 2), + return ThreadUtils.newFixedThreadScheduledPool(ConfigurationService.getInt(REAPING_THREADS), "ZKLocksChildReaper"); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/servlet/AuthFilter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/servlet/AuthFilter.java b/core/src/main/java/org/apache/oozie/servlet/AuthFilter.java index 054f484..a2bc2c5 100644 --- a/core/src/main/java/org/apache/oozie/servlet/AuthFilter.java +++ b/core/src/main/java/org/apache/oozie/servlet/AuthFilter.java @@ -40,7 +40,7 @@ import org.apache.oozie.util.ZKUtils; * the configuration loading. */ public class AuthFilter extends AuthenticationFilter { - private static final String OOZIE_PREFIX = "oozie.authentication."; + public static final String OOZIE_PREFIX = "oozie.authentication."; private HttpServlet optionsServlet; private ZKUtils zkUtils = null; http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/servlet/CallbackServlet.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/servlet/CallbackServlet.java b/core/src/main/java/org/apache/oozie/servlet/CallbackServlet.java index e488069..6123021 100644 --- a/core/src/main/java/org/apache/oozie/servlet/CallbackServlet.java +++ b/core/src/main/java/org/apache/oozie/servlet/CallbackServlet.java @@ -32,6 +32,7 @@ import org.apache.oozie.DagEngineException; import org.apache.oozie.ErrorCode; import org.apache.oozie.client.rest.RestConstants; import org.apache.oozie.service.CallbackService; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.DagEngineService; import org.apache.oozie.service.Services; import org.apache.oozie.util.IOUtils; @@ -56,7 +57,7 @@ public class CallbackServlet extends JsonRestServlet { @Override public void init() { - maxDataLen = Services.get().getConf().getInt(CONF_MAX_DATA_LEN, 2 * 1024); + maxDataLen = ConfigurationService.getInt(CONF_MAX_DATA_LEN); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java index 8dc9608..2ca3ce5 100644 --- a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java +++ b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java @@ -33,6 +33,7 @@ import org.apache.oozie.client.rest.*; import org.apache.oozie.command.CommandException; import org.apache.oozie.coord.CoordUtils; import org.apache.oozie.service.BundleEngineService; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.CoordinatorEngineService; import org.apache.oozie.service.DagEngineService; import org.apache.oozie.service.Services; @@ -824,7 +825,7 @@ public class V1JobServlet extends BaseJobServlet { int offset = (startStr != null) ? Integer.parseInt(startStr) : 1; offset = (offset < 1) ? 1 : offset; // Get default number of coordinator actions to be retrieved - int defaultLen = Services.get().getConf().getInt(COORD_ACTIONS_DEFAULT_LENGTH, 1000); + int defaultLen = ConfigurationService.getInt(COORD_ACTIONS_DEFAULT_LENGTH); int len = (lenStr != null) ? Integer.parseInt(lenStr) : 0; len = getCoordinatorJobLength(defaultLen, len); try { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java b/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java index 188144e..fdce6b5 100644 --- a/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java +++ b/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java @@ -64,6 +64,7 @@ import org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecuto import org.apache.oozie.executor.jpa.SLASummaryQueryExecutor.SLASummaryQuery; import org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry; import org.apache.oozie.lock.LockToken; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.EventHandlerService; import org.apache.oozie.service.JPAService; import org.apache.oozie.service.JobsConcurrencyService; @@ -97,8 +98,8 @@ public class SLACalculatorMemory implements SLACalculator { @Override public void init(Configuration conf) throws ServiceException { - capacity = conf.getInt(SLAService.CONF_CAPACITY, 5000); - jobEventLatency = conf.getInt(SLAService.CONF_JOB_EVENT_LATENCY, 90 * 1000); + capacity = ConfigurationService.getInt(conf, SLAService.CONF_CAPACITY); + jobEventLatency = ConfigurationService.getInt(conf, SLAService.CONF_JOB_EVENT_LATENCY); slaMap = new ConcurrentHashMap<String, SLACalcStatus>(); historySet = Collections.synchronizedSet(new HashSet<String>()); jpaService = Services.get().get(JPAService.class); http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/sla/listener/SLAEmailEventListener.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/sla/listener/SLAEmailEventListener.java b/core/src/main/java/org/apache/oozie/sla/listener/SLAEmailEventListener.java index 8664a36..535859f 100644 --- a/core/src/main/java/org/apache/oozie/sla/listener/SLAEmailEventListener.java +++ b/core/src/main/java/org/apache/oozie/sla/listener/SLAEmailEventListener.java @@ -43,6 +43,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.oozie.action.email.EmailActionExecutor; import org.apache.oozie.action.email.EmailActionExecutor.JavaMailAuthenticator; import org.apache.oozie.client.event.SLAEvent; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.sla.listener.SLAEventListener; import org.apache.oozie.sla.service.SLAService; import org.apache.oozie.util.XLog; @@ -100,7 +101,7 @@ public class SLAEmailEventListener extends SLAEventListener { @Override public void init(Configuration conf) throws Exception { - oozieBaseUrl = conf.get(OOZIE_BASE_URL); + oozieBaseUrl = ConfigurationService.get(conf, OOZIE_BASE_URL); // Get SMTP properties from the configuration used in Email Action String smtpHost = conf.get(EmailActionExecutor.EMAIL_SMTP_HOST, SMTP_HOST_DEFAULT); String smtpPort = conf.get(EmailActionExecutor.EMAIL_SMTP_PORT, SMTP_PORT_DEFAULT); @@ -146,7 +147,7 @@ public class SLAEmailEventListener extends SLAEventListener { } alertEvents = new HashSet<SLAEvent.EventStatus>(); - String alertEventsStr = conf.get(SLAService.CONF_ALERT_EVENTS); + String alertEventsStr = ConfigurationService.get(conf, SLAService.CONF_ALERT_EVENTS); if (alertEventsStr != null) { String[] alertEvt = alertEventsStr.split(",", -1); for (String evt : alertEvt) { http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/sla/service/SLAService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/sla/service/SLAService.java b/core/src/main/java/org/apache/oozie/sla/service/SLAService.java index 89615bc..a4562e7 100644 --- a/core/src/main/java/org/apache/oozie/sla/service/SLAService.java +++ b/core/src/main/java/org/apache/oozie/sla/service/SLAService.java @@ -24,6 +24,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.oozie.ErrorCode; import org.apache.oozie.client.event.JobEvent.EventStatus; import org.apache.oozie.executor.jpa.JPAExecutorException; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.EventHandlerService; import org.apache.oozie.service.SchedulerService; import org.apache.oozie.service.Service; @@ -58,8 +59,8 @@ public class SLAService implements Service { public void init(Services services) throws ServiceException { try { Configuration conf = services.getConf(); - Class<? extends SLACalculator> calcClazz = (Class<? extends SLACalculator>) conf.getClass( - CONF_CALCULATOR_IMPL, null); + Class<? extends SLACalculator> calcClazz = (Class<? extends SLACalculator>) ConfigurationService.getClass( + conf, CONF_CALCULATOR_IMPL); calcImpl = calcClazz == null ? new SLACalculatorMemory() : (SLACalculator) calcClazz.newInstance(); calcImpl.init(conf); eventHandler = Services.get().get(EventHandlerService.class); @@ -74,8 +75,8 @@ public class SLAService implements Service { Runnable slaThread = new SLAWorker(calcImpl); // schedule runnable by default every 30 sec - int slaCheckInterval = services.getConf().getInt(CONF_SLA_CHECK_INTERVAL, 30); - int slaCheckInitialDelay = services.getConf().getInt(CONF_SLA_CHECK_INITIAL_DELAY, 10); + int slaCheckInterval = ConfigurationService.getInt(conf, CONF_SLA_CHECK_INTERVAL); + int slaCheckInitialDelay = ConfigurationService.getInt(conf, CONF_SLA_CHECK_INITIAL_DELAY); services.get(SchedulerService.class).schedule(slaThread, slaCheckInitialDelay, slaCheckInterval, SchedulerService.Unit.SEC); slaEnabled = true; http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/util/ConfigUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/ConfigUtils.java b/core/src/main/java/org/apache/oozie/util/ConfigUtils.java index ca0ce24..a56c5a2 100644 --- a/core/src/main/java/org/apache/oozie/util/ConfigUtils.java +++ b/core/src/main/java/org/apache/oozie/util/ConfigUtils.java @@ -19,7 +19,8 @@ package org.apache.oozie.util; import org.apache.hadoop.conf.Configuration; -import org.apache.oozie.service.Services; +import org.apache.oozie.service.ConfigurationService; +import org.apache.oozie.service.StatusTransitService; import org.apache.oozie.servlet.ServicesLoader; /** @@ -28,6 +29,12 @@ import org.apache.oozie.servlet.ServicesLoader; public class ConfigUtils { private final static XLog LOG = XLog.getLog(ConfigUtils.class); + public static boolean BOOLEAN_DEFAULT = false; + public static String STRING_DEFAULT = ""; + public static int INT_DEFAULT = 0; + public static float FLOAT_DEFAULT = 0f; + public static long LONG_DEFAULT = 0l; + /** * Fetches a property using both a deprecated name and the new name. The deprecated property * has precedence over the new name. If the deprecated name is used a warning is written to @@ -85,13 +92,13 @@ public class ConfigUtils { else { sb.append("http://"); } - sb.append(Services.get().getConf().get("oozie.http.hostname")); + sb.append(ConfigurationService.get("oozie.http.hostname")); sb.append(":"); if (secure) { - sb.append(Services.get().getConf().get("oozie.https.port")); + sb.append(ConfigurationService.get("oozie.https.port")); } else { - sb.append(Services.get().getConf().get("oozie.http.port")); + sb.append(ConfigurationService.get("oozie.http.port")); } sb.append("/oozie"); return sb.toString(); @@ -105,4 +112,8 @@ public class ConfigUtils { public static String getOozieEffectiveUrl() { return getOozieURL(ServicesLoader.isSSLEnabled()); } + + public static boolean isBackwardSupportForCoordStatus() { + return ConfigurationService.getBoolean(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS); + } } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/util/DateUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/DateUtils.java b/core/src/main/java/org/apache/oozie/util/DateUtils.java index 9587625..ec9d0be 100644 --- a/core/src/main/java/org/apache/oozie/util/DateUtils.java +++ b/core/src/main/java/org/apache/oozie/util/DateUtils.java @@ -32,6 +32,7 @@ import java.util.regex.Pattern; import org.apache.hadoop.conf.Configuration; import org.apache.oozie.coord.TimeUnit; +import org.apache.oozie.service.ConfigurationService; /** * Date utility classes to parse and format datetimes in Oozie expected datetime formats. @@ -65,7 +66,7 @@ public class DateUtils { * @param conf Oozie server configuration. */ public static void setConf(Configuration conf) { - String tz = conf.get(OOZIE_PROCESSING_TIMEZONE_KEY, OOZIE_PROCESSING_TIMEZONE_DEFAULT); + String tz = ConfigurationService.get(conf, OOZIE_PROCESSING_TIMEZONE_KEY); if (!VALID_TIMEZONE_PATTERN.matcher(tz).matches()) { throw new RuntimeException("Invalid Oozie timezone, it must be 'UTC' or 'GMT(+/-)####"); } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/util/StatusUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/StatusUtils.java b/core/src/main/java/org/apache/oozie/util/StatusUtils.java index 93b6193..24eba21 100644 --- a/core/src/main/java/org/apache/oozie/util/StatusUtils.java +++ b/core/src/main/java/org/apache/oozie/util/StatusUtils.java @@ -21,6 +21,7 @@ package org.apache.oozie.util; import org.apache.hadoop.conf.Configuration; import org.apache.oozie.CoordinatorJobBean; import org.apache.oozie.client.Job; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.SchemaService; import org.apache.oozie.service.Services; import org.apache.oozie.service.StatusTransitService; @@ -37,9 +38,7 @@ public class StatusUtils { Job.Status newStatus = null; if (coordJob != null) { newStatus = coordJob.getStatus(); - Configuration conf = Services.get().getConf(); - boolean backwardSupportForCoordStatus = conf.getBoolean( - StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, false); + boolean backwardSupportForCoordStatus = ConfigUtils.isBackwardSupportForCoordStatus(); if (backwardSupportForCoordStatus) { if (coordJob.getAppNamespace() != null && coordJob.getAppNamespace().equals(SchemaService.COORDINATOR_NAMESPACE_URI_1)) { @@ -79,9 +78,7 @@ public class StatusUtils { Job.Status newStatus = null; if (coordJob != null) { newStatus = coordJob.getStatus(); - Configuration conf = Services.get().getConf(); - boolean backwardSupportForCoordStatus = conf.getBoolean( - StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, false); + boolean backwardSupportForCoordStatus = ConfigUtils.isBackwardSupportForCoordStatus(); if (backwardSupportForCoordStatus) { if (coordJob.getAppNamespace() != null && coordJob.getAppNamespace().equals(SchemaService.COORDINATOR_NAMESPACE_URI_1)) { @@ -108,9 +105,7 @@ public class StatusUtils { public static boolean getStatusForCoordActionInputCheck(CoordinatorJobBean coordJob) { boolean ret = false; if (coordJob != null) { - Configuration conf = Services.get().getConf(); - boolean backwardSupportForCoordStatus = conf.getBoolean( - StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, false); + boolean backwardSupportForCoordStatus = ConfigUtils.isBackwardSupportForCoordStatus(); if (backwardSupportForCoordStatus) { if (coordJob.getAppNamespace() != null && coordJob.getAppNamespace().equals(SchemaService.COORDINATOR_NAMESPACE_URI_1)) { @@ -137,8 +132,7 @@ public class StatusUtils { boolean ret = false; if (coordJob != null) { Configuration conf = Services.get().getConf(); - boolean backwardSupportForCoordStatus = conf.getBoolean( - StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, false); + boolean backwardSupportForCoordStatus = ConfigUtils.isBackwardSupportForCoordStatus(); if (backwardSupportForCoordStatus) { if (coordJob.getAppNamespace() != null && coordJob.getAppNamespace().equals(SchemaService.COORDINATOR_NAMESPACE_URI_1)) { @@ -154,14 +148,13 @@ public class StatusUtils { /** * Get the status of coordinator job for Oozie versions (3.2 and before) when RUNNINGWITHERROR, * SUSPENDEDWITHERROR and PAUSEDWITHERROR are not supported - * @param coordJob + * @param currentJobStatus * @return */ public static Job.Status getStatusIfBackwardSupportTrue(Job.Status currentJobStatus) { Job.Status newStatus = currentJobStatus; - Configuration conf = Services.get().getConf(); - boolean backwardSupportForStatesWithoutError = conf.getBoolean( - StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, true); + boolean backwardSupportForStatesWithoutError = ConfigurationService.getBoolean(StatusTransitService + .CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR); if (backwardSupportForStatesWithoutError) { if (currentJobStatus == Job.Status.PAUSEDWITHERROR) { newStatus = Job.Status.PAUSED; http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/util/XLogFilter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/XLogFilter.java b/core/src/main/java/org/apache/oozie/util/XLogFilter.java index 0a350db..5c0d1f3 100644 --- a/core/src/main/java/org/apache/oozie/util/XLogFilter.java +++ b/core/src/main/java/org/apache/oozie/util/XLogFilter.java @@ -29,6 +29,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.Services; import com.google.common.annotations.VisibleForTesting; @@ -307,7 +308,7 @@ public class XLogFilter { } long diffHours = (endDate.getTime() - startDate.getTime()) / (60 * 60 * 1000); if (isActionList) { - int actionLogDuration = Services.get().getConf().getInt(MAX_ACTIONLIST_SCAN_DURATION, -1); + int actionLogDuration = ConfigurationService.getInt(MAX_ACTIONLIST_SCAN_DURATION); if (actionLogDuration == -1) { return; } @@ -319,7 +320,7 @@ public class XLogFilter { } } else { - int logDuration = Services.get().getConf().getInt(MAX_SCAN_DURATION, -1); + int logDuration = ConfigurationService.getInt(MAX_SCAN_DURATION); if (logDuration == -1) { return; } http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/util/ZKUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/ZKUtils.java b/core/src/main/java/org/apache/oozie/util/ZKUtils.java index f535f86..6162178 100644 --- a/core/src/main/java/org/apache/oozie/util/ZKUtils.java +++ b/core/src/main/java/org/apache/oozie/util/ZKUtils.java @@ -48,6 +48,7 @@ import static org.apache.oozie.service.HadoopAccessorService.KERBEROS_KEYTAB; import static org.apache.oozie.service.HadoopAccessorService.KERBEROS_PRINCIPAL; import org.apache.oozie.event.listener.ZKConnectionListener; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.ServiceException; import org.apache.oozie.service.Services; import org.apache.zookeeper.ZooDefs.Perms; @@ -132,7 +133,10 @@ public class ZKUtils { */ private ZKUtils() throws Exception { log = XLog.getLog(getClass()); - zkId = Services.get().getConf().get(OOZIE_INSTANCE_ID, Services.get().getConf().get("oozie.http.hostname")); + zkId = ConfigurationService.get(OOZIE_INSTANCE_ID); + if (zkId.isEmpty()) { + zkId = ConfigurationService.get("oozie.http.hostname"); + } createClient(); advertiseService(); checkAndSetACLs(); @@ -173,9 +177,9 @@ public class ZKUtils { private void createClient() throws Exception { // Connect to the ZooKeeper server RetryPolicy retryPolicy = ZKUtils.getRetryPolicy(); - String zkConnectionString = Services.get().getConf().get(ZK_CONNECTION_STRING, "localhost:2181"); + String zkConnectionString = ConfigurationService.get(ZK_CONNECTION_STRING); String zkNamespace = getZKNameSpace(); - zkConnectionTimeout = Services.get().getConf().getInt(ZK_CONNECTION_TIMEOUT, 180); + zkConnectionTimeout = ConfigurationService.getInt(ZK_CONNECTION_TIMEOUT); ACLProvider aclProvider; if (Services.get().getConf().getBoolean(ZK_SECURE, false)) { @@ -413,7 +417,7 @@ public class ZKUtils { * @return oozie.zookeeper.namespace */ public static String getZKNameSpace() { - return Services.get().getConf().get(ZK_NAMESPACE, "oozie"); + return ConfigurationService.get(ZK_NAMESPACE); } /** * Return ZK connection timeout http://git-wip-us.apache.org/repos/asf/oozie/blob/2fc2fc9e/core/src/main/java/org/apache/oozie/workflow/lite/LiteWorkflowAppParser.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/workflow/lite/LiteWorkflowAppParser.java b/core/src/main/java/org/apache/oozie/workflow/lite/LiteWorkflowAppParser.java index cfa8697..c857011 100644 --- a/core/src/main/java/org/apache/oozie/workflow/lite/LiteWorkflowAppParser.java +++ b/core/src/main/java/org/apache/oozie/workflow/lite/LiteWorkflowAppParser.java @@ -18,6 +18,7 @@ package org.apache.oozie.workflow.lite; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.workflow.WorkflowException; import org.apache.oozie.util.ELUtils; import org.apache.oozie.util.IOUtils; @@ -160,7 +161,8 @@ public class LiteWorkflowAppParser { traversed.put(app.getNode(StartNodeDef.START).getName(), VisitStatus.VISITING); validate(app, app.getNode(StartNodeDef.START), traversed); //Validate whether fork/join are in pair or not - if (jobConf.getBoolean(WF_VALIDATE_FORK_JOIN, true) && Services.get().getConf().getBoolean(VALIDATE_FORK_JOIN, true)) { + if (jobConf.getBoolean(WF_VALIDATE_FORK_JOIN, true) + && ConfigurationService.getBoolean(VALIDATE_FORK_JOIN)) { validateForkJoin(app); } return app;
