ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1516385 - in /ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent: ./ impl/
Date Thu, 22 Aug 2013 08:39:46 GMT
Author: bramk
Date: Thu Aug 22 08:39:46 2013
New Revision: 1516385

URL: http://svn.apache.org/r1516385
Log:
ACE-347 ACE-382 Moved feedback to seperate interface/handler

Added:
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackHandler.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
Modified:
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventLoggerImpl.java

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java Thu Aug 22 08:39:46
2013
@@ -79,6 +79,13 @@ public interface AgentContext {
     AgentUpdateHandler getAgentUpdateHandler();
 
     /**
+     * Return the feedback handler.
+     * 
+     * @return The handler
+     */
+    FeedbackHandler getFeedbackHandler();
+
+    /**
      * Return the agent control service.
      * 
      * @return The service

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java Thu Aug 22 08:39:46
2013
@@ -18,8 +18,6 @@
  */
 package org.apache.ace.agent;
 
-import java.util.List;
-
 /**
  * The agent's control (service) interface. Provides control functions and access to configuration
for consumers that
  * wish to control the agent's behavior.
@@ -38,9 +36,6 @@ public interface AgentControl {
     /** Returns the update handler */
     AgentUpdateHandler getAgentUpdateHandler();
 
-    /** Returns the feedback channels names */
-    List<String> getFeedbackChannelNames();
-
-    /** Returns the feedback channel for a name */
-    FeedbackChannel getFeedbackChannel(String name);
+    /** Returns the feedback handler */
+    FeedbackHandler getFeedbackHandler();
 }

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackHandler.java?rev=1516385&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackHandler.java Thu Aug 22
08:39:46 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.agent;
+
+import java.util.List;
+
+/**
+ * Agent control delegate interface that is responsible for handling feedback channels.
+ */
+public interface FeedbackHandler {
+
+    /** Returns the feedback channels names */
+    List<String> getChannelNames();
+
+    /** Returns the feedback channel for a name */
+    FeedbackChannel getChannel(String name);
+}

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java Thu Aug 22
08:39:46 2013
@@ -37,6 +37,7 @@ import org.apache.ace.agent.ConnectionHa
 import org.apache.ace.agent.DeploymentHandler;
 import org.apache.ace.agent.DiscoveryHandler;
 import org.apache.ace.agent.DownloadHandler;
+import org.apache.ace.agent.FeedbackHandler;
 import org.apache.ace.agent.IdentificationHandler;
 import org.apache.felix.deploymentadmin.DeploymentAdminImpl;
 import org.apache.felix.dm.Component;
@@ -86,6 +87,7 @@ public class Activator extends Dependenc
         m_agentControl = new AgentControlImpl(m_agentContext);
         m_agentUpdateHandler = new AgentUpdateHandlerImpl(context);
 
+        // TODO replace with setters
         configureField(m_agentContext, AgentControl.class, m_agentControl);
         configureField(m_agentContext, ConfigurationHandler.class, new ConfigurationHandlerImpl());
         configureField(m_agentContext, ConnectionHandler.class, new ConnectionHandlerImpl());
@@ -95,6 +97,7 @@ public class Activator extends Dependenc
         configureField(m_agentContext, IdentificationHandler.class, new IdentificationHandlerImpl());
         configureField(m_agentContext, ScheduledExecutorService.class, m_executorService);
         configureField(m_agentContext, AgentUpdateHandler.class, m_agentUpdateHandler);
+        configureField(m_agentContext, FeedbackHandler.class, new FeedbackHandlerImpl());
 
         Component agentContextComponent = createComponent()
             .setImplementation(m_agentContext)

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java Thu
Aug 22 08:39:46 2013
@@ -31,6 +31,7 @@ import org.apache.ace.agent.ConnectionHa
 import org.apache.ace.agent.DeploymentHandler;
 import org.apache.ace.agent.DiscoveryHandler;
 import org.apache.ace.agent.DownloadHandler;
+import org.apache.ace.agent.FeedbackHandler;
 import org.apache.ace.agent.IdentificationHandler;
 import org.apache.ace.agent.impl.Activator.InternalEvents;
 import org.apache.ace.agent.impl.Activator.InternalLogger;
@@ -50,12 +51,13 @@ public class AgentContextImpl implements
     private volatile DownloadHandler m_downloadHandler;
     private volatile ConnectionHandler m_connectionHandler;
     private volatile AgentUpdateHandler m_agentUpdateHandler;
+    private volatile FeedbackHandler m_feedbackHandler;
 
     private volatile ScheduledExecutorService m_executorService;
 
     private final InternalLogger m_logger;
     private final InternalEvents m_events;
-    
+
     private final File m_workDir;
 
     public AgentContextImpl(File workDir, InternalLogger logger, InternalEvents events) {
@@ -73,11 +75,13 @@ public class AgentContextImpl implements
         startHandler(m_downloadHandler);
         startHandler(m_connectionHandler);
         startHandler(m_agentUpdateHandler);
+        startHandler(m_feedbackHandler);
         startHandler(m_agentControl);
     }
 
     public void stop() throws Exception {
         stopHandler(m_agentControl);
+        stopHandler(m_feedbackHandler);
         stopHandler(m_configurationHandler);
         stopHandler(m_identificationHandler);
         stopHandler(m_discoveryHandler);
@@ -139,6 +143,11 @@ public class AgentContextImpl implements
     }
 
     @Override
