log publisher implementation contd.

Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/fa543bf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/fa543bf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/fa543bf6

Branch: refs/heads/master
Commit: fa543bf6cd8bcff7254cc120f78deb2c0079ac45
Parents: 41001a9
Author: Isuru <[email protected]>
Authored: Wed Feb 12 10:26:20 2014 +0530
Committer: Isuru <[email protected]>
Committed: Wed Feb 12 10:26:20 2014 +0530

----------------------------------------------------------------------
 .../stratos/cartridge/agent/CartridgeAgent.java | 22 +++++++++++++++-----
 .../data/publisher/log/LogPublisherManager.java |  5 ++++-
 2 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fa543bf6/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
index c1fb542..ddb5279 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
@@ -141,16 +141,32 @@ public class CartridgeAgent implements Runnable {
 
         // start log publishing
         LogPublisherManager logPublisherManager = new LogPublisherManager();
+        publishLogs(logPublisherManager);
+
+        while (!terminated);
+
+        logPublisherManager.stop();
+    }
+
+    private static void publishLogs (LogPublisherManager logPublisherManager) {
+
         // check if enabled
         if (DataPublisherConfiguration.getInstance().isEnabled()) {
 
             List<String> logFilePaths = 
CartridgeAgentConfiguration.getInstance().getLogFilePaths();
             if (logFilePaths == null) {
                 log.error("No valid log file paths found, no logs will be 
published");
+                return;
 
             } else {
                 // initialize the log publishing
-                
logPublisherManager.init(DataPublisherConfiguration.getInstance());
+                try {
+                    
logPublisherManager.init(DataPublisherConfiguration.getInstance());
+
+                } catch (DataPublisherException e) {
+                    log.error("Error occurred in log publisher 
initialization", e);
+                    return;
+                }
 
                 // start a log publisher for each file path
                 for (String logFilePath : logFilePaths) {
@@ -163,10 +179,6 @@ public class CartridgeAgent implements Runnable {
                 }
             }
         }
-
-        while (!terminated);
-
-        logPublisherManager.stop();
     }
 
     private void onArtifactUpdateEvent(ArtifactUpdatedEvent event) {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fa543bf6/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/data/publisher/log/LogPublisherManager.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/data/publisher/log/LogPublisherManager.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/data/publisher/log/LogPublisherManager.java
index 1049fdd..8c61b62 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/data/publisher/log/LogPublisherManager.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/data/publisher/log/LogPublisherManager.java
@@ -42,7 +42,7 @@ public class LogPublisherManager {
     private static StreamDefinition streamDefinition = null;
     private static List<LogPublisher> fileBasedLogPublishers = new 
ArrayList<LogPublisher>();
 
-    public void init (DataPublisherConfiguration dataPublisherConfig) {
+    public void init (DataPublisherConfiguration dataPublisherConfig) throws 
DataPublisherException {
 
         this.dataPublisherConfig = dataPublisherConfig;
 
@@ -52,6 +52,9 @@ public class LogPublisherManager {
 
         // wait till monitoring server ports are active
         
CartridgeAgentUtils.waitUntilPortsActive(dataPublisherConfig.getMonitoringServerIp(),
 ports);
+        
if(!CartridgeAgentUtils.checkPortsActive(dataPublisherConfig.getMonitoringServerIp(),
 ports)) {
+            throw new DataPublisherException("Monitoring server not not 
active, data publishing is aborted");
+        }
 
         // stream definition identifier = {log.publisher.<cluster id>}
         try {

Reply via email to