diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java b/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java index 5a424cb8f223..352d9a84eb6b 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java @@ -31,7 +31,11 @@ public class ImageFormatHelper { @Inject public void setFormats(List formats) { - ImageFormatHelper.formats = formats; + ImageFormatHelper.initFormats(formats); + } + + private static synchronized void initFormats(List newFormats) { + formats = newFormats; } public static ImageFormat getFormat(String format) { diff --git a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java index bd414dbf4bc7..e53d2e9ad883 100644 --- a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java +++ b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java @@ -30,16 +30,8 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; -import org.apache.cloudstack.framework.events.Event; -import org.apache.cloudstack.framework.events.EventBus; -import org.apache.cloudstack.framework.events.EventBusException; -import org.apache.cloudstack.framework.events.EventSubscriber; -import org.apache.cloudstack.framework.events.EventTopic; -import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.log4j.Logger; -import com.cloud.utils.Ternary; -import com.cloud.utils.component.ManagerBase; import com.rabbitmq.client.AMQP; import com.rabbitmq.client.AlreadyClosedException; import com.rabbitmq.client.Channel; @@ -51,6 +43,16 @@ import com.rabbitmq.client.ShutdownListener; import com.rabbitmq.client.ShutdownSignalException; +import org.apache.cloudstack.framework.events.Event; +import org.apache.cloudstack.framework.events.EventBus; +import org.apache.cloudstack.framework.events.EventBusException; +import org.apache.cloudstack.framework.events.EventSubscriber; +import org.apache.cloudstack.framework.events.EventTopic; +import org.apache.cloudstack.managed.context.ManagedContextRunnable; + +import com.cloud.utils.Ternary; +import com.cloud.utils.component.ManagerBase; + @Local(value = EventBus.class) public class RabbitMQEventBus extends ManagerBase implements EventBus { @@ -138,23 +140,23 @@ public boolean configure(String name, Map params) throws Configu return true; } - public void setServer(String amqpHost) { + public static void setServer(String amqpHost) { RabbitMQEventBus.amqpHost = amqpHost; } - public void setUsername(String username) { + public static void setUsername(String username) { RabbitMQEventBus.username = username; } - public void setPassword(String password) { + public static void setPassword(String password) { RabbitMQEventBus.password = password; } - public void setPort(Integer port) { + public static void setPort(Integer port) { RabbitMQEventBus.port = port; } - public void setSecureProtocol(String protocol) { + public static void setSecureProtocol(String protocol) { RabbitMQEventBus.secureProtocol = protocol; } @@ -163,11 +165,11 @@ public void setName(String name) { this.name = name; } - public void setExchange(String exchange) { + public static void setExchange(String exchange) { RabbitMQEventBus.amqpExchangeName = exchange; } - public void setRetryInterval(Integer retryInterval) { + public static void setRetryInterval(Integer retryInterval) { RabbitMQEventBus.retryInterval = retryInterval; } @@ -378,7 +380,7 @@ private synchronized Connection createConnection() throws Exception { } if (useSsl != null && !useSsl.isEmpty() && useSsl.equalsIgnoreCase("true")) { - factory.useSslProtocol(this.secureProtocol); + factory.useSslProtocol(secureProtocol); } Connection connection = factory.newConnection(); connection.addShutdownListener(disconnectHandler); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java index 86950458fe14..5407d764474d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java @@ -35,15 +35,19 @@ public class KVMHAMonitor extends KVMHABase implements Runnable { private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class); - private Map _storagePool = new ConcurrentHashMap(); + private final Map _storagePool = new ConcurrentHashMap(); - private String _hostIP; /* private ip address */ + private final String _hostIP; /* private ip address */ public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) { if (pool != null) { _storagePool.put(pool._poolUUID, pool); } _hostIP = host; + configureHeartBeatPath(scriptPath); + } + + private static synchronized void configureHeartBeatPath(String scriptPath) { KVMHABase.s_heartBeatPath = scriptPath; } diff --git a/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java b/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java index 9d0ab6847460..28a9c0f5d461 100644 --- a/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java +++ b/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java @@ -16,19 +16,22 @@ // under the License. package com.cloud.api.auth; -import com.cloud.utils.component.ComponentContext; -import com.cloud.utils.component.ManagerBase; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.ejb.Local; + +import org.apache.log4j.Logger; + import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.auth.APIAuthenticationManager; import org.apache.cloudstack.api.auth.APIAuthenticator; import org.apache.cloudstack.api.auth.PluggableAPIAuthenticator; -import org.apache.log4j.Logger; -import javax.ejb.Local; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.cloud.utils.component.ComponentContext; +import com.cloud.utils.component.ManagerBase; @Local(value = APIAuthenticationManager.class) @SuppressWarnings("unchecked") @@ -52,17 +55,25 @@ public void setApiAuthenticators(List authenticators) @Override public boolean start() { - s_authenticators = new HashMap>(); + initAuthenticator(); for (Class authenticator: getCommands()) { APICommand command = authenticator.getAnnotation(APICommand.class); if (command != null && !command.name().isEmpty() && APIAuthenticator.class.isAssignableFrom(authenticator)) { - s_authenticators.put(command.name().toLowerCase(), authenticator); + addAuthenticator(authenticator, command); } } return true; } + private static synchronized void addAuthenticator(Class authenticator, APICommand command) { + s_authenticators.put(command.name().toLowerCase(), authenticator); + } + + private static synchronized void initAuthenticator() { + s_authenticators = new ConcurrentHashMap>(); + } + @Override public List> getCommands() { List> cmdList = new ArrayList>(); diff --git a/utils/src/com/cloud/utils/component/ComponentContext.java b/utils/src/com/cloud/utils/component/ComponentContext.java index b041ecfc1fa8..8948b2789ee1 100644 --- a/utils/src/com/cloud/utils/component/ComponentContext.java +++ b/utils/src/com/cloud/utils/component/ComponentContext.java @@ -273,6 +273,10 @@ public boolean isInitializeBeans() { } public void setInitializeBeans(boolean initializeBeans) { + initInitializeBeans(initializeBeans); + } + + private static synchronized void initInitializeBeans(boolean initializeBeans) { s_initializeBeans = initializeBeans; } }