Author: stevel Date: Mon May 19 19:24:40 2014 New Revision: 1595998 URL: http://svn.apache.org/r1595998 Log: IDE review of package org.apache.slider packages
Removed: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AMRestartSupport.java incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/common/tools/TestSliderServiceUtils.groovy Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/ClasspathConstructor.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/CommandLineBuilder.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/persist/ConfPersister.java incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/registry/zk/ZKIntegration.java Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/api/ClusterDescription.java Mon May 19 19:24:40 2014 @@ -165,40 +165,40 @@ public class ClusterDescription implemen * the Slider AM and the application that it deploys */ public Map<String, String> options = - new HashMap<String, String>(); + new HashMap<>(); /** * cluster information * This is only valid when querying the cluster status. */ public Map<String, String> info = - new HashMap<String, String>(); + new HashMap<>(); /** * Statistics. This is only relevant when querying the cluster status */ public Map<String, Map<String, Integer>> statistics = - new HashMap<String, Map<String, Integer>>(); + new HashMap<>(); /** * Instances: role->count */ public Map<String, List<String>> instances = - new HashMap<String, List<String>>(); + new HashMap<>(); /** * Role options, * role -> option -> value */ public Map<String, Map<String, String>> roles = - new HashMap<String, Map<String, String>>(); + new HashMap<>(); /** * List of key-value pairs to add to a client config to set up the client */ public Map<String, String> clientProperties = - new HashMap<String, String>(); + new HashMap<>(); /** * Status information @@ -569,7 +569,7 @@ public class ClusterDescription implemen */ @JsonIgnore public Set<String> getRoleNames() { - return new HashSet<String>(roles.keySet()); + return new HashSet<>(roles.keySet()); } /** Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java Mon May 19 19:24:40 2014 @@ -608,13 +608,14 @@ public class SliderClient extends Abstra * @param name cluster name * @param resolved flag to indicate the cluster should be resolved * @return the loaded configuration - * @throws IOException - * @throws SliderException + * @throws IOException IO problems + * @throws SliderException slider explicit issues * @throws UnknownApplicationInstanceException if the file is not found */ - public AggregateConf loadInstanceDefinition(String name, boolean resolved) throws - IOException, - SliderException { + public AggregateConf loadInstanceDefinition(String name, + boolean resolved) throws + IOException, + SliderException { Path clusterDirectory = sliderFileSystem.buildClusterDirPath(name); AggregateConf instanceDefinition = loadInstanceDefinitionUnresolved( @@ -692,7 +693,7 @@ public class SliderClient extends Abstra // add the tags if available Set<String> applicationTags = provider.getApplicationTags(sliderFileSystem, - appOperations.getGlobalOptions().get(AgentKeys.APP_DEF)); + appOperations.getGlobalOptions().get(AgentKeys.APP_DEF)); AppMasterLauncher amLauncher = new AppMasterLauncher(clustername, SliderKeys.APP_TYPE, config, Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java Mon May 19 19:24:40 2014 @@ -69,10 +69,10 @@ public class SliderYarnClientImpl extend */ public List<ApplicationReport> listInstances(String user) throws YarnException, IOException { - Set<String> types = new HashSet<String>(1); + Set<String> types = new HashSet<>(1); types.add(SliderKeys.APP_TYPE); List<ApplicationReport> allApps = getApplications(types); - List<ApplicationReport> results = new ArrayList<ApplicationReport>(); + List<ApplicationReport> results = new ArrayList<>(); for (ApplicationReport report : allApps) { if (user == null || user.equals(report.getUser())) { results.add(report); @@ -96,7 +96,7 @@ public class SliderYarnClientImpl extend YarnException { List<ApplicationReport> instances = listInstances(user); List<ApplicationReport> results = - new ArrayList<ApplicationReport>(instances.size()); + new ArrayList<>(instances.size()); for (ApplicationReport report : instances) { if (report.getName().equals(appname)) { results.add(report); @@ -239,7 +239,7 @@ public class SliderYarnClientImpl extend IOException { List<ApplicationReport> instances = listInstances(user); List<ApplicationReport> results = - new ArrayList<ApplicationReport>(instances.size()); + new ArrayList<>(instances.size()); for (ApplicationReport app : instances) { if (app.getName().equals(appname) && isApplicationLive(app)) { Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTree.java Mon May 19 19:24:40 2014 @@ -55,15 +55,14 @@ public final class ConfTree { /** * Metadata */ - public Map<String, Object> metadata = new HashMap<String, Object>( - INITAL_MAP_CAPACITY); + public Map<String, Object> metadata = new HashMap<>(INITAL_MAP_CAPACITY); /** * Global options */ public Map<String, String> global = - new HashMap<String, String>(INITAL_MAP_CAPACITY); + new HashMap<>(INITAL_MAP_CAPACITY); /** @@ -71,7 +70,7 @@ public final class ConfTree { * role -> option -> value */ public Map<String, Map<String, String>> components = - new HashMap<String, Map<String, String>>(INITAL_MAP_CAPACITY); + new HashMap<>(INITAL_MAP_CAPACITY); /** Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/ConfTreeOperations.java Mon May 19 19:24:40 2014 @@ -148,7 +148,7 @@ public class ConfTreeOperations { return operations; } //create a new instances - Map<String, String> map = new HashMap<String, String>(); + Map<String, String> map = new HashMap<>(); confTree.components.put(name, map); return new MapOperations(name, map); } @@ -159,7 +159,7 @@ public class ConfTreeOperations { */ @JsonIgnore public Set<String> getComponentNames() { - return new HashSet<String>(confTree.components.keySet()); + return new HashSet<>(confTree.components.keySet()); } Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/conf/MapOperations.java Mon May 19 19:24:40 2014 @@ -46,7 +46,7 @@ public class MapOperations implements Ma public final String name; public MapOperations() { - options = new HashMap<String, String>(); + options = new HashMap<>(); name = ""; } Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/AbstractLauncher.java Mon May 19 19:24:40 2014 @@ -57,15 +57,15 @@ public abstract class AbstractLauncher e /** * Env vars; set up at final launch stage */ - protected final Map<String, String> envVars = new HashMap<String, String>(); + protected final Map<String, String> envVars = new HashMap<>(); protected final MapOperations env = new MapOperations("env", envVars); protected final ContainerLaunchContext containerLaunchContext = Records.newRecord(ContainerLaunchContext.class); - protected final List<String> commands = new ArrayList<String>(20); + protected final List<String> commands = new ArrayList<>(20); protected final Map<String, LocalResource> localResources = - new HashMap<String, LocalResource>(); + new HashMap<>(); private final Map<String, ByteBuffer> serviceData = - new HashMap<String, ByteBuffer>(); + new HashMap<>(); // security Credentials credentials = new Credentials(); @@ -266,7 +266,7 @@ public abstract class AbstractLauncher e public String[] dumpEnvToString() { - List<String> nodeEnv = new ArrayList<String>(); + List<String> nodeEnv = new ArrayList<>(); for (Map.Entry<String, String> entry : env.entrySet()) { String envElt = String.format("%s=\"%s\"", Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/ClasspathConstructor.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/ClasspathConstructor.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/ClasspathConstructor.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/ClasspathConstructor.java Mon May 19 19:24:40 2014 @@ -40,7 +40,7 @@ public class ClasspathConstructor { // public static final String CLASS_PATH_SEPARATOR = ApplicationConstants.CLASS_PATH_SEPARATOR; public static final String CLASS_PATH_SEPARATOR = File.pathSeparator; - private final List<String> pathElements = new ArrayList<String>(); + private final List<String> pathElements = new ArrayList<>(); public ClasspathConstructor() { } @@ -54,8 +54,8 @@ public class ClasspathConstructor { String[] cp = config.getTrimmedStrings( YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH); - return cp!= null ? Arrays.asList(cp) : new ArrayList<String>(0); - + return cp != null ? Arrays.asList(cp) : new ArrayList<String>(0); + } Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/CommandLineBuilder.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/CommandLineBuilder.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/CommandLineBuilder.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/launch/CommandLineBuilder.java Mon May 19 19:24:40 2014 @@ -30,12 +30,12 @@ import java.util.List; * Special support for JVM command buildup. */ public class CommandLineBuilder { - protected final List<String> argumentList = new ArrayList<String>(20); + protected final List<String> argumentList = new ArrayList<>(20); /** * Add an entry to the command list - * @param arg argument -this will be converted to a string + * @param args arguments -these will be converted strings */ public void add(Object... args) { for (Object arg : args) { Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java Mon May 19 19:24:40 2014 @@ -30,6 +30,7 @@ import org.apache.hadoop.yarn.YarnUncaug import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; @@ -86,7 +87,7 @@ public class ServiceLauncher<S extends S private volatile S service; private int serviceExitCode; - private final List<IrqHandler> interruptHandlers = new ArrayList<IrqHandler>(1); + private final List<IrqHandler> interruptHandlers = new ArrayList<>(1); private Configuration configuration; private String serviceClassName; private static AtomicBoolean signalAlreadyReceived = new AtomicBoolean(false); @@ -217,14 +218,16 @@ public class ServiceLauncher<S extends S ClassNotFoundException, InstantiationException, IllegalAccessException, - ExitUtil.ExitException { + ExitUtil.ExitException, + NoSuchMethodException, + InvocationTargetException { configuration = conf; //Instantiate the class -this requires the service to have a public // zero-argument constructor Class<?> serviceClass = this.getClass().getClassLoader().loadClass(serviceClassName); - Object instance = serviceClass.newInstance(); + Object instance = serviceClass.getConstructor().newInstance(); if (!(instance instanceof Service)) { //not a service throw new ExitUtil.ExitException(EXIT_BAD_CONFIGURATION, @@ -341,7 +344,7 @@ public class ServiceLauncher<S extends S /** * Parse the command line, building a configuration from it, then * launch the service and wait for it to finish. finally, exit - * passing the status code to the {@link #exit(int)} method. + * passing the status code to the #exit(int) method. * @param args arguments to the service. arg[0] is * assumed to be the service classname and is automatically */ @@ -371,7 +374,7 @@ public class ServiceLauncher<S extends S if (argCount <= 1 ) { return new String[0]; } - List<String> argsList = new ArrayList<String>(argCount); + List<String> argsList = new ArrayList<>(argCount); ListIterator<String> arguments = args.listIterator(); //skip that first entry arguments.next(); Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/main/ServiceShutdownHook.java Mon May 19 19:24:40 2014 @@ -39,7 +39,7 @@ public class ServiceShutdownHook impleme private Runnable hook; public ServiceShutdownHook(Service service) { - serviceRef = new WeakReference<Service>(service); + serviceRef = new WeakReference<>(service); } public void register(int priority) { Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/persist/ConfPersister.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/persist/ConfPersister.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/persist/ConfPersister.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/persist/ConfPersister.java Mon May 19 19:24:40 2014 @@ -70,7 +70,7 @@ public class ConfPersister { LoggerFactory.getLogger(ConfPersister.class); - private final ConfTreeSerDeser confTreeSerDeser =new ConfTreeSerDeser(); + private final ConfTreeSerDeser confTreeSerDeser = new ConfTreeSerDeser(); private final CoreFileSystem coreFS; private final FileSystem fileSystem; Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/registry/zk/ZKIntegration.java URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/registry/zk/ZKIntegration.java?rev=1595998&r1=1595997&r2=1595998&view=diff ============================================================================== --- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/registry/zk/ZKIntegration.java (original) +++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/core/registry/zk/ZKIntegration.java Mon May 19 19:24:40 2014 @@ -198,7 +198,7 @@ public class ZKIntegration implements Wa CreateMode createMode) throws KeeperException, InterruptedException { //initial create of full path assert acl != null; - assert acl.size() > 0; + assert !acl.isEmpty(); assert parent != null; String path = parent; if (entry != null) { @@ -226,7 +226,7 @@ public class ZKIntegration implements Wa CreateMode createMode) throws KeeperException, InterruptedException { String history = "/"; for (String entry : paths) { - createPath(history, ((String) entry), acl, createMode); + createPath(history, entry, acl, createMode); history = history + entry + "/"; } } @@ -236,7 +236,7 @@ public class ZKIntegration implements Wa * @return an unordered list of clusters under a user */ public List<String> getClusters() throws KeeperException, InterruptedException { - return zookeeper.getChildren(userPath, (Watcher) null); + return zookeeper.getChildren(userPath, null); } /**