Move LockMasterListener initialization to system context

This reverts commit d178b25daa484dda44bb34e63cb719d1c3cc1519 and moves
the initialization to the system context, which really where it should have
been from the beginning.
This commit is contained in:
Darren Shepherd 2013-10-25 15:10:51 -07:00
parent 56f1277339
commit ad74948480
3 changed files with 52 additions and 3 deletions

View File

@ -36,6 +36,7 @@
</bean>
<bean id="managementServerImpl" class="com.cloud.server.ManagementServerImpl">
<property name="lockMasterListener" ref="lockMasterListener" />
<property name="userAuthenticators"
value="#{userAuthenticatorsRegistry.registered}" />
<property name="userPasswordEncoders"

View File

@ -0,0 +1,36 @@
<!--
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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean id="lockMasterListener" class="com.cloud.server.LockMasterListener" >
<constructor-arg>
<bean class="org.apache.cloudstack.utils.identity.ManagementServerNode" factory-method="getManagementServerId" />
</constructor-arg>
</bean>
</beans>

View File

@ -599,8 +599,6 @@ import com.cloud.vm.dao.VMInstanceDao;
public class ManagementServerImpl extends ManagerBase implements ManagementServer {
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
private static final LockMasterListener s_lockMasterListener = new LockMasterListener(ManagementServerNode.getManagementServerId());
@Inject
public AccountManager _accountMgr;
@Inject
@ -716,6 +714,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Inject
DeploymentPlanningManager _dpMgr;
LockMasterListener _lockMasterListener;
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker"));
@Inject private KeystoreManager _ksMgr;
@ -820,7 +820,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
public boolean start() {
s_logger.info("Startup CloudStack management server...");
_clusterMgr.registerListener(s_lockMasterListener);
if ( _lockMasterListener == null ) {
_lockMasterListener = new LockMasterListener(ManagementServerNode.getManagementServerId());
}
_clusterMgr.registerListener(_lockMasterListener);
enableAdminUser("password");
return true;
@ -3881,4 +3885,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) {
this._storagePoolAllocators = storagePoolAllocators;
}
public LockMasterListener getLockMasterListener() {
return _lockMasterListener;
}
public void setLockMasterListener(LockMasterListener lockMasterListener) {
this._lockMasterListener = lockMasterListener;
}
}