+    public FeedbackHandler getFeedbackHandler() {
+        return m_feedbackHandler;
+    }
+
+    @Override
     public File getWorkDir() {
         return m_workDir;
     }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java Thu
Aug 22 08:39:46 2013
@@ -19,10 +19,6 @@
 package org.apache.ace.agent.impl;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 import org.apache.ace.agent.AgentContext;
 import org.apache.ace.agent.AgentControl;
@@ -30,7 +26,7 @@ import org.apache.ace.agent.AgentUpdateH
 import org.apache.ace.agent.ConfigurationHandler;
 import org.apache.ace.agent.DeploymentHandler;
 import org.apache.ace.agent.DownloadHandler;
-import org.apache.ace.agent.FeedbackChannel;
+import org.apache.ace.agent.FeedbackHandler;
 
 /**
  * Implementation of the public agent control service.
@@ -40,12 +36,8 @@ public class AgentControlImpl implements
 
     private final AgentContext m_agentContext;
 
-    private final Map<String, FeedbackChannelImpl> m_feedbackChannels = new HashMap<String,
FeedbackChannelImpl>();
-
     public AgentControlImpl(AgentContext agentContext) throws IOException {
         m_agentContext = agentContext;
-        // TODO get from configuration
-        m_feedbackChannels.put("auditlog", new FeedbackChannelImpl(m_agentContext, "auditlog"));
     }
 
     @Override
@@ -64,20 +56,12 @@ public class AgentControlImpl implements
     }
 
     @Override
-    public List<String> getFeedbackChannelNames() {
-        // TODO get from configuration
-        List<String> channels = new ArrayList<String>();
-        channels.addAll(m_feedbackChannels.keySet());
-        return channels;
-    }
-
-    @Override
-    public FeedbackChannel getFeedbackChannel(String name) {
-        return m_feedbackChannels.get(name);
+    public AgentUpdateHandler getAgentUpdateHandler() {
+        return m_agentContext.getAgentUpdateHandler();
     }
 
     @Override
-    public AgentUpdateHandler getAgentUpdateHandler() {
-        return m_agentContext.getAgentUpdateHandler();
+    public FeedbackHandler getFeedbackHandler() {
+        return m_agentContext.getFeedbackHandler();
     }
 }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java Thu
Aug 22 08:39:46 2013
@@ -121,9 +121,9 @@ public class DefaultController implement
         m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Controller syncing...");
         long interval = configurationHandler.getLong(CONFIG_KEY_SYNCINTERVAL, CONFIG_DEFAULT_SYNCINTERVAL);
         try {
+            runSafeFeedback();
             runSafeAgent();
             runSafeUpdate();
-            runSafeFeedback();
         }
         catch (RetryAfterException e) {
             interval = e.getSeconds();
@@ -194,9 +194,9 @@ public class DefaultController implement
         AgentControl agentControl = m_agentContext.getAgentControl();
 
         m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Synchronizing feedback channels");
-        List<String> channelNames = agentControl.getFeedbackChannelNames();
+        List<String> channelNames = agentControl.getFeedbackHandler().getChannelNames();
         for (String channelName : channelNames) {
-            FeedbackChannel channel = agentControl.getFeedbackChannel(channelName);
+            FeedbackChannel channel = agentControl.getFeedbackHandler().getChannel(channelName);
             if (channel != null) {
                 channel.sendFeedback();
             }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventLoggerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventLoggerImpl.java?rev=1516385&r1=1516384&r2=1516385&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventLoggerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventLoggerImpl.java Thu
Aug 22 08:39:46 2013
@@ -236,7 +236,8 @@ public class EventLoggerImpl implements 
     }
 
     private void writeEvent(int eventType, Map<String, String> payload) {
-        FeedbackChannel channel = m_agentControl.getFeedbackChannel(EVENTLOGGER_FEEDBACKCHANNEL);
+        FeedbackChannel channel = m_agentControl.getFeedbackHandler()
+            .getChannel(EVENTLOGGER_FEEDBACKCHANNEL);
         if (channel != null) {
             try {
                 channel.write(eventType, payload);

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java?rev=1516385&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
(added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
Thu Aug 22 08:39:46 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.agent.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ace.agent.FeedbackChannel;
+import org.apache.ace.agent.FeedbackHandler;
+
+/**
+ * Default implementation of the feedback handler.
+ */
+public class FeedbackHandlerImpl extends HandlerBase implements FeedbackHandler {
+
+    private final Map<String, FeedbackChannelImpl> m_feedbackChannels = new HashMap<String,
FeedbackChannelImpl>();
+
+    public FeedbackHandlerImpl() {
+        super("feedback");
+    }
+
+    @Override
+    protected void onStart() throws Exception {
+        // TODO get from configuration
+        m_feedbackChannels.put("auditlog", new FeedbackChannelImpl(getAgentContext(), "auditlog"));
+    }
+
+    @Override
+    protected void onStop() throws Exception {
+        m_feedbackChannels.clear();
+    }
+
+    @Override
+    public List<String> getChannelNames() {
+        List<String> names = new ArrayList<String>(m_feedbackChannels.keySet());
+        return java.util.Collections.unmodifiableList(names);
+    }
+
+    @Override
+    public FeedbackChannel getChannel(String name) {
+        return m_feedbackChannels.get(name);
+    }
+}



Mime
View raw message