ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1546569 - in /ace/trunk/org.apache.ace.agent: src/org/apache/ace/agent/ src/org/apache/ace/agent/impl/ test/org/apache/ace/agent/impl/
Date Fri, 29 Nov 2013 14:24:50 GMT
Author: jawi
Date: Fri Nov 29 14:24:49 2013
New Revision: 1546569

URL: http://svn.apache.org/r1546569
Log:
ACE-433 - clean ups and bugfixes:

- removed the deprecated methods from ConfigurationHandler(Impl);
- due to the new way controllers are instantiated and used in the agent,
  it always misses the "initial" configuration event. However, we can now
  use the configuration handler directly in the #onInit() method to 
  obtain our initial configuration values.


Modified:
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.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/DefaultController.java
    ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/EventLoggerImplTest.java

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java?rev=1546569&r1=1546568&r2=1546569&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java Fri
Nov 29 14:24:49 2013
@@ -54,19 +54,6 @@ public interface ConfigurationHandler {
     String get(String key, String defaultValue);
 
     /**
-     * Store a single configuration value.
-     * 
-     * @param key
-     *            The key, must not be <code>null</code>
-     * @param value
-     *            The value, must not be <code>null</code>
-     * @deprecated use {@link #putAll(Map)} instead which allows the configuration to be
updated without partial
-     *             visibility issues.
-     */
-    @Deprecated
-    void put(String key, String value);
-
-    /**
      * Store a configuration value.
      * 
      * @param props
@@ -75,17 +62,6 @@ public interface ConfigurationHandler {
     void putAll(Map<String, String> props);
 
     /**
-     * Remove a configuration value.
-     * 
-     * @param key
-     *            The key, must not be <code>null</code>
-     * @deprecated use {@link #putAll(Map)} instead which allows the configuration to be
updated without partial
-     *             visibility issues.
-     */
-    @Deprecated
-    void remove(String key);
-
-    /**
      * Retrieve the configuration value associated with the key, or the specified default.
      * 
      * @param key
@@ -97,19 +73,6 @@ public interface ConfigurationHandler {
     long getLong(String key, long defaultValue);
 
     /**
-     * Store a configuration value.
-     * 
-     * @param key
-     *            The key, must not be <code>null</code>
-     * @param value
-     *            The value
-     * @deprecated use {@link #putAll(Map)} instead which allows the configuration to be
updated without partial
-     *             visibility issues.
-     */
-    @Deprecated
-    void putLong(String key, long value);
-
-    /**
      * Retrieve the configuration value associated with the key, or the specified default.
      * 
      * @param key
@@ -119,17 +82,4 @@ public interface ConfigurationHandler {
      * @return The associated value if it exists, otherwise the default value
      */
     boolean getBoolean(String key, boolean defaultValue);
-
-    /**
-     * Store a configuration value.
-     * 
-     * @param key
-     *            The key, must not be <code>null</code>
-     * @param value
-     *            The value
-     * @deprecated use {@link #putAll(Map)} instead which allows the configuration to be
updated without partial
-     *             visibility issues.
-     */
-    @Deprecated
-    void putBoolean(String key, boolean Value);
 }

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=1546569&r1=1546568&r2=1546569&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
Fri Nov 29 14:24:49 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.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -95,16 +95,6 @@ public class ConfigurationHandlerImpl ex
     }
 
     @Override
-    public void put(String key, String value) {
-        String previous = (String) m_configProps.put(key, value);
-        if (previous == null || !previous.equals(value)) {
-            fireConfigChangeEventAsynchronously();
-            // causes the config to be written eventually...
-            scheduleStore();
-        }
-    }
-
-    @Override
     public void putAll(Map<String, String> props) {
         m_configProps.putAll(props);
         fireConfigChangeEventAsynchronously();
@@ -112,26 +102,6 @@ public class ConfigurationHandlerImpl ex
         scheduleStore();
     }
 
-    @Override
-    public void putBoolean(String key, boolean value) {
-        put(key, String.valueOf(value));
-    }
-
-    @Override
-    public void putLong(String key, long value) {
-        put(key, String.valueOf(value));
-    }
-
-    @Override
-    public void remove(String key) {
-        Object value = m_configProps.remove(key);
-        if (value != null) {
-            fireConfigChangeEventAsynchronously();
-            // causes the config to be written eventually...
-            scheduleStore();
-        }
-    }
-
     /**
      * Called by {@link ResettableTimer} when a certain timeout has exceeded.
      */

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=1546569&r1=1546568&r2=1546569&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 Fri
Nov 29 14:24:49 2013
@@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.ace.agent.ConfigurationHandler;
 import org.apache.ace.agent.DownloadHandle;
 import org.apache.ace.agent.DownloadHandle.DownloadProgressListener;
 import org.apache.ace.agent.DownloadResult;
@@ -69,7 +70,7 @@ public class DefaultController extends C
         @Override
         public void doInstallUpdate(UpdateHandler delegate, UpdateInfo updateInfo) throws
RetryAfterException {
             m_type = updateInfo.m_type;
-            
+
             DefaultController controller = getController();
             controller.logInfo("Starting download of %s update, %s => %s...", m_type,
updateInfo.m_from, updateInfo.m_to);
 
@@ -474,6 +475,17 @@ public class DefaultController extends C
     @Override
     protected void onInit() throws Exception {
         getEventsHandler().addListener(this);
+
+        // The controller is started *after* all other components, causing it to miss the
initial configuration-update
+        // event, hence we need to get the configuration ourselves for the first time...
+        ConfigurationHandler config = getConfigurationHandler();
+        m_updateStreaming.set(config.getBoolean(CONFIG_CONTROLLER_STREAMING, m_updateStreaming.get()));
+        m_fixPackage.set(config.getBoolean(CONFIG_CONTROLLER_FIXPACKAGES, m_fixPackage.get()));
+        m_interval.set(config.getLong(CONFIG_CONTROLLER_SYNCINTERVAL, m_interval.get()));
+        m_syncDelay.set(config.getLong(CONFIG_CONTROLLER_SYNCDELAY, m_syncDelay.get()));
+        m_maxRetries.set(config.getLong(CONFIG_CONTROLLER_RETRIES, m_maxRetries.get()));
+
+        logDebug("Config initialized: update: %s, fixPkg: %s, syncDelay: %d, syncInterval:
%d, maxRetries: %d", m_updateStreaming.get(), m_fixPackage.get(), m_syncDelay.get(), m_interval.get(),
m_maxRetries.get());
     }
 
     @Override

Modified: ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/EventLoggerImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/EventLoggerImplTest.java?rev=1546569&r1=1546568&r2=1546569&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/EventLoggerImplTest.java
(original)
+++ ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/EventLoggerImplTest.java
Fri Nov 29 14:24:49 2013
@@ -137,7 +137,7 @@ public class EventLoggerImplTest extends
     @Test
     public void testExcludeEvent() throws Exception {
         ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class);
-        configurationHandler.put(AgentConstants.CONFIG_LOGGING_EXCLUDE_EVENTS, "1001,1002");
+        configureAgent(configurationHandler, AgentConstants.CONFIG_LOGGING_EXCLUDE_EVENTS,
"1001,1002");
 
         FrameworkEvent event = new FrameworkEvent(32, new Object());
 



Mime
View raw message