Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81C8818B04 for ; Thu, 18 Feb 2016 00:26:02 +0000 (UTC) Received: (qmail 40766 invoked by uid 500); 18 Feb 2016 00:26:02 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 40701 invoked by uid 500); 18 Feb 2016 00:26:01 -0000 Mailing-List: contact dev-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 dev@cloudstack.apache.org Received: (qmail 40690 invoked by uid 99); 18 Feb 2016 00:26:01 -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; Thu, 18 Feb 2016 00:26:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92680E020D; Thu, 18 Feb 2016 00:26:01 +0000 (UTC) From: rafaelweingartner To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: CLOUDSTACK-8830 CLONE - VM snapshot fails... Content-Type: text/plain Message-Id: <20160218002601.92680E020D@git1-us-west.apache.org> Date: Thu, 18 Feb 2016 00:26:01 +0000 (UTC) Github user rafaelweingartner commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/798#discussion_r53255088 --- Diff: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java --- @@ -1464,4 +1440,45 @@ private String deleteDir(String dir) { private static String getVolumeRelativeDirInSecStroage(long volumeId) { return "volumes/" + volumeId; } + + /** + * This method is to check if a given TaskInfo Object is valid( and has name and entity name assigned).It return true if TaskInfo Object is valid and false otherwise. + * + * @param TaskInfo + * info + * @return boolean(true or false) + **/ + private boolean isvalidTaskInfoObj(TaskInfo info){ + return !(info == null || info.getEntityName() == null || info.getName() == null); + } + + private boolean waitForRunningTaskOnVM(String vmName, String taskName, VmwareContext context) throws Exception { + try { + ManagedObjectReference taskmgr = context.getServiceContent().getTaskManager(); + List tasks = context.getVimClient().getDynamicProperty(taskmgr, "recentTask"); + + for (ManagedObjectReference taskMor : tasks) { + TaskInfo info = (TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info")); + + if (!isvalidTaskInfoObj(info)) { --- End diff -- I noticed you are only suggesting ;), no need to say that, when we review a PR we suggest changes to improve it, which is normal. I am going to ask again, Do you mean remove the “isvalidTaskInfoObj” and add that condition to the (if)? That would not reduce the code complexity, in the worst case scenario the complexity would be the same. At the line you commented, when we use that “isvalidTaskInfoObj” to mask the complexity on the logic to check if a task, we can remove some complexity from one method to another; doing that, we facilitate code documentation and unit tests writing. For instance, if you want to suggest something to reduce code complexity or the so called cyclomatic complexity, you should take a look at lines 1467 and 1468, there you have a lot of room for improvements. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---