Removed * imports. Improved code formatting and refactored code.
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/041cc678 Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/041cc678 Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/041cc678 Branch: refs/heads/master Commit: 041cc678333834fcd9a5d3fe263f4b3cf8a29bd7 Parents: d63d91f Author: Imesha Sudasingha <[email protected]> Authored: Tue Jul 11 08:30:18 2017 +0530 Committer: Imesha Sudasingha <[email protected]> Committed: Tue Jul 11 08:30:18 2017 +0530 ---------------------------------------------------------------------- README.md | 26 ++++++---- .../java/org/apache/oodt/config/Component.java | 50 ++++++++++++++++++++ .../oodt/config/ConfigurationManager.java | 6 +-- .../config/ConfigurationManagerFactory.java | 2 +- .../java/org/apache/oodt/config/Constants.java | 21 -------- .../DistributedConfigurationManager.java | 11 +++-- .../oodt/config/distributed/ZNodePaths.java | 8 +++- .../config/distributed/cli/CmdLineOptions.java | 3 +- .../cli/DistributedConfigurationPublisher.java | 15 +++--- .../config/distributed/utils/CuratorUtils.java | 13 ++--- .../StandaloneConfigurationManager.java | 4 +- .../cas/filemgr/system/XmlRpcFileManager.java | 34 ++++++++++--- 12 files changed, 130 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 2337b92..46e7fd5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Welcome to Apache OODT <http://oodt.apache.org/> +============================================================= + Welcome to Apache OODT <http://oodt.apache.org/> +============================================================= OODT is a grid middleware framework used on a number of successful projects at NASA's Jet Propulsion Laboratory/California Institute of Technology, and many @@ -17,7 +19,8 @@ other research institutions and universities, specifically those part of the: OODT is a Top Level project of the Apache Software Foundation <http://www.apache.org/>. -## Getting Started +Getting Started +=============== OODT is primarily written in Java, with some components available in Python. It requires Java 5 and uses the Maven 2 <http://maven.apache.org/> build @@ -28,8 +31,8 @@ this directory: For the Python components, see the "agility" subdirectory. -## Contributing - +Contributing +============ To contribute a patch, follow these instructions (note that installing [Hub](http://hub.github.com) is not strictly required, but is recommended). @@ -50,7 +53,8 @@ To contribute a patch, follow these instructions (note that installing ``` -## License (see also LICENSE.txt) +License (see also LICENSE.txt) +============================== Collective work: Copyright 2010-2012 The Apache Software Foundation. @@ -73,7 +77,8 @@ Apache OODT includes a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the licenses listed in the LICENSE.txt file. -## Export control +Export control +============== This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or @@ -99,7 +104,8 @@ The following provides more details on the included cryptographic software: encrypted PDF files. See http://www.bouncycastle.org/ for more details on Bouncy Castle. -## Documentation +Documentation +============= You can build a local copy of the OODT documentation including JavaDocs using the following Maven 2 command in the OODT source directory: @@ -119,7 +125,8 @@ than likely you'll need to add to the MAVEN_OPTS environment variable in order to set the Java heap maximum size with "-Xmx512m" or larger before attempting to run "mvn site". -## Mailing Lists +Mailing Lists +============= Discussion about OODT takes place on the following mailing lists: @@ -137,7 +144,8 @@ dev-subscribe@oodt...). To unsubscribe, send a message to <LIST>[email protected]. For more instructions, send a message to <LIST>[email protected]. -## Issue Tracker +Issue Tracker +============= If you encounter errors in OODT or want to suggest an improvement or a new feature, please visit the OODT issue tracker http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/Component.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/Component.java b/config/src/main/java/org/apache/oodt/config/Component.java new file mode 100644 index 0000000..2c7123e --- /dev/null +++ b/config/src/main/java/org/apache/oodt/config/Component.java @@ -0,0 +1,50 @@ +/* + * 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.oodt.config; + +/** + * An enum to represent available OODT components and their corresponding names to be used when setting up configuration + * management. + * + * @author Imesha Sudasingha + */ +public enum Component { + FILE_MANAGER("filemgr", "FILEMGR_HOME"), + RESOURCE_MANAGER("resmgr", "RESMGR_HOME"); + + /** Shorthand name of the component. Will be used when creating ZNodes in zookeeper */ + String name; + /** + * Environment variable of ${COMPONENT_HOME} which will be set by the executing script when running that component. + * For example, ${FILEMGR_HOME} will be set by the {@link #FILE_MANAGER} bash script. + */ + String home; + + Component(String name, String home) { + this.name = name; + this.home = home; + } + + public String getName() { + return name; + } + + public String getHome() { + return home; + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java index d4706a2..56fea0d 100644 --- a/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java +++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManager.java @@ -24,15 +24,15 @@ package org.apache.oodt.config; */ public abstract class ConfigurationManager { - protected Constants.Component component; + protected Component component; - public ConfigurationManager(Constants.Component component) { + public ConfigurationManager(Component component) { this.component = component; } public abstract void loadConfiguration() throws Exception; - public Constants.Component getComponent() { + public Component getComponent() { return component; } } http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java b/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java index e616f96..9eecfaa 100644 --- a/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java +++ b/config/src/main/java/org/apache/oodt/config/ConfigurationManagerFactory.java @@ -50,7 +50,7 @@ public class ConfigurationManagerFactory { * management * @return ConfigurationManager instance to used by the corresponding component. */ - public static ConfigurationManager getConfigurationManager(Constants.Component component, List<String> propertiesFiles) { + public static ConfigurationManager getConfigurationManager(Component component, List<String> propertiesFiles) { if (Boolean.getBoolean(ENABLE_DISTRIBUTED_CONFIGURATION)) { logger.info("Using distributed configuration management for {}", component); return new DistributedConfigurationManager(component); http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/Constants.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/Constants.java b/config/src/main/java/org/apache/oodt/config/Constants.java index 5fb62ed..0453eaa 100644 --- a/config/src/main/java/org/apache/oodt/config/Constants.java +++ b/config/src/main/java/org/apache/oodt/config/Constants.java @@ -61,27 +61,6 @@ public class Constants { public static final String ZK_PASSWORD = "org.apache.oodt.config.zk.password"; } - public enum Component { - FILE_MANAGER("filemgr", "FILEMGR_HOME"), - RESOURCE_MANAGER("resmgr", "RESMGR_HOME"); - - String name; - String home; - - Component(String name, String home) { - this.name = name; - this.home = home; - } - - public String getName() { - return name; - } - - public String getHome() { - return home; - } - } - public static class ZPaths { /** Separator for ZNode paths */ public static final String SEPARATOR = "/"; http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java index a5f1ef6..6572270 100644 --- a/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java +++ b/config/src/main/java/org/apache/oodt/config/distributed/DistributedConfigurationManager.java @@ -19,6 +19,7 @@ package org.apache.oodt.config.distributed; import org.apache.commons.io.FileUtils; import org.apache.curator.framework.CuratorFramework; +import org.apache.oodt.config.Component; import org.apache.oodt.config.ConfigurationManager; import org.apache.oodt.config.Constants; import org.apache.oodt.config.Constants.Properties; @@ -38,8 +39,8 @@ import static org.apache.oodt.config.Constants.Properties.ZK_PROPERTIES_FILE; import static org.apache.oodt.config.Constants.SEPARATOR; /** - * Distributed configuration manager implementation. This class make use of a {@link CuratorFramework} instance to connect - * to zookeeper + * Distributed configuration manager implementation. This class make use of a {@link CuratorFramework} instance to + * connect to zookeeper * * @author Imesha Sudasingha. */ @@ -51,10 +52,10 @@ public class DistributedConfigurationManager extends ConfigurationManager { private String connectString; private CuratorFramework client; /** Name of the OODT component, to which this class is providing configuration support */ - private Constants.Component component; + private Component component; private ZNodePaths zNodePaths; - public DistributedConfigurationManager(Constants.Component component) { + public DistributedConfigurationManager(Component component) { super(component); this.component = component; this.zNodePaths = new ZNodePaths(this.component.getName()); @@ -182,7 +183,7 @@ public class DistributedConfigurationManager extends ConfigurationManager { return path.toString(); } - public Constants.Component getComponent() { + public Component getComponent() { return component; } http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java b/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java index eb40fa4..01792ba 100644 --- a/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java +++ b/config/src/main/java/org/apache/oodt/config/distributed/ZNodePaths.java @@ -17,7 +17,10 @@ package org.apache.oodt.config.distributed; -import static org.apache.oodt.config.Constants.ZPaths.*; +import static org.apache.oodt.config.Constants.ZPaths.COMPONENTS_PATH_NAME; +import static org.apache.oodt.config.Constants.ZPaths.CONFIGURATION_PATH_NAME; +import static org.apache.oodt.config.Constants.ZPaths.PROPERTIES_PATH_NAME; +import static org.apache.oodt.config.Constants.ZPaths.SEPARATOR; /** * Class responsible for handling all the Zookeeper ZNode paths related to configuration @@ -39,7 +42,8 @@ public class ZNodePaths { private String configurationZNodeRoot; /** - * Creates the ZNode path structure accordingly to the <pre>componentName</pre> and <pre>propertiesFileNames</pre> given. + * Creates the ZNode path structure accordingly to the <pre>componentName</pre> and <pre>propertiesFileNames</pre> + * given. * * @param componentName Name of the OODT component */ http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/distributed/cli/CmdLineOptions.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/cli/CmdLineOptions.java b/config/src/main/java/org/apache/oodt/config/distributed/cli/CmdLineOptions.java index b6972d5..a262387 100644 --- a/config/src/main/java/org/apache/oodt/config/distributed/cli/CmdLineOptions.java +++ b/config/src/main/java/org/apache/oodt/config/distributed/cli/CmdLineOptions.java @@ -30,7 +30,8 @@ public class CmdLineOptions { private String connectString; @Option(name = "-publish", usage = "Publishes configuration specified in the spring config file to zookeeper. " + - "Any current similar config in zookeeper will be overwritten. If not specified, command will be assumed as a publish") + "Any current similar config in zookeeper will be overwritten. If not specified, " + + "command will be assumed as a publish") private boolean publish = false; @Option(name = "-verify", usage = "Verifies the content in the local files and the published ones. Results will be printed.") http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java b/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java index 0036664..25a45ba 100644 --- a/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java +++ b/config/src/main/java/org/apache/oodt/config/distributed/cli/DistributedConfigurationPublisher.java @@ -19,6 +19,7 @@ package org.apache.oodt.config.distributed.cli; import org.apache.commons.io.FileUtils; import org.apache.curator.framework.CuratorFramework; +import org.apache.oodt.config.Component; import org.apache.oodt.config.Constants; import org.apache.oodt.config.distributed.ZNodePaths; import org.apache.oodt.config.distributed.utils.CuratorUtils; @@ -54,9 +55,9 @@ public class DistributedConfigurationPublisher { private String connectString; private CuratorFramework client; private ZNodePaths zNodePaths; - private Constants.Component component; + private Component component; - public DistributedConfigurationPublisher(Constants.Component component) { + public DistributedConfigurationPublisher(Component component) { this.component = component; this.zNodePaths = new ZNodePaths(this.component.getName()); @@ -83,8 +84,8 @@ public class DistributedConfigurationPublisher { } /** - * Creates a {@link CuratorFramework} instance and start it. This method will wait a maximum amount of - * {@link Constants.Properties#ZK_STARTUP_TIMEOUT} milli-seconds until the client connects to the zookeeper ensemble. + * Creates a {@link CuratorFramework} instance and start it. This method will wait a maximum amount of {@link + * Constants.Properties#ZK_STARTUP_TIMEOUT} milli-seconds until the client connects to the zookeeper ensemble. */ private void startZookeeper() { client = CuratorUtils.newCuratorFrameworkClient(connectString, logger); @@ -135,8 +136,8 @@ public class DistributedConfigurationPublisher { } /** - * Verified whether the actual content of the local files specified to be published are 100% similar to the ones that - * has been published and stored in zookeeper at the moment. + * Verified whether the actual content of the local files specified to be published are 100% similar to the ones + * that has been published and stored in zookeeper at the moment. * * @return true | if content are up to date and similar */ @@ -324,7 +325,7 @@ public class DistributedConfigurationPublisher { logger.info("Exiting CLI ..."); } - public Constants.Component getComponent() { + public Component getComponent() { return component; } } http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/distributed/utils/CuratorUtils.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/distributed/utils/CuratorUtils.java b/config/src/main/java/org/apache/oodt/config/distributed/utils/CuratorUtils.java index e591750..6f2ff27 100644 --- a/config/src/main/java/org/apache/oodt/config/distributed/utils/CuratorUtils.java +++ b/config/src/main/java/org/apache/oodt/config/distributed/utils/CuratorUtils.java @@ -35,7 +35,8 @@ import java.util.ArrayList; import java.util.List; import static org.apache.oodt.config.Constants.Properties.ZK_PROPERTIES_FILE; -import static org.apache.oodt.config.Constants.ZPaths.*; +import static org.apache.oodt.config.Constants.ZPaths.NAMESPACE; +import static org.apache.oodt.config.Constants.ZPaths.SEPARATOR; public class CuratorUtils { @@ -111,11 +112,11 @@ public class CuratorUtils { int maxRetryCount = Integer.parseInt(System.getProperty(Constants.Properties.ZK_CONNECTION_TIMEOUT, "3")); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() - .namespace(NAMESPACE) - .connectString(connectString) - .retryPolicy(new ExponentialBackoffRetry(retryInitialWaitMs, maxRetryCount)) - .connectionTimeoutMs(connectionTimeoutMs) - .sessionTimeoutMs(sessionTimeoutMs); + .namespace(NAMESPACE) + .connectString(connectString) + .retryPolicy(new ExponentialBackoffRetry(retryInitialWaitMs, maxRetryCount)) + .connectionTimeoutMs(connectionTimeoutMs) + .sessionTimeoutMs(sessionTimeoutMs); /* * If authorization information is available, those will be added to the client. NOTE: These auth info are http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java b/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java index 3e82580..cc3fe1a 100644 --- a/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java +++ b/config/src/main/java/org/apache/oodt/config/standalone/StandaloneConfigurationManager.java @@ -17,8 +17,8 @@ package org.apache.oodt.config.standalone; +import org.apache.oodt.config.Component; import org.apache.oodt.config.ConfigurationManager; -import org.apache.oodt.config.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +38,7 @@ public class StandaloneConfigurationManager extends ConfigurationManager { private List<String> propertiesFiles; - public StandaloneConfigurationManager(Constants.Component component, List<String> propertiesFiles) { + public StandaloneConfigurationManager(Component component, List<String> propertiesFiles) { super(component); this.propertiesFiles = propertiesFiles != null ? propertiesFiles : new ArrayList<String>(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/041cc678/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java index 60ee1bf..aa7075c 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java @@ -25,8 +25,20 @@ import org.apache.oodt.cas.filemgr.datatransfer.TransferStatusTracker; import org.apache.oodt.cas.filemgr.metadata.ProductMetKeys; import org.apache.oodt.cas.filemgr.metadata.extractors.FilemgrMetExtractor; import org.apache.oodt.cas.filemgr.repository.RepositoryManager; -import org.apache.oodt.cas.filemgr.structs.*; -import org.apache.oodt.cas.filemgr.structs.exceptions.*; +import org.apache.oodt.cas.filemgr.structs.Element; +import org.apache.oodt.cas.filemgr.structs.ExtractorSpec; +import org.apache.oodt.cas.filemgr.structs.FileTransferStatus; +import org.apache.oodt.cas.filemgr.structs.Product; +import org.apache.oodt.cas.filemgr.structs.ProductPage; +import org.apache.oodt.cas.filemgr.structs.ProductType; +import org.apache.oodt.cas.filemgr.structs.Query; +import org.apache.oodt.cas.filemgr.structs.Reference; +import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException; +import org.apache.oodt.cas.filemgr.structs.exceptions.DataTransferException; +import org.apache.oodt.cas.filemgr.structs.exceptions.QueryFormulationException; +import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException; +import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException; +import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException; import org.apache.oodt.cas.filemgr.structs.query.ComplexQuery; import org.apache.oodt.cas.filemgr.structs.query.QueryFilter; import org.apache.oodt.cas.filemgr.structs.query.QueryResult; @@ -41,16 +53,26 @@ import org.apache.oodt.cas.filemgr.versioning.VersioningUtils; import org.apache.oodt.cas.metadata.Metadata; import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; import org.apache.oodt.commons.date.DateUtils; +import org.apache.oodt.config.Component; import org.apache.oodt.config.ConfigurationManager; import org.apache.oodt.config.ConfigurationManagerFactory; -import org.apache.oodt.config.Constants; import org.apache.xmlrpc.WebServer; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -112,7 +134,7 @@ public class XmlRpcFileManager { propertiesFiles.add(System.getProperty("org.apache.oodt.cas.filemgr.properties")); } - configurationManager = ConfigurationManagerFactory.getConfigurationManager(Constants.Component.FILE_MANAGER, propertiesFiles); + configurationManager = ConfigurationManagerFactory.getConfigurationManager(Component.FILE_MANAGER, propertiesFiles); this.loadConfiguration(); LOG.log(Level.INFO, "File Manager started by " + System.getProperty("user.name", "unknown"));
