Switched AgentManager to use ConfigDepot

This commit is contained in:
Alex Huang 2013-08-05 10:47:57 -07:00
parent 30c3341509
commit cf3bbb1fb1
7 changed files with 9 additions and 180 deletions

View File

@ -1,52 +0,0 @@
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-engine-compute</artifactId>
<name>Apache CloudStack Cloud Engine Compute Component</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-ipc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-components-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
</build>
</project>

View File

@ -1,34 +0,0 @@
/*
* 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.compute;
import java.util.logging.Handler;
public interface ComputeOrchestrator {
/**
* start the vm
* @param vm vm
* @param reservationId
*/
void start(String vm, String reservationId, Handler handler);
void cancel(String reservationId);
void stop(String vm, String reservationId);
}

View File

@ -1,42 +0,0 @@
/*
* 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.compute;
import java.util.logging.Handler;
public class ComputeOrchestratorImpl implements ComputeOrchestrator {
@Override
public void cancel(String reservationId) {
}
@Override
public void stop(String vm, String reservationId) {
// Retrieve the VM
// Locate the HypervisorGuru based on the VM type
// Call HypervisorGuru to stop the VM
}
@Override
public void start(String vm, String reservationId, Handler handler) {
// TODO Auto-generated method stub
}
}

View File

@ -1,36 +0,0 @@
/*
* 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.platform.planning;
import org.apache.cloudstack.framework.ipc.Ipc;
public interface Concierge {
@Ipc(topic="cs.concierge.reserve")
String reserve(String vm, String planner, Long until);
@Ipc(topic="cs.concierge.cancel")
String cancel(String reservationId);
@Ipc(topic="cs.concierge.claim")
String claim(String reservationId);
@Ipc(topic="cs.concierge.reserveAnother")
String reserveAnother(String reservationId);
}

View File

@ -32,7 +32,6 @@
</build>
<modules>
<module>api</module>
<module>compute</module>
<module>orchestration</module>
<module>storage</module>
<module>storage/volume</module>

View File

@ -97,7 +97,6 @@ import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceState;
import com.cloud.resource.ServerResource;
import com.cloud.storage.resource.DummySecondaryStorageResource;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory;
@ -148,7 +147,6 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
protected ConfigurationDao _configDao = null;
@Inject
protected ClusterDao _clusterDao = null;
protected int _port;
@Inject
protected HighAvailabilityManager _haMgr = null;
@ -194,12 +192,13 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
protected final ConfigKey<Integer> DirectAgentPoolSize = new ConfigKey<Integer>(Integer.class, "direct.agent.pool.size", "Advance", AgentManager.class, "500",
"Default size for DirectAgentPool", false, null);
protected ConfigValue<Integer> _port;
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
_port = NumbersUtil.parseInt(configs.get("port"), 8250);
final int workers = NumbersUtil.parseInt(configs.get("workers"), 5);
_port = _configDepot.get(Port);
ConfigValue<Integer> workers = _configDepot.get(Workers);
_pingInterval = _configDepot.get(PingInterval);
@ -225,8 +224,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
//allow core threads to time out even when there are no items in the queue
_connectExecutor.allowCoreThreadTimeOut(true);
_connection = new NioServer("AgentManager", _port, workers + 10, this);
s_logger.info("Listening on " + _port + " with " + workers + " workers");
_connection = new NioServer("AgentManager", _port.value(), workers.value() + 10, this);
s_logger.info("Listening on " + _port.value() + " with " + workers.value() + " workers");
ConfigValue<Integer> size = _configDepot.get(DirectAgentPoolSize);

View File

@ -83,7 +83,6 @@ import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.Status.Event;
import com.cloud.resource.ResourceState;
import com.cloud.resource.ServerResource;
import com.cloud.serializer.GsonHelper;
import com.cloud.storage.resource.DummySecondaryStorageResource;
@ -508,13 +507,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
throw new CloudRuntimeException("Unable to resolve " + ip);
}
try {
ch = SocketChannel.open(new InetSocketAddress(addr, _port));
ch = SocketChannel.open(new InetSocketAddress(addr, _port.value()));
ch.configureBlocking(true); // make sure we are working at blocking mode
ch.socket().setKeepAlive(true);
ch.socket().setSoTimeout(60 * 1000);
try {
SSLContext sslContext = Link.initSSLContext(true);
sslEngine = sslContext.createSSLEngine(ip, _port);
sslEngine = sslContext.createSSLEngine(ip, _port.value());
sslEngine.setUseClientMode(true);
Link.doHandshake(ch, sslEngine, true);
@ -1241,10 +1240,6 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
public boolean executeResourceUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException {
return _resourceMgr.executeUserRequest(hostId, event);
}
protected class ClusterDispatcher implements ClusterManager.Dispatcher {
@Override
public String getName() {
@ -1317,7 +1312,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
boolean result = false;
try {
result = executeResourceUserRequest(cmd.getHostId(), cmd.getEvent());
result = _resourceMgr.executeUserRequest(cmd.getHostId(), cmd.getEvent());
s_logger.debug("Result is " + result);
} catch (AgentUnavailableException ex) {
s_logger.warn("Agent is unavailable", ex);