OODT-916 convert magic numbers
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/a666bd1a Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/a666bd1a Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/a666bd1a Branch: refs/heads/master Commit: a666bd1af8c1fbf5f6ecc01e710c4978dbc1d827 Parents: 3b03afc Author: Tom Barber <[email protected]> Authored: Mon Nov 2 21:06:10 2015 +0000 Committer: Tom Barber <[email protected]> Committed: Mon Nov 2 21:06:10 2015 +0000 ---------------------------------------------------------------------- .../oodt/cas/filemgr/browser/model/CasDB.java | 7 ++-- .../cli/action/CatalogServiceCliAction.java | 9 +++-- .../XmlRpcCommunicationChannelClient.java | 7 ++-- .../impl/CatalogServiceClientFactory.java | 7 ++-- .../system/impl/CatalogServiceLocalFactory.java | 18 +++++---- .../org/apache/oodt/commons/Configuration.java | 42 +++++++++++++++----- .../org/apache/oodt/commons/ExecServer.java | 12 ++++-- .../org/apache/oodt/commons/Executable.java | 7 +++- .../org/apache/oodt/commons/MultiServer.java | 23 ++++++----- .../apache/oodt/commons/activity/Activity.java | 13 ++++-- .../oodt/commons/activity/DatagramLogger.java | 10 +++-- .../DatagramLoggingActivityFactory.java | 7 +++- .../apache/oodt/commons/exec/EnvUtilities.java | 3 +- .../apache/oodt/commons/exec/ExecHelper.java | 3 +- .../org/apache/oodt/commons/io/LogWriter.java | 7 +++- .../oodt/commons/io/LoggerOutputStream.java | 3 +- .../apache/oodt/commons/util/DateConvert.java | 18 ++++++--- .../oodt/cas/crawl/daemon/CrawlDaemon.java | 5 ++- .../cas/filemgr/catalog/DataSourceCatalog.java | 5 ++- .../catalog/DataSourceCatalogFactory.java | 8 ++-- .../filemgr/catalog/LuceneCatalogFactory.java | 14 ++++--- .../datatransfer/RemoteDataTransferer.java | 15 +++---- .../tools/MetadataBasedProductMover.java | 9 +++-- .../filemgr/tools/OptimizeLuceneCatalog.java | 6 ++- .../apache/oodt/grid/ProductQueryServlet.java | 7 +++- .../preconditions/MimeTypeComparator.java | 2 +- .../oodt/cas/metadata/util/MimeTypeUtils.java | 3 +- .../apache/oodt/pcs/tools/PCSHealthMonitor.java | 6 ++- .../oodt/pcs/util/WorkflowManagerUtils.java | 2 +- .../product/handlers/ofsn/util/OFSNUtils.java | 3 +- .../xmlquery/ChunkedProductInputStream.java | 5 ++- .../java/org/apache/oodt/profile/Profile.java | 22 +++++----- .../cas/protocol/ftp/CogJGlobusFtpProtocol.java | 3 +- .../oodt/cas/protocol/http/HttpProtocol.java | 3 +- .../cas/protocol/sftp/JschSftpProtocol.java | 3 +- .../retrievalsystem/FileRetrievalSystem.java | 16 +++++--- .../retrievalsystem/RetrievalSetup.java | 5 ++- .../monitor/ganglia/GangliaAdapter.java | 3 +- .../cas/resource/scheduler/LRUScheduler.java | 3 +- .../system/XmlRpcResourceManagerClient.java | 12 ++++-- .../cas/product/data/DataDeliveryServlet.java | 6 ++- .../apache/oodt/cas/product/data/DataUtils.java | 3 +- .../product/data/DatasetDeliveryServlet.java | 3 +- .../engine/processor/ConditionProcessor.java | 4 +- .../engine/processor/TaskProcessor.java | 15 ++++--- .../oodt/cas/workflow/examples/LongTask.java | 6 ++- .../examples/RandomStatusUpdateTask.java | 3 +- ...SourceWorkflowInstanceRepositoryFactory.java | 5 ++- .../LuceneWorkflowInstanceRepository.java | 3 +- ...LuceneWorkflowInstanceRepositoryFactory.java | 5 ++- ...MemoryWorkflowInstanceRepositoryFactory.java | 5 ++- .../structs/HighestFIFOPrioritySorter.java | 3 +- .../oodt/cas/workflow/structs/Priority.java | 6 ++- .../oodt/xmlquery/CompressedStringCodec.java | 21 ++++++---- 54 files changed, 283 insertions(+), 161 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/CasDB.java ---------------------------------------------------------------------- diff --git a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/CasDB.java b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/CasDB.java index 4d58948..ffb57d0 100644 --- a/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/CasDB.java +++ b/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/model/CasDB.java @@ -32,6 +32,7 @@ import java.util.logging.Logger; public class CasDB { + public static final int INT = 20; URL filemgrUrl; XmlRpcFileManagerClient client; public Results results; @@ -117,7 +118,7 @@ public class CasDB { try { ProductType type = client.getProductTypeByName(productType); Vector<Product> products = (Vector<Product>) client.query(query, type); - int maxVal = 20; + int maxVal = INT; if (products.size() < maxVal) { maxVal = products.size(); } @@ -142,7 +143,7 @@ public class CasDB { Vector<Product> products = (Vector<Product>) client .getProductsByProductType(type); // for(int i=0;i<products.size();i++){ - int maxVal = 20; + int maxVal = INT; if (products.size() < maxVal) { maxVal = products.size(); } @@ -162,7 +163,7 @@ public class CasDB { try { type = client.getProductTypeByName(productType); Vector<Product> products = (Vector<Product>) client.query(casQ, type); - int maxVal = 20; + int maxVal = INT; if (products.size() < maxVal) { maxVal = products.size(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/catalog/src/main/java/org/apache/oodt/cas/catalog/cli/action/CatalogServiceCliAction.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/cli/action/CatalogServiceCliAction.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/cli/action/CatalogServiceCliAction.java index 0cd80ff..90ed978 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/cli/action/CatalogServiceCliAction.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/cli/action/CatalogServiceCliAction.java @@ -30,6 +30,9 @@ import org.apache.oodt.cas.cli.action.CmdLineAction; */ public abstract class CatalogServiceCliAction extends CmdLineAction { + public static final int VAL = 1024; + public static final int VAL1 = 20; + public static final int VAL2 = 60; private CatalogServiceClient client; private String getUrl() { @@ -37,15 +40,15 @@ public abstract class CatalogServiceCliAction extends CmdLineAction { } private int getChunkSize() { - return Integer.getInteger("org.apache.oodt.cas.catalog.chunkSize", 1024); + return Integer.getInteger("org.apache.oodt.cas.catalog.chunkSize", VAL); } private int getRequestTimeout() { - return Integer.getInteger("org.apache.oodt.cas.catalog.requestTimeout", 20); + return Integer.getInteger("org.apache.oodt.cas.catalog.requestTimeout", VAL1); } private int getConnectionTimeout() { - return Integer.getInteger("org.apache.oodt.cas.catalog.connectionTimeout", 60); + return Integer.getInteger("org.apache.oodt.cas.catalog.connectionTimeout", VAL2); } private int getAutoPagerSize() { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java index 9622b18..9d9c6a8 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/server/channel/xmlrpc/XmlRpcCommunicationChannelClient.java @@ -55,14 +55,15 @@ import java.util.Vector; */ public class XmlRpcCommunicationChannelClient extends AbstractCommunicationChannelClient { - protected XmlRpcClient client; + public static final int INT = 60; + protected XmlRpcClient client; protected int chunkSize; public XmlRpcCommunicationChannelClient(URL serverUrl, int connectionTimeout, int requestTimeout, int chunkSize) { super(); CommonsXmlRpcTransportFactory transportFactory = new CommonsXmlRpcTransportFactory(serverUrl); - transportFactory.setConnectionTimeout(connectionTimeout * 60 * 1000); - transportFactory.setTimeout(requestTimeout * 60 * 1000); + transportFactory.setConnectionTimeout(connectionTimeout * INT * 1000); + transportFactory.setTimeout(requestTimeout * INT * 1000); this.client = new XmlRpcClient(serverUrl, transportFactory); this.chunkSize = chunkSize; } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java index 426626f..78b5d33 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClientFactory.java @@ -34,12 +34,13 @@ import org.springframework.beans.factory.annotation.Required; * <p> */ public class CatalogServiceClientFactory implements CatalogServiceFactory { - - protected CommunicationChannelClientFactory communicationChannelClientFactory; + + public static final int INT = 500; + protected CommunicationChannelClientFactory communicationChannelClientFactory; protected int autoPagerSize; public CatalogServiceClientFactory() { - this.autoPagerSize = 500; + this.autoPagerSize = INT; } public CatalogServiceClient createCatalogService() { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocalFactory.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocalFactory.java b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocalFactory.java index 5ef8204..8b36c98 100644 --- a/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocalFactory.java +++ b/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceLocalFactory.java @@ -17,19 +17,20 @@ package org.apache.oodt.cas.catalog.system.impl; //JDK imports -import java.io.File; -import java.util.logging.Level; -import java.util.logging.Logger; - -//OODT imports import org.apache.oodt.cas.catalog.mapping.IngestMapperFactory; import org.apache.oodt.cas.catalog.repository.CatalogRepositoryFactory; import org.apache.oodt.cas.catalog.struct.TransactionIdFactory; import org.apache.oodt.cas.catalog.system.CatalogServiceFactory; -//Spring imports import org.springframework.beans.factory.annotation.Required; +import java.io.File; +import java.util.logging.Level; +import java.util.logging.Logger; + +//OODT imports +//Spring imports + //OODT imports /** @@ -42,7 +43,8 @@ import org.springframework.beans.factory.annotation.Required; */ public class CatalogServiceLocalFactory implements CatalogServiceFactory { - private static Logger LOG = Logger.getLogger(CatalogServiceLocalFactory.class.getName()); + public static final int INT = 200; + private static Logger LOG = Logger.getLogger(CatalogServiceLocalFactory.class.getName()); protected CatalogRepositoryFactory catalogRepositoryFactory = null; protected IngestMapperFactory ingestMapperFactory = null; @@ -53,7 +55,7 @@ public class CatalogServiceLocalFactory implements CatalogServiceFactory { protected boolean oneCatalogFailsAllFail = false; protected boolean simplifyQueries = false; protected boolean disableIntersectingCrossCatalogQueries = false; - protected int crossCatalogResultSortingThreshold = 200; + protected int crossCatalogResultSortingThreshold = INT; public CatalogServiceLocalFactory() {} http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/Configuration.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/Configuration.java b/commons/src/main/java/org/apache/oodt/commons/Configuration.java index d57265c..a6e2fd3 100644 --- a/commons/src/main/java/org/apache/oodt/commons/Configuration.java +++ b/commons/src/main/java/org/apache/oodt/commons/Configuration.java @@ -17,18 +17,38 @@ package org.apache.oodt.commons; -import java.io.*; +import org.apache.oodt.commons.util.DOMParser; +import org.apache.oodt.commons.util.XML; + +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.util.*; -import org.apache.oodt.commons.util.*; -import org.w3c.dom.*; -import org.xml.sax.*; +import java.rmi.registry.Registry; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.StringTokenizer; + import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NoInitialContextException; -import java.rmi.registry.Registry; /** EDA Configuration. * @@ -37,7 +57,9 @@ import java.rmi.registry.Registry; * @author Kelly */ public class Configuration { - /** The singleton configuration. */ + public static final int INT = 7577; + public static final int INT1 = 6000000; + /** The singleton configuration. */ static Configuration configuration = null; /** Name of property that specifies the direcotries that contains XML entities. */ @@ -198,8 +220,8 @@ public class Configuration { } Configuration() { - serverMgrPort = 7577; - nameServerStateFrequency = 6000000; + serverMgrPort = INT; + nameServerStateFrequency = INT1; nameServerObjectKey = "StandardNS%20POA"; nameServerPort = "10000"; nameServerHost = "localhost"; @@ -732,7 +754,7 @@ public class Configuration { context = new InitialContext(contextEnvironment); } catch (NamingException ex) { exception = ex; - } catch (Throwable t) { + } catch (Exception t) { System.err.println("Unexpected throwable " + t.getClass().getName() + " getting initial context: " + t.getMessage()); t.printStackTrace(); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/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 3a84c30..5adb83c 100644 --- a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java +++ b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java @@ -57,7 +57,10 @@ import javax.naming.NamingException; * @author Kelly */ public class ExecServer { - /** Start a server. + + public static final int MILLIS = 15000; + + /** Start a server. * * The command-line should have two arguments: * @@ -339,7 +342,7 @@ public class ExecServer { new Thread() { public void run() { try { - Thread.sleep(15000); + Thread.sleep(MILLIS); } catch (InterruptedException ignore) {} System.exit(1); } @@ -373,7 +376,8 @@ public class ExecServer { org.omg.CORBA.ORB orb = s._orb(); orb.shutdown(false/*=>terminate without waiting for reqs to complete*/); } - } catch (Throwable ignore) {} + } catch (Exception ignore) { + } } /** @@ -393,7 +397,7 @@ public class ExecServer { Context objectContext = configuration.getObjectContext(); objectContext.rebind(name, server.getServant()); objectContext.close(); - } catch (Throwable ex) { + } catch (Exception ex) { System.err.println("Exception binding at " + new Date() + "; will keep trying..."); ex.printStackTrace(); } finally { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/Executable.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/Executable.java b/commons/src/main/java/org/apache/oodt/commons/Executable.java index 6af49f8..beef03b 100644 --- a/commons/src/main/java/org/apache/oodt/commons/Executable.java +++ b/commons/src/main/java/org/apache/oodt/commons/Executable.java @@ -28,7 +28,10 @@ import java.io.*; * @author Kelly */ public abstract class Executable { - /** Construct an executable. + + public static final int INT = 1024; + + /** Construct an executable. */ public Executable() {} @@ -70,7 +73,7 @@ public abstract class Executable { new Thread() { public void run() { try { - byte[] buf = new byte[1024]; + byte[] buf = new byte[INT]; for (;;) { int numRead = in.read(buf); if (numRead == -1) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/MultiServer.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/MultiServer.java b/commons/src/main/java/org/apache/oodt/commons/MultiServer.java index d47accd..ba06b72 100644 --- a/commons/src/main/java/org/apache/oodt/commons/MultiServer.java +++ b/commons/src/main/java/org/apache/oodt/commons/MultiServer.java @@ -17,6 +17,16 @@ package org.apache.oodt.commons; +import org.apache.oodt.commons.util.LogInit; +import org.apache.oodt.commons.util.XML; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Constructor; @@ -28,20 +38,13 @@ import java.util.Hashtable; import java.util.Map; import java.util.Timer; import java.util.TimerTask; + import javax.naming.Context; import javax.naming.NamingException; import javax.naming.spi.NamingManager; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.oodt.commons.util.LogInit; -import org.apache.oodt.commons.util.XML; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; /** * The MultiServer runs multiple server objects in a single JVM. Instead of running a @@ -176,11 +179,11 @@ public class MultiServer { } }); startup(); - } catch (Throwable ex) { + } catch (Exception ex) { ex.printStackTrace(); try { shutdown(); - } catch (Throwable ignore) {} + } catch (Exception ignore) {} System.exit(1); } for (;;) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/activity/Activity.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/activity/Activity.java b/commons/src/main/java/org/apache/oodt/commons/activity/Activity.java index 39610f2..8b3e677 100644 --- a/commons/src/main/java/org/apache/oodt/commons/activity/Activity.java +++ b/commons/src/main/java/org/apache/oodt/commons/activity/Activity.java @@ -17,12 +17,13 @@ package org.apache.oodt.commons.activity; +import org.apache.oodt.commons.net.Net; + import java.net.InetAddress; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Random; -import org.apache.oodt.commons.net.Net; /** * An activity is an occurrence of some active action. It has a unique ID in the @@ -33,7 +34,11 @@ import org.apache.oodt.commons.net.Net; * @version $Revision: 1.2 $ */ public abstract class Activity { - /** + + public static final int INT = 32; + public static final int INT1 = 0xff; + + /** * Creates a new {@link Activity} instance. * */ @@ -102,14 +107,14 @@ public abstract class Activity { InetAddress addr = Net.getLocalHost(); // Get the local host's IP address long nextNum = ++counter; // Get the next 64 bit number Date date = new Date(); // Get the current time - byte[] bytes = new byte[32]; // Make space for 32 random bytes + byte[] bytes = new byte[INT]; // Make space for 32 random bytes RANDOM.nextBytes(bytes); // Fill in 32 random bytes MessageDigest messageDigest = MessageDigest.getInstance("MD5");// Prepare to take a hash messageDigest.update((String.valueOf(addr) + nextNum + date).getBytes()); // Add the 1st 3 components byte[] sig = messageDigest.digest(bytes); // And add the random bytes StringBuilder output = new StringBuilder(); // Make space to store the hash as a string for (byte aSig : sig) { - output.append(Integer.toHexString(((int) aSig) & 0xff));// Store it as a hex value + output.append(Integer.toHexString(((int) aSig) & INT1));// Store it as a hex value } return output.toString(); // And return the string } catch (NoSuchAlgorithmException ex) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLogger.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLogger.java b/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLogger.java index 64bf60b..03a0014 100644 --- a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLogger.java +++ b/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLogger.java @@ -37,14 +37,18 @@ import java.util.Map; * @version $Revision: 1.1 $ */ class DatagramLogger { - public static void main(String[] argv) throws Throwable { + + public static final int VAL = 4556; + public static final int INT = 2048; + + public static void main(String[] argv) throws Throwable { if (argv.length > 0) { System.err.println("This program takes NO command line arguments."); System.err.println("Set the activity.port property to adjust the port number."); System.err.println("Set the activity.storage property to set the Storage class to use."); System.exit(1); } - int port = Integer.getInteger("activity.port", 4556); + int port = Integer.getInteger("activity.port", VAL); String className = System.getProperty("activity.storage"); if (className == null) { System.err.println("No Storage class defined via the `activity.storage' property; exiting..."); @@ -53,7 +57,7 @@ class DatagramLogger { Class storageClass = Class.forName(className); storage = (Storage) storageClass.newInstance(); DatagramSocket socket = new DatagramSocket(port); - byte[] buf = new byte[2048]; + byte[] buf = new byte[INT]; DatagramPacket packet = new DatagramPacket(buf, buf.length); for (;;) { socket.receive(packet); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactory.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactory.java b/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactory.java index dd95806..5325747 100644 --- a/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactory.java +++ b/commons/src/main/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactory.java @@ -45,14 +45,17 @@ import java.net.UnknownHostException; * @version $Revision: 1.1 $ */ public class DatagramLoggingActivityFactory implements ActivityFactory { - /** + + public static final int VAL = 4556; + + /** * Creates a new {@link DatagramLoggingActivityFactory} instance. */ public DatagramLoggingActivityFactory() { String hostname = System.getProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host", System.getProperty("activity.host", "")); port = Integer.getInteger("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port", - Integer.getInteger("activity.port", 4556)); + Integer.getInteger("activity.port", VAL)); if (hostname.length() == 0) { throw new IllegalStateException( "System property `org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host'" http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java b/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java index aefadd2..5e630a7 100644 --- a/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java +++ b/commons/src/main/java/org/apache/oodt/commons/exec/EnvUtilities.java @@ -43,6 +43,7 @@ public final class EnvUtilities { private static final Logger LOG = Logger.getLogger(EnvUtilities.class .getName()); + public static final int INT = 4096; private EnvUtilities() throws InstantiationException { throw new InstantiationException("Don't construct utility classes!"); @@ -141,7 +142,7 @@ public final class EnvUtilities { */ public static String slurp(InputStream in) throws IOException { StringBuilder out = new StringBuilder(); - byte[] b = new byte[4096]; + byte[] b = new byte[INT]; for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/exec/ExecHelper.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/exec/ExecHelper.java b/commons/src/main/java/org/apache/oodt/commons/exec/ExecHelper.java index b5df16e..3dc1fe2 100644 --- a/commons/src/main/java/org/apache/oodt/commons/exec/ExecHelper.java +++ b/commons/src/main/java/org/apache/oodt/commons/exec/ExecHelper.java @@ -42,6 +42,7 @@ import java.util.logging.Logger; * */ public final class ExecHelper { + public static final int INT = 1024; private static Logger LOG = Logger.getLogger(ExecHelper.class.getName()); /** @@ -349,7 +350,7 @@ public final class ExecHelper { stdout = new InputStreamReader(process.getInputStream(), charset); stderr = new InputStreamReader(process.getErrorStream(), charset); } - char[] buffer = new char[1024]; + char[] buffer = new char[INT]; boolean done = false; boolean stdoutclosed = false; http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/io/LogWriter.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/io/LogWriter.java b/commons/src/main/java/org/apache/oodt/commons/io/LogWriter.java index d6d89ee..aaa1f0e 100644 --- a/commons/src/main/java/org/apache/oodt/commons/io/LogWriter.java +++ b/commons/src/main/java/org/apache/oodt/commons/io/LogWriter.java @@ -34,14 +34,17 @@ import java.util.Date; * @author Kelly */ public class LogWriter extends java.io.Writer { - /** Constructor. + + public static final int CAPACITY = 80; + + /** Constructor. * * @param timestamp The time for messages logged with the returned writer. * @param source The source of the log message. * @param category The messages' category. */ LogWriter(Date timestamp, String source, Object category) { - buf = new StringBuffer(/*length*/ 80); + buf = new StringBuffer(/*length*/ CAPACITY); lock = buf; this.timestamp = timestamp; this.source = source; http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/io/LoggerOutputStream.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/io/LoggerOutputStream.java b/commons/src/main/java/org/apache/oodt/commons/io/LoggerOutputStream.java index d89689c..f29f782 100644 --- a/commons/src/main/java/org/apache/oodt/commons/io/LoggerOutputStream.java +++ b/commons/src/main/java/org/apache/oodt/commons/io/LoggerOutputStream.java @@ -32,8 +32,9 @@ public class LoggerOutputStream extends OutputStream { public static final String NUM_BYTES_PER_WRITE_PROPERTY = "org.apache.oodt.commons.io.logger.os.bytes.per.write"; + public static final int VAL = 512; private static final int NUM_BYTES_PER_WRITE = Integer.getInteger( - NUM_BYTES_PER_WRITE_PROPERTY, 512); + NUM_BYTES_PER_WRITE_PROPERTY, VAL); private Logger logger; private CharBuffer buffer; http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/commons/src/main/java/org/apache/oodt/commons/util/DateConvert.java ---------------------------------------------------------------------- diff --git a/commons/src/main/java/org/apache/oodt/commons/util/DateConvert.java b/commons/src/main/java/org/apache/oodt/commons/util/DateConvert.java index f328d1c..8eae030 100644 --- a/commons/src/main/java/org/apache/oodt/commons/util/DateConvert.java +++ b/commons/src/main/java/org/apache/oodt/commons/util/DateConvert.java @@ -30,7 +30,7 @@ import java.util.TimeZone; */ public class DateConvert { - /** + /** The number of milliseconds in a minute. */ private final static long MS_IN_MINUTE = 60000; @@ -71,9 +71,13 @@ public class DateConvert { The format string representing the Year-Month-Day format. */ private final static String YMD_FORMAT = "yyyy-MM-dd"; + public static final int INT = 24; + public static final int BEGIN_INDEX = 23; + public static final int ERROR_OFFSET = 24; + public static final int ERROR_OFFSET1 = 25; - /** + /** Constructor given no arguments. This is a static-only class that may not be instantiated. @@ -161,12 +165,12 @@ public class DateConvert { dateFormat.setLenient(false); // The length of the input string should be at least 24 characters. - if (inputString == null || inputString.length() < 24) { + if (inputString == null || inputString.length() < INT) { throw new ParseException("An exception occurred because the input date/time string was null or under 24 characters in length.", inputString.length()); } // Evaluate the the specified offset and set the time zone. - String offsetString = inputString.substring(23); + String offsetString = inputString.substring(BEGIN_INDEX); if (offsetString.equals("Z")) { dateFormat.setTimeZone(TimeZone.getTimeZone("Greenwich Mean Time")); } @@ -179,7 +183,8 @@ public class DateConvert { offsetFormat.applyPattern("HH:mm"); } else { - throw new ParseException("An exception occurred because the offset portion was not the valid length of 3 or 6 characters.", 25); + throw new ParseException("An exception occurred because the offset portion was not the valid length of 3 or 6 characters.", + ERROR_OFFSET1); } // Validate the given offset. @@ -189,7 +194,8 @@ public class DateConvert { dateFormat.setTimeZone(TimeZone.getTimeZone("GMT" + offsetString)); } else { - throw new ParseException("An exception occurred because the offset portion of the input date/time string was not 'Z' or did not start with '+' or '-'.", 24); + throw new ParseException("An exception occurred because the offset portion of the input date/time string was not 'Z' or did not start with '+' or '-'.", + ERROR_OFFSET); } // Parse the given string. http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemon.java ---------------------------------------------------------------------- diff --git a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemon.java b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemon.java index cb13ad2..f993303 100644 --- a/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemon.java +++ b/crawler/src/main/java/org/apache/oodt/cas/crawl/daemon/CrawlDaemon.java @@ -40,6 +40,7 @@ import java.util.logging.Logger; */ public class CrawlDaemon { + public static final double DOUBLE = 1000.0; /* our log stream */ private static Logger LOG = Logger.getLogger(CrawlDaemon.class.getName()); @@ -95,9 +96,9 @@ public class CrawlDaemon { LOG.log(Level.INFO, "Crawl Daemon: Shutting down gracefully"); LOG.log(Level.INFO, "Num Crawls: [" + this.numCrawls + "]"); LOG.log(Level.INFO, "Total time spent crawling: [" - + (this.milisCrawling / 1000.0) + "] seconds"); + + (this.milisCrawling / DOUBLE) + "] seconds"); LOG.log(Level.INFO, "Average Crawl Time: [" - + (this.getAverageCrawlTime() / 1000.0) + "] seconds"); + + (this.getAverageCrawlTime() / DOUBLE) + "] seconds"); server.shutdown(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java index 4d0e145..f178d9b 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java @@ -69,7 +69,8 @@ import javax.sql.DataSource; */ public class DataSourceCatalog implements Catalog { - /* our sql data source */ + public static final int INT = 60; + /* our sql data source */ protected DataSource dataSource = null; /* our log stream */ @@ -1874,7 +1875,7 @@ public class DataSourceCatalog implements Catalog { long timeDifferenceMilis = currentTime.getTime() - lastUpdateTimeDate.getTime(); long timeDifferenceSeconds = timeDifferenceMilis * 1000; - long timeDifferenceMinutes = timeDifferenceSeconds / 60; + long timeDifferenceMinutes = timeDifferenceSeconds / INT; return timeDifferenceMinutes < cacheUpdateMinutes; } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalogFactory.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalogFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalogFactory.java index 1f4f1c8..352e24c 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalogFactory.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalogFactory.java @@ -36,7 +36,9 @@ import javax.sql.DataSource; * */ public class DataSourceCatalogFactory implements CatalogFactory { - /* our data source */ + public static final int VAL = 20; + public static final long VAL1 = 5L; + /* our data source */ protected DataSource dataSource = null; /* our validation layer */ @@ -129,11 +131,11 @@ public class DataSourceCatalogFactory implements CatalogFactory { pageSize = Integer .getInteger( "org.apache.oodt.cas.filemgr.catalog.datasource.pageSize", - 20); + VAL); cacheUpdateMinutes = Long .getLong( "org.apache.oodt.cas.filemgr.catalog.datasource.cacheUpdateMinutes", - 5L); + VAL1); productIdString = Boolean.parseBoolean( System.getProperty("org.apache.oodt.cas.filemgr.catalog.datasource.productId.string", "false") ); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalogFactory.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalogFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalogFactory.java index 1f64633..f70fa71 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalogFactory.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalogFactory.java @@ -41,7 +41,11 @@ import org.apache.lucene.index.IndexWriter; */ public class LuceneCatalogFactory implements CatalogFactory { - /* path to the index directory for lucene catalogs */ + public static final int VAL = 20; + public static final int VAL1 = 60; + public static final int VAL2 = 60; + public static final int VAL3 = 20; + /* path to the index directory for lucene catalogs */ private String indexFilePath = null; /* our validation layer */ @@ -92,18 +96,18 @@ public class LuceneCatalogFactory implements CatalogFactory { .getValidationLayerFromFactory(validationLayerFactoryClass); } - pageSize = Integer.getInteger("org.apache.oodt.cas.filemgr.catalog.lucene.pageSize", 20); + pageSize = Integer.getInteger("org.apache.oodt.cas.filemgr.catalog.lucene.pageSize", VAL); commitLockTimeOut = Long .getLong( "org.apache.oodt.cas.filemgr.catalog.lucene.commitLockTimeout.seconds", - 60); + VAL1); writeLockTimeOut = Long .getLong( "org.apache.oodt.cas.filemgr.catalog.lucene.writeLockTimeout.seconds", - 60); + VAL2); mergeFactor = Integer.getInteger( - "org.apache.oodt.cas.filemgr.catalog.lucene.mergeFactor", 20); + "org.apache.oodt.cas.filemgr.catalog.lucene.mergeFactor", VAL3); } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java index bf8b7e9..827dcef 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/datatransfer/RemoteDataTransferer.java @@ -50,10 +50,11 @@ import java.util.logging.Logger; */ public class RemoteDataTransferer implements DataTransfer { - /* - * the url pointer to the file manager that we'll remotely transfer the file - * to - */ + public static final int NUM_BYTES = 1024; + /* + * the url pointer to the file manager that we'll remotely transfer the file + * to + */ private URL fileManagerUrl = null; /* @@ -174,15 +175,15 @@ public class RemoteDataTransferer implements DataTransfer { int offset = 0; while (true) { fileData = (byte[]) client.retrieveFile( - dataStoreFile.getAbsolutePath(), offset, 1024); + dataStoreFile.getAbsolutePath(), offset, NUM_BYTES); if (fileData.length <= 0) { break; } fOut.write(fileData); - if (fileData.length < 1024) { + if (fileData.length < NUM_BYTES) { break; } - offset += 1024; + offset += NUM_BYTES; } } catch (Exception e) { throw new DataTransferException("", e); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java index 8092018..2cf6649 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java @@ -49,10 +49,11 @@ import java.util.logging.Logger; */ public class MetadataBasedProductMover { + public static final double DOUBLE = 1000.0; /* - * the metadata path sepc string, e.g., - * /path/to/final/loc/[LocalDay]/[Filename] - */ + * the metadata path sepc string, e.g., + * /path/to/final/loc/[LocalDay]/[Filename] + */ private String pathSpec = null; /* the client to the file manager */ @@ -113,7 +114,7 @@ public class MetadataBasedProductMover { long timeBefore = System.currentTimeMillis(); fmgrClient.moveProduct(p, newLocPath); long timeAfter = System.currentTimeMillis(); - double seconds = ((timeAfter - timeBefore) * 1.0) / (1000.0); + double seconds = ((timeAfter - timeBefore) * 1.0) / DOUBLE; LOG.log(Level.INFO, "Product: [" + p.getProductName() + "] move successful: took: [" + seconds + "] seconds"); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/OptimizeLuceneCatalog.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/OptimizeLuceneCatalog.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/OptimizeLuceneCatalog.java index 9cec69b..dd92f28 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/OptimizeLuceneCatalog.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/OptimizeLuceneCatalog.java @@ -37,6 +37,8 @@ import org.apache.lucene.index.IndexWriter; */ public class OptimizeLuceneCatalog { + public static final double DOUBLE = 1000.0; + public static final int INT = 20; /* the path to the lucene index directory */ private String catalogPath = null; @@ -66,7 +68,7 @@ public class OptimizeLuceneCatalog { long timeBefore = System.currentTimeMillis(); writer.optimize(); long timeAfter = System.currentTimeMillis(); - double numSeconds = ((timeAfter - timeBefore) * 1.0) / 1000.0; + double numSeconds = ((timeAfter - timeBefore) * 1.0) / DOUBLE; LOG.log(Level.INFO, "LuceneCatalog: [" + this.catalogPath + "] optimized: took: [" + numSeconds + "] seconds"); } catch (IOException e) { @@ -105,7 +107,7 @@ public class OptimizeLuceneCatalog { } if (mergeFactor == -1) { - mergeFactor = 20; // default + mergeFactor = INT; // default } OptimizeLuceneCatalog optimizer = new OptimizeLuceneCatalog(catPath, http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java ---------------------------------------------------------------------- diff --git a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java index 7f6c0d9..20408af 100755 --- a/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java +++ b/grid/src/main/java/org/apache/oodt/grid/ProductQueryServlet.java @@ -41,7 +41,10 @@ import javax.servlet.http.HttpServletResponse; * */ public class ProductQueryServlet extends QueryServlet { - /** {@inheritDoc} */ + + public static final int INT = 512; + + /** {@inheritDoc} */ protected List getServers(Configuration config) { return config.getProductServers(); } @@ -96,7 +99,7 @@ public class ProductQueryServlet extends QueryServlet { BufferedInputStream in = null; // Start with no input stream try { // Then try ... in = new BufferedInputStream(result.getInputStream()); // To open the input stream - byte[] buf = new byte[512]; // And a byte buffer for data + byte[] buf = new byte[INT]; // And a byte buffer for data int num; // And a place to count data while ((num = in.read(buf)) != -1) // While we read { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java index 193d640..b9ad353 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/MimeTypeComparator.java @@ -62,7 +62,7 @@ public class MimeTypeComparator extends PreConditionComparator<String> { .readMagicHeader(new FileInputStream(product))); } return tikaMimeType.compareTo(mimeType); - } catch (Throwable e) { + } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); throw new PreconditionComparatorException( "Failed to get mime-type for " + product + " : " http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java ---------------------------------------------------------------------- diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java index da613d5..76a79fc 100644 --- a/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java +++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/util/MimeTypeUtils.java @@ -51,6 +51,7 @@ import org.apache.tika.mime.MimeTypesFactory; public final class MimeTypeUtils { private static final String SEPARATOR = ";"; + public static final int HEADER_BYTE_SIZE = 1024; /* our Tika mime type registry */ private MimeTypes mimeTypes; @@ -338,7 +339,7 @@ public final class MimeTypeUtils { } public static byte[] readMagicHeader(InputStream stream) throws IOException { - return readMagicHeader(stream, 1024); + return readMagicHeader(stream, HEADER_BYTE_SIZE); } public static byte[] readMagicHeader(InputStream stream, int headerByteSize) http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java index 75f2eef..dd65060 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/tools/PCSHealthMonitor.java @@ -60,6 +60,8 @@ import java.util.logging.Logger; */ public final class PCSHealthMonitor implements CoreMetKeys, PCSHealthMonitorMetKeys { + public static final double DOUBLE = 1000.0; + public static final double DOUBLE1 = 1000.0; private static Logger LOG = Logger.getLogger(PCSHealthMonitor.class.getName()); private FileManagerUtils fm; @@ -359,7 +361,7 @@ public final class PCSHealthMonitor implements CoreMetKeys, health.setCrawlerName(info.getCrawlerName()); health.setNumCrawls(controller.getNumCrawls()); health - .setAvgCrawlTime((double) (controller.getAverageCrawlTime() / 1000.0)); + .setAvgCrawlTime((double) (controller.getAverageCrawlTime() / DOUBLE)); statuses.add(health); } catch (Exception e) { @@ -560,7 +562,7 @@ public final class PCSHealthMonitor implements CoreMetKeys, System.out.println(info.getCrawlerName() + ":"); System.out.println("Number of Crawls: " + controller.getNumCrawls()); System.out.println("Average Crawl Time (seconds): " - + (double) (controller.getAverageCrawlTime() / 1000.0)); + + (double) (controller.getAverageCrawlTime() / DOUBLE1)); System.out.println(""); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java ---------------------------------------------------------------------- diff --git a/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java b/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java index 020ec6e..3d2fac8 100644 --- a/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java +++ b/pcs/core/src/main/java/org/apache/oodt/pcs/util/WorkflowManagerUtils.java @@ -80,7 +80,7 @@ public class WorkflowManagerUtils { try { return this.client.getWorkflowInstances(); - } catch (Throwable ignore) { + } catch (Exception ignore) { return Collections.EMPTY_LIST; } } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/util/OFSNUtils.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/util/OFSNUtils.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/util/OFSNUtils.java index 719c245..b8b4583 100644 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/util/OFSNUtils.java +++ b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/util/OFSNUtils.java @@ -60,6 +60,7 @@ import javax.xml.parsers.ParserConfigurationException; */ public final class OFSNUtils implements OODTMetKeys, OFSNXMLMetKeys, OFSNMetKeys { + public static final int INT = 1024; private static Logger LOG = Logger.getLogger(OFSNUtils.class.getName()); public static String extractFieldFromQuery(XMLQuery query, String name) { for (Iterator<QueryElement> i = query.getWhereElementSet().iterator(); i @@ -136,7 +137,7 @@ public final class OFSNUtils implements OODTMetKeys, OFSNXMLMetKeys, public static File buildZipFile(String zipFileFullPath, File[] files) { // Create a buffer for reading the files - byte[] buf = new byte[1024]; + byte[] buf = new byte[INT]; ZipOutputStream out = null; try { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java b/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java index e3a43d1..f4376f0 100644 --- a/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java +++ b/product/src/main/java/org/apache/oodt/xmlquery/ChunkedProductInputStream.java @@ -209,6 +209,7 @@ final class ChunkedProductInputStream extends InputStream { /** Is the stream open? */ private boolean open; - /** Size of chunks. */ - private static final int BLOCK_SIZE = Integer.getInteger("org.apache.oodt.xmlquery.blockSize", 4096); + public static final int VAL = 4096; + /** Size of chunks. */ + private static final int BLOCK_SIZE = Integer.getInteger("org.apache.oodt.xmlquery.blockSize", VAL); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/profile/src/main/java/org/apache/oodt/profile/Profile.java ---------------------------------------------------------------------- diff --git a/profile/src/main/java/org/apache/oodt/profile/Profile.java b/profile/src/main/java/org/apache/oodt/profile/Profile.java index cc0dc16..510c348 100644 --- a/profile/src/main/java/org/apache/oodt/profile/Profile.java +++ b/profile/src/main/java/org/apache/oodt/profile/Profile.java @@ -21,16 +21,9 @@ package org.apache.oodt.profile; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; - -import java.io.Serializable; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.oodt.commons.util.Documentable; import org.apache.oodt.commons.util.XML; + import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; @@ -42,6 +35,12 @@ import org.xml.sax.SAXException; import java.io.BufferedReader; import java.io.FileReader; import java.io.OutputStreamWriter; +import java.io.Serializable; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * A profile. @@ -51,13 +50,14 @@ import java.io.OutputStreamWriter; * @author Kelly */ public class Profile implements Serializable, Cloneable, Comparable<Object>, Documentable { - /** Serial version unique ID. */ + /** Serial version unique ID. */ static final long serialVersionUID = -3936851809184360591L; /** The formal public identifier of the profiles DTD. */ public static final String PROFILES_DTD_FPI = "-//JPL//DTD Profile 1.1//EN"; + public static final int INT = 512; - /** The system identifier of the profiles DTD. */ + /** The system identifier of the profiles DTD. */ public static String PROFILES_DTD_URL = "http://oodt.jpl.nasa.gov/grid-profile/dtd/prof.dtd"; /** @@ -383,7 +383,7 @@ public class Profile implements Serializable, Cloneable, Comparable<Object>, Doc } StringBuilder b = new StringBuilder(); BufferedReader reader = new BufferedReader(new FileReader(argv[0])); - char[] buf = new char[512]; + char[] buf = new char[INT]; int num; while ((num = reader.read(buf)) != -1) { b.append(buf, 0, num); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java index 3273b7a..3da3636 100644 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java +++ b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java @@ -39,13 +39,14 @@ import java.util.Vector; */ public class CogJGlobusFtpProtocol implements Protocol { + public static final int PORT = 21; private FTPClient ftp; private boolean isConnected; private int port; private String homeDir; public CogJGlobusFtpProtocol() { - this(21); + this(PORT); } public CogJGlobusFtpProtocol(int port) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java index 1146b19..b3ff038 100644 --- a/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java +++ b/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http/HttpProtocol.java @@ -49,6 +49,7 @@ import java.util.Map; */ public class HttpProtocol implements Protocol { + public static final int INT = 1024; private static Map<String, List<HttpFile>> linkChildren = new HashMap<String, List<HttpFile>>(); private HttpFile parentFile; @@ -119,7 +120,7 @@ public class HttpProtocol implements Protocol { in = HttpUtils.resolveUri(currentFile.getLink().toURI(), fromFile.getPath()).toURL().openStream(); } - byte[] buffer = new byte[1024]; + byte[] buffer = new byte[INT]; int numRead; long numWritten = 0; while ((numRead = in.read(buffer)) != -1) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/protocol/sftp/src/main/java/org/apache/oodt/cas/protocol/sftp/JschSftpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/sftp/src/main/java/org/apache/oodt/cas/protocol/sftp/JschSftpProtocol.java b/protocol/sftp/src/main/java/org/apache/oodt/cas/protocol/sftp/JschSftpProtocol.java index 3c82489..1ddbe45 100644 --- a/protocol/sftp/src/main/java/org/apache/oodt/cas/protocol/sftp/JschSftpProtocol.java +++ b/protocol/sftp/src/main/java/org/apache/oodt/cas/protocol/sftp/JschSftpProtocol.java @@ -46,6 +46,7 @@ import java.util.Vector; */ public class JschSftpProtocol implements Protocol { + public static final int PORT = 22; private Session session; private ChannelSftp sftpChannel; @@ -57,7 +58,7 @@ public class JschSftpProtocol implements Protocol { private static final JSch jsch = new JSch(); public JschSftpProtocol() { - this(22); + this(PORT); } public JschSftpProtocol(int port) { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java index fde2d18..5c211ed 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java @@ -119,13 +119,17 @@ import com.google.common.base.Strings; */ public class FileRetrievalSystem { - /* our log stream */ + /* our log stream */ private static final Logger LOG = Logger .getLogger(FileRetrievalSystem.class.getName()); private final static int MAX_RETRIES = 3; + public static final int INT = 180; + public static final int TIMEOUT = 5000; + public static final int TIMEOUT1 = 5000; + public static final int TIMEOUT2 = 600; - private LinkedList<ProtocolFile> failedDownloadList; + private LinkedList<ProtocolFile> failedDownloadList; private HashSet<ProtocolFile> currentlyDownloading; @@ -386,12 +390,12 @@ public class FileRetrievalSystem { public void waitUntilAllCurrentDownloadsAreComplete() throws ProtocolException { synchronized (this) { - for (int i = 0; i < 180; i++) { + for (int i = 0; i < INT; i++) { try { if (this.avaliableSessions.size() == this.numberOfSessions) { return; } else { - this.wait(5000); + this.wait(TIMEOUT); } } catch (Exception ignored) { } @@ -495,7 +499,7 @@ public class FileRetrievalSystem { + file + " . . . retrying in 5 secs"); synchronized (this) { try { - wait(5000); + wait(TIMEOUT1); } catch (Exception ignored) { } } @@ -919,7 +923,7 @@ public class FileRetrievalSystem { // close out threadpool threadController.shutdown(); // give a max of 10 minutes to finish downloading any files - threadController.awaitTermination(600, TimeUnit.SECONDS); + threadController.awaitTermination(TIMEOUT2, TimeUnit.SECONDS); } catch (Exception e) { // log failure } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java index 7567911..bbc009e 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java @@ -46,7 +46,8 @@ import java.util.logging.Logger; */ public class RetrievalSetup { - private final Config config; + public static final int TIMEOUT = 5000; + private final Config config; private final HashSet<File> alreadyProcessedPropFiles; @@ -202,7 +203,7 @@ public class RetrievalSetup { "Waiting data download thread for 5 secs to give the property files download thread a head start"); synchronized (this) { try { - this.wait(5000); + this.wait(TIMEOUT); } catch (Exception ignored) { } } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaAdapter.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaAdapter.java b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaAdapter.java index 64ea0b5..35db224 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaAdapter.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaAdapter.java @@ -46,6 +46,7 @@ import java.util.Map; public class GangliaAdapter { private static final String ENCODING = "ISO-8859-1"; + public static final int PORT = -9999; private String host; @@ -58,7 +59,7 @@ public class GangliaAdapter { } protected GangliaAdapter(){ - this(null, -9999); + this(null, PORT); } /** http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java index 698c871..38b89c4 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java @@ -50,6 +50,7 @@ public class LRUScheduler implements Scheduler { /* our log stream */ private static final Logger LOG = Logger.getLogger(LRUScheduler.class .getName()); + public static final double DOUBLE = 1000.0; private LRUQueueManager queueManager; @@ -86,7 +87,7 @@ public class LRUScheduler implements Scheduler { for (;;) { try { - long sleepTime = (long)(waitTime * 1000.0); + long sleepTime = (long)(waitTime * DOUBLE); Thread.currentThread().sleep(sleepTime); } catch (Exception ignore) {} http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java index 0c6a318..bb19e13 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java @@ -56,6 +56,10 @@ import java.util.logging.Logger; */ public class XmlRpcResourceManagerClient { + public static final int VAL = 20; + public static final int INT = 60; + public static final int VAL1 = 60; + public static final int INT1 = 60; /* our xml rpc client */ private XmlRpcClient client = null; @@ -99,13 +103,13 @@ public class XmlRpcResourceManagerClient { int connectionTimeoutMins = Integer .getInteger( "org.apache.oodt.cas.resource.system.xmlrpc.connectionTimeout.minutes", - 20); - int connectionTimeout = connectionTimeoutMins * 60 * 1000; + VAL); + int connectionTimeout = connectionTimeoutMins * INT * 1000; int requestTimeoutMins = Integer .getInteger( "org.apache.oodt.cas.resource.system.xmlrpc.requestTimeout.minutes", - 60); - int requestTimeout = requestTimeoutMins * 60 * 1000; + VAL1); + int requestTimeout = requestTimeoutMins * INT1 * 1000; transportFactory.setConnectionTimeout(connectionTimeout); transportFactory.setTimeout(requestTimeout); client = new XmlRpcClient(url, transportFactory); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java index 7855c43..4ab6b59 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java @@ -55,6 +55,8 @@ import javax.servlet.ServletException; public class DataDeliveryServlet extends HttpServlet implements DataDeliveryKeys { + public static final int INT = 512; + /** {@inheritDoc} */ public void init(ServletConfig config) throws ServletException { super.init(config); @@ -187,7 +189,7 @@ public class DataDeliveryServlet extends HttpServlet implements // 3. Deliver the data. o2 = res.getOutputStream(); - byte[] buf = new byte[512]; + byte[] buf = new byte[INT]; int n; while ((n = in.read(buf)) != -1) { o2.write(buf, 0, n); @@ -241,7 +243,7 @@ public class DataDeliveryServlet extends HttpServlet implements URLConnection c = url.openConnection(); InputStream in = c.getInputStream(); OutputStream out = res.getOutputStream(); - byte[] buf = new byte[512]; + byte[] buf = new byte[INT]; int n; while ((n = in.read(buf)) != -1) { out.write(buf, 0, n); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java index cb2267f..6ab2ee0 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java @@ -63,6 +63,7 @@ public final class DataUtils implements DataDeliveryKeys { } }; + public static final int INT = 512; public static String createDatasetZipFile(ProductType type, String workingDirPath) throws IOException, CasProductException { @@ -218,7 +219,7 @@ public final class DataUtils implements DataDeliveryKeys { private static void addZipEntryFromStream(InputStream is, ZipOutputStream os, String filename) throws IOException { - byte[] buf = new byte[512]; + byte[] buf = new byte[INT]; os.putNextEntry(new ZipEntry(filename)); int len; http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java index 2542764..7e79c98 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java @@ -59,6 +59,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements /* serial version UID */ private static final long serialVersionUID = -6692665690674186105L; + public static final int INT = 512; /* our file manager client */ private XmlRpcFileManagerClient client; @@ -192,7 +193,7 @@ public class DatasetDeliveryServlet extends HttpServlet implements // 3. Deliver the data. o2 = res.getOutputStream(); - byte[] buf = new byte[512]; + byte[] buf = new byte[INT]; int n; while ((n = in.read(buf)) != -1) { o2.write(buf, 0, n); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/ConditionProcessor.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/ConditionProcessor.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/ConditionProcessor.java index 1cee170..bb00d39 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/ConditionProcessor.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/ConditionProcessor.java @@ -32,6 +32,8 @@ import org.apache.oodt.cas.workflow.structs.WorkflowInstance; */ public class ConditionProcessor extends TaskProcessor { + public static final double DOUBLE = 0.1; + public ConditionProcessor(WorkflowLifecycleManager lifecycleManager, WorkflowInstance inst) { super(lifecycleManager, inst); } @@ -56,7 +58,7 @@ public class ConditionProcessor extends TaskProcessor { @Override public void setWorkflowInstance(WorkflowInstance instance) { instance.setPriority(Priority - .getPriority(instance.getPriority().getValue() - 0.1)); + .getPriority(instance.getPriority().getValue() - DOUBLE)); super.setWorkflowInstance(instance); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java index 0ec3744..cd9c092 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java @@ -18,15 +18,16 @@ package org.apache.oodt.cas.workflow.engine.processor; //JDK imports +import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager; +import org.apache.oodt.cas.workflow.structs.Priority; +import org.apache.oodt.cas.workflow.structs.WorkflowInstance; +import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance; + import java.util.Calendar; import java.util.List; import java.util.Vector; //OODT imports -import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager; -import org.apache.oodt.cas.workflow.structs.Priority; -import org.apache.oodt.cas.workflow.structs.WorkflowInstance; -import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance; /** * @@ -39,6 +40,8 @@ import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance; */ public class TaskProcessor extends WorkflowProcessor { + public static final double DOUBLE = 0.1; + public static final int INT = 60; private Class<? extends WorkflowTaskInstance> instanceClass; private String jobId; @@ -66,7 +69,7 @@ public class TaskProcessor extends WorkflowProcessor { @Override public void setWorkflowInstance(WorkflowInstance instance) { instance.setPriority(Priority - .getPriority(instance.getPriority().getValue() + 0.1)); + .getPriority(instance.getPriority().getValue() + DOUBLE)); super.setWorkflowInstance(instance); } @@ -88,7 +91,7 @@ public class TaskProcessor extends WorkflowProcessor { Calendar calendar = Calendar.getInstance(); calendar.setTime(this.getWorkflowInstance().getState().getStartTime()); long elapsedTime = ((System.currentTimeMillis() - calendar - .getTimeInMillis()) / 1000) / 60; + .getTimeInMillis()) / 1000) / INT; if (elapsedTime >= requiredBlockTimeElapse) { tps.add(this); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/LongTask.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/LongTask.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/LongTask.java index bfcbd01..d186f55 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/LongTask.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/LongTask.java @@ -33,7 +33,9 @@ import org.apache.oodt.cas.metadata.Metadata; */ public class LongTask implements WorkflowTaskInstance { - /** + public static final long LONG = 10L; + + /** * */ public LongTask() { @@ -48,7 +50,7 @@ public class LongTask implements WorkflowTaskInstance { public void run(Metadata metadata, WorkflowTaskConfiguration config) { //simulate that this job takes a passed in amount of seconds to execute for - long waitSeconds = (String)metadata.getMetadata("numSeconds") != null ? Long.parseLong((String)metadata.getMetadata("numSeconds")):10L; + long waitSeconds = (String)metadata.getMetadata("numSeconds") != null ? Long.parseLong((String)metadata.getMetadata("numSeconds")): LONG; System.out.println("Task: Num seconds: "+waitSeconds); try{ http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/RandomStatusUpdateTask.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/RandomStatusUpdateTask.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/RandomStatusUpdateTask.java index 8f06c49..928a649 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/RandomStatusUpdateTask.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/examples/RandomStatusUpdateTask.java @@ -45,6 +45,7 @@ import java.util.logging.Logger; * programmatically. */ public class RandomStatusUpdateTask implements WorkflowTaskInstance { + public static final long MILLIS = 5000L; private static Logger LOG = Logger.getLogger(RandomStatusUpdateTask.class.getName()); private static final String[] statuses = new String[] { "THINKING", "RUNNING", "WAITING", "INFINITELY WAITING", "WATCHING TV", @@ -75,7 +76,7 @@ public class RandomStatusUpdateTask implements WorkflowTaskInstance { String statusPicked = statuses[idx]; updateWorkflowInstanceStatus(workflowInstId, statusPicked); try { - Thread.currentThread().sleep(5000L); + Thread.currentThread().sleep(MILLIS); } catch (InterruptedException ignore) { } numPicked++; http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java index be665c4..b58ce96 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/DataSourceWorkflowInstanceRepositoryFactory.java @@ -38,7 +38,8 @@ import javax.sql.DataSource; public class DataSourceWorkflowInstanceRepositoryFactory implements WorkflowInstanceRepositoryFactory { - /* our data source */ + public static final int VAL = 20; + /* our data source */ private DataSource dataSource = null; /* whether or not we are quoting the task_id and workflow_id fields */ @@ -80,7 +81,7 @@ public class DataSourceWorkflowInstanceRepositoryFactory implements quoteFields = Boolean .getBoolean("org.apache.oodt.cas.workflow.instanceRep.datasource.quoteFields"); pageSize = Integer.getInteger( - "org.apache.oodt.cas.workflow.instanceRep.pageSize", 20); + "org.apache.oodt.cas.workflow.instanceRep.pageSize", VAL); } http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java index 52689cb..eca00ec 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java @@ -69,6 +69,7 @@ import org.safehaus.uuid.UUIDGenerator; public class LuceneWorkflowInstanceRepository extends AbstractPaginatibleInstanceRepository { + public static final int MERGE_FACTOR = 20; /* path to lucene index directory to store wInst info */ private String idxFilePath = null; @@ -443,7 +444,7 @@ public class LuceneWorkflowInstanceRepository extends try { writer = new IndexWriter(idxFilePath, new StandardAnalyzer(), createIndex); - writer.setMergeFactor(20); + writer.setMergeFactor(MERGE_FACTOR); Document doc = toDoc(wInst); writer.addDocument(doc); http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepositoryFactory.java index 5b8bdc8..b0dc070 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepositoryFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepositoryFactory.java @@ -40,7 +40,8 @@ import org.apache.lucene.index.IndexWriter; public class LuceneWorkflowInstanceRepositoryFactory implements WorkflowInstanceRepositoryFactory { - /* the path to the lucene index directory */ + public static final int VAL = 20; + /* the path to the lucene index directory */ private String indexFilePath = null; private int pageSize = -1; @@ -62,7 +63,7 @@ public class LuceneWorkflowInstanceRepositoryFactory implements // do env variable replacement indexFilePath = PathUtils.replaceEnvVariables(indexFilePath); pageSize = Integer.getInteger( - "org.apache.oodt.cas.workflow.instanceRep.pageSize", 20); + "org.apache.oodt.cas.workflow.instanceRep.pageSize", VAL); } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/MemoryWorkflowInstanceRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/MemoryWorkflowInstanceRepositoryFactory.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/MemoryWorkflowInstanceRepositoryFactory.java index afe6989..539c961 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/MemoryWorkflowInstanceRepositoryFactory.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/MemoryWorkflowInstanceRepositoryFactory.java @@ -28,7 +28,8 @@ package org.apache.oodt.cas.workflow.instrepo; */ public class MemoryWorkflowInstanceRepositoryFactory implements WorkflowInstanceRepositoryFactory { - + + public static final int VAL = 20; private int pageSize = -1; /** @@ -38,7 +39,7 @@ public class MemoryWorkflowInstanceRepositoryFactory implements */ public MemoryWorkflowInstanceRepositoryFactory() { pageSize = Integer.getInteger( - "org.apache.oodt.cas.workflow.instanceRep.pageSize", 20); + "org.apache.oodt.cas.workflow.instanceRep.pageSize", VAL); } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/HighestFIFOPrioritySorter.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/HighestFIFOPrioritySorter.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/HighestFIFOPrioritySorter.java index 883537a..dca168c 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/HighestFIFOPrioritySorter.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/HighestFIFOPrioritySorter.java @@ -43,6 +43,7 @@ import java.util.logging.Logger; */ public class HighestFIFOPrioritySorter implements PrioritySorter { + public static final double DOUBLE = 1000.0; private int secondsBetweenBoosts; private double boostAmount; private double boostCap; @@ -86,7 +87,7 @@ public class HighestFIFOPrioritySorter implements PrioritySorter { aliveTime = 0.0; } - double boostPercentage = aliveTime / 1000.0 + double boostPercentage = aliveTime / DOUBLE / (double) this.secondsBetweenBoosts; return Math.max( processorStub.getWorkflowInstance().getPriority().getValue(), http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Priority.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Priority.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Priority.java index 6552e83..28058c3 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Priority.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Priority.java @@ -45,9 +45,10 @@ public abstract class Priority implements Comparable<Priority> { return "LOW"; } }; + public static final double DOUBLE = 2.5; public static final Priority MEDIUM_LOW = new Priority() { public double getValue() { - return 2.5; + return DOUBLE; } public String getName() { @@ -63,9 +64,10 @@ public abstract class Priority implements Comparable<Priority> { return "MEDIUM"; } }; + public static final double DOUBLE1 = 7.5; public static final Priority MEDIUM_HIGH = new Priority() { public double getValue() { - return 7.5; + return DOUBLE1; } public String getName() { http://git-wip-us.apache.org/repos/asf/oodt/blob/a666bd1a/xmlquery/src/main/java/org/apache/oodt/xmlquery/CompressedStringCodec.java ---------------------------------------------------------------------- diff --git a/xmlquery/src/main/java/org/apache/oodt/xmlquery/CompressedStringCodec.java b/xmlquery/src/main/java/org/apache/oodt/xmlquery/CompressedStringCodec.java index de26113..9f7175e 100755 --- a/xmlquery/src/main/java/org/apache/oodt/xmlquery/CompressedStringCodec.java +++ b/xmlquery/src/main/java/org/apache/oodt/xmlquery/CompressedStringCodec.java @@ -18,20 +18,22 @@ package org.apache.oodt.xmlquery; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; import org.apache.oodt.commons.io.Base64DecodingInputStream; import org.apache.oodt.commons.io.Base64EncodingOutputStream; import org.apache.oodt.commons.util.XML; + import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + /** A result encoder/decoder for compressed strings. * * This codec uses a GZIP compressed string format for objects. @@ -39,7 +41,10 @@ import org.w3c.dom.Node; * @author Kelly */ class CompressedStringCodec implements Codec { - public Node encode(Object object, Document doc) throws DOMException { + + public static final int INT = 1024; + + public Node encode(Object object, Document doc) throws DOMException { ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); try { Base64EncodingOutputStream base64 = new Base64EncodingOutputStream(byteArray); @@ -66,7 +71,7 @@ class CompressedStringCodec implements Codec { GZIPInputStream gzip = new GZIPInputStream(base64); StringBuilder b = new StringBuilder(); int numRead; - byte[] buf = new byte[1024]; + byte[] buf = new byte[INT]; while ((numRead = gzip.read(buf)) != -1) { b.append(new String(buf, 0, numRead)); }
