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 5413C18342 for ; Wed, 8 Jul 2015 19:19:40 +0000 (UTC) Received: (qmail 88346 invoked by uid 500); 8 Jul 2015 19:19:36 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 88248 invoked by uid 500); 8 Jul 2015 19:19:36 -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 87944 invoked by uid 99); 8 Jul 2015 19:19:36 -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; Wed, 08 Jul 2015 19:19:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4D977E35D7; Wed, 8 Jul 2015 19:19:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: widodh@apache.org To: commits@cloudstack.apache.org Date: Wed, 08 Jul 2015 19:19:49 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [14/50] [abbrv] git commit: updated refs/heads/reporter to 28300b5 CLOUDSTACK-8590 - Refactoring NiciraNVP resource - Refactoring NiciraNvpResource - Added NiciraNvpMaintainCommandWrapper - Removing 1 execute methods form NiciraNvpResource - Added 1 unit test Signed-off-by: wilderrodrigues Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6a51294d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6a51294d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6a51294d Branch: refs/heads/reporter Commit: 6a51294d1972bbfd116fcd9ed36835c48423b76b Parents: 0d943d5 Author: wilderrodrigues Authored: Tue Jun 23 09:38:56 2015 +0200 Committer: wilderrodrigues Committed: Wed Jul 1 15:04:56 2015 +0200 ---------------------------------------------------------------------- .../network/resource/NiciraNvpResource.java | 10 +----- .../NiciraNvpMaintainCommandWrapper.java | 36 ++++++++++++++++++++ .../resource/NiciraNvpRequestWrapperTest.java | 13 +++++++ 3 files changed, 50 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java index 3c1f9b5..9af541f 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java @@ -50,8 +50,6 @@ import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer; import com.cloud.agent.api.DeleteLogicalSwitchPortCommand; import com.cloud.agent.api.FindLogicalSwitchPortAnswer; import com.cloud.agent.api.FindLogicalSwitchPortCommand; -import com.cloud.agent.api.MaintainAnswer; -import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupNiciraNvpCommand; @@ -204,9 +202,7 @@ public class NiciraNvpResource implements ServerResource { // [TODO] Remove when all the commands are refactored. } - if (cmd instanceof MaintainCommand) { - return executeRequest((MaintainCommand)cmd); - } else if (cmd instanceof CreateLogicalSwitchCommand) { + if (cmd instanceof CreateLogicalSwitchCommand) { return executeRequest((CreateLogicalSwitchCommand)cmd, numRetries); } else if (cmd instanceof DeleteLogicalSwitchCommand) { return executeRequest((DeleteLogicalSwitchCommand)cmd, numRetries); @@ -650,10 +646,6 @@ public class NiciraNvpResource implements ServerResource { } - private Answer executeRequest(final MaintainCommand cmd) { - return new MaintainAnswer(cmd); - } - private Answer retry(final Command cmd, final int numRetries) { s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries); return executeRequest(cmd, numRetries); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java new file mode 100644 index 0000000..3015378 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java @@ -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. +// + +package com.cloud.network.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.MaintainAnswer; +import com.cloud.agent.api.MaintainCommand; +import com.cloud.network.resource.NiciraNvpResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; + +@ResourceWrapper(handles = MaintainCommand.class) +public final class NiciraNvpMaintainCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final MaintainCommand command, final NiciraNvpResource niciraNvpResource) { + return new MaintainAnswer(command); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java index 5e5425e..ba22d18 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java @@ -27,6 +27,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.ReadyCommand; public class NiciraNvpRequestWrapperTest { @@ -45,4 +46,16 @@ public class NiciraNvpRequestWrapperTest { assertTrue(answer.getResult()); } + + @Test + public void testMaintainCommandWrapper() { + final MaintainCommand command = new MaintainCommand(); + + final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, niciraNvpResource); + + assertTrue(answer.getResult()); + } } \ No newline at end of file