OODT-904 remove redundant throws
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/dd7577b5 Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/dd7577b5 Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/dd7577b5 Branch: refs/heads/master Commit: dd7577b50690dd7fbf4aecf8057372b21ed8ba40 Parents: 0cc60d1 Author: Tom Barber <[email protected]> Authored: Sun Oct 25 16:21:18 2015 +0000 Committer: Tom Barber <[email protected]> Committed: Sun Oct 25 16:21:18 2015 +0000 ---------------------------------------------------------------------- .../org/apache/oodt/commons/ExecServer.java | 3 - .../oodt/commons/activity/XMLStorage.java | 11 +- .../apache/oodt/commons/database/SqlScript.java | 5 +- .../java/org/apache/oodt/commons/util/XML.java | 7 +- .../cas/curation/service/MetadataResource.java | 64 +- .../handlers/DatabaseProfileManager.java | 18 +- .../oodt/cas/pushpull/config/RemoteSpecs.java | 591 ++++++++++--------- .../apache/oodt/cas/pushpull/daemon/Daemon.java | 142 ++--- .../oodt/cas/resource/mux/QueueMuxMonitor.java | 19 +- .../cas/resource/mux/QueueMuxScheduler.java | 19 +- .../resource/system/extern/XmlRpcBatchStub.java | 11 +- 11 files changed, 426 insertions(+), 464 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/commons/src/main/java/org/apache/oodt/commons/ExecServer.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java index 0d12531..3c6f1d5 100644 --- a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java +++ b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java @@ -431,9 +431,6 @@ public class ExecServer { } catch (IllegalAccessException ex) { System.err.println("Initializer \"" + iname + "\" isn't public; aborting"); throw new EDAException(ex); - } catch (EDAException ex) { - System.err.println("Initializer \"" + iname + "\" failed: " + ex.getMessage()); - throw new EDAException(ex); } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/commons/src/main/java/org/apache/oodt/commons/activity/XMLStorage.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/activity/XMLStorage.java b/commons/src/main/java/org/apache/oodt/commons/activity/XMLStorage.java index 6d77e51..a573c80 100644 --- a/commons/src/main/java/org/apache/oodt/commons/activity/XMLStorage.java +++ b/commons/src/main/java/org/apache/oodt/commons/activity/XMLStorage.java @@ -17,14 +17,15 @@ package org.apache.oodt.commons.activity; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import java.io.IOException; -import java.util.Iterator; import java.util.List; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; /** * Storage that saves activities as XML documents. @@ -58,10 +59,6 @@ public abstract class XMLStorage implements Storage { saveDocument(doc); } catch (ParserConfigurationException ex) { throw new IllegalStateException("Unexpected ParserConfigurationException: " + ex.getMessage()); - } catch (IOException ex) { - System.err.println("Unable to save activity " + id + " due to " + ex.getClass().getName() + ": " - + ex.getMessage()); - ex.printStackTrace(); } } http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/commons/src/main/java/org/apache/oodt/commons/database/SqlScript.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/database/SqlScript.java b/commons/src/main/java/org/apache/oodt/commons/database/SqlScript.java index 1a9e48b..ee3f9bf 100644 --- a/commons/src/main/java/org/apache/oodt/commons/database/SqlScript.java +++ b/commons/src/main/java/org/apache/oodt/commons/database/SqlScript.java @@ -26,9 +26,9 @@ import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; -import java.util.Iterator; import java.util.List; import java.util.Vector; + import javax.sql.DataSource; /** @@ -98,9 +98,6 @@ public class SqlScript { sqlScript.loadScript(); sqlScript.execute(); - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/commons/src/main/java/org/apache/oodt/commons/util/XML.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/XML.java b/commons/src/main/java/org/apache/oodt/commons/util/XML.java index e631962..2c862a8 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/XML.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/XML.java @@ -82,7 +82,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import javax.xml.parsers.DocumentBuilder; @@ -207,10 +206,8 @@ public class XML { */ public static String serialize(Document doc, boolean omitXMLDeclaration) { StringWriter writer = new StringWriter(); - try { - serialize(doc, writer, omitXMLDeclaration); - } catch (IOException cantHappen) {} - return writer.getBuffer().toString(); + serialize(doc, writer, omitXMLDeclaration); + return writer.getBuffer().toString(); } /** Serialize an XML DOM document into a String. http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java ---------------------------------------------------------------------- diff --git a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java index 4322ee1..2cef366 100644 --- a/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java +++ b/curator/services/src/main/java/org/apache/oodt/cas/curation/service/MetadataResource.java @@ -19,14 +19,40 @@ package org.apache.oodt.cas.curation.service; //JDK imports +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import net.sf.json.JSONSerializer; + +import org.apache.oodt.cas.curation.structs.ExtractorConfig; +import org.apache.oodt.cas.curation.util.CurationXmlStructFactory; +import org.apache.oodt.cas.curation.util.ExtractorConfigReader; +import org.apache.oodt.cas.filemgr.catalog.Catalog; +import org.apache.oodt.cas.filemgr.repository.XMLRepositoryManager; +import org.apache.oodt.cas.filemgr.structs.Element; +import org.apache.oodt.cas.filemgr.structs.Product; +import org.apache.oodt.cas.filemgr.structs.ProductType; +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.RepositoryManagerException; +import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException; +import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient; +import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory; +import org.apache.oodt.cas.filemgr.validation.XMLValidationLayer; +import org.apache.oodt.cas.metadata.MetExtractor; +import org.apache.oodt.cas.metadata.Metadata; +import org.apache.oodt.cas.metadata.SerializableMetadata; +import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; +import org.apache.oodt.cas.metadata.util.GenericMetadataObjectFactory; +import org.springframework.util.StringUtils; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; -import java.util.Arrays; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -36,8 +62,6 @@ import java.util.Set; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - -//JAX-RS imports import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.DefaultValue; @@ -54,40 +78,10 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - - +//JAX-RS imports //JSON imports -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; -import net.sf.json.JSONSerializer; - - - //OODT imports -import org.apache.oodt.cas.curation.service.CurationService; -import org.apache.oodt.cas.curation.structs.ExtractorConfig; -import org.apache.oodt.cas.curation.util.CurationXmlStructFactory; -import org.apache.oodt.cas.curation.util.ExtractorConfigReader; -import org.apache.oodt.cas.filemgr.catalog.Catalog; -import org.apache.oodt.cas.filemgr.repository.XMLRepositoryManager; -import org.apache.oodt.cas.filemgr.structs.Element; -import org.apache.oodt.cas.filemgr.structs.Product; -import org.apache.oodt.cas.filemgr.structs.ProductType; -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.RepositoryManagerException; -import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException; -import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient; -import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory; -import org.apache.oodt.cas.filemgr.validation.XMLValidationLayer; -import org.apache.oodt.cas.metadata.MetExtractor; -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.metadata.SerializableMetadata; -import org.apache.oodt.cas.metadata.exceptions.MetExtractionException; -import org.apache.oodt.cas.metadata.util.GenericMetadataObjectFactory; - //SPRING imports -import org.springframework.util.StringUtils; @Path("metadata") /** @@ -776,8 +770,6 @@ public class MetadataResource extends CurationService { return true; } catch (RepositoryManagerException e) { e.printStackTrace(); - } catch (ValidationLayerException e) { - e.printStackTrace(); } return false; } http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java b/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java index 28a9b9c..f630417 100755 --- a/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java +++ b/profile/src/main/java/org/apache/oodt/profile/handlers/DatabaseProfileManager.java @@ -173,14 +173,7 @@ public abstract class DatabaseProfileManager implements ProfileManager public Profile get(String profId) throws ProfileException { // Create database connection - try - { - return(get(conn, profId)); - } - catch (ProfileException e) - { - throw e; - } + return(get(conn, profId)); } public Collection getAll() { @@ -231,14 +224,7 @@ public abstract class DatabaseProfileManager implements ProfileManager } public int size() throws ProfileException { - try - { - return(size(conn)); - } - catch (ProfileException e) - { - throw e; - } + return(size(conn)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java index 6359fcd..b39eb20 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/config/RemoteSpecs.java @@ -47,310 +47,311 @@ import java.util.LinkedList; */ public class RemoteSpecs implements ConfigParserMetKeys { - LinkedList<Parser> parsers; - - LinkedList<RenamingConvention> renamingConvs; - - LinkedList<DaemonInfo> daemonInfoList; - - SiteInfo siteInfo; - - public RemoteSpecs() { - this.parsers = new LinkedList<Parser>(); - this.renamingConvs = new LinkedList<RenamingConvention>(); - daemonInfoList = new LinkedList<DaemonInfo>(); - siteInfo = new SiteInfo(); - } + LinkedList<Parser> parsers; + + LinkedList<RenamingConvention> renamingConvs; + + LinkedList<DaemonInfo> daemonInfoList; + + SiteInfo siteInfo; + + public RemoteSpecs() { + this.parsers = new LinkedList<Parser>(); + this.renamingConvs = new LinkedList<RenamingConvention>(); + daemonInfoList = new LinkedList<DaemonInfo>(); + siteInfo = new SiteInfo(); + } + + public void loadRemoteSpecs(File remoteSpecsFile) throws ConfigException { + try { + + Element root = XMLUtils.getDocumentRoot( + new FileInputStream(remoteSpecsFile)).getDocumentElement(); + NodeList aliasSpecList = root.getElementsByTagName(ALIAS_SPEC_TAG); + for (int i = 0; i < aliasSpecList.getLength(); i++) { + this.parseAndStoreLoginInfo(new File(PathUtils + .replaceEnvVariables(((Element) aliasSpecList.item(i)) + .getAttribute(FILE_ATTR)))); + } + + // get DAEMON elements + NodeList daemonList = root.getElementsByTagName(DAEMON_TAG); + for (int i = 0; i < daemonList.getLength(); i++) { + Node daemonNode = daemonList.item(i); + + // check if set to active (skip otherwise) + if (PathUtils.replaceEnvVariables( + ((Element) daemonNode).getAttribute(ACTIVE_ATTR)) + .equals("no")) + continue; + + DaemonInfo di = null; + + // get site alias + String siteAlias = PathUtils + .replaceEnvVariables(((Element) daemonNode) + .getAttribute(ALIAS_ATTR)); + RemoteSite dataFilesRemoteSite = this.siteInfo + .getSiteByAlias(siteAlias); + if (dataFilesRemoteSite == null) + throw new ConfigException("Alias '" + siteAlias + + "' in SiteInfo file '" + + remoteSpecsFile.getAbsolutePath() + + "' has not been defined"); - public void loadRemoteSpecs(File remoteSpecsFile) throws ConfigException { - try { + // get RUNINFO element + NodeList runInfoList = ((Element) daemonNode) + .getElementsByTagName(RUN_INFO_TAG); + String firstRunDateTimeString = null, period = null, epsilon = null; + boolean runOnReboot = false; + if (runInfoList.getLength() > 0) { + Element runInfo = (Element) runInfoList.item(0); + firstRunDateTimeString = runInfo + .getAttribute(FIRSTRUN_DATETIME_ATTR); + period = runInfo.getAttribute(PERIOD_ATTR); + runOnReboot = (runInfo.getAttribute(RUNONREBOOT_ATTR) + .toLowerCase().equals("yes")) ? true : false; + epsilon = runInfo.getAttribute(EPSILON_ATTR); + if (epsilon.equals("")) + epsilon = "0s"; + } - Element root = XMLUtils.getDocumentRoot( - new FileInputStream(remoteSpecsFile)).getDocumentElement(); - NodeList aliasSpecList = root.getElementsByTagName(ALIAS_SPEC_TAG); - for (int i = 0; i < aliasSpecList.getLength(); i++) { - this.parseAndStoreLoginInfo(new File(PathUtils - .replaceEnvVariables(((Element) aliasSpecList.item(i)) - .getAttribute(FILE_ATTR)))); + // get PROPINFO elements + NodeList propInfoList = ((Element) daemonNode) + .getElementsByTagName(PROP_INFO_TAG); + LinkedList<PropFilesInfo> pfiList = new LinkedList<PropFilesInfo>(); + PropFilesInfo pfi = null; + if (propInfoList.getLength() > 0) { + Node propInfoNode = propInfoList.item(0); + + // get directory where the property files are + File propertyFilesDir = new File(PathUtils + .replaceEnvVariables(((Element) propInfoNode) + .getAttribute(DIR_ATTR))); + + pfi = new PropFilesInfo(propertyFilesDir); + + // get PROPFILES elements + NodeList propFilesList = ((Element) propInfoNode) + .getElementsByTagName(PROP_FILES_TAG); + String propFilesRegExp = null; + if (propFilesList.getLength() > 0) { + for (int k = 0; k < propFilesList.getLength(); k++) { + Node propFilesNode = propFilesList.item(k); + propFilesRegExp = ((Element) propFilesNode) + .getAttribute(REG_EXP_ATTR); + pfi + .addPropFiles( + propFilesRegExp, + PushPullObjectFactory + .createNewInstance((Class<Parser>) Class + .forName(PathUtils + .replaceEnvVariables(((Element) propFilesNode) + .getAttribute(PARSER_ATTR))))); } - - // get DAEMON elements - NodeList daemonList = root.getElementsByTagName(DAEMON_TAG); - for (int i = 0; i < daemonList.getLength(); i++) { - Node daemonNode = daemonList.item(i); - - // check if set to active (skip otherwise) - if (PathUtils.replaceEnvVariables( - ((Element) daemonNode).getAttribute(ACTIVE_ATTR)) - .equals("no")) - continue; - - DaemonInfo di = null; - - // get site alias - String siteAlias = PathUtils - .replaceEnvVariables(((Element) daemonNode) - .getAttribute(ALIAS_ATTR)); - RemoteSite dataFilesRemoteSite = this.siteInfo - .getSiteByAlias(siteAlias); - if (dataFilesRemoteSite == null) - throw new ConfigException("Alias '" + siteAlias - + "' in SiteInfo file '" - + remoteSpecsFile.getAbsolutePath() - + "' has not been defined"); - - // get RUNINFO element - NodeList runInfoList = ((Element) daemonNode) - .getElementsByTagName(RUN_INFO_TAG); - String firstRunDateTimeString = null, period = null, epsilon = null; - boolean runOnReboot = false; - if (runInfoList.getLength() > 0) { - Element runInfo = (Element) runInfoList.item(0); - firstRunDateTimeString = runInfo - .getAttribute(FIRSTRUN_DATETIME_ATTR); - period = runInfo.getAttribute(PERIOD_ATTR); - runOnReboot = (runInfo.getAttribute(RUNONREBOOT_ATTR) - .toLowerCase().equals("yes")); - epsilon = runInfo.getAttribute(EPSILON_ATTR); - if (epsilon.equals("")) - epsilon = "0s"; - } - - // get PROPINFO elements - NodeList propInfoList = ((Element) daemonNode) - .getElementsByTagName(PROP_INFO_TAG); - LinkedList<PropFilesInfo> pfiList = new LinkedList<PropFilesInfo>(); - PropFilesInfo pfi; - if (propInfoList.getLength() > 0) { - Node propInfoNode = propInfoList.item(0); - - // get directory where the property files are - File propertyFilesDir = new File(PathUtils - .replaceEnvVariables(((Element) propInfoNode) - .getAttribute(DIR_ATTR))); - - pfi = new PropFilesInfo(propertyFilesDir); - - // get PROPFILES elements - NodeList propFilesList = ((Element) propInfoNode) - .getElementsByTagName(PROP_FILES_TAG); - String propFilesRegExp = null; - if (propFilesList.getLength() > 0) { - for (int k = 0; k < propFilesList.getLength(); k++) { - Node propFilesNode = propFilesList.item(k); - propFilesRegExp = ((Element) propFilesNode) - .getAttribute(REG_EXP_ATTR); - pfi - .addPropFiles( - propFilesRegExp, - PushPullObjectFactory - .createNewInstance((Class<Parser>) Class - .forName(PathUtils - .replaceEnvVariables(((Element) propFilesNode) - .getAttribute(PARSER_ATTR))))); - } - } else - throw new ConfigException( - "No propFiles element specified for deamon with alias '" - + siteAlias + "' in RemoteSpecs file '" + } else + throw new ConfigException( + "No propFiles element specified for deamon with alias '" + + siteAlias + "' in RemoteSpecs file '" + + remoteSpecsFile.getAbsolutePath() + + "'"); + + // get DOWNLOADINFO element if given + NodeList downloadInfoList = ((Element) propInfoNode) + .getElementsByTagName(DOWNLOAD_INFO_TAG); + if (downloadInfoList.getLength() > 0) { + Node downloadInfo = downloadInfoList.item(0); + String propFilesAlias = PathUtils + .replaceEnvVariables(((Element) downloadInfo) + .getAttribute(ALIAS_ATTR)); + String propFilesRenamingConv = ((Element) downloadInfo) + .getAttribute(RENAMING_CONV_ATTR); + boolean allowAliasOverride = PathUtils + .replaceEnvVariables( + ((Element) downloadInfo) + .getAttribute(ALLOW_ALIAS_OVERRIDE_ATTR)) + .equals("yes"); + boolean deleteFromServer = PathUtils + .replaceEnvVariables( + ((Element) downloadInfo) + .getAttribute(DELETE_FROM_SERVER_ATTR)) + .equals("yes"); + RemoteSite propFilesRemoteSite = this.siteInfo + .getSiteByAlias(propFilesAlias); + if (propFilesRemoteSite == null) + throw new ConfigException("Alias '" + + propFilesAlias + + "' in RemoteSpecs file '" + remoteSpecsFile.getAbsolutePath() - + "'"); - - // get DOWNLOADINFO element if given - NodeList downloadInfoList = ((Element) propInfoNode) - .getElementsByTagName(DOWNLOAD_INFO_TAG); - if (downloadInfoList.getLength() > 0) { - Node downloadInfo = downloadInfoList.item(0); - String propFilesAlias = PathUtils - .replaceEnvVariables(((Element) downloadInfo) - .getAttribute(ALIAS_ATTR)); - String propFilesRenamingConv = ((Element) downloadInfo) - .getAttribute(RENAMING_CONV_ATTR); - boolean allowAliasOverride = PathUtils - .replaceEnvVariables( - ((Element) downloadInfo) - .getAttribute(ALLOW_ALIAS_OVERRIDE_ATTR)) - .equals("yes"); - boolean deleteFromServer = PathUtils - .replaceEnvVariables( - ((Element) downloadInfo) - .getAttribute(DELETE_FROM_SERVER_ATTR)) - .equals("yes"); - RemoteSite propFilesRemoteSite = this.siteInfo - .getSiteByAlias(propFilesAlias); - if (propFilesRemoteSite == null) - throw new ConfigException("Alias '" - + propFilesAlias - + "' in RemoteSpecs file '" - + remoteSpecsFile.getAbsolutePath() - + "' has not been defined"); - String regExp = ((Element) downloadInfo) - .getAttribute(REG_EXP_ATTR); - if (regExp.equals("")) - NodeList propsList = ((Element) propInfoNode) - .getElementsByTagName(PROP_FILE_TAG); - HashMap<File, Parser> propFileToParserMap = new HashMap<File, Parser>(); - for (int p = 0; p < propsList.getLength(); p++) { - Element propElem = (Element) propsList.item(p); - propFileToParserMap - .put( - new File( - PathUtils - .replaceEnvVariables(propElem - .getAttribute(PATH_ATTR))), - PushPullObjectFactory - .createNewInstance((Class<Parser>) Class - .forName(PathUtils - .replaceEnvVariables(propElem - .getAttribute(PARSER_ATTR))))); - } - pfi.setDownloadInfo(new DownloadInfo( - propFilesRemoteSite, propFilesRenamingConv, - deleteFromServer, propertyFilesDir, - allowAliasOverride), propFileToParserMap); - } - - // get AFTERUSE element - NodeList afterUseList = ((Element) propInfoNode) - .getElementsByTagName(AFTER_USE_TAG); - if (afterUseList.getLength() > 0) { - Element afterUse = (Element) afterUseList.item(0); - File onSuccessDir = new File(PathUtils - .replaceEnvVariables(afterUse - .getAttribute(MOVEON_TO_SUCCESS_ATTR))); - File onFailDir = new File(PathUtils - .replaceEnvVariables(afterUse - .getAttribute(MOVEON_TO_FAIL_ATTR))); - pfi.setAfterUseEffects(onSuccessDir, onFailDir); - boolean deleteOnSuccess = Boolean.parseBoolean(PathUtils - .replaceEnvVariables(afterUse - .getAttribute(DELETE_ON_SUCCESS_ATTR))); - pfi.setDeleteOnSuccess(deleteOnSuccess); - } - - } else - throw new ConfigException( - "No propInfo element specified for deamon with alias '" - + siteAlias + "' in RemoteSpecs file '" - + remoteSpecsFile.getAbsolutePath() + "'"); - - // get DATAINFO elements - NodeList dataInfoList = ((Element) daemonNode) - .getElementsByTagName(DATA_INFO_TAG); - DataFilesInfo dfi; - if (dataInfoList.getLength() > 0) { - Node dataInfo = dataInfoList.item(0); - String queryElement = ((Element) dataInfo) - .getAttribute(QUERY_ELEM_ATTR); - if (Strings.isNullOrEmpty(queryElement)) { - queryElement = null; - } else { - queryElement = PathUtils.replaceEnvVariables(queryElement); - } - String renamingConv = ((Element) dataInfo) - .getAttribute(RENAMING_CONV_ATTR); - if (Strings.isNullOrEmpty(renamingConv)) { - renamingConv = null; - } - boolean allowAliasOverride = PathUtils.replaceEnvVariables( - ((Element) dataInfo) - .getAttribute(ALLOW_ALIAS_OVERRIDE_ATTR)) - .equals("yes"); - File stagingArea = new File(PathUtils - .replaceEnvVariables(((Element) dataInfo) - .getAttribute(STAGING_AREA_ATTR))); - boolean deleteFromServer = PathUtils.replaceEnvVariables( - ((Element) dataInfo) - .getAttribute(DELETE_FROM_SERVER_ATTR)) - .equals("yes"); - dfi = new DataFilesInfo(queryElement, new DownloadInfo( - dataFilesRemoteSite, renamingConv, - deleteFromServer, stagingArea, allowAliasOverride)); - } else - throw new ConfigException( - "No dataInfo element specified for deamon with alias '" - + siteAlias + "' in RemoteSpecs file '" - + remoteSpecsFile.getAbsolutePath() + "'"); - - daemonInfoList.add(new DaemonInfo(firstRunDateTimeString, - period, epsilon, runOnReboot, pfi, dfi)); + + "' has not been defined"); + String regExp = ((Element) downloadInfo) + .getAttribute(REG_EXP_ATTR); + if (regExp.equals("")) + regExp = propFilesRegExp; + NodeList propsList = ((Element) propInfoNode) + .getElementsByTagName(PROP_FILE_TAG); + HashMap<File, Parser> propFileToParserMap = new HashMap<File, Parser>(); + for (int p = 0; p < propsList.getLength(); p++) { + Element propElem = (Element) propsList.item(p); + propFileToParserMap + .put( + new File( + PathUtils + .replaceEnvVariables(propElem + .getAttribute(PATH_ATTR))), + PushPullObjectFactory + .createNewInstance((Class<Parser>) Class + .forName(PathUtils + .replaceEnvVariables(propElem + .getAttribute(PARSER_ATTR))))); } - } catch (Exception e) { - e.printStackTrace(); - throw new ConfigException("Failed to load crawl elements : " - + e.getMessage()); - } + pfi.setDownloadInfo(new DownloadInfo( + propFilesRemoteSite, propFilesRenamingConv, + deleteFromServer, propertyFilesDir, + allowAliasOverride), propFileToParserMap); + } + + // get AFTERUSE element + NodeList afterUseList = ((Element) propInfoNode) + .getElementsByTagName(AFTER_USE_TAG); + if (afterUseList.getLength() > 0) { + Element afterUse = (Element) afterUseList.item(0); + File onSuccessDir = new File(PathUtils + .replaceEnvVariables(afterUse + .getAttribute(MOVEON_TO_SUCCESS_ATTR))); + File onFailDir = new File(PathUtils + .replaceEnvVariables(afterUse + .getAttribute(MOVEON_TO_FAIL_ATTR))); + pfi.setAfterUseEffects(onSuccessDir, onFailDir); + boolean deleteOnSuccess = Boolean.parseBoolean(PathUtils + .replaceEnvVariables(afterUse + .getAttribute(DELETE_ON_SUCCESS_ATTR))); + pfi.setDeleteOnSuccess(deleteOnSuccess); + } + + } else + throw new ConfigException( + "No propInfo element specified for deamon with alias '" + + siteAlias + "' in RemoteSpecs file '" + + remoteSpecsFile.getAbsolutePath() + "'"); + + // get DATAINFO elements + NodeList dataInfoList = ((Element) daemonNode) + .getElementsByTagName(DATA_INFO_TAG); + DataFilesInfo dfi = null; + if (dataInfoList.getLength() > 0) { + Node dataInfo = dataInfoList.item(0); + String queryElement = ((Element) dataInfo) + .getAttribute(QUERY_ELEM_ATTR); + if (Strings.isNullOrEmpty(queryElement)) { + queryElement = null; + } else { + queryElement = PathUtils.replaceEnvVariables(queryElement); + } + String renamingConv = ((Element) dataInfo) + .getAttribute(RENAMING_CONV_ATTR); + if (Strings.isNullOrEmpty(renamingConv)) { + renamingConv = null; + } + boolean allowAliasOverride = PathUtils.replaceEnvVariables( + ((Element) dataInfo) + .getAttribute(ALLOW_ALIAS_OVERRIDE_ATTR)) + .equals("yes"); + File stagingArea = new File(PathUtils + .replaceEnvVariables(((Element) dataInfo) + .getAttribute(STAGING_AREA_ATTR))); + boolean deleteFromServer = PathUtils.replaceEnvVariables( + ((Element) dataInfo) + .getAttribute(DELETE_FROM_SERVER_ATTR)) + .equals("yes"); + dfi = new DataFilesInfo(queryElement, new DownloadInfo( + dataFilesRemoteSite, renamingConv, + deleteFromServer, stagingArea, allowAliasOverride)); + } else + throw new ConfigException( + "No dataInfo element specified for deamon with alias '" + + siteAlias + "' in RemoteSpecs file '" + + remoteSpecsFile.getAbsolutePath() + "'"); + + daemonInfoList.add(new DaemonInfo(firstRunDateTimeString, + period, epsilon, runOnReboot, pfi, dfi)); + } + } catch (Exception e) { + e.printStackTrace(); + throw new ConfigException("Failed to load crawl elements : " + + e.getMessage()); } - - void parseAndStoreLoginInfo(File loginInfoFile) throws ConfigException { - try { - NodeList sourceList = XMLUtils.getDocumentRoot(new FileInputStream(loginInfoFile)) - .getElementsByTagName(SOURCE_TAG); - for (int i = 0; i < sourceList.getLength(); i++) { - - // get source element - Node sourceNode = sourceList.item(i); - - // get host of this source - String host = PathUtils - .replaceEnvVariables(((Element) sourceNode) - .getAttribute(HOST_ATTR)); - - // get all login info for this source - NodeList loginList = ((Element) sourceNode) - .getElementsByTagName(LOGIN_ATTR); - for (int j = 0; j < loginList.getLength(); j++) { - - // get a single login info - Node loginNode = loginList.item(j); - String type = PathUtils - .replaceEnvVariables(((Element) loginNode) - .getAttribute(TYPE_ATTR)); - String alias = PathUtils - .replaceEnvVariables(((Element) loginNode) - .getAttribute(ALIAS_ATTR)); - String username = null, password = null, cdTestDir = null; - int maxConnections = -1; - - // parse this login info - NodeList loginInfo = loginNode.getChildNodes(); - for (int k = 0; k < loginInfo.getLength(); k++) { - - // get a single login info element - Node node = loginInfo.item(k); - - // determine what element type it is - if (node.getNodeName().equals(USERNAME_TAG)) { - username = PathUtils.replaceEnvVariables( - XMLUtils.getSimpleElementText((Element) node, true)); - } else if (node.getNodeName().equals(PASSWORD_TAG)) { - password = PathUtils.replaceEnvVariables( - XMLUtils.getSimpleElementText((Element) node, true)); - } else if (node.getNodeName().equals(CD_TEST_DIR_TAG)) { - cdTestDir = PathUtils.replaceEnvVariables( - XMLUtils.getSimpleElementText((Element) node, true)); - } else if (node.getNodeName().equals(MAX_CONN_TAG)) { - maxConnections = Integer.parseInt(PathUtils.replaceEnvVariables( - XMLUtils.getSimpleElementText((Element) node, true))); - } - } - - this.siteInfo.addSite(new RemoteSite(alias, new URL(type - + "://" + host), username, password, cdTestDir, maxConnections)); - } + } + + void parseAndStoreLoginInfo(File loginInfoFile) throws ConfigException { + try { + NodeList sourceList = XMLUtils.getDocumentRoot(new FileInputStream(loginInfoFile)) + .getElementsByTagName(SOURCE_TAG); + for (int i = 0; i < sourceList.getLength(); i++) { + + // get source element + Node sourceNode = sourceList.item(i); + + // get host of this source + String host = PathUtils + .replaceEnvVariables(((Element) sourceNode) + .getAttribute(HOST_ATTR)); + + // get all login info for this source + NodeList loginList = ((Element) sourceNode) + .getElementsByTagName(LOGIN_ATTR); + for (int j = 0; j < loginList.getLength(); j++) { + + // get a single login info + Node loginNode = loginList.item(j); + String type = PathUtils + .replaceEnvVariables(((Element) loginNode) + .getAttribute(TYPE_ATTR)); + String alias = PathUtils + .replaceEnvVariables(((Element) loginNode) + .getAttribute(ALIAS_ATTR)); + String username = null, password = null, cdTestDir = null; + int maxConnections = -1; + + // parse this login info + NodeList loginInfo = loginNode.getChildNodes(); + for (int k = 0; k < loginInfo.getLength(); k++) { + + // get a single login info element + Node node = loginInfo.item(k); + + // determine what element type it is + if (node.getNodeName().equals(USERNAME_TAG)) { + username = PathUtils.replaceEnvVariables( + XMLUtils.getSimpleElementText((Element) node, true)); + } else if (node.getNodeName().equals(PASSWORD_TAG)) { + password = PathUtils.replaceEnvVariables( + XMLUtils.getSimpleElementText((Element) node, true)); + } else if (node.getNodeName().equals(CD_TEST_DIR_TAG)) { + cdTestDir = PathUtils.replaceEnvVariables( + XMLUtils.getSimpleElementText((Element) node, true)); + } else if (node.getNodeName().equals(MAX_CONN_TAG)) { + maxConnections = Integer.parseInt(PathUtils.replaceEnvVariables( + XMLUtils.getSimpleElementText((Element) node, true))); } - } catch (Exception e) { - throw new ConfigException("Failed to load external source info : " - + e.getMessage(), e); + } + + this.siteInfo.addSite(new RemoteSite(alias, new URL(type + + "://" + host), username, password, cdTestDir, maxConnections)); } + } + } catch (Exception e) { + throw new ConfigException("Failed to load external source info : " + + e.getMessage(), e); } + } - public LinkedList<DaemonInfo> getDaemonInfoList() { - return this.daemonInfoList; - } + public LinkedList<DaemonInfo> getDaemonInfoList() { + return this.daemonInfoList; + } - public SiteInfo getSiteInfo() { - return this.siteInfo; - } + public SiteInfo getSiteInfo() { + return this.siteInfo; + } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java index 805b900..cee0373 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/daemon/Daemon.java @@ -51,11 +51,11 @@ import javax.management.ObjectName; * specified by the properties file passed in. A Crawler will be created per the * properties file and executed at six hour intervals. This class can be * controlled by CrawlDaemonController after is has been started up. - * + * * @author bfoster */ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, - DaemonMBean { + DaemonMBean { private static final long serialVersionUID = 7660972939723142802L; @@ -107,7 +107,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Constructor - * + * * @throws RemoteException * @throws RemoteException * @throws InstantiationException @@ -115,7 +115,8 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, * @throws SecurityException */ public Daemon(int rmiRegPort, int daemonID, Config config, - DaemonInfo daemonInfo, SiteInfo siteInfo) throws RemoteException { + DaemonInfo daemonInfo, SiteInfo siteInfo) throws RemoteException, + InstantiationException { super(); this.rmiRegPort = rmiRegPort; @@ -133,20 +134,20 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, registerRMIServer(); } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to bind to RMI server : " - + e.getMessage()); + + e.getMessage()); } try { // registry CrawlDaemon as MBean so it can be used with jconsole mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName( - "org.apache.oodt.cas.pushpull.daemon:type=Daemon" - + this.getDaemonID()); + "org.apache.oodt.cas.pushpull.daemon:type=Daemon" + + this.getDaemonID()); mbs.registerMBean(this, name); } catch (Exception e) { LOG.log(Level.SEVERE, - "Failed to register CrawlDaemon as a MBean Object : " - + e.getMessage()); + "Failed to register CrawlDaemon as a MBean Object : " + + e.getMessage()); } } @@ -154,17 +155,18 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, return "Daemon" + this.getDaemonID(); } - private void registerRMIServer() throws RemoteException { + private void registerRMIServer() throws RemoteException, + MalformedURLException, NotBoundException, AlreadyBoundException { try { Naming.bind("//localhost:" + this.rmiRegPort + "/daemon" - + this.getDaemonID(), this); + + this.getDaemonID(), this); LOG.log(Level.INFO, "Created Daemon ID = " + this.getDaemonID() - + " on RMI registry port " + this.rmiRegPort); + + " on RMI registry port " + this.rmiRegPort); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("Failed to bind Daemon with ID = " - + this.getDaemonID() + " to RMI registry at port " - + this.rmiRegPort); + + this.getDaemonID() + " to RMI registry at port " + + this.rmiRegPort); } } @@ -177,7 +179,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, * Loads and executes the Crawler specified by the properties file. It will * crawl the URLs specified in the properties file in the sequence * given--one at a time. - * + * * @throws DirStructException */ public void startDaemon() { @@ -188,9 +190,9 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, // check if Daemon should sleep first long timeTilNextRun; if ((timeTilNextRun = Daemon.this.calculateTimeTilNextRun()) != 0 - && !(Daemon.this.beforeToday(daemonInfo - .getFirstRunDateTime()) && daemonInfo - .runOnReboot())) + && !(Daemon.this.beforeToday(daemonInfo + .getFirstRunDateTime()) && daemonInfo + .runOnReboot())) sleep(timeTilNextRun); for (keepRunning = true; keepRunning;) { @@ -209,7 +211,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, try { rs.retrieveFiles(daemonInfo.getPropFilesInfo(), - daemonInfo.getDataFilesInfo()); + daemonInfo.getDataFilesInfo()); } catch (Exception e) { e.printStackTrace(); } finally { @@ -222,15 +224,15 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, Daemon.this.notifyDaemonListenerOfFinish(); Daemon.this.calculateAndStoreElapsedTime(startTime); if (Daemon.this.keepRunning - && daemonInfo.getTimeIntervalInMilliseconds() >= 0) { + && daemonInfo.getTimeIntervalInMilliseconds() >= 0) { sleep(Daemon.this.calculateTimeTilNextRun()); } else { break; } } LOG.log(Level.INFO, "Daemon with ID = " - + Daemon.this.getDaemonID() + " on RMI registry port " - + Daemon.this.rmiRegPort + " is shutting down"); + + Daemon.this.getDaemonID() + " on RMI registry port " + + Daemon.this.rmiRegPort + " is shutting down"); Daemon.this.unregister(); } }).start(); @@ -240,10 +242,10 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, try { // unregister CrawlDaemon from RMI registry Naming.unbind("//localhost:" + this.rmiRegPort + "/daemon" - + this.getDaemonID()); + + this.getDaemonID()); this.mbs.unregisterMBean(new ObjectName( - "org.apache.oodt.cas.pushpull.daemon:type=Daemon" - + this.getDaemonID())); + "org.apache.oodt.cas.pushpull.daemon:type=Daemon" + + this.getDaemonID())); UnicastRemoteObject.unexportObject(this, true); this.daemonListener.wasUnregisteredWith(this); } catch (Exception e) { @@ -268,10 +270,10 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, return 0; } else { int numOfPeriods = (int) (diff / daemonInfo - .getTimeIntervalInMilliseconds()); + .getTimeIntervalInMilliseconds()); long nextRunTime = gcStartDateTime.getTimeInMillis() - + ((numOfPeriods + 1) * daemonInfo - .getTimeIntervalInMilliseconds()); + + ((numOfPeriods + 1) * daemonInfo + .getTimeIntervalInMilliseconds()); return nextRunTime - now.getTimeInMillis(); } } @@ -293,9 +295,9 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, private void sleep(long length) { if (length > 0) { LOG.log(Level.INFO, "Daemon with ID = " + this.getDaemonID() - + " on RMI registry port " + this.rmiRegPort - + " is going to sleep until " - + new Date(System.currentTimeMillis() + length)); + + " on RMI registry port " + this.rmiRegPort + + " is going to sleep until " + + new Date(System.currentTimeMillis() + length)); synchronized (this) { try { wait(length); @@ -314,13 +316,13 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, public synchronized void pauseDaemon() { try { LOG.log(Level.INFO, "Daemon with ID = " + this.getDaemonID() - + " on RMI registry port " + this.rmiRegPort - + " has been stopped"); + + " on RMI registry port " + this.rmiRegPort + + " has been stopped"); this.wait(0); } catch (Exception e) { } LOG.log(Level.INFO, "Daemon with ID = " + this.getDaemonID() - + " on RMI registry port " + this.rmiRegPort + " has resumed"); + + " on RMI registry port " + this.rmiRegPort + " has resumed"); } /** @@ -342,7 +344,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Can be used to determine if Crawler is presently running - * + * * @return true if Crawler is runnning * @uml.property name="isRunning" */ @@ -352,7 +354,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Average runtime for the Crawler - * + * * @return average runtime for the Crawler */ public long getAverageRunTime() { @@ -361,7 +363,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Gets the total crawling time of the Crawler - * + * * @return Total crawling time of Crawler */ public long getMillisCrawling() { @@ -370,7 +372,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Gets the time between the start of Crawler executions - * + * * @return Time interval between Crawler start times */ public long getTimeInterval() { @@ -379,7 +381,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Gets the total number of times the Crawler has been run - * + * * @return The number of times Crawler has run */ public int getNumCrawls() { @@ -388,24 +390,24 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, public String[] downloadedFilesInStagingArea() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .getStagingArea().list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return !name.startsWith("Downloading_") - && !(name.endsWith("info.tmp") || name - .endsWith("cas")); - } - }); + .getStagingArea().list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return !name.startsWith("Downloading_") + && !(name.endsWith("info.tmp") || name + .endsWith("cas")); + } + }); } public String[] downloadingFilesInStagingArea() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .getStagingArea().list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.startsWith("Downloading_") - && !(name.endsWith("info.tmp") || name - .endsWith("cas")); - } - }); + .getStagingArea().list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.startsWith("Downloading_") + && !(name.endsWith("info.tmp") || name + .endsWith("cas")); + } + }); } public int numberOfFilesDownloadingInStagingArea() { @@ -438,35 +440,36 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, // ***************DataFilesInfo******************* public String getDataFilesRemoteSite() { RemoteSite remoteSite = this.daemonInfo.getDataFilesInfo() - .getDownloadInfo().getRemoteSite(); + .getDownloadInfo().getRemoteSite(); return (remoteSite == null) ? "" : remoteSite.toString(); } public String getDataFilesRenamingConv() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .getRenamingConv(); + .getRenamingConv(); } public boolean getDeleteDataFilesFromServer() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .deleteFromServer(); + .deleteFromServer(); } public String getQueryMetadataElementName() { String element = this.daemonInfo.getDataFilesInfo() - .getQueryMetadataElementName(); + .getQueryMetadataElementName(); if (element == null || element.equals("")) + element = "Filename"; return this.daemonInfo.getDataFilesInfo().getQueryMetadataElementName(); } public File getDataFilesStagingArea() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .getStagingArea(); + .getStagingArea(); } public boolean getAllowAliasOverride() { return this.daemonInfo.getDataFilesInfo().getDownloadInfo() - .isAllowAliasOverride(); + .isAllowAliasOverride(); } // **************DataFilesInfo******************** @@ -474,18 +477,18 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, // **************PropFilesInfo******************** public String getPropertyFilesRemoteSite() { RemoteSite remoteSite = this.daemonInfo.getPropFilesInfo() - .getDownloadInfo().getRemoteSite(); + .getDownloadInfo().getRemoteSite(); return (remoteSite == null) ? "" : remoteSite.toString(); } public String getPropertyFilesRenamingConv() { return this.daemonInfo.getPropFilesInfo().getDownloadInfo() - .getRenamingConv(); + .getRenamingConv(); } public boolean getDeletePropertyFilesFromServer() { return this.daemonInfo.getPropFilesInfo().getDownloadInfo() - .deleteFromServer(); + .deleteFromServer(); } public String getPropertyFilesOnSuccessDir() { @@ -507,7 +510,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Gets the time in milliseconds for when the CrawlDaemon constructor was * invoked. - * + * * @return * @uml.property name="daemonCreationTime" */ @@ -525,7 +528,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, /** * Starts the program - * + * * @param args * Not Used * @throws IOException @@ -541,6 +544,7 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, if (args[i].equals("--rmiPort")) rmiPort = Integer.parseInt(args[++i]); else if (args[i].equals("--waitForNotification")) + waitForCrawlNotification = true; } LocateRegistry.createRegistry(rmiPort); @@ -549,16 +553,16 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, // registry CrawlDaemon as MBean so it can be used with jconsole MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName( - "org.apache.oodt.cas.pushpull.daemon:type=Daemon"); + "org.apache.oodt.cas.pushpull.daemon:type=Daemon"); } catch (Exception e) { LOG.log(Level.SEVERE, - "Failed to register CrawlDaemon as a MBean Object : " - + e.getMessage()); + "Failed to register CrawlDaemon as a MBean Object : " + + e.getMessage()); } } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to create CrawlDaemon : " - + e.getMessage()); + + e.getMessage()); } finally { // terminate the CrawlDaemon LOG.log(Level.INFO, "Terminating CrawlDaemon"); @@ -566,4 +570,4 @@ public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface, } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxMonitor.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxMonitor.java b/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxMonitor.java index 4063b20..073a723 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxMonitor.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxMonitor.java @@ -16,6 +16,12 @@ */ package org.apache.oodt.cas.resource.mux; +import org.apache.oodt.cas.resource.monitor.Monitor; +import org.apache.oodt.cas.resource.scheduler.QueueManager; +import org.apache.oodt.cas.resource.structs.ResourceNode; +import org.apache.oodt.cas.resource.structs.exceptions.MonitorException; +import org.apache.oodt.cas.resource.structs.exceptions.QueueManagerException; + import java.net.URL; import java.util.Iterator; import java.util.LinkedHashSet; @@ -25,12 +31,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import org.apache.oodt.cas.resource.monitor.Monitor; -import org.apache.oodt.cas.resource.scheduler.QueueManager; -import org.apache.oodt.cas.resource.structs.ResourceNode; -import org.apache.oodt.cas.resource.structs.exceptions.MonitorException; -import org.apache.oodt.cas.resource.structs.exceptions.QueueManagerException; - /** * @author starchmd * @version $Revision$ @@ -185,12 +185,7 @@ public class QueueMuxMonitor implements Monitor { List<String> ret = new LinkedList<String>(); //Get list of queues List<String> queues = null; - try - { - queues = qManager.getQueues(); - } catch (QueueManagerException e) { - LOG.log(Level.SEVERE, "Cannot list queues."); - } + queues = qManager.getQueues(); //Search each queu to see if it contains given node for (String queue : queues) { try http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxScheduler.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxScheduler.java b/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxScheduler.java index 951a7ae..faa6014 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxScheduler.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/mux/QueueMuxScheduler.java @@ -19,18 +19,9 @@ package org.apache.oodt.cas.resource.mux; //JDKimports -import java.util.logging.Level; -import java.util.logging.Logger; - - - - - - -//OODT imports +import org.apache.oodt.cas.resource.batchmgr.Batchmgr; import org.apache.oodt.cas.resource.jobqueue.JobQueue; import org.apache.oodt.cas.resource.monitor.Monitor; -import org.apache.oodt.cas.resource.batchmgr.Batchmgr; import org.apache.oodt.cas.resource.scheduler.QueueManager; import org.apache.oodt.cas.resource.scheduler.Scheduler; import org.apache.oodt.cas.resource.structs.JobSpec; @@ -39,6 +30,11 @@ import org.apache.oodt.cas.resource.structs.exceptions.JobQueueException; import org.apache.oodt.cas.resource.structs.exceptions.QueueManagerException; import org.apache.oodt.cas.resource.structs.exceptions.SchedulerException; +import java.util.logging.Level; +import java.util.logging.Logger; + +//OODT imports + /** * This scheduler multiplexes between multiple schedulers based on the "queue" . * @@ -94,9 +90,6 @@ public class QueueMuxScheduler implements Scheduler { job = queue.getNextJob(); LOG.log(Level.INFO, "Scheduling job: ["+ job.getJob().getId()+ "] for execution"); schedule(job); - } catch (JobQueueException je) { - LOG.log(Level.WARNING,"Error getting job from queue: " - + je.getLocalizedMessage()); } catch (SchedulerException se) { LOG.log(Level.WARNING,"Error occured scheduling job: "+se.getLocalizedMessage()); try { http://git-wip-us.apache.org/repos/asf/oodt/blob/dd7577b5/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java index 5add384..5e614ae 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java @@ -62,7 +62,7 @@ public class XmlRpcBatchStub { private static Map jobThreadMap = null; - public XmlRpcBatchStub(int port) { + public XmlRpcBatchStub(int port) throws Exception { webServerPort = port; // start up the web server @@ -129,9 +129,10 @@ public class XmlRpcBatchStub { return true; } - private boolean genericExecuteJob(Hashtable jobHash, Object jobInput) { - JobInstance exec; - JobInput in; + private boolean genericExecuteJob(Hashtable jobHash, Object jobInput) + throws JobException { + JobInstance exec = null; + JobInput in = null; try { Job job = XmlRpcStructFactory.getJobFromXmlRpc(jobHash); @@ -162,6 +163,7 @@ public class XmlRpcBatchStub { synchronized (jobThreadMap) { Thread endThread = (Thread) jobThreadMap.get(job.getId()); if (endThread != null) + endThread = null; } return false; } @@ -169,6 +171,7 @@ public class XmlRpcBatchStub { synchronized (jobThreadMap) { Thread endThread = (Thread) jobThreadMap.get(job.getId()); if (endThread != null) + endThread = null; } return runner.wasSuccessful();
