Skip to content

Commit dad9e5d

Browse files
author
Mike Tutkowski
committed
CLOUDSTACK-8813: Notify listeners when a host has been added to a cluster, is about to be removed from a cluster, or has been removed from a cluster
1 parent bee2bdc commit dad9e5d

63 files changed

Lines changed: 6210 additions & 375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/com/cloud/agent/api/CreateStoragePoolCommand.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
package com.cloud.agent.api;
2121

22-
import com.cloud.storage.StoragePool;
23-
2422
import java.util.Map;
2523

24+
import com.cloud.storage.StoragePool;
25+
2626
public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
2727
public static final String DATASTORE_NAME = "datastoreName";
2828
public static final String IQN = "iqn";
@@ -32,9 +32,6 @@ public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
3232
private boolean _createDatastore;
3333
private Map<String, String> _details;
3434

35-
public CreateStoragePoolCommand() {
36-
}
37-
3835
public CreateStoragePoolCommand(boolean add, StoragePool pool) {
3936
super(add, pool);
4037
}

core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,41 @@
2424
import com.cloud.storage.template.TemplateProp;
2525

2626
public class ModifyStoragePoolAnswer extends Answer {
27-
StoragePoolInfo poolInfo;
28-
Map<String, TemplateProp> templateInfo;
29-
String localDatastoreName = null;
30-
31-
protected ModifyStoragePoolAnswer() {
32-
}
27+
private StoragePoolInfo _poolInfo;
28+
private Map<String, TemplateProp> _templateInfo;
29+
private String _localDatastoreName;
3330

3431
public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes, long availableBytes, Map<String, TemplateProp> tInfo) {
3532
super(cmd);
36-
this.result = true;
37-
this.poolInfo =
38-
new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);
3933

40-
this.templateInfo = tInfo;
41-
}
34+
result = true;
4235

43-
public StoragePoolInfo getPoolInfo() {
44-
return poolInfo;
36+
_poolInfo = new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);
37+
38+
_templateInfo = tInfo;
4539
}
4640

4741
public void setPoolInfo(StoragePoolInfo poolInfo) {
48-
this.poolInfo = poolInfo;
42+
_poolInfo = poolInfo;
4943
}
5044

