Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A073518106 for ; Mon, 24 Aug 2015 04:43:07 +0000 (UTC) Received: (qmail 76828 invoked by uid 500); 24 Aug 2015 04:43:02 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 76789 invoked by uid 500); 24 Aug 2015 04:43:02 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 76769 invoked by uid 99); 24 Aug 2015 04:43:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Aug 2015 04:43:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 20724DFBA4; Mon, 24 Aug 2015 04:43:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: koushik@apache.org To: commits@cloudstack.apache.org Date: Mon, 24 Aug 2015 04:43:02 -0000 Message-Id: <440c7674cf0c4b43bbaca8d2fc54a2e0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/master to e7ddbd4 Repository: cloudstack Updated Branches: refs/heads/master 6d57a86cb -> e7ddbd498 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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c989921f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c989921f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c989921f Branch: refs/heads/master Commit: c989921fb7adcfd125ca5f541c0f9c5d1c512c54 Parents: 05a29f0 Author: Koushik Das Authored: Fri Aug 14 17:11:52 2015 +0530 Committer: Koushik Das Committed: Fri Aug 14 17:11:52 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/c989921f/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/c989921f/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/c989921f/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