Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7F666200D3D for ; Mon, 13 Nov 2017 08:57:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7DB48160BF3; Mon, 13 Nov 2017 07:57:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9A96D160BE4 for ; Mon, 13 Nov 2017 08:57:04 +0100 (CET) Received: (qmail 48450 invoked by uid 500); 13 Nov 2017 07:57:03 -0000 Mailing-List: contact issues-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 issues@cloudstack.apache.org Received: (qmail 48441 invoked by uid 500); 13 Nov 2017 07:57:03 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 48437 invoked by uid 99); 13 Nov 2017 07:57:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Nov 2017 07:57:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E42711A030B for ; Mon, 13 Nov 2017 07:57:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id PEKOW5c6iPmq for ; Mon, 13 Nov 2017 07:57:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 3F6DF5FB02 for ; Mon, 13 Nov 2017 07:57:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 79E5AE04F4 for ; Mon, 13 Nov 2017 07:57:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 111C4240CE for ; Mon, 13 Nov 2017 07:57:00 +0000 (UTC) Date: Mon, 13 Nov 2017 07:57:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-10132) Multiple Management Servers Support for agents MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 13 Nov 2017 07:57:05 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-10132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16249211#comment-16249211 ] ASF GitHub Bot commented on CLOUDSTACK-10132: --------------------------------------------- rhtyd commented on a change in pull request #2309: CLOUDSTACK-10132: Multiple Management Servers Support for agents URL: https://github.com/apache/cloudstack/pull/2309#discussion_r150465994 ########## File path: server/src/org/apache/cloudstack/agent/mslb/AgentMSLBServiceImpl.java ########## @@ -0,0 +1,137 @@ +// 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 org.apache.cloudstack.agent.mslb; + +import com.cloud.agent.AgentManager; +import com.cloud.agent.api.ReadyCommand; +import com.cloud.host.HostVO; +import com.cloud.host.Status; +import com.cloud.hypervisor.Hypervisor; +import com.cloud.resource.ResourceManager; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import java.util.stream.Collectors; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.apache.cloudstack.agent.mslb.algorithm.AgentMSLBRoundRobinAlgorithm; +import org.apache.cloudstack.agent.mslb.algorithm.AgentMSLBShuffleAlgorithm; +import org.apache.cloudstack.agent.mslb.algorithm.AgentMSLBStaticAlgorithm; +import org.apache.cloudstack.config.ApiServiceConfiguration; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; +import org.apache.log4j.Logger; + +import com.cloud.utils.component.ComponentLifecycleBase; +import com.cloud.utils.exception.CloudRuntimeException; +import com.google.common.base.Strings; + +public class AgentMSLBServiceImpl extends ComponentLifecycleBase implements AgentMSLB, Configurable { + public static final Logger LOG = Logger.getLogger(AgentMSLBServiceImpl.class); + + public static final ConfigKey ConnectedAgentLBAlgorithm = new ConfigKey<>("Advanced", String.class, + "connected.agent.mslb.algorithm", "static", + "The algorithm to applied on the provided 'host' management server list that is sent to indirect agents. Allowed values are: static, roundrobin and shuffle.", + true, ConfigKey.Scope.Global); + + private static Map algorithmMap = new HashMap<>(); + + @Inject + ResourceManager resourceManager; + @Inject + AgentManager agentManager; + + @Override + public List getManagementServerList() { + final String msServerAddresses = ApiServiceConfiguration.ManagementServerAddresses.value(); + if (Strings.isNullOrEmpty(msServerAddresses)) { + throw new CloudRuntimeException(String.format("No management server addresses are defined in '%s' setting", + ApiServiceConfiguration.ManagementServerAddresses.key())); + } + + return getAgentMSLBAlgorithm().getMSList(Arrays.asList(msServerAddresses.replace(" ", "").split(","))); + } + + protected List getOrderedRunningIndirectAgentIds() { + List hosts = resourceManager.findDirectlyConnectedHosts(); + if (hosts != null) { + return hosts.stream() + .filter(x -> x.getState().equals(Status.Up) && x.getHypervisorType().equals(Hypervisor.HypervisorType.KVM)) + .sorted((x,y) -> Long.compare(x.getId(), y.getId())) + .collect(Collectors.toList()); + } + return null; + } + + @Override + public void propagateManagementServerListToAgents() { + List hosts = getOrderedRunningIndirectAgentIds(); + if (hosts != null) { + for (HostVO h : hosts) { Review comment: @nvazquez I don't think it's a good idea, `resource claim and ownership` is not within the scope of this feature. This method will send command/answers to all the hosts (even those not managed by the `this` management server) and may cause disconnections. In case of multiple management servers, this will cause all the management servers to send multiple requests to all the agents. (note, when you do agent.send(), if the agent is not connected to `this` management server, it will use clustered mgmt server impl to send the request to the forwarding agent which is via other mgmt servers). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 > Multiple Management Servers Support for agents > ---------------------------------------------- > > Key: CLOUDSTACK-10132 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10132 > Project: CloudStack > Issue Type: Improvement > Security Level: Public(Anyone can view this level - this is the default.) > Affects Versions: 4.11.0.0 > Reporter: Nicolas Vazquez > Assignee: Nicolas Vazquez > > Multiple Management Servers Support for agents -- This message was sent by Atlassian JIRA (v6.4.14#64029)