mirror of https://github.com/apache/cloudstack.git
bug 14301: Decouple synchronized crosss management server call with clustering transport, remove obsolete code. Reviewed-by: Kelven
This commit is contained in:
parent
f23e4cab71
commit
a18df2728c
|
|
@ -28,20 +28,15 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
|||
import org.apache.commons.httpclient.params.HttpClientParams;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class ClusterServiceServletImpl implements ClusterService {
|
||||
private static final long serialVersionUID = 4574025200012566153L;
|
||||
private static final Logger s_logger = Logger.getLogger(ClusterServiceServletImpl.class);
|
||||
|
||||
private String _serviceUrl;
|
||||
|
||||
private final Gson _gson;
|
||||
private int _requestTimeoutSeconds;
|
||||
|
||||
public ClusterServiceServletImpl() {
|
||||
_gson = GsonHelper.getGson();
|
||||
}
|
||||
|
||||
public ClusterServiceServletImpl(String serviceUrl, int requestTimeoutSeconds) {
|
||||
|
|
@ -49,8 +44,6 @@ public class ClusterServiceServletImpl implements ClusterService {
|
|||
|
||||
this._serviceUrl = serviceUrl;
|
||||
this._requestTimeoutSeconds = requestTimeoutSeconds;
|
||||
|
||||
_gson = GsonHelper.getGson();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,84 +65,6 @@ public class ClusterServiceServletImpl implements ClusterService {
|
|||
return executePostMethod(client, method);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public String execute(String callingPeer, long agentId, String gsonPackage, boolean stopOnError) throws RemoteException {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Post (sync-call) " + gsonPackage + " to " + _serviceUrl + " for agent " + agentId + " from " + callingPeer);
|
||||
}
|
||||
|
||||
HttpClient client = getHttpClient();
|
||||
PostMethod method = new PostMethod(_serviceUrl);
|
||||
|
||||
method.addParameter("method", Integer.toString(RemoteMethodConstants.METHOD_EXECUTE));
|
||||
method.addParameter("agentId", Long.toString(agentId));
|
||||
method.addParameter("gsonPackage", gsonPackage);
|
||||
method.addParameter("stopOnError", stopOnError ? "1" : "0");
|
||||
|
||||
return executePostMethod(client, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long executeAsync(String callingPeer, long agentId, String gsonPackage, boolean stopOnError) throws RemoteException {
|
||||
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Post (Async-call) " + gsonPackage + " to " + _serviceUrl + " for agent " + agentId + " from " + callingPeer);
|
||||
}
|
||||
|
||||
HttpClient client = getHttpClient();
|
||||
PostMethod method = new PostMethod(_serviceUrl);
|
||||
|
||||
method.addParameter("method", Integer.toString(RemoteMethodConstants.METHOD_EXECUTE_ASYNC));
|
||||
method.addParameter("agentId", Long.toString(agentId));
|
||||
method.addParameter("gsonPackage", gsonPackage);
|
||||
method.addParameter("stopOnError", stopOnError ? "1" : "0");
|
||||
method.addParameter("caller", callingPeer);
|
||||
|
||||
String result = executePostMethod(client, method);
|
||||
if(result == null) {
|
||||
s_logger.error("Empty return from remote async-execution on " + _serviceUrl);
|
||||
throw new RemoteException("Invalid result returned from async-execution on peer : " + _serviceUrl);
|
||||
}
|
||||
|
||||
try {
|
||||
return _gson.fromJson(result, Long.class);
|
||||
} catch(Throwable e) {
|
||||
s_logger.error("Unable to parse executeAsync return : " + result);
|
||||
throw new RemoteException("Invalid result returned from async-execution on peer : " + _serviceUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onAsyncResult(String executingPeer, long agentId, long seq, String gsonPackage) throws RemoteException {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Forward Async-call answer to remote listener, agent: " + agentId
|
||||
+ ", excutingPeer: " + executingPeer
|
||||
+ ", seq: " + seq + ", gsonPackage: " + gsonPackage);
|
||||
}
|
||||
HttpClient client = getHttpClient();
|
||||
PostMethod method = new PostMethod(_serviceUrl);
|
||||
|
||||
method.addParameter("method", Integer.toString(RemoteMethodConstants.METHOD_ASYNC_RESULT));
|
||||
method.addParameter("agentId", Long.toString(agentId));
|
||||
method.addParameter("gsonPackage", gsonPackage);
|
||||
method.addParameter("seq", Long.toString(seq));
|
||||
method.addParameter("executingPeer", executingPeer);
|
||||
|
||||
String result = executePostMethod(client, method);
|
||||
if(result.contains("recurring=true")) {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Remote listener returned recurring=true");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Remote listener returned recurring=false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public boolean ping(String callingPeer) throws RemoteException {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
|
|
@ -60,12 +59,6 @@ public class DummyClusterManagerImpl implements ClusterManager {
|
|||
throw new CloudRuntimeException("Unsupported feature");
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public long sendToAgent(Long hostId, Command[] cmds, boolean stopOnError, Listener listener) throws AgentUnavailableException {
|
||||
throw new CloudRuntimeException("Unsupported feature");
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public boolean executeAgentUserRequest(long agentId, Event event) throws AgentUnavailableException {
|
||||
throw new CloudRuntimeException("Unsupported feature");
|
||||
|
|
|
|||
Loading…
Reference in New Issue