Skip to content

Commit a05ec6d

Browse files
author
Alex Huang
committed
Fixed up the agent separation. Added comments for config packaging.
1 parent 1f5699b commit a05ec6d

18 files changed

Lines changed: 152 additions & 188 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,29 @@
2020

2121
import com.cloud.agent.api.Answer;
2222
import com.cloud.agent.api.Command;
23+
import com.cloud.agent.api.StartupCommand;
2324
import com.cloud.agent.manager.Commands;
2425
import com.cloud.exception.AgentUnavailableException;
26+
import com.cloud.exception.ConnectionException;
2527
import com.cloud.exception.OperationTimedoutException;
28+
import com.cloud.host.Host;
2629
import com.cloud.host.HostVO;
2730
import com.cloud.host.Status;
2831
import com.cloud.hypervisor.Hypervisor.HypervisorType;
32+
import com.cloud.resource.ServerResource;
2933

3034
/**
3135
* AgentManager manages hosts. It directly coordinates between the DAOs and the connections it manages.
3236
*/
3337
public interface AgentManager {
34-
final static String WaitCK = "wait";
35-
static final ConfigKey<Integer> Wait = new ConfigKey<Integer>("Advanced", Integer.class, WaitCK, "1800", "Time in seconds to wait for control commands to return", true);
38+
static final ConfigKey<Integer> Wait = new ConfigKey<Integer>("Advanced", Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return", true);
3639

3740
public enum TapAgentsAction {
3841
Add, Del, Contains,
3942
}
4043

44+
boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
45+
4146
/**
4247
* easy send method that returns null if there's any errors. It handles all exceptions.
4348
*

engine/components-api/src/com/cloud/resource/ResourceManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String,
109109

110110
public HostVO findHostByName(String name);
111111

112-
public List<HostVO> listHostsByNameLike(String name);
113-
114112
HostStats getHostStatistics(long hostId);
115113

116114
Long getGuestOSCategoryId(long hostId);

engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.log4j.Logger;
4242

4343
import org.apache.cloudstack.context.ServerContexts;
44-
import org.apache.cloudstack.framework.config.ConfigDepot;
4544
import org.apache.cloudstack.framework.config.ConfigKey;
4645
import org.apache.cloudstack.framework.config.Configurable;
4746
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -166,9 +165,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
166165

167166
@Inject ResourceManager _resourceMgr;
168167

169-
@Inject
170-
protected ConfigDepot _configDepot;
171-
172168
protected final ConfigKey<Integer> Workers = new ConfigKey<Integer>(Integer.class, "workers", "Advance", "5",
173169
"Number of worker threads handling remote agent connections.", false);
174170
protected final ConfigKey<Integer> Port = new ConfigKey<Integer>(Integer.class, "port", "Advance", "8250", "Port to listen on for remote agent connections.", false);
@@ -678,7 +674,7 @@ protected boolean loadDirectlyConnectedHost(HostVO host, boolean forRebalance) {
678674
}
679675
}
680676

681-
protected AgentAttache createAttacheForDirectConnect(HostVO host, ServerResource resource)
677+
protected AgentAttache createAttacheForDirectConnect(Host host, ServerResource resource)
682678
throws ConnectionException {
683679
// if (resource instanceof DummySecondaryStorageResource || resource instanceof KvmDummyResourceBase) {
684680
// return new DummyAttache(this, host.getId(), false);
@@ -1383,7 +1379,8 @@ public void disconnectWithoutInvestigation(final long hostId, final Status.Event
13831379
disconnectInternal(hostId, event, false);
13841380
}
13851381

1386-
public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
1382+
@Override
1383+
public boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
13871384
AgentAttache attache;
13881385

13891386
attache = createAttacheForDirectConnect(host, resource);
@@ -1394,7 +1391,7 @@ public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds,
13941391
attache.process(answers);
13951392
attache = notifyMonitorsOfConnection(attache, cmds, forRebalance);
13961393

1397-
return attache;
1394+
return attache != null;
13981395
}
13991396

14001397
@Override

engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected AgentAttache createAttacheForConnect(HostVO host, Link link) {
279279
}
280280

281281
@Override
282-
protected AgentAttache createAttacheForDirectConnect(HostVO host, ServerResource resource) {
282+
protected AgentAttache createAttacheForDirectConnect(Host host, ServerResource resource) {
283283
// if (resource instanceof DummySecondaryStorageResource) {
284284
// return new DummyAttache(this, host.getId(), false);
285285
// }

engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
import javax.inject.Inject;
2727
import javax.naming.ConfigurationException;
2828

29-
import com.cloud.host.Host;
30-
import com.cloud.host.Status;
31-
import com.cloud.utils.fsm.NoTransitionException;
32-
import com.cloud.utils.fsm.StateMachine2;
3329
import org.apache.log4j.Logger;
3430

3531
import com.cloud.agent.AgentManager;
@@ -38,15 +34,19 @@
3834
import com.cloud.agent.api.Answer;
3935
import com.cloud.agent.api.Command;
4036
import com.cloud.agent.api.SetupCommand;
37+
import com.cloud.agent.api.StartupCommand;
4138
import com.cloud.agent.manager.Commands;
4239
import com.cloud.dc.ClusterDetailsDao;
4340
import com.cloud.dc.ClusterVO;
4441
import com.cloud.dc.dao.ClusterDao;
4542
import com.cloud.exception.AgentUnavailableException;
43+
import com.cloud.exception.ConnectionException;
4644
import com.cloud.exception.DiscoveryException;
4745
import com.cloud.exception.OperationTimedoutException;
46+
import com.cloud.host.Host;
4847
import com.cloud.host.HostEnvironment;
4948
import com.cloud.host.HostVO;
49+
import com.cloud.host.Status;
5050
import com.cloud.host.Status.Event;
5151
import com.cloud.host.dao.HostDao;
5252
import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -56,6 +56,8 @@
5656
import com.cloud.resource.ServerResource;
5757
import com.cloud.utils.component.ManagerBase;
5858
import com.cloud.utils.exception.CloudRuntimeException;
59+
import com.cloud.utils.fsm.NoTransitionException;
60+
import com.cloud.utils.fsm.StateMachine2;
5961

6062
public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentManager {
6163
private static final Logger logger = Logger.getLogger(DirectAgentManagerSimpleImpl.class);
@@ -276,4 +278,10 @@ public boolean isAgentAttached(long hostId) {
276278
return false;
277279
}
278280

281+
@Override
282+
public boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
283+
// TODO Auto-generated method stub
284+
return false;
285+
}
286+
279287
}

framework/cluster/src/com/cloud/cluster/ClusterManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface ClusterManager extends Manager {
2626
"Interval to check for the heart beat between management server nodes", false);
2727
final ConfigKey<Integer> HeartbeatThreshold = new ConfigKey<Integer>(Integer.class, "cluster.heartbeat.threshold", "management-server", "150000",
2828
"Threshold before self-fence the management server", true);
29+
final ConfigKey<String> ManagementHostIPAdr = new ConfigKey<String>("Advanced", String.class, "host", "localhost", "The ip address of management server", true);
2930

3031
void OnReceiveClusterServicePdu(ClusterServicePdu pdu);
3132

framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ public String getConfigComponentName() {
11081108

11091109
@Override
11101110
public ConfigKey<?>[] getConfigKeys() {
1111-
return new ConfigKey<?>[] {HeartbeatInterval, HeartbeatThreshold};
1111+
return new ConfigKey<?>[] {HeartbeatInterval, HeartbeatThreshold, ManagementHostIPAdr};
11121112
}
11131113

11141114
private boolean pingManagementNode(ManagementServerHostVO mshost) {

framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String toString() {
8181

8282
static ConfigDepotImpl s_depot = null;
8383

84-
static void init(ConfigDepotImpl depot) {
84+
static public void init(ConfigDepotImpl depot) {
8585
s_depot = depot;
8686
}
8787

framework/config/src/org/apache/cloudstack/framework/config/Configurable.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
*/
2727
public interface Configurable {
2828

29+
/**
30+
* @return The name of the component that provided this configuration
31+
* variable. This value is saved in the database so someone can easily
32+
* identify who provides this variable.
33+
**/
2934
String getConfigComponentName();
3035

36+
/**
37+
* @return The list of config keys provided by this configuable.
38+
*/
3139
ConfigKey<?>[] getConfigKeys();
3240
}

framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigDepotImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@
5555
* - Move all of the configurations to using ConfigDepot
5656
* - Completely eliminate Config.java
5757
* - Figure out the correct categories.
58-
*
58+
* - Add a scope for management server, where if the scope is management server
59+
* then the override is retrieved from a properties file. Imagine adding a
60+
* new management server node and it is much more capable system than previous
61+
* management servers, you want the adjustments to thread pools etc to be
62+
* very different than other management serves.
63+
* - Add validation methods to ConfigKey<?>. If a validation class is declared
64+
* when constructing a ConfigKey then configuration server should use the
65+
* validation class to validate the value the admin input for the key.
5966
*/
6067
public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemIntegrityChecker {
6168
private final static Logger s_logger = Logger.getLogger(ConfigDepotImpl.class);
@@ -69,6 +76,7 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemInt
6976
HashMap<String, Pair<String, ConfigKey<?>>> _allKeys = new HashMap<String, Pair<String, ConfigKey<?>>>(1007);
7077

7178
public ConfigDepotImpl() {
79+
ConfigKey.init(this);
7280
}
7381

7482
@Override

0 commit comments

Comments
 (0)