ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1524311 - in /ace/trunk: org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ org.apache.ace.agent/ org.apache.ace.agent/src/org/apache/ace/agent/ org.apache.ace.agent/src/org/apache/ace/agent/impl/ run-target/
Date Wed, 18 Sep 2013 07:22:52 GMT
Author: jawi
Date: Wed Sep 18 07:22:51 2013
New Revision: 1524311

URL: http://svn.apache.org/r1524311
Log:
ACE-323 - processed some review comments:

- moved the event topic for configuration changes to the AgentConstants to
  make it "publicly" available/usable;
- changed the named of the internally used event topics for reporting the
  installation progress to include 'defaultController' as to make it clear
  that it is something used only by this controller;
- fixed a typo in the property name (syndelay -> synCdelay);
- refactored the ResettableTimer to make use of the existing Scheduled-
  ExecutorService, instead of keeping its own instance;
- added some checks to the usages of ScheduledExecutorService to see whether
  it is not already shut down.


Modified:
    ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentDeploymentTest.java
    ace/trunk/org.apache.ace.agent/bnd.bnd
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionUtil.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/DiscoveryHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandleImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventsHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/InternalConstants.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ResettableTimer.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java
    ace/trunk/run-target/target.bndrun

Modified: ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentDeploymentTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentDeploymentTest.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentDeploymentTest.java
(original)
+++ ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/AgentDeploymentTest.java
Wed Sep 18 07:22:51 2013
@@ -324,8 +324,8 @@ public class AgentDeploymentTest extends
         }
     }
 
-    private static final String AGENT_INSTALLATION_START = "agent/installation/START";
-    private static final String AGENT_INSTALLATION_COMPLETE = "agent/installation/COMPLETE";
+    private static final String AGENT_INSTALLATION_START = "agent/defaultController/installation/START";
+    private static final String AGENT_INSTALLATION_COMPLETE = "agent/defaultController/installation/COMPLETE";
 
     private static final String AGENT_ID = "007";
     private static final String TEST_BUNDLE_NAME_PREFIX = "test.bundle";

Modified: ace/trunk/org.apache.ace.agent/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/bnd.bnd?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.agent/bnd.bnd Wed Sep 18 07:22:51 2013
@@ -44,4 +44,5 @@ javac.debug:  off
 -runbundles: org.apache.felix.gogo.command,\
 	org.apache.felix.gogo.runtime,\
 	org.apache.felix.gogo.shell
--runproperties: agent.controller.syncdelay=1
+-runproperties: agent.controller.syncdelay=1,\
+	agent.identification.agentid=demo

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java Wed Sep 18
07:22:51 2013
@@ -98,7 +98,7 @@ public interface AgentConstants {
      * Configuration option to set initial sync delay seconds of the default controller.
Should be an int, default is
      * <code>5</code>.
      */
-    String CONFIG_CONTROLLER_SYNCDELAY = CONFIG_KEY_NAMESPACE + ".controller.syndelay";
+    String CONFIG_CONTROLLER_SYNCDELAY = CONFIG_KEY_NAMESPACE + ".controller.syncdelay";
 
     /**
      * Configuration option to set initial sync interval seconds of the default controller.
Should be an int, default is
@@ -167,22 +167,32 @@ public interface AgentConstants {
     String CONFIG_FEEDBACK_CHANNELS = CONFIG_KEY_NAMESPACE + ".feedback.channels";
 
     /**
-     * Event topic for deployment install events.
+     * Event topic used to report changes in the agent's configuration. This topic is used
to report configuration
+     * changes to all interested listeners. To receive these events, register an {@link EventListener}
and check for
+     * this topic. The payload for these kind of events is a snapshot(!) of the current configuration.
+     */
+    String EVENT_AGENT_CONFIG_CHANGED = "agent/config/CHANGED";
+
+    /**
+     * Event topic for deployment install events, as used by the deployment admin service.
Note that this event is only
+     * fired for the installation of deployment packages.
      */
     String EVENT_DEPLOYMENT_INSTALL = "org/osgi/service/deployment/INSTALL";
 
     /**
-     * Event topic for deployment uninstall events.
+     * Event topic for deployment uninstall events, as used by the deployment admin service.
Note that this event is
+     * only fired for the uninstallation of deployment packages.
      */
     String EVENT_DEPLOYMENT_UNINSTALL = "org/osgi/service/deployment/UNINSTALL";
 
     /**
-     * Event topic for deployment install events.
+     * Event topic for deployment install events, as used by the deployment admin service.
Note that this event is only
+     * fired when the installation of deployment packages completes.
      */
     String EVENT_DEPLOYMENT_COMPLETE = "org/osgi/service/deployment/COMPLETE";
 
     /**
-     * HTTP headers name for Deployment Package size estimate.
+     * HTTP header name used for Deployment Package size estimate, in bytes.
      */
     String HEADER_DPSIZE = "X-ACE-DPSize";
 }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java Wed Sep