51-
public Map<String, TemplateProp> getTemplateInfo() {
52-
return templateInfo;
45+
public StoragePoolInfo getPoolInfo() {
46+
return _poolInfo;
5347
}
5448

5549
public void setTemplateInfo(Map<String, TemplateProp> templateInfo) {
56-
this.templateInfo = templateInfo;
50+
_templateInfo = templateInfo;
5751
}
5852

59-
public String getLocalDatastoreName() {
60-
return localDatastoreName;
53+
public Map<String, TemplateProp> getTemplateInfo() {
54+
return _templateInfo;
6155
}
6256

6357
public void setLocalDatastoreName(String localDatastoreName) {
64-
this.localDatastoreName = localDatastoreName;
58+
_localDatastoreName = localDatastoreName;
6559
}
6660

61+
public String getLocalDatastoreName() {
62+
return _localDatastoreName;
63+
}
6764
}

core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,49 @@
2626
import com.cloud.storage.StoragePool;
2727

2828
public class ModifyStoragePoolCommand extends Command {
29-
30-
boolean add;
31-
StorageFilerTO pool;
32-
String localPath;
33-
String[] options;
3429
public static final String LOCAL_PATH_PREFIX = "/mnt/";
3530

36-
public ModifyStoragePoolCommand() {
37-
38-
}
31+
private boolean _add;
32+
private StorageFilerTO _pool;
33+
private String _localPath;
34+
private String _storagePath;
3935

4036
public ModifyStoragePoolCommand(boolean add, StoragePool pool, String localPath) {
41-
this.add = add;
42-
this.pool = new StorageFilerTO(pool);
43-
this.localPath = localPath;
44-
37+
_add = add;
38+
_pool = new StorageFilerTO(pool);
39+
_localPath = localPath;
4540
}
4641

4742
public ModifyStoragePoolCommand(boolean add, StoragePool pool) {
4843
this(add, pool, LOCAL_PATH_PREFIX + File.separator + UUID.nameUUIDFromBytes((pool.getHostAddress() + pool.getPath()).getBytes()));
4944
}
5045

51-
public StorageFilerTO getPool() {
52-
return pool;
46+
public boolean getAdd() {
47+
return _add;
5348
}
5449

5550
public void setPool(StoragePool pool) {
56-
this.pool = new StorageFilerTO(pool);
51+
_pool = new StorageFilerTO(pool);
5752
}
5853

59-
public boolean getAdd() {
60-
return add;
54+
public StorageFilerTO getPool() {
55+
return _pool;
6156
}
6257

63-
@Override
64-
public boolean executeInSequence() {
65-
return false;
58+
public String getLocalPath() {
59+
return _localPath;
6660
}
6761

68-
public String getLocalPath() {
69-
return localPath;
62+
public void setStoragePath(String storagePath) {
63+
_storagePath = storagePath;
7064
}
7165

72-
public void setOptions(String[] options) {
73-
this.options = options;
66+
public String getStoragePath() {
67+
return _storagePath;
7468
}
7569

70+
@Override
71+
public boolean executeInSequence() {
72+
return false;
73+
}
7674
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.api;
21+
22+
public class ModifyTargetsAnswer extends Answer {
23+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.api;
21+
22+
import java.util.List;
23+
import java.util.Map;
24+
25+
public class ModifyTargetsCommand extends Command {
26+
public static final String IQN = "iqn";
27+
public static final String STORAGE_HOST = "storageHost";
28+
public static final String STORAGE_PORT = "storagePort";
29+
public static final String CHAP_NAME = "chapName";
30+
public static final String CHAP_SECRET = "chapSecret";
31+
public static final String MUTUAL_CHAP_NAME = "mutualChapName";
32+
public static final String MUTUAL_CHAP_SECRET = "mutualChapSecret";
33+
34+
private boolean _add;
35+
private List<Map<String, String>> _targets;
36+
37+
public void setAdd(boolean add) {
38+
_add = add;
39+
}
40+
41+
public boolean getAdd() {
42+
return _add;
43+
}
44+
45+
public void setTargets(List<Map<String, String>> targets) {
46+
_targets = targets;
47+
}
48+
49+
public List<Map<String, String>> getTargets() {
50+
return _targets;
51+
}
52+
53+
@Override
54+
public boolean executeInSequence() {
55+
return false;
56+
}
57+
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21+
import java.util.List;
22+
2123
import com.cloud.storage.DataStoreProviderApiService;
2224
import com.cloud.utils.component.Manager;
2325

@@ -29,4 +31,6 @@ public interface DataStoreProviderManager extends Manager, DataStoreProviderApiS
2931
DataStoreProvider getDefaultImageDataStoreProvider();
3032

3133
DataStoreProvider getDefaultCacheDataStoreProvider();
34+
35+
List<DataStoreProvider> getProviders();
3236
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
import com.cloud.exception.StorageConflictException;
2222

2323
public interface HypervisorHostListener {
24+
boolean hostAdded(long hostId);
25+
2426
boolean hostConnect(long hostId, long poolId) throws StorageConflictException;
2527

2628
boolean hostDisconnected(long hostId, long poolId);
29+
30+
boolean hostAboutToBeRemoved(long hostId);
31+
32+
boolean hostRemoved(long hostId, long clusterId);
2733
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@
2626
import com.cloud.storage.Volume;
2727

2828
public interface PrimaryDataStoreDriver extends DataStoreDriver {
29-
public ChapInfo getChapInfo(VolumeInfo volumeInfo);
29+
ChapInfo getChapInfo(VolumeInfo volumeInfo);
3030

31-
public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
31+
boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
3232

33-
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
33+
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
3434

3535
// intended for managed storage (cloud.storage_pool.managed = true)
3636
// if not managed, return volume.getSize()
37-
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);
37+
long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);
3838

3939
// intended for managed storage (cloud.storage_pool.managed = true)
4040
// if managed storage, return the total number of bytes currently in use for the storage pool in question
4141
// if not managed storage, return 0
42-
public long getUsedBytes(StoragePool storagePool);
42+
long getUsedBytes(StoragePool storagePool);
4343

4444
// intended for managed storage (cloud.storage_pool.managed = true)
4545
// if managed storage, return the total number of IOPS currently in use for the storage pool in question
4646
// if not managed storage, return 0
47-
public long getUsedIops(StoragePool storagePool);
47+
long getUsedIops(StoragePool storagePool);
4848

49-
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
49+
void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
5050

51-
public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
51+
void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
5252
}

engine/components-api/src/com/cloud/agent/AgentManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public enum TapAgentsAction {
4242
Add, Del, Contains,
4343
}
4444

45-
boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
45+
boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance, boolean newHost) throws ConnectionException;
4646

4747
/**
4848
* easy send method that returns null if there's any errors. It handles all exceptions.
@@ -131,8 +131,6 @@ public enum TapAgentsAction {
131131

132132
Answer sendTo(Long dcId, HypervisorType type, Command cmd);
133133

134-
// public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
135-
136134
public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId);
137135

138136
boolean isAgentAttached(long hostId);
@@ -146,4 +144,10 @@ public enum TapAgentsAction {
146144
boolean reconnect(long hostId);
147145

148146
void rescan();
147+
148+
void notifyMonitorsOfNewlyAddedHost(long hostId);
149+
150+
void notifyMonitorsOfHostAboutToBeRemoved(long hostId);
151+
152+
void notifyMonitorsOfRemovedHost(long hostId, long clusterId);
149153
}

engine/components-api/src/com/cloud/agent/Listener.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public interface Listener {
6363
*/
6464
AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd);
6565

66+
/**
67+
* This method is called by AgentManager when a host is added to a cluster.
68+
* @param long the ID of the newly added host
69+
*/
70+
void processHostAdded(long hostId);
71+
6672
/**
6773
* This method is called by AgentManager when an agent made a
6874
* connection to this server if the listener has
@@ -86,6 +92,18 @@ public interface Listener {
8692
*/
8793
boolean processDisconnect(long agentId, Status state);
8894

95+
/**
96+
* This method is called by AgentManager when a host is about to be removed from a cluster.
97+
* @param long the ID of the host that's about to be removed
98+
*/
99+
void processHostAboutToBeRemoved(long hostId);
100+
101+
/**
102+
* This method is called by AgentManager when a host is removed from a cluster.
103+
* @param long the ID of the newly removed host
104+
*/
105+
void processHostRemoved(long hostId, long clusterId);
106+
89107
/**
90108
* If this Listener is passed to the send() method, this method
91109
* is called by AgentManager after processing an answer

0 commit comments

Comments
 (0)