qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r748561 - in /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server: ./ configuration/ configuration/management/ management/
Date Fri, 27 Feb 2009 15:40:57 GMT
Author: aidan
Date: Fri Feb 27 15:40:56 2009
New Revision: 748561

URL: http://svn.apache.org/viewvc?rev=748561&view=rev
Log:
QPID-1699: reload the config file sections that we can when we receive SIGHUP. Add jmx method
to do so.

Added:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagement.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java?rev=748561&r1=748560&r2=748561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java Fri Feb 27
15:40:56 2009
@@ -26,6 +26,8 @@
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 
+import javax.management.NotCompliantMBeanException;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
@@ -47,6 +49,7 @@
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.pool.ReadWriteThreadModel;
 import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
 import org.apache.qpid.server.logging.management.LoggingManagementMBean;
 import org.apache.qpid.server.protocol.AMQPFastProtocolHandler;
 import org.apache.qpid.server.protocol.AMQPProtocolProvider;
@@ -267,6 +270,9 @@
         
         configureLoggingManagementMBean(logConfigFile, logWatchTime);
 
+        ConfigurationManagementMBean configMBean = new ConfigurationManagementMBean();
+        configMBean.register();
+        
         //fixme .. use QpidProperties.getVersionString when we have fixed the classpath issues
         // that are causing the broker build to pick up the wrong properties file and hence
say
         // Starting Qpid Client 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java?rev=748561&r1=748560&r2=748561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
Fri Feb 27 15:40:56 2009
@@ -27,14 +27,23 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import javax.management.NotCompliantMBeanException;
+
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.ConfigurationFactory;
 import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+
+import sun.misc.Signal;
+import sun.misc.SignalHandler;
 
-public class ServerConfiguration
+public class ServerConfiguration implements SignalHandler
 {
 
     private static Configuration _config;
@@ -52,6 +61,10 @@
     private Map<String, VirtualHostConfiguration> _virtualHosts = new HashMap<String,
VirtualHostConfiguration>();
     private SecurityConfiguration _securityConfiguration = null;
 
+    private File _configFile;
+
+    private ConfigurationManagementMBean _mbean;
+
     // Map of environment variables to config items
     private static final Map<String, String> envVarMap = new HashMap<String, String>();
     
@@ -82,6 +95,8 @@
     public ServerConfiguration(File configurationURL) throws ConfigurationException
     {
         this(parseConfig(configurationURL));
+        _configFile = configurationURL;
+        sun.misc.Signal.handle(new sun.misc.Signal("HUP"), this);
     }
 
     public ServerConfiguration(Configuration conf) throws ConfigurationException
@@ -94,8 +109,9 @@
         _securityConfiguration = new SecurityConfiguration(conf.subset("security"));
 
         setupVirtualHosts(conf);
+        
     }
-
+    
     private void setupVirtualHosts(Configuration conf) throws ConfigurationException
     {
         List vhosts = conf.getList("virtualhosts");
@@ -181,6 +197,37 @@
         return conf;
     }
 
+    @Override
+    public void handle(Signal arg0)
+    {
+        try
+        {
+            reparseConfigFile();
+        }
+        catch (ConfigurationException e)
+        {
+            // Not much we can do about it really. 
+        }        
+    }
+
+    public void reparseConfigFile() throws ConfigurationException
+    {
+        if (_configFile != null)
+        {
+            Configuration newConfig = parseConfig(_configFile);
+            _securityConfiguration = new SecurityConfiguration(newConfig.subset("security"));
+            ApplicationRegistry.getInstance().getAccessManager().configurePlugins(_securityConfiguration);
+            
+            VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry();
+            for (String hostname : _virtualHosts.keySet())
+            {
+                VirtualHost vhost = vhostRegistry.getVirtualHost(hostname);
+                SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newConfig.subset("virtualhosts.virtualhost."+hostname+".security"));
+                vhost.getAccessManager().configureHostPlugins(hostSecurityConfig);
+            }
+        }
+    }
+
     public String getQpidWork()
     {
         return System.getProperty("QPID_WORK", System.getProperty("java.io.tmpdir"));

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagement.java?rev=748561&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagement.java
(added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagement.java
Fri Feb 27 15:40:56 2009
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.qpid.server.configuration.management;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.MBeanAttribute;
+
+public interface ConfigurationManagement
+{
+
+    String TYPE = "ConfigurationManagement";
+    int VERSION = 1;
+    
+    /**
+     * Reload the 
+     * @throws ConfigurationException 
+     */
+    @MBeanAttribute(name="reloadSecurityConfiguration", 
+                    description = "Force a reload of the security configuration sections")
+    void reloadSecurityConfiguration() throws ConfigurationException;
+    
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java?rev=748561&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
(added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
Fri Feb 27 15:40:56 2009
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.qpid.server.configuration.management;
+
+import javax.management.NotCompliantMBeanException;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+public class ConfigurationManagementMBean extends AMQManagedObject implements ConfigurationManagement
+{
+
+    public ConfigurationManagementMBean() throws NotCompliantMBeanException
+    {
+        super(ConfigurationManagement.class, ConfigurationManagement.TYPE, ConfigurationManagement.VERSION);
+    }
+
+    @Override
+    public String getObjectInstanceName()
+    {
+        return ConfigurationManagement.TYPE;
+    }
+
+    @Override
+    public void reloadSecurityConfiguration() throws ConfigurationException
+    {
+        ApplicationRegistry.getInstance().getConfiguration().reparseConfigFile();
+    }
+
+}

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java?rev=748561&r1=748560&r2=748561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
Fri Feb 27 15:40:56 2009
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.server.management;
 
+import org.apache.qpid.server.configuration.management.ConfigurationManagement;
 import org.apache.qpid.server.logging.management.LoggingManagement;
 import org.apache.qpid.server.security.access.management.UserManagement;
 import org.apache.log4j.Logger;
@@ -38,6 +39,8 @@
 import java.security.AccessController;
 import java.security.Principal;
 import java.security.AccessControlContext;
+import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Set;
 import java.util.Properties;
 
@@ -57,6 +60,13 @@
     private MBeanServer _mbs;
     private static Properties _userRoles = new Properties();
 
+    private static HashSet<String> _adminOnlyMethods = new HashSet<String>();
+    {
+        _adminOnlyMethods.add(UserManagement.TYPE); 
+        _adminOnlyMethods.add(LoggingManagement.TYPE);
+        _adminOnlyMethods.add(ConfigurationManagement.TYPE);
+    }
+    
     public static MBeanServerForwarder newProxyInstance()
     {
         final InvocationHandler handler = new MBeanInvocationHandlerImpl();
@@ -155,13 +165,8 @@
         {
             ObjectName object = (ObjectName) args[0];
             
-            if (UserManagement.TYPE.equals(object.getKeyProperty("type"))
-                    || LoggingManagement.TYPE.equals(object.getKeyProperty("type")))
-            {
-                return true;
-            }
+            return _adminOnlyMethods.contains(object.getKeyProperty("type"));
         }
-
         return false;
     }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message