From commits-return-96809-archive-asf-public=cust-asf.ponee.io@cloudstack.apache.org Tue Jan 7 09:41:28 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2E98A180643 for ; Tue, 7 Jan 2020 10:41:28 +0100 (CET) Received: (qmail 67033 invoked by uid 500); 7 Jan 2020 09:41:27 -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 67024 invoked by uid 99); 7 Jan 2020 09:41:27 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jan 2020 09:41:27 +0000 From: GitBox To: commits@cloudstack.apache.org Subject: [GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3795: Agent lb on svm Message-ID: <157839008739.11111.12392455260312094704.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Tue, 07 Jan 2020 09:41:27 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit DaanHoogland commented on a change in pull request #3795: Agent lb on svm URL: https://github.com/apache/cloudstack/pull/3795#discussion_r363664511 ########## File path: server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java ########## @@ -136,17 +144,48 @@ public int compare(Long x, Long y) { } final List agentBasedHosts = new ArrayList<>(); for (final Host host : allHosts) { - if (host == null || host.getResourceState() == ResourceState.Creating || host.getResourceState() == ResourceState.Error) { - continue; + conditionallyAddHost(agentBasedHosts, host); + } + return agentBasedHosts; + } + + private void conditionallyAddHost(List agentBasedHosts, Host host) { + if (host == null) { + if (LOG.isTraceEnabled()) { + LOG.trace("trying to add no host to a list"); } - if (host.getType() == Host.Type.Routing || host.getType() == Host.Type.ConsoleProxy || host.getType() == Host.Type.SecondaryStorage || host.getType() == Host.Type.SecondaryStorageVM) { - if (host.getHypervisorType() != null && host.getHypervisorType() != Hypervisor.HypervisorType.KVM && host.getHypervisorType() != Hypervisor.HypervisorType.LXC) { - continue; - } - agentBasedHosts.add(host); + return; + } + if (host.getResourceState() == ResourceState.Creating) { + if (LOG.isTraceEnabled()) { + LOG.trace(String.format("host is in creating state, not adding to the host list, (id = %s)", host.getUuid())); } + return; } - return agentBasedHosts; + if (host.getResourceState() == ResourceState.Error) { Review comment: refactorred have a look, @rhtyd . I think it is cosmetic but it does make a point. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services