You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by go...@apache.org on 2016/08/25 20:20:02 UTC
[33/46] incubator-slider git commit: SLIDER-1165 Create
yarn-native-services branch on Slider corresponding to the
yarn-native-services branch on Hadoop
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java
deleted file mode 100644
index 86025ee..0000000
--- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderVersionInfo.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.common.tools;
-
-import org.apache.hadoop.util.VersionInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Locale;
-import java.util.Properties;
-
-/**
- * Extract the version properties, which will look something like
- * <pre>
- * application.name=${pom.name}
- * application.version=${pom.version}
- * application.build=${buildNumber}
- * application.build.java.version=${java.version}
- * application.build.info=${pom.name}-${pom.version} Built against ${buildNumber} on ${java.version} by ${user.name}
- * </pre>
- *
- * the <code>mvn process-resources</code> target will expand the properties
- * and add the resources to target/classes, which will then look something like
- * <pre>
- * application.name=Slider Core
- * application.version=0.7.1-SNAPSHOT
- * application.build=1dd69
- * application.build.java.version=1.7.0_45
- * application.build.user=stevel
- * application.build.info=Slider Core-0.7.1-SNAPSHOT Built against 1dd69 on 1.7.0_45 by stevel
- * </pre>
- *
- * Note: the values will change and more properties added.
- */
-public class SliderVersionInfo {
- private static final Logger log = LoggerFactory.getLogger(SliderVersionInfo.class);
-
- /**
- * Name of the resource containing the filled-in-at-runtime props
- */
- public static final String VERSION_RESOURCE =
- "org/apache/slider/providers/dynamic/application.properties";
-
- public static final String APP_NAME = "application.name";
- public static final String APP_VERSION = "application.version";
- public static final String APP_BUILD = "application.build";
- public static final String APP_BUILD_JAVA_VERSION = "application.build.java.version";
- public static final String APP_BUILD_USER = "application.build.user";
- public static final String APP_BUILD_INFO = "application.build.info";
- public static final String HADOOP_BUILD_INFO = "hadoop.build.info";
- public static final String HADOOP_DEPLOYED_INFO = "hadoop.deployed.info";
-
-
- public static Properties loadVersionProperties() {
- Properties props = new Properties();
- URL resURL = SliderVersionInfo.class.getClassLoader()
- .getResource(VERSION_RESOURCE);
- assert resURL != null : "Null resource " + VERSION_RESOURCE;
-
- try {
- InputStream inStream = resURL.openStream();
- assert inStream != null : "Null input stream from " + VERSION_RESOURCE;
- props.load(inStream);
- } catch (IOException e) {
- log.warn("IOE loading " + VERSION_RESOURCE, e);
- }
- return props;
- }
-
- /**
- * Load the version info and print it
- * @param logger logger
- */
- public static void loadAndPrintVersionInfo(Logger logger) {
- Properties props = loadVersionProperties();
- logger.info(props.getProperty(APP_BUILD_INFO));
- logger.info("Compiled against Hadoop {}",
- props.getProperty(HADOOP_BUILD_INFO));
- logger.info(getHadoopVersionString());
- }
-
- public static String getHadoopVersionString() {
- return String.format(Locale.ENGLISH,
- "Hadoop runtime version %s with source checksum %s and build date %s",
- VersionInfo.getBranch(),
- VersionInfo.getSrcChecksum(),
- VersionInfo.getDate());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/build/BuildHelper.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/build/BuildHelper.java b/slider-core/src/main/java/org/apache/slider/core/build/BuildHelper.java
deleted file mode 100644
index 1098e2c..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/build/BuildHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.build;
-
-import org.apache.hadoop.util.VersionInfo;
-import org.apache.slider.common.tools.SliderVersionInfo;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * classes to help with the build
- */
-public class BuildHelper {
- /**
- * Add the cluster build information; this will include Hadoop details too
- * @param dest map to insert this too
- * @param prefix prefix for the build info
- */
- public static void addBuildMetadata(Map<String, Object> dest, String prefix) {
-
- Properties props = SliderVersionInfo.loadVersionProperties();
- dest.put(prefix + "." + SliderVersionInfo.APP_BUILD_INFO,
- props.getProperty(
- SliderVersionInfo.APP_BUILD_INFO));
- dest.put(prefix + "." + SliderVersionInfo.HADOOP_BUILD_INFO,
- props.getProperty(SliderVersionInfo.HADOOP_BUILD_INFO));
-
- dest.put(prefix + "." + SliderVersionInfo.HADOOP_DEPLOYED_INFO,
- VersionInfo.getBranch() + " @" + VersionInfo.getSrcChecksum());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/build/InstanceBuilder.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/build/InstanceBuilder.java b/slider-core/src/main/java/org/apache/slider/core/build/InstanceBuilder.java
deleted file mode 100644
index 8155214..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/build/InstanceBuilder.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.build;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.slider.api.InternalKeys;
-import org.apache.slider.api.OptionKeys;
-import org.apache.slider.api.ResourceKeys;
-import org.apache.slider.api.StatusKeys;
-import org.apache.slider.common.SliderKeys;
-import org.apache.slider.common.SliderXmlConfKeys;
-import org.apache.slider.common.tools.CoreFileSystem;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.core.conf.ConfTreeOperations;
-import org.apache.slider.core.conf.MapOperations;
-import org.apache.slider.core.exceptions.BadClusterStateException;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.apache.slider.core.exceptions.ErrorStrings;
-import org.apache.slider.core.exceptions.SliderException;
-import org.apache.slider.core.persist.ConfPersister;
-import org.apache.slider.core.persist.InstancePaths;
-import org.apache.slider.core.persist.LockAcquireFailedException;
-import org.apache.slider.core.persist.LockHeldAction;
-import org.apache.slider.core.zk.ZKPathBuilder;
-import org.apache.slider.core.zk.ZookeeperUtils;
-import org.apache.slider.providers.agent.AgentKeys;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-
-import static org.apache.slider.api.InternalKeys.INTERNAL_ADDONS_DIR_PATH;
-import static org.apache.slider.api.InternalKeys.INTERNAL_APPDEF_DIR_PATH;
-import static org.apache.slider.api.InternalKeys.INTERNAL_QUEUE;
-import static org.apache.slider.api.OptionKeys.INTERNAL_AM_TMP_DIR;
-import static org.apache.slider.api.OptionKeys.INTERNAL_TMP_DIR;
-import static org.apache.slider.api.OptionKeys.INTERNAL_APPLICATION_HOME;
-import static org.apache.slider.api.OptionKeys.INTERNAL_APPLICATION_IMAGE_PATH;
-import static org.apache.slider.api.OptionKeys.INTERNAL_DATA_DIR_PATH;
-import static org.apache.slider.api.OptionKeys.INTERNAL_GENERATED_CONF_PATH;
-import static org.apache.slider.api.OptionKeys.INTERNAL_SNAPSHOT_CONF_PATH;
-import static org.apache.slider.api.OptionKeys.ZOOKEEPER_HOSTS;
-import static org.apache.slider.api.OptionKeys.ZOOKEEPER_PATH;
-import static org.apache.slider.api.OptionKeys.ZOOKEEPER_QUORUM;
-import static org.apache.slider.api.RoleKeys.ROLE_PREFIX;
-import static org.apache.slider.common.SliderKeys.COMPONENT_AM;
-import static org.apache.slider.common.SliderKeys.COMPONENT_SEPARATOR;
-import static org.apache.slider.common.SliderKeys.COMPONENT_TYPE_EXTERNAL_APP;
-import static org.apache.slider.common.SliderKeys.COMPONENT_TYPE_KEY;
-import static org.apache.slider.common.tools.SliderUtils.isClusternameValid;
-
-/**
- * Build up the instance of a cluster.
- */
-public class InstanceBuilder {
-
- private final String clustername;
- private final Configuration conf;
- private final CoreFileSystem coreFS;
- private final InstancePaths instancePaths;
- private AggregateConf instanceDescription;
- private Map<String, Path> externalAppDefs = new HashMap<>();
- private TreeSet<Integer> priorities = new TreeSet<>();
-
- private static final Logger log =
- LoggerFactory.getLogger(InstanceBuilder.class);
-
- public InstanceBuilder(CoreFileSystem coreFileSystem,
- Configuration conf,
- String clustername) {
- this.clustername = clustername;
- this.conf = conf;
- this.coreFS = coreFileSystem;
- Path instanceDir = coreFileSystem.buildClusterDirPath(clustername);
- instancePaths = new InstancePaths(instanceDir);
-
- }
-
- public AggregateConf getInstanceDescription() {
- return instanceDescription;
- }
-
- public InstancePaths getInstancePaths() {
- return instancePaths;
- }
-
-
- @Override
- public String toString() {
- return "Builder working with " + clustername + " at " +
- getInstanceDir();
- }
-
- private Path getInstanceDir() {
- return instancePaths.instanceDir;
- }
-
- /**
- * Initial part of the build process
- * @param instanceConf
- * @param provider
- */
- public void init(
- String provider,
- AggregateConf instanceConf) {
-
-
- this.instanceDescription = instanceConf;
-
- //internal is extended
- ConfTreeOperations internalOps = instanceConf.getInternalOperations();
-
- Map<String, Object> md = internalOps.getConfTree().metadata;
- long time = System.currentTimeMillis();
- md.put(StatusKeys.INFO_CREATE_TIME_HUMAN, SliderUtils.toGMTString(time));
- md.put(StatusKeys.INFO_CREATE_TIME_MILLIS, Long.toString(time));
-
- MapOperations globalOptions = internalOps.getGlobalOptions();
- BuildHelper.addBuildMetadata(md, "create");
- SliderUtils.setInfoTime(md,
- StatusKeys.INFO_CREATE_TIME_HUMAN,
- StatusKeys.INFO_CREATE_TIME_MILLIS,
- System.currentTimeMillis());
-
- internalOps.set(INTERNAL_AM_TMP_DIR,
- instancePaths.tmpPathAM.toUri());
- internalOps.set(INTERNAL_TMP_DIR,
- instancePaths.tmpPath.toUri());
- internalOps.set(INTERNAL_SNAPSHOT_CONF_PATH,
- instancePaths.snapshotConfPath.toUri());
- internalOps.set(INTERNAL_GENERATED_CONF_PATH,
- instancePaths.generatedConfPath.toUri());
- internalOps.set(INTERNAL_DATA_DIR_PATH,
- instancePaths.dataPath.toUri());
- internalOps.set(INTERNAL_APPDEF_DIR_PATH,
- instancePaths.appDefPath.toUri());
- internalOps.set(INTERNAL_ADDONS_DIR_PATH,
- instancePaths.addonsPath.toUri());
-
-
- internalOps.set(InternalKeys.INTERNAL_PROVIDER_NAME, provider);
- internalOps.set(OptionKeys.APPLICATION_NAME, clustername);
-
- }
-
- /**
- * Set the queue used to start the application
- * @param queue
- * @throws BadConfigException
- */
- public void setQueue(String queue) throws BadConfigException {
- if(queue != null) {
- if(SliderUtils.isUnset(queue)) {
- throw new BadConfigException("Queue value cannot be empty.");
- }
-
- instanceDescription.getInternalOperations().set(INTERNAL_QUEUE, queue);
- }
- }
-
- /**
- * Set up the image/app home path
- * @param appImage path in the DFS to the tar file
- * @param appHomeDir other strategy: home dir
- * @throws BadConfigException if both are found
- */
- public void setImageDetailsIfAvailable(
- Path appImage,
- String appHomeDir) throws BadConfigException {
- boolean appHomeUnset = SliderUtils.isUnset(appHomeDir);
- // App home or image
- if (appImage != null) {
- if (!appHomeUnset) {
- // both args have been set
- throw new BadConfigException(
- ErrorStrings.E_BOTH_IMAGE_AND_HOME_DIR_SPECIFIED);
- }
- instanceDescription.getInternalOperations().set(INTERNAL_APPLICATION_IMAGE_PATH,
- appImage.toUri());
- } else {
- // the alternative is app home, which now MUST be set
- if (!appHomeUnset) {
- instanceDescription.getInternalOperations().set(INTERNAL_APPLICATION_HOME,
- appHomeDir);
- }
- }
- }
-
-
- /**
- * Propagate any critical principals from the current site config down to the HBase one.
- */
- public void propagatePrincipals() {
- String dfsPrincipal = conf.get(SliderXmlConfKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY);
- if (dfsPrincipal != null) {
- String siteDfsPrincipal = OptionKeys.SITE_XML_PREFIX +
- SliderXmlConfKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY;
- instanceDescription.getAppConfOperations().set(siteDfsPrincipal, dfsPrincipal);
- }
- }
-
- public void propagateFilename() {
- String fsDefaultName = conf.get(
- CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY);
- instanceDescription.getAppConfOperations().set(OptionKeys.SITE_XML_PREFIX +
- CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
- fsDefaultName
- );
-
- instanceDescription.getAppConfOperations().set(OptionKeys.SITE_XML_PREFIX +
- SliderXmlConfKeys.FS_DEFAULT_NAME_CLASSIC,
- fsDefaultName
- );
-
- }
-
-
- public void takeSnapshotOfConfDir(Path appconfdir) throws
- IOException,
- BadConfigException,
- BadClusterStateException {
- FileSystem srcFS = FileSystem.get(appconfdir.toUri(), conf);
- if (!srcFS.isDirectory(appconfdir)) {
- throw new BadConfigException(
- "Source Configuration directory is not valid: %s",
- appconfdir.toString());
- }
- // bulk copy
- FsPermission clusterPerms = coreFS.getInstanceDirectoryPermissions();
- // first the original from wherever to the DFS
- SliderUtils.copyDirectory(conf, appconfdir, instancePaths.snapshotConfPath,
- clusterPerms);
- }
-
-
- private Set<String> getExternalComponents(ConfTreeOperations ops)
- throws BadConfigException {
- Set<String> externalComponents = new HashSet<>();
- if (ops.getGlobalOptions().containsKey(COMPONENT_TYPE_KEY)) {
- throw new BadConfigException(COMPONENT_TYPE_KEY + " must be " +
- "specified per-component, not in global");
- }
-
- for (Entry<String, Map<String, String>> entry : ops.getComponents()
- .entrySet()) {
- if (COMPONENT_AM.equals(entry.getKey())) {
- continue;
- }
- Map<String, String> options = entry.getValue();
- if (COMPONENT_TYPE_EXTERNAL_APP.equals(options.get(COMPONENT_TYPE_KEY))) {
- externalComponents.add(entry.getKey());
- }
- }
- return externalComponents;
- }
-
- private void mergeExternalComponent(ConfTreeOperations ops,
- ConfTreeOperations externalOps, String externalComponent,
- Integer priority) throws BadConfigException {
- for (String subComponent : externalOps.getComponentNames()) {
- if (COMPONENT_AM.equals(subComponent)) {
- continue;
- }
- String prefix = externalComponent + COMPONENT_SEPARATOR;
- log.debug("Merging options for {} into {}", subComponent,
- prefix + subComponent);
- MapOperations subComponentOps = ops.getOrAddComponent(
- prefix + subComponent);
- if (priority == null) {
- SliderUtils.mergeMaps(subComponentOps,
- ops.getComponent(externalComponent).options);
- subComponentOps.remove(COMPONENT_TYPE_KEY);
- }
-
- SliderUtils.mergeMapsIgnoreDuplicateKeysAndPrefixes(subComponentOps,
- externalOps.getComponent(subComponent),
- SliderKeys.COMPONENT_KEYS_TO_SKIP);
-
- // add prefix to existing prefix
- String existingPrefix = subComponentOps.get(ROLE_PREFIX);
- if (existingPrefix != null) {
- if (!subComponent.startsWith(existingPrefix)) {
- throw new BadConfigException("Bad prefix " + existingPrefix +
- " for subcomponent " + subComponent + " of " + externalComponent);
- }
- prefix = prefix + existingPrefix;
- }
- subComponentOps.set(ROLE_PREFIX, prefix);
-
- // adjust priority
- if (priority != null) {
- subComponentOps.put(ResourceKeys.COMPONENT_PRIORITY,
- Integer.toString(priority));
- priorities.add(priority);
- priority++;
- }
- }
- }
-
- private int getNextPriority() {
- if (priorities.isEmpty()) {
- return 1;
- } else {
- return priorities.last() + 1;
- }
- }
-
- public void resolve()
- throws BadConfigException, IOException, BadClusterStateException {
- ConfTreeOperations appConf = instanceDescription.getAppConfOperations();
- ConfTreeOperations resources = instanceDescription.getResourceOperations();
-
- for (Entry<String, Map<String, String>> entry : resources.getComponents()
- .entrySet()) {
- if (COMPONENT_AM.equals(entry.getKey())) {
- continue;
- }
- if (entry.getValue().containsKey(ResourceKeys.COMPONENT_PRIORITY)) {
- priorities.add(Integer.parseInt(entry.getValue().get(
- ResourceKeys.COMPONENT_PRIORITY)));
- }
- }
-
- Set<String> externalComponents = getExternalComponents(appConf);
- if (!externalComponents.isEmpty()) {
- log.info("Found external components {}", externalComponents);
- }
-
- for (String component : externalComponents) {
- if (!isClusternameValid(component)) {
- throw new BadConfigException(component + " is not a valid external " +
- "component");
- }
- Path componentClusterDir = coreFS.buildClusterDirPath(component);
- try {
- coreFS.verifyPathExists(componentClusterDir);
- } catch (IOException e) {
- throw new BadConfigException("external component " + component +
- " doesn't exist");
- }
- AggregateConf componentConf = new AggregateConf();
- ConfPersister persister = new ConfPersister(coreFS, componentClusterDir);
- try {
- persister.load(componentConf);
- } catch (Exception e) {
- throw new BadConfigException("Couldn't read configuration for " +
- "external component " + component);
- }
-
- ConfTreeOperations componentAppConf = componentConf.getAppConfOperations();
- String externalAppDef = componentAppConf.get(AgentKeys.APP_DEF);
- if (SliderUtils.isSet(externalAppDef)) {
- Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername),
- component + "_" + SliderKeys.DEFAULT_APP_PKG);
- componentAppConf.set(AgentKeys.APP_DEF, newAppDef);
- componentAppConf.append(AgentKeys.APP_DEF_ORIGINAL, externalAppDef);
- log.info("Copying external appdef {} to {} for {}", externalAppDef,
- newAppDef, component);
- externalAppDefs.put(externalAppDef, newAppDef);
- externalAppDef = newAppDef.toString();
- }
-
- for (String rcomp : componentConf.getResourceOperations()
- .getComponentNames()) {
- if (COMPONENT_AM.equals(rcomp)) {
- continue;
- }
- log.debug("Adding component {} to appConf for {}", rcomp, component);
- componentAppConf.getOrAddComponent(rcomp);
- }
- componentConf.resolve();
-
- for (String rcomp : componentConf.getResourceOperations()
- .getComponentNames()) {
- if (COMPONENT_AM.equals(rcomp)) {
- continue;
- }
- String componentAppDef = componentAppConf.getComponentOpt(
- rcomp, AgentKeys.APP_DEF, null);
- if (SliderUtils.isUnset(componentAppDef) ||
- componentAppDef.equals(externalAppDef)) {
- continue;
- }
- if (externalAppDefs.containsKey(componentAppDef)) {
- log.info("Using external appdef {} for {}",
- externalAppDefs.get(componentAppDef), rcomp);
- } else {
- String existingPrefix = componentAppConf.getComponentOpt(rcomp,
- ROLE_PREFIX, null);
- if (SliderUtils.isUnset(existingPrefix)) {
- existingPrefix = "";
- } else {
- existingPrefix = COMPONENT_SEPARATOR + SliderUtils.trimPrefix(
- existingPrefix);
- }
- Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername),
- component + existingPrefix + "_" + SliderKeys.DEFAULT_APP_PKG);
- externalAppDefs.put(componentAppDef, newAppDef);
- log.info("Copying external appdef {} to {} for {}", componentAppDef,
- newAppDef, component + COMPONENT_SEPARATOR + rcomp);
- }
- componentAppConf.setComponentOpt(rcomp, AgentKeys.APP_DEF,
- externalAppDefs.get(componentAppDef).toString());
- componentAppConf.appendComponentOpt(rcomp,
- AgentKeys.APP_DEF_ORIGINAL, componentAppDef);
- }
- Set<Path> newAppDefs = new HashSet<>();
- newAppDefs.addAll(externalAppDefs.values());
- if (newAppDefs.size() != externalAppDefs.size()) {
- throw new IllegalStateException("Values repeat in external appdefs "
- + externalAppDefs);
- }
- log.info("External appdefs after {}: {}", component, externalAppDefs);
-
- mergeExternalComponent(appConf, componentAppConf, component, null);
- mergeExternalComponent(resources, componentConf.getResourceOperations(),
- component, getNextPriority());
- }
- }
-
-
- /**
- * Persist this
- * @param appconfdir conf dir
- * @param overwrite if true, we don't need to create cluster dir
- * @throws IOException
- * @throws SliderException
- * @throws LockAcquireFailedException
- */
- public void persist(Path appconfdir, boolean overwrite) throws
- IOException,
- SliderException,
- LockAcquireFailedException {
- if (!overwrite) {
- coreFS.createClusterDirectories(instancePaths);
- }
- ConfPersister persister =
- new ConfPersister(coreFS, getInstanceDir());
- ConfDirSnapshotAction action = null;
- if (appconfdir != null) {
- action = new ConfDirSnapshotAction(appconfdir);
- }
- persister.save(instanceDescription, action);
- for (Entry<String, Path> appDef : externalAppDefs.entrySet()) {
- SliderUtils.copy(conf, new Path(appDef.getKey()), appDef.getValue());
- }
- }
-
- /**
- * Add the ZK paths to the application options.
- *
- * @param zkBinding ZK binding
- */
- public void addZKBinding(ZKPathBuilder zkBinding) throws BadConfigException {
-
- String quorum = zkBinding.getAppQuorum();
- if (SliderUtils.isSet(quorum)) {
- MapOperations globalAppOptions =
- instanceDescription.getAppConfOperations().getGlobalOptions();
- globalAppOptions.put(ZOOKEEPER_PATH, zkBinding.getAppPath());
- globalAppOptions.put(ZOOKEEPER_QUORUM, quorum);
- globalAppOptions.put(ZOOKEEPER_HOSTS,
- ZookeeperUtils.convertToHostsOnlyList(quorum));
- }
- }
-
- /**
- * Class to execute the snapshotting of the configuration directory
- * while the persistence lock is held.
- *
- * This guarantees that there won't be an attempt to launch a cluster
- * until the snapshot is complete -as the write lock won't be released
- * until afterwards.
- */
- private class ConfDirSnapshotAction implements LockHeldAction {
-
- private final Path appconfdir;
-
- private ConfDirSnapshotAction(Path appconfdir) {
- this.appconfdir = appconfdir;
- }
-
- @Override
- public void execute() throws IOException, SliderException {
-
- takeSnapshotOfConfDir(appconfdir);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/build/InstanceIO.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/build/InstanceIO.java b/slider-core/src/main/java/org/apache/slider/core/build/InstanceIO.java
deleted file mode 100644
index 3a8f805..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/build/InstanceIO.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.build;
-
-import org.apache.hadoop.fs.Path;
-import org.apache.slider.common.tools.CoreFileSystem;
-import org.apache.slider.core.conf.AggregateConf;
-import org.apache.slider.core.exceptions.BadClusterStateException;
-import org.apache.slider.core.exceptions.SliderException;
-import org.apache.slider.core.persist.ConfPersister;
-import org.apache.slider.core.persist.LockAcquireFailedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class InstanceIO {
- protected static final Logger log =
- LoggerFactory.getLogger(InstanceIO.class);
-
- /**
- * Load in an instance definition -but do not resolve it
- * @param sliderFileSystem filesystem
- * @param clusterDirectory CD
- * @return the unresolved aggregate configuration
- * @throws IOException
- * @throws SliderException
- * @throws BadClusterStateException if a lock could not be acquired
- */
- public static AggregateConf loadInstanceDefinitionUnresolved(
- CoreFileSystem sliderFileSystem,
- Path clusterDirectory)
- throws IOException, SliderException {
- AggregateConf instanceDefinition = new AggregateConf();
- ConfPersister persister =
- new ConfPersister(sliderFileSystem, clusterDirectory);
- try {
- persister.load(instanceDefinition);
- } catch (LockAcquireFailedException e) {
- log.debug("Lock acquisition failure of {}", clusterDirectory, e);
-
- throw new BadClusterStateException(
- "Application at %s is locked for reading",
- clusterDirectory.toString());
- }
- return instanceDefinition;
- }
-
-
- /**
- * Update a persisted instance definition
- * @param coreFS filesystem
- * @param dir directory to load from
- * @param instanceDefinition instance definition to save do
- * @throws SliderException
- * @throws IOException
- * @throws LockAcquireFailedException
- */
- public static void saveInstanceDefinition(CoreFileSystem coreFS,
- Path dir,
- AggregateConf instanceDefinition)
- throws SliderException, IOException, LockAcquireFailedException {
- ConfPersister persister =
- new ConfPersister(coreFS, dir);
- persister.save(instanceDefinition, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/AbstractInputPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/AbstractInputPropertiesValidator.java b/slider-core/src/main/java/org/apache/slider/core/conf/AbstractInputPropertiesValidator.java
deleted file mode 100644
index 336b4dc..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/AbstractInputPropertiesValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.core.conf;
-
-import org.apache.slider.core.exceptions.BadConfigException;
-
-/**
- *
- */
-public abstract class AbstractInputPropertiesValidator implements InputPropertiesValidator{
-
- abstract void validatePropertyNamePrefix(String key) throws BadConfigException;
-
- public void validate(ConfTreeOperations props)
- throws BadConfigException {
- validateGlobalProperties(props);
- validateComponentProperties(props);
-
- }
-
- protected void validateComponentProperties(ConfTreeOperations props)
- throws BadConfigException {
- for (String compName : props.getComponentNames()) {
- MapOperations mo = props.getComponent(compName);
- if (mo == null) continue;
- for (String key : mo.keySet()) {
- validatePropertyNamePrefix(key);
- }
- }
- }
-
- abstract void validateGlobalProperties(ConfTreeOperations props)
- throws BadConfigException;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/AggregateConf.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/AggregateConf.java b/slider-core/src/main/java/org/apache/slider/core/conf/AggregateConf.java
deleted file mode 100644
index 18c3156..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/AggregateConf.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.conf;
-
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.slider.common.SliderKeys;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.io.IOException;
-
-/**
- * Aggregate Configuration.
- *
- * It is serializable to JSON
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public final class AggregateConf {
-
- private String name;
- private ConfTree resources;
- private ConfTree internal;
- private ConfTree appConf;
-
- private ConfTreeOperations resourceOperations;
- private ConfTreeOperations appConfOperations;
- private ConfTreeOperations internalOperations;
-
- private String passphrase;
-
- public AggregateConf() {
- this(new ConfTree(), new ConfTree(), new ConfTree());
- }
-
- public AggregateConf(String name) {
- this(new ConfTree(), new ConfTree(), new ConfTree());
- this.name = name;
- }
-
- public AggregateConf(ConfTree resources,
- ConfTree appConf,
- ConfTree internal) {
- setResources(resources);
- setAppConf(appConf);
- setInternal(internal);
- }
-
- /**
- * Take a snapshot of the configuration
- * @param instanceDefinition source
- * @throws IOException marshalling/copying problems
- */
- public AggregateConf(AggregateConf instanceDefinition) throws IOException {
- ConfTreeOperations resourcesSnapshot =
- ConfTreeOperations.fromInstance(instanceDefinition.getResources());
- ConfTreeOperations appConfSnapshot =
- ConfTreeOperations.fromInstance(instanceDefinition.getAppConf());
- ConfTreeOperations internalsSnapshot =
- ConfTreeOperations.fromInstance(instanceDefinition.getInternal());
- //build a new aggregate from the snapshots
- setResources(resourcesSnapshot.confTree);
- setAppConf(appConfSnapshot.confTree);
- setInternal(internalsSnapshot.confTree);
- }
-
- public void setResources(ConfTree resources) {
- this.resources = resources;
- resourceOperations = new ConfTreeOperations(resources);
- }
-
- public void setAppConf(ConfTree appConf) {
- this.appConf = appConf;
- appConfOperations = new ConfTreeOperations(appConf);
- }
-
- public ConfTree getInternal() {
- return internal;
- }
-
- public void setInternal(ConfTree internal) {
- this.internal = internal;
- internalOperations = new ConfTreeOperations(internal);
- }
-
- public ConfTree getResources() {
- return resources;
- }
-
- public ConfTree getAppConf() {
- return appConf;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @JsonIgnore
- public ConfTreeOperations getResourceOperations() {
- return resourceOperations;
- }
-
-
- @JsonIgnore
- public ConfTreeOperations getAppConfOperations() {
- return appConfOperations;
- }
-
- @JsonIgnore
- public ConfTreeOperations getInternalOperations() {
- return internalOperations;
- }
-
- /**
- * predicate to query if all sections have data structures
- * @return true if every section is non-null
- */
- @JsonIgnore
- public boolean isComplete() {
- return resources != null && appConf != null && internal != null;
- }
-
- public void validate() throws BadConfigException {
- if (!isComplete()) {
- throw new BadConfigException("Incomplete instance %s", this);
- }
- resourceOperations.validate();
- internalOperations.validate();
- appConfOperations.validate();
- }
-
- public void resolve() throws BadConfigException {
- validate();
- resourceOperations.resolve();
- internalOperations.resolve();
- appConfOperations.resolve();
- }
-
- @JsonIgnore
- public String getPassphrase() {
- if (passphrase == null) {
- passphrase = RandomStringUtils.randomAlphanumeric(
- Integer.valueOf(SliderKeys.PASS_LEN));
- }
-
- return passphrase;
- }
-
- /**
- * Is this app package versioned?
- *
- * @return true if {@link SliderKeys#APP_VERSION} was set in the app config
- * provided during creation of this app
- * @since 0.80.0-incubating
- */
- public boolean isVersioned() {
- return StringUtils.isNotEmpty(getAppConfOperations().getGlobalOptions()
- .get(SliderKeys.APP_VERSION));
- }
-
- /**
- * string operation includes all the inner conftrees
- * @return a string description
- */
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("{");
- sb.append(",\n\"internal\": ").append(internal);
- sb.append(",\n\"resources\": ").append(resources);
- sb.append(",\n\"appConf\" :").append(appConf);
- sb.append('}');
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java b/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java
deleted file mode 100644
index be7c56f..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.conf;
-
-import org.apache.slider.core.persist.ConfTreeSerDeser;
-import org.apache.slider.core.persist.PersistKeys;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A conf tree represents one of the configuration trees
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public final class ConfTree {
-
- /**
- * Size of an initial map. This is kept low so the cost of having
- * many conf trees in a process is low.
- */
- public static final int INITAL_MAP_CAPACITY = 3;
-
- protected static final Logger
- log = LoggerFactory.getLogger(ConfTree.class);
-
- /**
- * version counter
- */
- public String schema = PersistKeys.SCHEMA;
-
- /**
- * Metadata
- */
- public Map<String, Object> metadata = new HashMap<>(INITAL_MAP_CAPACITY);
-
-
- /**
- * Global options
- */
- public Map<String, String> global =
- new HashMap<>(INITAL_MAP_CAPACITY);
-
-
- /**
- * Credentials
- */
- public Map<String, List<String>> credentials =
- new HashMap<>(INITAL_MAP_CAPACITY);
-
- /**
- * Role options,
- * role -> option -> value
- */
- public Map<String, Map<String, String>> components =
- new HashMap<>(INITAL_MAP_CAPACITY);
-
-
- /**
- * Shallow clone
- * @return a shallow clone
- * @throws CloneNotSupportedException
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- @Override
- public String toString() {
- try {
- return toJson();
- } catch (Exception e) {
- log.warn("Failed to convert to JSON ", e);
- return super.toString();
- }
- }
-
- /**
- * Convert to a JSON string
- * @return a JSON string description
- * @throws IOException Problems mapping/writing the object
- */
- public String toJson() throws IOException,
- JsonGenerationException,
- JsonMappingException {
- return ConfTreeSerDeser.toString(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java b/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java
deleted file mode 100644
index 526e17d..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.conf;
-
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.apache.slider.core.persist.ConfTreeSerDeser;
-import org.apache.slider.core.persist.PersistKeys;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class ConfTreeOperations {
-
- public final ConfTree confTree;
- private final MapOperations globalOptions;
-
- protected static final Logger
- log = LoggerFactory.getLogger(ConfTreeOperations.class);
-
-
- public ConfTreeOperations(ConfTree confTree) {
- assert confTree != null : "null tree";
- assert confTree.components != null : "null tree components";
- this.confTree = confTree;
- globalOptions = new MapOperations("global", confTree.global);
- }
-
- /**
- * Get the underlying conf tree
- * @return the tree
- */
- public ConfTree getConfTree() {
- return confTree;
- }
-
- /**
- * Validate the configuration
- * @throws BadConfigException
- */
- public void validate() throws BadConfigException {
- validate(null);
- }
-
- /**
- * Validate the configuration
- * @param validator a provided properties validator
- * @throws BadConfigException
- */
- public void validate(InputPropertiesValidator validator) throws BadConfigException {
- String version = confTree.schema;
- if (version == null) {
- throw new BadConfigException("'version' undefined");
- }
- if (!PersistKeys.SCHEMA.equals(version)) {
- throw new BadConfigException(
- "version %s incompatible with supported version %s",
- version,
- PersistKeys.SCHEMA);
- }
- if (validator != null) {
- validator.validate(this);
- }
- }
-
- /**
- * Resolve a ConfTree by mapping all global options into each component
- * -if there is none there already
- */
- public void resolve() {
- for (Map.Entry<String, Map<String, String>> comp : confTree.components.entrySet()) {
- mergeInGlobal(comp.getValue());
- }
- }
-
- /**
- * Merge any options
- * @param component dest values
- */
- public void mergeInGlobal(Map<String, String> component) {
- SliderUtils.mergeMapsIgnoreDuplicateKeys(component, confTree.global);
- }
-
- /**
- * Get operations on the global set
- * @return a wrapped map
- */
- public MapOperations getGlobalOptions() {
- return globalOptions;
- }
-
-
- /**
- * look up a component and return its options
- * @param component component name
- * @return component mapping or null
- */
- public MapOperations getComponent(String component) {
- Map<String, String> instance = confTree.components.get(component);
- if (instance != null) {
- return new MapOperations(component, instance);
- }
- return null;
- }
-
- /**
- * look up a component and return its options with the specified replacements
- * @param component component name
- * @param replacementOptions replacement options
- * @return component mapping or null
- */
- public MapOperations getComponent(String component, Map<String,String>
- replacementOptions) {
- Map<String, String> instance = confTree.components.get(component);
- if (instance != null) {
- Map<String, String> newInstance = new HashMap<>();
- newInstance.putAll(instance);
- newInstance.putAll(replacementOptions);
- return new MapOperations(component, newInstance);
- }
- return null;
- }
-
- /**
- * Get at the underlying component map
- * @return a map of components. This is the raw ConfTree data structure
- */
- public Map<String, Map<String, String>> getComponents() {
- return confTree.components;
- }
-
- /**
- * Get a component -adding it to the components map if
- * none with that name exists
- * @param name role
- * @return role mapping
- */
- public MapOperations getOrAddComponent(String name) {
- MapOperations operations = getComponent(name);
- if (operations != null) {
- return operations;
- }
- //create a new instances
- Map<String, String> map = new HashMap<>();
- confTree.components.put(name, map);
- return new MapOperations(name, map);
- }
-
-
- /*
- * return the Set of names names
- */
- @JsonIgnore
- public Set<String> getComponentNames() {
- return new HashSet<String>(confTree.components.keySet());
- }
-
-
-
- /**
- * Get a component whose presence is mandatory
- * @param name component name
- * @return the mapping
- * @throws BadConfigException if the name is not there
- */
- public MapOperations getMandatoryComponent(String name) throws
- BadConfigException {
- MapOperations ops = getComponent(name);
- if (ops == null) {
- throw new BadConfigException("Missing component " + name);
- }
- return ops;
- }
-
- /**
- * Set a global option, converting it to a string as needed
- * @param key key
- * @param value non null value
- */
- public void set(String key, Object value) {
- globalOptions.put(key, value.toString());
- }
- /**
- * get a global option
- * @param key key
- * @return value or null
- *
- */
- public String get(String key) {
- return globalOptions.get(key);
- }
- /**
- * append to a global option
- * @param key key
- * @return value
- *
- */
- public String append(String key, String value) {
- if (SliderUtils.isUnset(value)) {
- return null;
- }
- if (globalOptions.containsKey(key)) {
- globalOptions.put(key, globalOptions.get(key) + "," + value);
- } else {
- globalOptions.put(key, value);
- }
- return globalOptions.get(key);
- }
-
- /**
- * Propagate all global keys matching a prefix
- * @param src source
- * @param prefix prefix
- */
- public void propagateGlobalKeys(ConfTree src, String prefix) {
- Map<String, String> global = src.global;
- for (Map.Entry<String, String> entry : global.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith(prefix)) {
- set(key, entry.getValue());
- }
- }
- }
-
- /**
- * Propagate all global keys matching a prefix
- * @param src source
- * @param prefix prefix
- */
- public void propagateGlobalKeys(ConfTreeOperations src, String prefix) {
- propagateGlobalKeys(src.confTree, prefix);
- }
-
- /**
- * Merge the map of a single component
- * @param component component name
- * @param map map to merge
- */
- public void mergeSingleComponentMap(String component, Map<String, String> map) {
- MapOperations comp = getOrAddComponent(component);
- comp.putAll(map);
- }
- /**
- * Merge the map of a single component
- * @param component component name
- * @param map map to merge
- */
- public void mergeSingleComponentMapPrefix(String component,
- Map<String, String> map,
- String prefix,
- boolean overwrite) {
- boolean needsMerge = false;
- for (Map.Entry<String, String> entry : map.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith(prefix)) {
- needsMerge = true;
- break;
- }
- }
- if (!needsMerge) {
- return;
- }
- MapOperations comp = getOrAddComponent(component);
- comp.mergeMapPrefixedKeys(map,prefix, overwrite);
- }
-
- /**
- * Merge in components
- * @param commandOptions component options on the CLI
- */
- public void mergeComponents(Map<String, Map<String, String>> commandOptions) {
- for (Map.Entry<String, Map<String, String>> entry : commandOptions.entrySet()) {
- mergeSingleComponentMap(entry.getKey(), entry.getValue());
- }
- }
-
- /**
- * Merge in components
- * @param commandOptions component options on the CLI
- */
- public void mergeComponentsPrefix(Map<String,
- Map<String, String>> commandOptions,
- String prefix,
- boolean overwrite) {
- for (Map.Entry<String, Map<String, String>> entry : commandOptions.entrySet()) {
- mergeSingleComponentMapPrefix(entry.getKey(), entry.getValue(), prefix, overwrite);
- }
- }
-
- /**
- * Merge in another tree -no overwrites of global or conf data
- * (note that metadata does a naive putAll merge/overwrite)
- * @param that the other tree
- */
- public void mergeWithoutOverwrite(ConfTree that) {
-
- getGlobalOptions().mergeWithoutOverwrite(that.global);
- confTree.metadata.putAll(that.metadata);
- confTree.credentials.putAll(that.credentials);
-
- for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) {
- MapOperations comp = getOrAddComponent(entry.getKey());
- comp.mergeWithoutOverwrite(entry.getValue());
- }
- }
-
- /**
- * Merge in another tree with overwrites
- * @param that the other tree
- */
- public void merge(ConfTree that) {
-
- getGlobalOptions().putAll(that.global);
- confTree.metadata.putAll(that.metadata);
- confTree.credentials.putAll(that.credentials);
-
- for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) {
- MapOperations comp = getOrAddComponent(entry.getKey());
- comp.putAll(entry.getValue());
- }
- }
-
-
- /**
- * Load from a resource. The inner conf tree is the loaded data -unresolved
- * @param resource resource
- * @return loaded value
- * @throws IOException load failure
- */
- public static ConfTreeOperations fromResource(String resource) throws
- IOException {
- ConfTreeSerDeser confTreeSerDeser = new ConfTreeSerDeser();
- ConfTreeOperations ops = new ConfTreeOperations(
- confTreeSerDeser.fromResource(resource) );
- return ops;
- }
-
- /**
- * Load from a resource. The inner conf tree is the loaded data -unresolved
- * @param resource resource
- * @return loaded value
- * @throws IOException load failure
- */
- public static ConfTreeOperations fromFile(File resource) throws
- IOException {
- ConfTreeSerDeser confTreeSerDeser = new ConfTreeSerDeser();
- ConfTreeOperations ops = new ConfTreeOperations(
- confTreeSerDeser.fromFile(resource) );
- return ops;
- }
-
- /**
- * Build from an existing instance -which is cloned via JSON ser/deser
- * @param instance the source instance
- * @return loaded value
- * @throws IOException load failure
- */
- public static ConfTreeOperations fromInstance(ConfTree instance) throws
- IOException {
- ConfTreeSerDeser confTreeSerDeser = new ConfTreeSerDeser();
- ConfTreeOperations ops = new ConfTreeOperations(
- confTreeSerDeser.fromJson(confTreeSerDeser.toJson(instance)) );
- return ops;
- }
-
- /**
- * Load from a file and merge it in
- * @param file file
- * @throws IOException any IO problem
- * @throws BadConfigException if the file is invalid
- */
- public void mergeFile(File file) throws IOException, BadConfigException {
- mergeFile(file, null);
- }
-
- /**
- * Load from a file and merge it in
- * @param file file
- * @param validator properties validator
- * @throws IOException any IO problem
- * @throws BadConfigException if the file is invalid
- */
- public void mergeFile(File file, InputPropertiesValidator validator) throws IOException, BadConfigException {
- ConfTreeSerDeser confTreeSerDeser = new ConfTreeSerDeser();
- ConfTree tree = confTreeSerDeser.fromFile(file);
- ConfTreeOperations ops = new ConfTreeOperations(tree);
- ops.validate(validator);
- merge(ops.confTree);
- }
-
- @Override
- public String toString() {
- return confTree.toString();
- }
-
- /**
- * Convert to a JSON string
- * @return a JSON string description
- */
- public String toJson() throws IOException,
- JsonGenerationException,
- JsonMappingException {
- return confTree.toJson();
- }
-
- /**
- * Get a component option
- * @param name component name
- * @param option option name
- * @param defVal default value
- * @return resolved value
- */
- public String getComponentOpt(String name, String option, String defVal) {
- MapOperations roleopts = getComponent(name);
- if (roleopts == null) {
- return defVal;
- }
- return roleopts.getOption(option, defVal);
- }
-
- /**
- * Get a component opt; use {@link Integer#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param name component name
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException if the role could not be parsed.
- */
- public int getComponentOptInt(String name, String option, int defVal) {
- String val = getComponentOpt(name, option, Integer.toString(defVal));
- return Integer.decode(val);
- }
-
- /**
- * Get a component opt as a boolean using {@link Boolean#valueOf(String)}.
- *
- * @param name component name
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException if the role could not be parsed.
- */
- public boolean getComponentOptBool(String name, String option, boolean defVal) {
- String val = getComponentOpt(name, option, Boolean.toString(defVal));
- return Boolean.valueOf(val);
- }
-
- /**
- * Set a component option, creating the component if necessary
- * @param component component name
- * @param option option name
- * @param val value
- */
- public void setComponentOpt(String component, String option, String val) {
- Map<String, String> roleopts = getOrAddComponent(component);
- roleopts.put(option, val);
- }
-
- /**
- * Set an integer role option, creating the role if necessary
- * @param role role name
- * @param option option name
- * @param val integer value
- */
- public void setComponentOpt(String role, String option, int val) {
- setComponentOpt(role, option, Integer.toString(val));
- }
- /**
- * Set a long role option, creating the role if necessary
- * @param role role name
- * @param option option name
- * @param val long value
- */
- public void setComponentOpt(String role, String option, long val) {
- setComponentOpt(role, option, Long.toString(val));
- }
-
- /**
- * append to a component option
- * @param key key
- * @return value
- *
- */
- public String appendComponentOpt(String role, String key, String value) {
- if (SliderUtils.isUnset(value)) {
- return null;
- }
- MapOperations roleopts = getComponent(role);
- if (roleopts == null) {
- return null;
- }
-
- if (roleopts.containsKey(key)) {
- roleopts.put(key, roleopts.get(key) + "," + value);
- } else {
- roleopts.put(key, value);
- }
- return roleopts.get(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/InputPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/InputPropertiesValidator.java b/slider-core/src/main/java/org/apache/slider/core/conf/InputPropertiesValidator.java
deleted file mode 100644
index 237c240..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/InputPropertiesValidator.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.core.conf;
-
-import org.apache.slider.core.exceptions.BadConfigException;
-
-/**
- *
- */
-public interface InputPropertiesValidator {
- void validate(ConfTreeOperations props) throws BadConfigException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java b/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java
deleted file mode 100644
index 9714a0f..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.conf;
-
-import com.google.common.base.Preconditions;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.BadConfigException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Standard map operations.
- *
- * This delegates the standard map interface to the map passed in,
- * so it can be used to add more actions to the map.
- */
-public class MapOperations implements Map<String, String> {
- private static final Logger log =
- LoggerFactory.getLogger(MapOperations.class);
- public static final String DAYS = ".days";
- public static final String HOURS = ".hours";
- public static final String MINUTES = ".minutes";
- public static final String SECONDS = ".seconds";
-
- /**
- * Global options
- */
- public final Map<String, String> options;
-
- public final String name;
-
- public MapOperations() {
- options = new HashMap<String, String>();
- name = "";
- }
-
- /**
- * Create an instance
- * @param name name
- * @param options source of options
- */
- public MapOperations(String name, Map<String, String> options) {
- Preconditions.checkArgument(options != null, "null map");
- this.options = options;
- this.name = name;
- }
-
- /**
- * Create an instance from an iterative map entry
- * @param entry entry to work with
- */
- public MapOperations(Map.Entry<String, Map<String, String>> entry) {
- Preconditions.checkArgument(entry != null, "null entry");
- this.name = entry.getKey();
- this.options = entry.getValue();
- }
-
- /**
- * Get an option value
- *
- * @param key key
- * @param defVal default value
- * @return option in map or the default
- */
- public String getOption(String key, String defVal) {
- String val = options.get(key);
- return val != null ? val : defVal;
- }
-
- /**
- * Get a boolean option
- *
- * @param key option key
- * @param defVal default value
- * @return option true if the option equals "true", or the default value
- * if the option was not defined at all.
- */
- public Boolean getOptionBool(String key, boolean defVal) {
- String val = getOption(key, Boolean.toString(defVal));
- return Boolean.valueOf(val);
- }
-
- /**
- * Get a cluster option or value
- *
- * @param key option key
- * @return the value
- * @throws BadConfigException if the option is missing
- */
-
- public String getMandatoryOption(String key) throws BadConfigException {
- String val = options.get(key);
- if (val == null) {
- if (log.isDebugEnabled()) {
- log.debug("Missing key {} from config containing {}",
- key, this);
- }
- String text = "Missing option " + key;
- if (SliderUtils.isSet(name)) {
- text += " from set " + name;
- }
- throw new BadConfigException(text);
- }
- return val;
- }
-
- /**
- * Get an integer option; use {@link Integer#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException if the role could not be parsed.
- */
- public int getOptionInt(String option, int defVal) {
- String val = getOption(option, Integer.toString(defVal));
- return Integer.decode(val);
- }
-
- /**
- * Get a long option; use {@link Long#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @param defVal default value
- * @return parsed value
- * @throws NumberFormatException
- */
- public long getOptionLong(String option, long defVal) {
- String val = getOption(option, Long.toString(defVal));
- return Long.decode(val);
- }
-
- /**
- * Get a mandatory integer option; use {@link Integer#decode(String)} so as to take hex
- * oct and bin values too.
- *
- * @param option option name
- * @return parsed value
- * @throws NumberFormatException if the option could not be parsed.
- * @throws BadConfigException if the option could not be found
- */
- public int getMandatoryOptionInt(String option) throws BadConfigException {
- getMandatoryOption(option);
- return getOptionInt(option, 0);
- }
-
- /**
- * Verify that an option is set: that is defined AND non-empty
- * @param key
- * @throws BadConfigException
- */
- public void verifyOptionSet(String key) throws BadConfigException {
- if (SliderUtils.isUnset(getOption(key, null))) {
- throw new BadConfigException("Unset option %s", key);
- }
- }
-
- public void mergeWithoutOverwrite(Map<String, String> that) {
- SliderUtils.mergeMapsIgnoreDuplicateKeys(options, that);
- }
-
- /**
- * Merge a map by prefixed keys
- * @param that the map to merge in
- * @param prefix prefix to match on
- * @param overwrite flag to enable overwrite
- */
- public void mergeMapPrefixedKeys(Map<String, String> that,
- String prefix,
- boolean overwrite) {
- for (Map.Entry<String, String> entry : that.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith(prefix)) {
- if (overwrite || get(key) == null) {
- put(key, entry.getValue());
- }
- }
- }
- }
-
- /**
- * Set a property if it is not already set
- * @param key key
- * @param value value
- */
- public void putIfUnset(String key, String value) {
- if (get(key) == null) {
- put(key, value);
- }
- }
-
- public void set(String key, Object value) {
- assert value != null;
- put(key, value.toString());
- }
-
- public int size() {
- return options.size();
- }
-
- public boolean isEmpty() {
- return options.isEmpty();
- }
-
- public boolean containsValue(Object value) {
- return options.containsValue(value);
- }
-
- public boolean containsKey(Object key) {
- return options.containsKey(key);
- }
-
- public String get(Object key) {
- return options.get(key);
- }
-
- public String put(String key, String value) {
- return options.put(key, value);
- }
-
- public String remove(Object key) {
- return options.remove(key);
- }
-
- public void putAll(Map<? extends String, ? extends String> m) {
- options.putAll(m);
- }
-
- public void clear() {
- options.clear();
- }
-
- public Set<String> keySet() {
- return options.keySet();
- }
-
- public Collection<String> values() {
- return options.values();
- }
-
- public Set<Map.Entry<String, String>> entrySet() {
- return options.entrySet();
- }
-
- @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
- public boolean equals(Object o) {
- return options.equals(o);
- }
-
- @Override
- public int hashCode() {
- return options.hashCode();
- }
-
- public boolean isSet(String key) {
- return SliderUtils.isSet(get(key));
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(name).append("=\n");
-
- for (Entry<String, String> entry : options.entrySet()) {
- builder.append(" ")
- .append(entry.getKey())
- .append('=')
- .append(entry.getValue())
- .append('\n');
- }
- return builder.toString();
- }
-
- /**
- * Get the time range of a set of keys
- * @param basekey base key to which suffix gets applied
- * @param defDays
- * @param defHours
- * @param defMins
- * @param defSecs
- * @return the aggregate time range in seconds
- */
- public long getTimeRange(String basekey,
- int defDays,
- int defHours,
- int defMins,
- int defSecs) {
- Preconditions.checkArgument(basekey != null);
- int days = getOptionInt(basekey + DAYS, defDays);
- int hours = getOptionInt(basekey + HOURS, defHours);
-
- int minutes = getOptionInt(basekey + MINUTES, defMins);
- int seconds = getOptionInt(basekey + SECONDS, defSecs);
- // range check
- Preconditions.checkState(days >= 0 && hours >= 0 && minutes >= 0
- && seconds >= 0,
- "Time range for %s has negative time component %s:%s:%s:%s",
- basekey, days, hours, minutes, seconds);
-
- // calculate total time, schedule the reset if expected
- long totalMinutes = (long) days * 24 * 60 + (long) hours * 24 + minutes;
- return totalMinutes * 60 + seconds;
- }
-
- /**
- * Get all entries with a specific prefix
- * @param prefix prefix
- * @return a prefixed map, possibly empty
- */
- public Map<String, String> prefixedWith(String prefix) {
-
- Map<String, String> prefixed = new HashMap<>(size());
- for (Entry<String, String> entry: entrySet()) {
- if (entry.getKey().startsWith(prefix)) {
- prefixed.put(entry.getKey(), entry.getValue());
- }
- }
- return prefixed;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/ResourcesInputPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/ResourcesInputPropertiesValidator.java b/slider-core/src/main/java/org/apache/slider/core/conf/ResourcesInputPropertiesValidator.java
deleted file mode 100644
index 19f6f8d..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/ResourcesInputPropertiesValidator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.core.conf;
-
-import org.apache.slider.api.ResourceKeys;
-import org.apache.slider.core.exceptions.BadConfigException;
-
-/**
- *
- */
-public class ResourcesInputPropertiesValidator
- extends AbstractInputPropertiesValidator {
-
- void validatePropertyNamePrefix(String key) throws BadConfigException {
- if (!key.startsWith("yarn.") && !key.equals(ResourceKeys.UNIQUE_NAMES)) {
- throw new BadConfigException(
- "argument %s does not have 'yarn.' prefix", key);
- }
- }
-
- protected void validateGlobalProperties(ConfTreeOperations props)
- throws BadConfigException {
- for (String key : props.getGlobalOptions().keySet()) {
- validatePropertyNamePrefix(key);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/conf/TemplateInputPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/conf/TemplateInputPropertiesValidator.java b/slider-core/src/main/java/org/apache/slider/core/conf/TemplateInputPropertiesValidator.java
deleted file mode 100644
index aad2757..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/conf/TemplateInputPropertiesValidator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.slider.core.conf;
-
-import org.apache.slider.core.exceptions.BadConfigException;
-
-/**
- *
- */
-public class TemplateInputPropertiesValidator
- extends AbstractInputPropertiesValidator {
-
- void validatePropertyNamePrefix(String key) throws BadConfigException {
- if (key.startsWith("yarn.")) {
- throw new BadConfigException(
- "argument %s has 'yarn.' prefix - this is not allowed in templates", key);
- }
- }
-
- @Override
- void validateGlobalProperties(ConfTreeOperations props) {
- // do nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/exceptions/BadClusterStateException.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadClusterStateException.java b/slider-core/src/main/java/org/apache/slider/core/exceptions/BadClusterStateException.java
deleted file mode 100644
index e73ce57..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadClusterStateException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-
-/**
- * The system is in a bad state
- */
-public class BadClusterStateException extends SliderException {
- public BadClusterStateException(String message,
- Object... args) {
- super(EXIT_BAD_STATE, message, args);
- }
-
- public BadClusterStateException(Throwable throwable,
- String message, Object... args) {
- super(EXIT_BAD_STATE, throwable, message, args);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/exceptions/BadCommandArgumentsException.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadCommandArgumentsException.java b/slider-core/src/main/java/org/apache/slider/core/exceptions/BadCommandArgumentsException.java
deleted file mode 100644
index 0d5d686..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadCommandArgumentsException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-public class BadCommandArgumentsException extends SliderException {
- public BadCommandArgumentsException(String s, Object... args) {
- super(EXIT_COMMAND_ARGUMENT_ERROR, s, args);
- }
-
- public BadCommandArgumentsException(Throwable throwable, String message,
- Object... args) {
- super(EXIT_COMMAND_ARGUMENT_ERROR, throwable, message, args);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/exceptions/BadConfigException.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadConfigException.java b/slider-core/src/main/java/org/apache/slider/core/exceptions/BadConfigException.java
deleted file mode 100644
index 65a8ea8..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/exceptions/BadConfigException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-/**
- * An exception to raise on a bad configuration
- */
-public class BadConfigException extends SliderException {
-
- public BadConfigException(String s) {
- super(EXIT_BAD_CONFIGURATION, s);
- }
-
- public BadConfigException(String message, Object... args) {
- super(EXIT_BAD_CONFIGURATION, message, args);
- }
-
- public BadConfigException(
- Throwable throwable,
- String message, Object... args) {
- super(EXIT_BAD_CONFIGURATION, throwable, message, args);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/java/org/apache/slider/core/exceptions/ErrorStrings.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/exceptions/ErrorStrings.java b/slider-core/src/main/java/org/apache/slider/core/exceptions/ErrorStrings.java
deleted file mode 100644
index 8b04969..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/exceptions/ErrorStrings.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.core.exceptions;
-
-public interface ErrorStrings {
- String E_UNSTABLE_CLUSTER = "Unstable Application Instance :";
- String E_CLUSTER_RUNNING = "Application Instance running";
- String E_ALREADY_EXISTS = "already exists";
- String PRINTF_E_INSTANCE_ALREADY_EXISTS = "Application Instance \"%s\" already exists and is defined in %s";
- String PRINTF_E_INSTANCE_DIR_ALREADY_EXISTS = "Application Instance dir already exists: %s";
- String E_MISSING_PATH = "Missing path ";
- String E_INCOMPLETE_CLUSTER_SPEC =
- "Cluster specification is marked as incomplete: ";
- String E_UNKNOWN_INSTANCE = "Unknown application instance ";
- String E_DESTROY_CREATE_RACE_CONDITION =
- "created while it was being destroyed";
- String E_UNKNOWN_ROLE = "Unknown role ";
- /**
- * ERROR Strings
- */
- String ERROR_NO_ACTION = "No action specified";
- String ERROR_UNKNOWN_ACTION = "Unknown command: ";
- String ERROR_NOT_ENOUGH_ARGUMENTS =
- "Not enough arguments for action: ";
- String ERROR_PARSE_FAILURE =
- "Failed to parse ";
- /**
- * All the remaining values after argument processing
- */
- String ERROR_TOO_MANY_ARGUMENTS =
- "Too many arguments";
- String ERROR_DUPLICATE_ENTRY = "Duplicate entry for ";
- String E_APPLICATION_NOT_RUNNING = "Application not running";
- String E_FINISHED_APPLICATION = E_APPLICATION_NOT_RUNNING + ": %s state=%s ";
- String E_NO_IMAGE_OR_HOME_DIR_SPECIFIED =
- "Neither an image path nor binary home directory were specified";
- String E_BOTH_IMAGE_AND_HOME_DIR_SPECIFIED =
- "Both application image path and home dir have been provided";
- String E_CONFIGURATION_DIRECTORY_NOT_FOUND =
- "Configuration directory \"%s\" not found";
-}