Repository: cloudstack Updated Branches: refs/heads/4.5 0b4f97251 -> 3d9cbf0bc
CLOUDSTACK-8733: Host stuck in rebalancing state during agent LB This is happening as ClusterServiceServletAdapter is started after ClusteredAgentManagerImpl. Fix is to start ClusterServiceServletAdapter before ClusteredAgentManagerImpl. (cherry-picked from c989921fb7adcfd125ca5f541c0f9c5d1c512c54) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3d9cbf0b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3d9cbf0b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3d9cbf0b Branch: refs/heads/4.5 Commit: 3d9cbf0bcb011f4012c94f0df040d9b8ddd325bc Parents: 0b4f972 Author: Koushik Das <[email protected]> Authored: Fri Aug 14 17:11:52 2015 +0530 Committer: Koushik Das <[email protected]> Committed: Tue Aug 25 09:37:50 2015 +0530 ---------------------------------------------------------------------- .../cluster/ClusterServiceServletAdapter.java | 6 ++- .../ClusterServiceServletAdapterTest.java | 47 ++++++++++++++++++++ .../jobs/impl/SyncQueueManagerImpl.java | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d9cbf0b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletAdapter.java ---------------------------------------------------------------------- diff --git a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletAdapter.java b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletAdapter.java index d36aed1..7451b5f 100644 --- a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletAdapter.java +++ b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletAdapter.java @@ -24,12 +24,12 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.log4j.Logger; - import org.apache.cloudstack.framework.config.ConfigDepot; import com.cloud.cluster.dao.ManagementServerHostDao; import com.cloud.utils.NumbersUtil; import com.cloud.utils.component.AdapterBase; +import com.cloud.utils.component.ComponentLifecycle; import com.cloud.utils.db.DbProperties; public class ClusterServiceServletAdapter extends AdapterBase implements ClusterServiceAdapter { @@ -50,6 +50,10 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster private int _clusterServicePort = DEFAULT_SERVICE_PORT; + public ClusterServiceServletAdapter() { + setRunLevel(ComponentLifecycle.RUN_LEVEL_FRAMEWORK); + } + @Override public ClusterService getPeerService(String strPeer) throws RemoteException { try { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d9cbf0b/framework/cluster/test/com/cloud/cluster/ClusterServiceServletAdapterTest.java ---------------------------------------------------------------------- diff --git a/framework/cluster/test/com/cloud/cluster/ClusterServiceServletAdapterTest.java b/framework/cluster/test/com/cloud/cluster/ClusterServiceServletAdapterTest.java new file mode 100644 index 0000000..28dbcaa --- /dev/null +++ b/framework/cluster/test/com/cloud/cluster/ClusterServiceServletAdapterTest.java @@ -0,0 +1,47 @@ +// 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 com.cloud.cluster; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.cloud.utils.component.ComponentLifecycle; + +@RunWith(MockitoJUnitRunner.class) +public class ClusterServiceServletAdapterTest { + + ClusterServiceServletAdapter clusterServiceServletAdapter; + ClusterManagerImpl clusterManagerImpl; + + @Before + public void setup() throws IllegalArgumentException, + IllegalAccessException, NoSuchFieldException, SecurityException { + clusterServiceServletAdapter = new ClusterServiceServletAdapter(); + clusterManagerImpl = new ClusterManagerImpl(); + } + + @Test + public void testRunLevel() { + int runLevel = clusterServiceServletAdapter.getRunLevel(); + assertTrue(runLevel == ComponentLifecycle.RUN_LEVEL_FRAMEWORK); + assertTrue(runLevel == clusterManagerImpl.getRunLevel()); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d9cbf0b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java index c17c581..2f97991 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java @@ -207,6 +207,7 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage @Override @DB public void returnItem(final long queueItemId) { + s_logger.info("Returning queue item " + queueItemId + " back to queue for second try in case of DB deadlock"); try { Transaction.execute(new TransactionCallbackNoReturn() { @Override
