You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2015/10/25 23:54:52 UTC

[12/12] oodt git commit: OODT-907 remove co

OODT-907 remove co


Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/905c96a9
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/905c96a9
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/905c96a9

Branch: refs/heads/master
Commit: 905c96a95169e88a70e33734d280d3e457993f49
Parents: 7a5e0fa
Author: Tom Barber <to...@analytical-labs.com>
Authored: Sun Oct 25 22:53:40 2015 +0000
Committer: Tom Barber <to...@analytical-labs.com>
Committed: Sun Oct 25 22:53:40 2015 +0000

----------------------------------------------------------------------
 .../apache/oodt/cas/pushpull/daemon/Daemon.java | 122 ++++++++++---------
 1 file changed, 63 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oodt/blob/905c96a9/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 661e242..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
@@ -55,7 +55,7 @@ import javax.management.ObjectName;
  * @author bfoster
  */
 public class Daemon extends UnicastRemoteObject implements DaemonRmiInterface,
-        DaemonMBean {
+                                                           DaemonMBean {
 
     private static final long serialVersionUID = 7660972939723142802L;
 
@@ -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);
         }
     }
 
@@ -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");
     }
 
     /**
@@ -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() {
@@ -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