mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Pass isForRebalance parameter to processConnect method of all the listeners - some listeners don't have to be notified when connection happens as a a part of Agent Rebalance process (VirtualMachineManagerImpl listener for instance)
This commit is contained in:
parent
826f5eedf1
commit
18dc85c765
@ -72,11 +72,12 @@ public interface Listener {
|
||||
* This method is called by AgentManager when an agent made a
|
||||
* connection to this server if the listener has
|
||||
* been registered for host events.
|
||||
* @param agentId id of the agent
|
||||
* @param cmd command sent by the agent to the server on startup.
|
||||
* @param forRebalance TODO
|
||||
* @param agentId id of the agent
|
||||
* @throws ConnectionException if host has problems and needs to put into maintenance state.
|
||||
*/
|
||||
void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException;
|
||||
void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* This method is called by AgentManager when an agent disconnects
|
||||
@ -119,12 +120,5 @@ public interface Listener {
|
||||
* @return true if processed; false if not.
|
||||
*/
|
||||
boolean processTimeout(long agentId, long seq);
|
||||
|
||||
|
||||
/**
|
||||
* If set to false, processConnect wouldn't be called for the host
|
||||
*
|
||||
* @return true when connect has to be processed when host connects as a part of rebalance process, false otherwise
|
||||
*/
|
||||
boolean processConnectForRebalanceHost();
|
||||
|
||||
}
|
||||
|
||||
@ -1062,16 +1062,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
||||
long hostId = attache.getId();
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
for (Pair<Integer, Listener> monitor : _hostMonitors) {
|
||||
//some listeneres don't have to be notified when host is connected as a part of rebalance process
|
||||
boolean processConnect = (!forRebalance || (forRebalance && monitor.second().processConnectForRebalanceHost()));
|
||||
if (s_logger.isDebugEnabled() && processConnect) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Sending Connect to listener: " + monitor.second().getClass().getSimpleName());
|
||||
}
|
||||
for (int i = 0; i < cmd.length; i++) {
|
||||
try {
|
||||
if (processConnect) {
|
||||
monitor.second().processConnect(host, cmd[i]);
|
||||
}
|
||||
monitor.second().processConnect(host, cmd[i], forRebalance);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ConnectionException) {
|
||||
ConnectionException ce = (ConnectionException)e;
|
||||
|
||||
@ -185,7 +185,7 @@ public class AgentMonitor extends Thread implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
s_logger.debug("Registering agent monitor for " + host.getId());
|
||||
}
|
||||
|
||||
@ -204,8 +204,4 @@ public class AgentMonitor extends Thread implements Listener {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class SynchronousListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,8 +132,4 @@ public class SynchronousListener implements Listener {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@ -681,10 +681,5 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class ComputeCapacityListener implements Listener {
|
||||
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO server, StartupCommand startup) throws ConnectionException {
|
||||
public void processConnect(HostVO server, StartupCommand startup, boolean forRebalance) throws ConnectionException {
|
||||
if (!(startup instanceof StartupRoutingCommand)) {
|
||||
return;
|
||||
}
|
||||
@ -191,9 +191,4 @@ public class ComputeCapacityListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class StorageCapacityListener implements Listener {
|
||||
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO server, StartupCommand startup) throws ConnectionException {
|
||||
public void processConnect(HostVO server, StartupCommand startup, boolean forRebalance) throws ConnectionException {
|
||||
|
||||
if (!(startup instanceof StartupStorageCommand)) {
|
||||
return;
|
||||
@ -123,10 +123,5 @@ public class StorageCapacityListener implements Listener {
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class ClusterAsyncExectuionListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,10 +76,6 @@ public class ClusterAsyncExectuionListener implements Listener {
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ public class ConsoleProxyListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
_proxyMgr.onAgentConnect(host, cmd);
|
||||
|
||||
if (cmd instanceof StartupProxyCommand) {
|
||||
@ -89,8 +89,4 @@ public class ConsoleProxyListener implements Listener {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -290,8 +290,4 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
return Hypervisor.HypervisorType.KVM.toString().equalsIgnoreCase(hypervisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (!(cmd instanceof StartupRoutingCommand )) {
|
||||
return;
|
||||
}
|
||||
@ -596,9 +596,4 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class SshKeysDistriMonitor implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
if (((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.KVM ||
|
||||
((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.XenServer) {
|
||||
@ -116,9 +116,4 @@ public class SshKeysDistriMonitor implements Listener {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class OvsListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd)
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance)
|
||||
throws ConnectionException {
|
||||
if (host.getType() != Host.Type.Routing) {
|
||||
return;
|
||||
@ -181,10 +181,4 @@ public class OvsListener implements Listener {
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class OvsTunnelListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd)
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance)
|
||||
throws ConnectionException {
|
||||
if (host.getType() != Host.Type.Routing) {
|
||||
return;
|
||||
@ -130,10 +130,5 @@ public class OvsTunnelListener implements Listener {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class SecurityGroupListener implements Listener {
|
||||
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Received a host startup notification");
|
||||
|
||||
@ -152,10 +152,4 @@ public class SecurityGroupListener implements Listener {
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class LocalStoragePoolListener implements Listener {
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (!(cmd instanceof StartupStorageCommand)) {
|
||||
return;
|
||||
}
|
||||
@ -134,10 +134,4 @@ public class LocalStoragePoolListener implements Listener {
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public class DownloadListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
downloadMonitor.handleSysTemplateDownload(agent);
|
||||
} else if ( cmd instanceof StartupStorageCommand) {
|
||||
@ -373,9 +373,4 @@ public class DownloadListener implements Listener {
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class StoragePoolMonitor implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
StartupRoutingCommand scCmd = (StartupRoutingCommand)cmd;
|
||||
if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM ||
|
||||
@ -107,8 +107,4 @@ public class StoragePoolMonitor implements Listener {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class StorageSyncListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,9 +81,4 @@ public class StorageSyncListener implements Listener {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class SecondaryStorageListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) {
|
||||
|
||||
if ((cmd instanceof StartupStorageCommand) ) {
|
||||
StartupStorageCommand scmd = (StartupStorageCommand)cmd;
|
||||
@ -108,9 +108,4 @@ public class SecondaryStorageListener implements Listener {
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ public class UploadListener implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) {
|
||||
if (!(cmd instanceof StartupStorageCommand)) {
|
||||
return;
|
||||
}
|
||||
@ -447,9 +447,4 @@ public class UploadListener implements Listener {
|
||||
this.currState = getState(currState.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1781,10 +1781,15 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO agent, StartupCommand cmd) throws ConnectionException {
|
||||
public void processConnect(HostVO agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
if (!(cmd instanceof StartupRoutingCommand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (forRebalance) {
|
||||
s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process");
|
||||
return;
|
||||
}
|
||||
|
||||
long agentId = agent.getId();
|
||||
|
||||
@ -1865,8 +1870,4 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processConnectForRebalanceHost() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user