18 07:22:51 2013
@@ -18,12 +18,11 @@
  */
 package org.apache.ace.agent;
 
-import java.io.IOException;
 
 /**
  * Exception that indicates that the upstream server responded with a Retry-After.
  */
-public class RetryAfterException extends IOException {
+public class RetryAfterException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
     private final int m_seconds;

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
(original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
Wed Sep 18 07:22:51 2013
@@ -18,9 +18,9 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_KEY_NAMESPACE;
 import static org.apache.ace.agent.AgentConstants.CONFIG_KEY_RETAIN;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -49,14 +49,13 @@ public class ConfigurationHandlerImpl ex
     /** File name use for storage. */
     public static final String CONFIG_STORAGE_FILENAME = "config.properties";
 
-    private final ResettableTimer m_timer;
+    private ResettableTimer m_timer;
     private volatile ConcurrentMap<Object, Object> m_configProps;
 
     public ConfigurationHandlerImpl() {
         super("configuration");
 
         m_configProps = new ConcurrentHashMap<Object, Object>();
-        m_timer = new ResettableTimer(this, 1, TimeUnit.SECONDS);
     }
 
     @Override
@@ -150,6 +149,8 @@ public class ConfigurationHandlerImpl ex
     protected void onInit() throws Exception {
         loadConfig();
         loadSystemProps();
+
+        m_timer = new ResettableTimer(getExecutorService(), this, 5, TimeUnit.SECONDS);
     }
 
     @Override
@@ -160,9 +161,6 @@ public class ConfigurationHandlerImpl ex
 
     @Override
     protected void onStop() throws Exception {
-        if (!m_timer.isShutDown()) {
-            m_timer.shutDown();
-        }
         // Make sure the configuration is written one last time...
         storeConfig();
     }
@@ -172,7 +170,7 @@ public class ConfigurationHandlerImpl ex
         for (Map.Entry<Object, Object> entry : m_configProps.entrySet()) {
             props.put((String) entry.getKey(), (String) entry.getValue());
         }
-        getEventsHandler().postEvent(AGENT_CONFIG_CHANGED, props);
+        getEventsHandler().postEvent(EVENT_AGENT_CONFIG_CHANGED, props);
     }
 
     private File getConfigDir() throws IOException {
@@ -225,7 +223,9 @@ public class ConfigurationHandlerImpl ex
     }
 
     private void scheduleStore() {
-        m_timer.schedule();
+        if (!m_timer.schedule()) {
+            logWarning("Cannot schedule task to store configuration. Executor is shut down!");
+        }
     }
 
     private void storeConfig() throws IOException {

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
(original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
Wed Sep 18 07:22:51 2013
@@ -18,14 +18,15 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_AUTHTYPE;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_KEYFILE;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_KEYPASS;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_PASSWORD;
+import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_SSL_PROTOCOL;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_TRUSTFILE;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_TRUSTPASS;
-import static org.apache.ace.agent.AgentConstants.*;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
+import static org.apache.ace.agent.AgentConstants.CONFIG_CONNECTION_USERNAME;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -101,7 +102,7 @@ public class ConnectionHandlerImpl exten
 
     @Override
     public void handle(String topic, Map<String, String> payload) {
-        if (AGENT_CONFIG_CHANGED.equals(topic)) {
+        if (EVENT_AGENT_CONFIG_CHANGED.equals(topic)) {
             m_credentials = getCredentials(payload);
         }
     }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionUtil.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionUtil.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionUtil.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionUtil.java Wed Sep
18 07:22:51 2013
@@ -120,7 +120,7 @@ class ConnectionUtil {
      * @throws IOException
      *             if retrieving the response code failed.
      */
-    public static int getResponseCode(URLConnection connection) throws IOException {
+    private static int getResponseCode(URLConnection connection) throws IOException {
         if (connection instanceof HttpURLConnection) {
             return ((HttpURLConnection) connection).getResponseCode();
         }

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=1524311&r1=1524310&r2=1524311&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 Wed
Sep 18 07:22:51 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONTROLLER_DISABLED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONTROLLER_FIXPACKAGES;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONTROLLER_RETRIES;
@@ -25,7 +26,6 @@ import static org.apache.ace.agent.Agent
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONTROLLER_SYNCDELAY;
 import static org.apache.ace.agent.AgentConstants.CONFIG_CONTROLLER_SYNCINTERVAL;
 import static org.apache.ace.agent.impl.ConnectionUtil.closeSilently;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.impl.InternalConstants.AGENT_INSTALLATION_COMPLETE;
 import static org.apache.ace.agent.impl.InternalConstants.AGENT_INSTALLATION_START;
 
@@ -37,6 +37,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -85,7 +86,8 @@ public class DefaultController extends C
                     clearDownloadState();
                 }
             }
-            else {
+
+            if (m_downloadHandle == null) {
                 controller.logInfo("Starting download of %s update, %s => %s...", updateInfo.m_type,
updateInfo.m_from, updateInfo.m_to);
 
                 m_updateInfo = updateInfo;
@@ -427,7 +429,7 @@ public class DefaultController extends C
 
     @Override
     public void handle(String topic, Map<String, String> payload) {
-        if (AGENT_CONFIG_CHANGED.equals(topic)) {
+        if (EVENT_AGENT_CONFIG_CHANGED.equals(topic)) {
             String value = payload.get(CONFIG_CONTROLLER_DISABLED);
             if (value != null && !"".equals(value)) {
                 m_disabled.set(Boolean.parseBoolean(value));
@@ -539,7 +541,14 @@ public class DefaultController extends C
 
     protected void scheduleRun(long seconds) {
         unscheduleRun();
-        m_scheduledFuture = getExecutorService().schedule(this, seconds, TimeUnit.SECONDS);
+
+        ScheduledExecutorService executor = getExecutorService();
+        if (executor.isShutdown()) {
+            logWarning("Cannot schedule controller task, executor is shut down!");
+        }
+        else {
+            m_scheduledFuture = executor.schedule(this, seconds, TimeUnit.SECONDS);
+        }
     }
 
     protected void sendDeploymentCompletedEvent(UpdateInfo updateInfo, boolean success) {

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java
(original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java
Wed Sep 18 07:22:51 2013
@@ -18,9 +18,9 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_DISCOVERY_CHECKING;
 import static org.apache.ace.agent.AgentConstants.CONFIG_DISCOVERY_SERVERURLS;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
 
 import java.io.IOException;
 import java.net.HttpURLConnection;
@@ -134,7 +134,7 @@ public class DiscoveryHandlerImpl extend
 
     @Override
     public void handle(String topic, Map<String, String> payload) {
-        if (AGENT_CONFIG_CHANGED.equals(topic)) {
+        if (EVENT_AGENT_CONFIG_CHANGED.equals(topic)) {
             String value = payload.get(CONFIG_DISCOVERY_SERVERURLS);
             if (value != null && !"".equals(value.trim())) {
                 String[] urls = value.trim().split("\\s*,\\s*");

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandleImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandleImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandleImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandleImpl.java Wed
Sep 18 07:22:51 2013
@@ -83,7 +83,14 @@ class DownloadHandleImpl implements Down
             }
         }
 
-        return m_future = getExecutor().submit(new DownloadCallableImpl(this, listener, m_file,
m_readBufferSize));
+        ExecutorService executor = getExecutor();
+        if (executor.isShutdown()) {
+            m_handler.logWarning("Cannot start download, executor is shut down!");
+        } else {
+            m_future = executor.submit(new DownloadCallableImpl(this, listener, m_file, m_readBufferSize));
+        }
+
+        return m_future;
     }
 
     @Override
@@ -108,7 +115,7 @@ class DownloadHandleImpl implements Down
     final ConnectionHandler getConnectionHandler() {
         return m_handler.getConnectionHandler();
     }
-    
+
     final URL getURL() {
         return m_url;
     }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventsHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventsHandlerImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventsHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/EventsHandlerImpl.java Wed
Sep 18 07:22:51 2013
@@ -21,6 +21,7 @@ package org.apache.ace.agent.impl;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.ace.agent.EventListener;
 import org.apache.ace.agent.EventsHandler;
@@ -56,7 +57,12 @@ public class EventsHandlerImpl extends C
         // Make sure that the payload isn't changed while posting events...
         final Map<String, String> eventPayload = new HashMap<String, String>(payload);
         for (final EventListener listener : m_listeners) {
-            getExecutorService().submit(new Runnable() {
+            ScheduledExecutorService executor = getExecutorService();
+            if (executor.isShutdown()) {
+                logWarning("Cannot post event, executor is shut down!");
+                return;
+            }
+            executor.submit(new Runnable() {
                 @Override
                 public void run() {
                     try {

Modified: 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=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
(original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/FeedbackHandlerImpl.java
Wed Sep 18 07:22:51 2013
@@ -18,8 +18,8 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_FEEDBACK_CHANNELS;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
 
 import java.io.IOException;
 import java.util.HashSet;
@@ -56,7 +56,7 @@ public class FeedbackHandlerImpl extends
 
     @Override
     public void handle(String topic, Map<String, String> payload) {
-        if (AGENT_CONFIG_CHANGED.equals(topic)) {
+        if (EVENT_AGENT_CONFIG_CHANGED.equals(topic)) {
             String value = payload.get(CONFIG_FEEDBACK_CHANNELS);
             if (value != null && !"".equals(value.trim())) {
                 Set<String> seen = new HashSet<String>(m_channels.keySet());

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/InternalConstants.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/InternalConstants.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/InternalConstants.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/InternalConstants.java Wed
Sep 18 07:22:51 2013
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.ace.agent.impl;
 
 /**
@@ -24,16 +23,13 @@ package org.apache.ace.agent.impl;
  */
 public interface InternalConstants {
     /**
-     * Event topic used to report changes in the agent's configuration.
-     */
-    String AGENT_CONFIG_CHANGED = "agent/config/CHANGED";
-    /**
-     * Internal event topic used when the installation of a deployment package or agent update
is started.
+     * Internal event topic used by the default controller to fire events when the installation
of a deployment package
+     * <em>or</em> agent update is started. This is sent always prior to the
beginning of an installation.
      */
-    String AGENT_INSTALLATION_START = "agent/installation/START";
+    String AGENT_INSTALLATION_START = "agent/defaultController/installation/START";
     /**
-     * Internal event topic used when the installation of a deployment package or agent update
is complete (either or
-     * not successful).
+     * Internal event topic used by the default controller to fire events when the installation
of a deployment package
+     * <em>or</em> agent update is complete (either or not successful).
      */
-    String AGENT_INSTALLATION_COMPLETE = "agent/installation/COMPLETE";
+    String AGENT_INSTALLATION_COMPLETE = "agent/defaultController/installation/COMPLETE";
 }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java Wed
Sep 18 07:22:51 2013
@@ -18,8 +18,8 @@
  */
 package org.apache.ace.agent.impl;
 
+import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 import static org.apache.ace.agent.AgentConstants.CONFIG_LOGGING_LEVEL;
-import static org.apache.ace.agent.impl.InternalConstants.AGENT_CONFIG_CHANGED;
 
 import java.util.Date;
 import java.util.Map;
@@ -43,7 +43,7 @@ public class LoggingHandlerImpl extends 
     
     @Override
     public void handle(String topic, Map<String, String> payload) {
-        if (AGENT_CONFIG_CHANGED.equals(topic)) {
+        if (EVENT_AGENT_CONFIG_CHANGED.equals(topic)) {
             String newValue = payload.get(CONFIG_LOGGING_LEVEL);
 
             m_logLevel = fromName(newValue);

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ResettableTimer.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ResettableTimer.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ResettableTimer.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ResettableTimer.java Wed
Sep 18 07:22:51 2013
@@ -20,14 +20,13 @@ package org.apache.ace.agent.impl;
 
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Provides a timer that can be reset.
  * <p>
- * Taken from Apache Felix UserAdmin File-based store implementation.
+ * Taken and adapted from Apache Felix UserAdmin File-based store implementation.
  * </p>
  */
 final class ResettableTimer {
@@ -40,20 +39,6 @@ final class ResettableTimer {
     /**
      * Creates a new {@link ResettableTimer} calling a given task when a given timeout exceeds.
      * 
-     * @param task
-     *            the task to execute upon timout, cannot be <code>null</code>;
-     * @param timeout
-     *            the timeout value, > 0;
-     * @param unit
-     *            the time unit of the timeout value, cannot be <code>null</code>.
-     */
-    public ResettableTimer(Runnable task, long timeout, TimeUnit unit) {
-        this(new ScheduledThreadPoolExecutor(1), task, timeout, unit);
-    }
-
-    /**
-     * Creates a new {@link ResettableTimer} calling a given task when a given timeout exceeds.
-     * 
      * @param executor
      *            the executor to use to execute the task, cannot be <code>null</code>;
      * @param task
@@ -64,19 +49,6 @@ final class ResettableTimer {
      *            the time unit of the timeout value, cannot be <code>null</code>.
      */
     public ResettableTimer(ScheduledExecutorService executor, Runnable task, long timeout,
TimeUnit unit) {
-        if (executor == null) {
-            throw new IllegalArgumentException("Executor cannot be null!");
-        }
-        if (task == null) {
-            throw new IllegalArgumentException("Task cannot be null!");
-        }
-        if (timeout <= 0) {
-            throw new IllegalArgumentException("Timeout cannot be negative!");
-        }
-        if (unit == null) {
-            throw new IllegalArgumentException("TimeUnit cannot be null!");
-        }
-
         m_executor = executor;
         m_task = task;
         m_timeout = timeout;
@@ -86,37 +58,20 @@ final class ResettableTimer {
     }
 
     /**
-     * Returns the state of this timer.
-     * 
-     * @return <code>true</code> if this timer is shut down, <code>false</code>
otherwise.
-     */
-    public boolean isShutDown() {
-        return m_executor.isShutdown();
-    }
-
-    /**
      * Schedules the task for execution with the contained timeout. If a task is already
pending or running, it will be
      * cancelled (not interrupted). The new task will be scheduled to run in now + timeout.
+     * 
+     * @return <code>true</code> if the schedule was successful, <code>false</code>
otherwise.
      */
-    public ScheduledFuture<?> schedule() {
+    public boolean schedule() {
         ScheduledFuture<?> currentTask = cancelCurrentTask();
+        if (m_executor.isShutdown()) {
+            // We cannot submit any new tasks...
+            return false;
+        }
         ScheduledFuture<?> newTask = m_executor.schedule(m_task, m_timeout, m_timeUnit);
         m_futureRef.compareAndSet(currentTask, newTask);
-        return newTask;
-    }
-
-    /**
-     * Shuts down this timer, allowing any pending tasks to execute. After this method is
called, {@link #schedule()}
-     * may no longer be called.
-     */
-    public void shutDown() {
-        m_executor.shutdown();
-        try {
-            m_executor.awaitTermination(2 * m_timeout, m_timeUnit);
-        }
-        catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }
+        return true;
     }
 
     /**

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java Wed
Sep 18 07:22:51 2013
@@ -46,16 +46,7 @@ abstract class UpdateHandlerBase extends
 
     @Override
     public final Version getHighestAvailableVersion() throws RetryAfterException, IOException
{
-        SortedSet<Version> available = new TreeSet<Version>();
-        try {
-            available = getAvailableVersions();
-        }
-        catch (IOException e) {
-            // Hopefully temporary problem due to remote IO or configuration. No cause to
abort the sync so we just
-            // log it as a warning.
-            logWarning("Exception while retrieving agent versions", e);
-        }
-
+        SortedSet<Version> available = getAvailableVersions();
         return getHighestVersion(available);
     }
 

Modified: ace/trunk/run-target/target.bndrun
URL: http://svn.apache.org/viewvc/ace/trunk/run-target/target.bndrun?rev=1524311&r1=1524310&r2=1524311&view=diff
==============================================================================
--- ace/trunk/run-target/target.bndrun (original)
+++ ace/trunk/run-target/target.bndrun Wed Sep 18 07:22:51 2013
@@ -11,4 +11,8 @@
 	org.apache.felix.eventadmin.Timeout=0,\
 	org.apache.felix.log.maxSize=1000,\
 	launch.keep=false,\
-	launch.storage.dir=bundle-cache
+	launch.storage.dir=bundle-cache,\
+	agent.logging.level=DEBUG,\
+	agent.controller.syncinterval=5,\
+	agent.controller.syncdelay=1,\
+	agent.identification.agentid=demo



Mime
View raw message