Author: pferraro
Date: 2009-04-07 13:19:12 -0400 (Tue, 07 Apr 2009)
New Revision: 2390
Added:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStatus.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/RpcResponseFilter.java
Removed:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/BooleanGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponseFilter.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/InetAddressGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/IntegerGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStateGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/StringGroupRpcResponse.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ThrowableGroupRpcResponse.java
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ClusteredMCMPHandlerRpcHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterListenerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HAModClusterServiceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
Log:
Expose results from mcmp requests
Simplify rpc response objects
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerImpl.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -29,6 +29,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -42,14 +43,12 @@
import org.jboss.logging.Logger;
import org.jboss.modcluster.Constants;
import org.jboss.modcluster.Utils;
-import org.jboss.modcluster.ha.rpc.BooleanGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler;
-import org.jboss.modcluster.ha.rpc.GroupRpcResponse;
-import org.jboss.modcluster.ha.rpc.GroupRpcResponseFilter;
+import org.jboss.modcluster.ha.rpc.DefaultRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponseFilter;
import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
import org.jboss.modcluster.ha.rpc.PeerMCMPDiscoveryStatus;
-import org.jboss.modcluster.ha.rpc.StringGroupRpcResponse;
-import org.jboss.modcluster.ha.rpc.ThrowableGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponse;
import org.jboss.modcluster.mcmp.AbstractMCMPHandler;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
@@ -251,11 +250,7 @@
return this.localHandler.getProxyConfiguration();
}
- GroupRpcResponse response = this.rpcStub.getProxyConfiguration();
-
- this.validateResponse(response, false);
-
- return ((StringGroupRpcResponse) response).getValue();
+ return this.rpcStub.getProxyConfiguration().getResult();
}
public String getProxyInfo()
@@ -265,11 +260,7 @@
return this.localHandler.getProxyInfo();
}
- GroupRpcResponse response = this.rpcStub.getProxyInfo();
-
- this.validateResponse(response, false);
-
- return ((StringGroupRpcResponse) response).getValue();
+ return this.rpcStub.getProxyInfo().getResult();
}
public void init(List<InetSocketAddress> initialProxies)
@@ -299,11 +290,7 @@
return this.localHandler.isProxyHealthOK();
}
- GroupRpcResponse response = this.rpcStub.isProxyHealthOK();
-
- this.validateResponse(response, false);
-
- return ((BooleanGroupRpcResponse) response).getValue();
+ return this.rpcStub.isProxyHealthOK().getResult().booleanValue();
}
public void markProxiesInError()
@@ -316,9 +303,7 @@
}
else
{
- GroupRpcResponse response = this.rpcStub.markProxiesInError();
-
- this.validateResponse(response, false);
+ this.rpcStub.markProxiesInError().getResult();
}
}
@@ -330,37 +315,45 @@
}
else
{
- GroupRpcResponse response = this.rpcStub.reset();
-
- this.validateResponse(response, false);
+ this.rpcStub.reset().getResult();
}
}
- public void sendRequest(MCMPRequest request)
+ public Map<MCMPServerState, String> sendRequest(MCMPRequest request)
{
if (this.singleton.isMasterNode())
{
- this.localHandler.sendRequest(request);
+ return this.localHandler.sendRequest(request);
}
- else
+
+ try
{
- GroupRpcResponse response = this.rpcStub.sendRequest(request);
+ return this.rpcStub.sendRequest(request).getResult();
+ }
+ catch (RuntimeException e)
+ {
+ this.recordRequestFailure();
- this.validateResponse(response, true);
+ throw e;
}
}
- public void sendRequests(List<MCMPRequest> requests)
+ public Map<MCMPServerState, List<String>>
sendRequests(List<MCMPRequest> requests)
{
if (this.singleton.isMasterNode())
{
- this.localHandler.sendRequests(requests);
+ return this.localHandler.sendRequests(requests);
}
- else
+
+ try
{
- GroupRpcResponse response = this.rpcStub.sendRequests(requests);
+ return this.rpcStub.sendRequests(requests).getResult();
+ }
+ catch (RuntimeException e)
+ {
+ this.recordRequestFailure();
- this.validateResponse(response, true);
+ throw e;
}
}
@@ -374,21 +367,6 @@
log.warn(this.sm.getString("modcluster.error.status.unsupported"));
}
- // ---------------------------------------------------------------- Private
-
- private void validateResponse(GroupRpcResponse response, boolean recordFailure)
- {
- if (response instanceof ThrowableGroupRpcResponse)
- {
- if (recordFailure)
- {
- this.recordRequestFailure();
- }
-
- throw ((ThrowableGroupRpcResponse) response).getValueAsRuntimeException();
- }
- }
-
private void sendDiscoveryEventToPartition(InetAddress address, int port, boolean
addition)
{
InetSocketAddress socketAddress = new InetSocketAddress(address, port);
@@ -400,13 +378,15 @@
this.pendingDiscoveryEvents.add(event);
- GroupRpcResponse response = this.rpcStub.mcmpServerDiscoveryEvent(event);
-
- if (response instanceof ThrowableGroupRpcResponse)
+ try
{
+ this.rpcStub.mcmpServerDiscoveryEvent(event).getResult();
+ }
+ catch (RuntimeException e)
+ {
// Just log it; we'll retry later
String msg = addition ? "modcluster.error.discovery.add" :
"modcluster.error.discovery.remove";
- log.error(this.sm.getString(msg, address, Integer.valueOf(port)),
((ThrowableGroupRpcResponse) response).getValue());
+ log.error(this.sm.getString(msg, address, Integer.valueOf(port)), e);
}
}
}
@@ -421,7 +401,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyConfiguration()
*/
- public GroupRpcResponse getProxyConfiguration()
+ public RpcResponse<String> getProxyConfiguration()
{
return this.invokeRpc("getProxyConfiguration");
}
@@ -429,7 +409,7 @@
/**
* @see org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyInfo()
*/
- public GroupRpcResponse getProxyInfo()
+ public RpcResponse<String> getProxyInfo()
{
return this.invokeRpc("getProxyInfo");
}
@@ -437,7 +417,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#isProxyHealthOK()
*/
- public GroupRpcResponse isProxyHealthOK()
+ public RpcResponse<Boolean> isProxyHealthOK()
{
return this.invokeRpc("isProxyHealthOk");
}
@@ -445,7 +425,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#markProxiesInError()
*/
- public GroupRpcResponse markProxiesInError()
+ public RpcResponse<Void> markProxiesInError()
{
return this.invokeRpc("markProxiesInError");
}
@@ -453,7 +433,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#mcmpServerDiscoveryEvent(org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent)
*/
- public GroupRpcResponse mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event)
+ public RpcResponse<Void> mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent
event)
{
try
{
@@ -461,14 +441,16 @@
}
catch (Exception e)
{
- return new ThrowableGroupRpcResponse(null, e);
+ DefaultRpcResponse<Void> response = new
DefaultRpcResponse<Void>(null);
+ response.setException(e);
+ return response;
}
}
/**
* @see org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#reset()
*/
- public GroupRpcResponse reset()
+ public RpcResponse<Void> reset()
{
return this.invokeRpc("reset");
}
@@ -476,7 +458,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequest(org.jboss.modcluster.mcmp.MCMPRequest)
*/
- public GroupRpcResponse sendRequest(MCMPRequest request)
+ public RpcResponse<Map<MCMPServerState, String>>
sendRequest(MCMPRequest request)
{
return this.invokeRpc("sendRequest", new Object[] { request },
MCMPREQ_TYPES, true);
}
@@ -484,17 +466,17 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequests(java.util.List)
*/
- public GroupRpcResponse sendRequests(List<MCMPRequest> requests)
+ public RpcResponse<Map<MCMPServerState, List<String>>>
sendRequests(List<MCMPRequest> requests)
{
return this.invokeRpc("sendRequests", new Object[] { requests },
MCMPREQS_TYPES, true);
}
- private GroupRpcResponse invokeRpc(String methodName)
+ private <T> RpcResponse<T> invokeRpc(String methodName)
{
return this.invokeRpc(methodName, NULL_ARGS, NULL_TYPES, false);
}
- private GroupRpcResponse invokeRpc(String methodName, Object[] args,
Class<?>[] types, boolean recordFailure)
+ private <T> RpcResponse<T> invokeRpc(String methodName, Object[] args,
Class<?>[] types, boolean recordFailure)
{
try
{
@@ -511,17 +493,18 @@
}
}
- private GroupRpcResponse invokeRpc(String methodName, Object[] args,
Class<?>[] types) throws Exception
+ @SuppressWarnings("unchecked")
+ private <T> RpcResponse<T> invokeRpc(String methodName, Object[] args,
Class<?>[] types) throws Exception
{
- List<?> responses =
ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAPartition().callMethodOnCluster(ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAServiceKey(),
methodName, args, types, false, new GroupRpcResponseFilter());
+ List<?> responses =
ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAPartition().callMethodOnCluster(ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAServiceKey(),
methodName, args, types, false, new RpcResponseFilter());
Throwable thrown = null;
for (Object obj : responses)
{
- if (obj instanceof GroupRpcResponse)
+ if (obj instanceof RpcResponse)
{
- return (GroupRpcResponse) obj;
+ return (RpcResponse) obj;
}
else if (obj instanceof Throwable)
{
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -63,17 +63,14 @@
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.config.ha.HAConfiguration;
import org.jboss.modcluster.config.ha.HAModClusterConfig;
-import org.jboss.modcluster.ha.rpc.BooleanGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler;
-import org.jboss.modcluster.ha.rpc.GroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.DefaultRpcResponse;
import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
import org.jboss.modcluster.ha.rpc.ModClusterServiceRpcHandler;
-import org.jboss.modcluster.ha.rpc.ModClusterServiceStateGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.ModClusterServiceStatus;
import org.jboss.modcluster.ha.rpc.PeerMCMPDiscoveryStatus;
-import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
-import org.jboss.modcluster.ha.rpc.StringGroupRpcResponse;
-import org.jboss.modcluster.ha.rpc.ThrowableGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponse;
import org.jboss.modcluster.load.LoadBalanceFactorProvider;
import org.jboss.modcluster.load.LoadBalanceFactorProviderFactory;
import org.jboss.modcluster.mcmp.MCMPHandler;
@@ -92,7 +89,7 @@
* @version $Revision$
*/
public class HAModClusterService extends HASingletonImpl<HAServiceEvent>
- implements LifecycleListener, HAModClusterServiceMBean,
ModClusterServiceRpcHandler<List<?>, MCMPServerState>,
LoadBalanceFactorProviderFactory, ServerProvider<Server>
+ implements LifecycleListener, HAModClusterServiceMBean,
ModClusterServiceRpcHandler<List<RpcResponse<ModClusterServiceStatus>>,
MCMPServerState>, LoadBalanceFactorProviderFactory, ServerProvider<Server>
{
private static final Class<?>[] CLUSTER_STATUS_COMPLETE_TYPES = new Class[] {
Map.class };
private static final Class<?>[] GET_CLUSTER_COORDINATOR_STATE_TYPES = new
Class[] { Set.class };
@@ -228,7 +225,7 @@
this.rpcHandler = new RpcHandler();
}
-
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.ServerProvider#getServer()
@@ -238,7 +235,6 @@
return this.serverProvider.getServer();
}
-
/**
* @{inheritDoc}
* @see
org.apache.catalina.LifecycleListener#lifecycleEvent(org.apache.catalina.LifecycleEvent)
@@ -419,6 +415,26 @@
}
/**
+ * @{inheritDoc}
+ * @see
org.jboss.ha.framework.server.HAServiceImpl#replicantsChanged(java.lang.String,
java.util.List, int, boolean)
+ */
+/*
+ @SuppressWarnings("unchecked")
+ @Override
+ public void replicantsChanged(String key, List newReplicants, int newViewId, boolean
merge)
+ {
+ if (this.getHAServiceKey().equals(key))
+ {
+ this.partitionTopologyChanged(newReplicants, newViewId, merge);
+ }
+ }
+
+ private MCMPServerState getStatus(String node)
+ {
+ return null;
+ }
+*/
+ /**
* {@inheritDoc}
* @return a list of cluster nodes from which to elect a new master
*/
@@ -494,7 +510,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ModClusterServiceRpcHandler#getClusterCoordinatorState(java.util.Set)
*/
- public List<?> getClusterCoordinatorState(Set<MCMPServerState>
masterList)
+ public List<RpcResponse<ModClusterServiceStatus>>
getClusterCoordinatorState(Set<MCMPServerState> masterList)
{
try
{
@@ -524,10 +540,12 @@
* This is the object that gets invoked on via reflection by HAPartition.
*/
@SuppressWarnings("synthetic-access")
- protected class RpcHandler extends HASingletonImpl<HAServiceEvent>.RpcHandler
implements ModClusterServiceRpcHandler<GroupRpcResponse, MCMPServer>,
ClusteredMCMPHandlerRpcHandler, ResetRequestSourceRpcHandler<GroupRpcResponse>
+ protected class RpcHandler extends HASingletonImpl<HAServiceEvent>.RpcHandler
implements ModClusterServiceRpcHandler<RpcResponse<ModClusterServiceStatus>,
MCMPServer>, ClusteredMCMPHandlerRpcHandler,
ResetRequestSourceRpcHandler<RpcResponse<List<MCMPRequest>>>
{
private final HAModClusterService coord = HAModClusterService.this;
- private final GroupRpcResponse SUCCESS = new
GroupRpcResponse(this.coord.getHAPartition().getClusterNode());
+ private final ClusterNode node = this.coord.getHAPartition().getClusterNode();
+ private final RpcResponse<Void> voidResponse = new
DefaultRpcResponse<Void>(this.node);
+
/*
public GroupRpcResponse getLocalAddress() throws IOException
{
@@ -539,7 +557,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#mcmpServerDiscoveryEvent(org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent)
*/
- public GroupRpcResponse mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event)
+ public RpcResponse<Void> mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent
event)
{
if (!this.coord.isMasterNode()) return null;
@@ -558,14 +576,14 @@
HAModClusterService.this.proxyChangeDigest.put(event.getSender(), event);
- return new
GroupRpcResponse(HAModClusterService.this.getHAPartition().getClusterNode());
+ return this.voidResponse;
}
}
/**
* @see
org.jboss.modcluster.ha.rpc.ModClusterServiceRpcHandler#getClusterCoordinatorState(java.util.Set)
*/
- public GroupRpcResponse getClusterCoordinatorState(Set<MCMPServer>
masterList)
+ public RpcResponse<ModClusterServiceStatus>
getClusterCoordinatorState(Set<MCMPServer> masterList)
{
// TODO is this the correct response here?
if (this.coord.isMasterNode()) return null;
@@ -577,11 +595,12 @@
Map<String, Set<ResetRequestSource.VirtualHost>> map =
Collections.emptyMap();
List<MCMPRequest> resetRequests = needReset ?
this.coord.resetRequestSource.getLocalResetRequests(map) : null;
- ClusterNode node = HAModClusterService.this.getHAPartition().getClusterNode();
List<MCMPServerDiscoveryEvent> events =
this.coord.clusteredHandler.getPendingDiscoveryEvents();
- GroupRpcResponse response = new ModClusterServiceStateGroupRpcResponse(node,
this.coord.latestLoad, ourStates, events, resetRequests);
+ DefaultRpcResponse<ModClusterServiceStatus> response = new
DefaultRpcResponse<ModClusterServiceStatus>(this.node);
+ response.setResult(new ModClusterServiceStatus(this.coord.latestLoad, ourStates,
events, resetRequests));
+
if (needReset)
{
this.coord.clusteredHandler.resetInitiated();
@@ -626,99 +645,105 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyConfiguration()
*/
- public GroupRpcResponse getProxyConfiguration()
+ public RpcResponse<String> getProxyConfiguration()
{
if (!this.coord.isMasterNode()) return null;
- ClusterNode node = HAModClusterService.this.getHAPartition().getClusterNode();
- String configuration = this.coord.localHandler.getProxyConfiguration();
+ DefaultRpcResponse<String> response = new
DefaultRpcResponse<String>(this.node);
- return new StringGroupRpcResponse(node, configuration);
+ response.setResult(this.coord.localHandler.getProxyConfiguration());
+
+ return response;
}
/**
* @see org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyInfo()
*/
- public GroupRpcResponse getProxyInfo()
+ public RpcResponse<String> getProxyInfo()
{
if (!this.coord.isMasterNode()) return null;
- ClusterNode node = HAModClusterService.this.getHAPartition().getClusterNode();
- String info = this.coord.localHandler.getProxyInfo();
+ DefaultRpcResponse<String> response = new
DefaultRpcResponse<String>(this.node);
- return new StringGroupRpcResponse(node, info);
+ response.setResult(this.coord.localHandler.getProxyInfo());
+
+ return response;
}
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#isProxyHealthOK()
*/
- public GroupRpcResponse isProxyHealthOK()
+ public RpcResponse<Boolean> isProxyHealthOK()
{
if (!this.coord.isMasterNode()) return null;
- ClusterNode node = HAModClusterService.this.getHAPartition().getClusterNode();
- boolean ok = this.coord.localHandler.isProxyHealthOK();
+ DefaultRpcResponse<Boolean> response = new
DefaultRpcResponse<Boolean>(this.node);
- return new BooleanGroupRpcResponse(node, ok);
+ response.setResult(Boolean.valueOf(this.coord.localHandler.isProxyHealthOK()));
+
+ return response;
}
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#markProxiesInError()
*/
- public GroupRpcResponse markProxiesInError()
+ public RpcResponse<Void> markProxiesInError()
{
if (!this.coord.isMasterNode()) return null;
this.coord.localHandler.markProxiesInError();
- return this.SUCCESS;
+ return this.voidResponse;
}
/**
* @see org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#reset()
*/
- public GroupRpcResponse reset()
+ public RpcResponse<Void> reset()
{
if (!this.coord.isMasterNode()) return null;
this.coord.localHandler.reset();
- return this.SUCCESS;
+ return this.voidResponse;
}
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequest(org.jboss.modcluster.mcmp.MCMPRequest)
*/
- public GroupRpcResponse sendRequest(MCMPRequest request)
+ public RpcResponse<Map<MCMPServerState, String>>
sendRequest(MCMPRequest request)
{
if (!this.coord.isMasterNode()) return null;
- this.coord.localHandler.sendRequest(request);
+ DefaultRpcResponse<Map<MCMPServerState, String>> response = new
DefaultRpcResponse<Map<MCMPServerState, String>>(this.node);
- return this.SUCCESS;
+ response.setResult(this.coord.localHandler.sendRequest(request));
+
+ return response;
}
/**
* @see
org.jboss.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequests(java.util.List)
*/
- public GroupRpcResponse sendRequests(List<MCMPRequest> requests)
+ public RpcResponse<Map<MCMPServerState, List<String>>>
sendRequests(List<MCMPRequest> requests)
{
if (!this.coord.isMasterNode()) return null;
- this.coord.localHandler.sendRequests(requests);
+ DefaultRpcResponse<Map<MCMPServerState, List<String>>>
response = new DefaultRpcResponse<Map<MCMPServerState,
List<String>>>(this.node);
- return this.SUCCESS;
+ response.setResult(this.coord.localHandler.sendRequests(requests));
+
+ return response;
}
/**
* @see
org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
*/
- public GroupRpcResponse getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response)
+ public RpcResponse<List<MCMPRequest>> getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> infoResponse)
{
- ClusterNode node = HAModClusterService.this.getHAPartition().getClusterNode();
- List<MCMPRequest> requests =
this.coord.resetRequestSource.getLocalResetRequests(response);
-
- return new ResetRequestGroupRpcResponse(node, requests);
+ DefaultRpcResponse<List<MCMPRequest>> response = new
DefaultRpcResponse<List<MCMPRequest>>(this.node);
+
response.setResult(this.coord.resetRequestSource.getLocalResetRequests(infoResponse));
+ return response;
}
}
@@ -818,7 +843,7 @@
nonresponsive.remove(partition.getClusterNode());
// FIXME -- what about our own dropped discovery events if we just became
master?
- List<?> responses = this.coord.getClusterCoordinatorState(masterList);
+ List<RpcResponse<ModClusterServiceStatus>> responses =
this.coord.getClusterCoordinatorState(masterList);
// Gather up all the reset requests in one list
// FIXME -- what about our own dropped requests if we just became master?
@@ -836,17 +861,18 @@
// Gather the info on who knows about what proxies
statuses.clear();
- for (Object response: responses)
+ for (RpcResponse<ModClusterServiceStatus> response: responses)
{
- if (response instanceof ModClusterServiceStateGroupRpcResponse)
+ ClusterNode node = response.getSender();
+
+ try
{
- ModClusterServiceStateGroupRpcResponse mcssgrr =
(ModClusterServiceStateGroupRpcResponse) response;
- ClusterNode node = mcssgrr.getSender();
+ ModClusterServiceStatus state = response.getResult();
// Check for discovery events we haven't processed
MCMPServerDiscoveryEvent latestEvent = latestEvents.get(node);
- for (MCMPServerDiscoveryEvent event:
mcssgrr.getUnacknowledgedEvents())
+ for (MCMPServerDiscoveryEvent event: state.getUnacknowledgedEvents())
{
if ((latestEvent == null) || (latestEvent.compareTo(event) < 0))
{
@@ -865,9 +891,9 @@
if (!resync) // don't bother if we are going to start over
{
- statuses.put(node, new PeerMCMPDiscoveryStatus(node,
mcssgrr.getStates(), latestEvent));
+ statuses.put(node, new PeerMCMPDiscoveryStatus(node,
state.getStates(), latestEvent));
- List<MCMPRequest> toAdd = mcssgrr.getResetRequests();
+ List<MCMPRequest> toAdd = state.getResetRequests();
if (toAdd != null)
{
resetRequests.addAll(toAdd);
@@ -876,7 +902,7 @@
ModClusterServiceDRMEntry removed = nonresponsive.remove(node);
if (removed != null)
{
- Integer lbf = Integer.valueOf(mcssgrr.getLoadBalanceFactor());
+ Integer lbf = Integer.valueOf(state.getLoadBalanceFactor());
for (String jvmRoute: removed.getJvmRoutes())
{
loadBalanceFactors.put(jvmRoute, lbf);
@@ -884,24 +910,13 @@
}
}
}
- else if (response instanceof ThrowableGroupRpcResponse)
+ catch (Exception e)
{
- ThrowableGroupRpcResponse tgrr = (ThrowableGroupRpcResponse) response;
- ClusterNode cn = tgrr.getSender();
+
this.coord.log.warn(this.coord.sm.getString("modcluster.error.rpc.known",
"getClusterCoordinatorState", node), e);
-
this.coord.log.warn(this.coord.sm.getString("modcluster.error.rpc.known",
"getClusterCoordinatorState", cn), tgrr.getValue());
-
// Don't remove from nonresponsive list and we'll pass back an
error
// status (null server list) to this peer
}
- else if (response instanceof Throwable)
- {
-
this.coord.log.warn(this.coord.sm.getString("modcluster.error.rpc.unknown",
"getClusterCoordinatorState"), (Throwable) response);
- }
- else
- {
-
this.coord.log.error(this.coord.sm.getString("modcluster.error.rpc.unexpected",
response, "getClusterCoordinatorState"));
- }
}
}
// We picked up previously unknown discovery events; start over
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -37,9 +37,8 @@
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
-import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
-import org.jboss.modcluster.ha.rpc.ThrowableGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponse;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -65,7 +64,7 @@
private final StringManager sm = StringManager.getManager(Constants.Package);
private final HASingletonMBean singleton;
- private final ResetRequestSourceRpcHandler<List<?>> rpcStub;
+ private final
ResetRequestSourceRpcHandler<List<RpcResponse<List<MCMPRequest>>>>
rpcStub;
public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig,
BalancerConfiguration balancerConfig, ServerProvider<Server> serverProvider,
MCMPRequestFactory requestFactory, HASingletonMBean singleton, HAServiceKeyProvider
serviceKeyProvider)
{
@@ -99,32 +98,23 @@
private void addRemoteRequests(List<MCMPRequest> resets, Map<String,
Set<VirtualHost>> resp)
{
- List<?> responses = this.rpcStub.getResetRequests(resp);
+ List<RpcResponse<List<MCMPRequest>>> responses =
this.rpcStub.getResetRequests(resp);
- for (Object response : responses)
+ for (RpcResponse<List<MCMPRequest>> response : responses)
{
- if (response instanceof ResetRequestGroupRpcResponse)
+ try
{
- resets.addAll(((ResetRequestGroupRpcResponse) response).getValue());
+ resets.addAll(response.getResult());
}
- else if (response instanceof ThrowableGroupRpcResponse)
+ catch (RuntimeException e)
{
- ThrowableGroupRpcResponse tgrr = (ThrowableGroupRpcResponse) response;
//FIXME what to do?
- log.warn(this.sm.getString("modcluster.error.rpc.known",
METHOD_NAME, tgrr.getSender()), tgrr.getValue());
+ log.warn(this.sm.getString("modcluster.error.rpc.known",
METHOD_NAME, response.getSender()), e);
}
- else if (response instanceof Throwable)
- {
- log.warn(this.sm.getString("modcluster.error.rpc.unknown",
METHOD_NAME), (Throwable) response);
- }
- else
- {
- log.error(this.sm.getString("modcluster.error.rpc.unexpected",
response, METHOD_NAME));
- }
}
}
- private static class RpcStub implements
ResetRequestSourceRpcHandler<List<?>>
+ private static class RpcStub implements
ResetRequestSourceRpcHandler<List<RpcResponse<List<MCMPRequest>>>>
{
private final HAServiceKeyProvider serviceKeyProvider;
@@ -136,7 +126,8 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
*/
- public List<?> getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response)
+ @SuppressWarnings("unchecked")
+ public List<RpcResponse<List<MCMPRequest>>>
getResetRequests(Map<String, Set<ResetRequestSource.VirtualHost>> response)
{
try
{
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/BooleanGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/BooleanGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/BooleanGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A {@link GroupRpcResponse} that wraps a boolean return value.
- *
- * @author Brian Stansberry
- *
- */
-public class BooleanGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final boolean value;
-
- public BooleanGroupRpcResponse(ClusterNode sender, boolean value)
- {
- super(sender);
- this.value = value;
- }
-
- public boolean getValue()
- {
- return this.value;
- }
-}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ClusteredMCMPHandlerRpcHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ClusteredMCMPHandlerRpcHandler.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ClusteredMCMPHandlerRpcHandler.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -22,8 +22,10 @@
package org.jboss.modcluster.ha.rpc;
import java.util.List;
+import java.util.Map;
import org.jboss.modcluster.mcmp.MCMPRequest;
+import org.jboss.modcluster.mcmp.MCMPServerState;
/**
* @author Paul Ferraro
@@ -31,19 +33,19 @@
*/
public interface ClusteredMCMPHandlerRpcHandler
{
- GroupRpcResponse sendRequest(MCMPRequest request);
+ RpcResponse<Map<MCMPServerState, String>> sendRequest(MCMPRequest
request);
- GroupRpcResponse sendRequests(List<MCMPRequest> requests);
+ RpcResponse<Map<MCMPServerState, List<String>>>
sendRequests(List<MCMPRequest> requests);
- GroupRpcResponse mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event);
+ RpcResponse<Void> mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event);
- GroupRpcResponse getProxyConfiguration();
+ RpcResponse<String> getProxyConfiguration();
- GroupRpcResponse getProxyInfo();
+ RpcResponse<String> getProxyInfo();
- GroupRpcResponse isProxyHealthOK();
+ RpcResponse<Boolean> isProxyHealthOK();
- GroupRpcResponse markProxiesInError();
+ RpcResponse<Void> markProxiesInError();
- GroupRpcResponse reset();
+ RpcResponse<Void> reset();
}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import java.io.Serializable;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A response to a group RPC call made by {@link
org.jboss.modcluster.ha.HAModClusterService}.
- *
- * @author Brian Stansberry
- */
-public class GroupRpcResponse implements Serializable
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 7427355308214918459L;
-
- private final ClusterNode sender;
-
- public GroupRpcResponse(ClusterNode sender)
- {
- this.sender = sender;
- }
-
- public ClusterNode getSender()
- {
- return this.sender;
- }
-}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponseFilter.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponseFilter.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponseFilter.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.ha.framework.interfaces.ResponseFilter;
-
-/**
- * A {@link ResponseFilter} that accepts any GroupRpcResponse and doesn't
- * need any further responses after receiving the first.
- *
- * @author Brian Stansberry
- *
- */
-public class GroupRpcResponseFilter implements ResponseFilter
-{
- private boolean stillNeed = true;
-
- public boolean isAcceptable(Object response, ClusterNode responder)
- {
- boolean acceptable = (response instanceof GroupRpcResponse);
- if (acceptable)
- this.stillNeed = false;
-
- return acceptable;
- }
-
- public boolean needMoreResponses()
- {
- return this.stillNeed;
- }
-
-}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/InetAddressGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/InetAddressGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/InetAddressGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import java.net.InetAddress;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A {@link GroupRpcResponse} that wraps an InetAddress return value.
- *
- * @author Brian Stansberry
- *
- */
-public class InetAddressGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final InetAddress value;
-
- public InetAddressGroupRpcResponse(ClusterNode sender, InetAddress value)
- {
- super(sender);
- this.value = value;
- }
-
- public InetAddress getValue()
- {
- return this.value;
- }
-
-}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/IntegerGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/IntegerGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/IntegerGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A {@link GroupRpcResponse} that wraps an int return value.
- *
- * @author Brian Stansberry
- *
- */
-public class IntegerGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final int value;
-
- public IntegerGroupRpcResponse(ClusterNode sender, int value)
- {
- super(sender);
- this.value = value;
- }
-
- public int getValue()
- {
- return this.value;
- }
-
-}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStateGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStateGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStateGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.modcluster.mcmp.MCMPRequest;
-import org.jboss.modcluster.mcmp.MCMPServerState;
-
-/**
- * GroupRpcResponse that provides the overall status picture for a
- * ModClusterService instance.
- *
- * @author Brian Stansberry
- */
-public class ModClusterServiceStateGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -6591593007825931165L;
-
- private final Set<MCMPServerState> states;
- private final List<MCMPServerDiscoveryEvent> unacknowledgedEvents;
- private final List<MCMPRequest> resetRequests;
- private final int loadBalanceFactor;
-
- public ModClusterServiceStateGroupRpcResponse(ClusterNode sender,
- int loadBalanceFactor,
- Set<MCMPServerState> states,
- List<MCMPServerDiscoveryEvent> unacknowledgedEvents,
- List<MCMPRequest> resetRequests)
- {
- super(sender);
- this.loadBalanceFactor = loadBalanceFactor;
- this.states = states;
- this.unacknowledgedEvents = unacknowledgedEvents;
- this.resetRequests = resetRequests;
- }
-
- public Set<MCMPServerState> getStates()
- {
- return this.states;
- }
-
- public List<MCMPServerDiscoveryEvent> getUnacknowledgedEvents()
- {
- return this.unacknowledgedEvents;
- }
-
- public List<MCMPRequest> getResetRequests()
- {
- return this.resetRequests;
- }
-
- public int getLoadBalanceFactor()
- {
- return this.loadBalanceFactor;
- }
-
-}
Copied:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStatus.java
(from rev 2349,
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStateGroupRpcResponse.java)
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStatus.java
(rev 0)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ModClusterServiceStatus.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.modcluster.ha.rpc;
+
+import java.util.List;
+import java.util.Set;
+
+import net.jcip.annotations.Immutable;
+
+import org.jboss.modcluster.mcmp.MCMPRequest;
+import org.jboss.modcluster.mcmp.MCMPServerState;
+
+/**
+ * GroupRpcResponse that provides the overall status picture for a
+ * ModClusterService instance.
+ *
+ * @author Brian Stansberry
+ */
+@Immutable
+public class ModClusterServiceStatus
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6591593007825931165L;
+
+ private final Set<MCMPServerState> states;
+ private final List<MCMPServerDiscoveryEvent> unacknowledgedEvents;
+ private final List<MCMPRequest> resetRequests;
+ private final int loadBalanceFactor;
+
+ public ModClusterServiceStatus(int loadBalanceFactor, Set<MCMPServerState>
states, List<MCMPServerDiscoveryEvent> unacknowledgedEvents, List<MCMPRequest>
resetRequests)
+ {
+ this.loadBalanceFactor = loadBalanceFactor;
+ this.states = states;
+ this.unacknowledgedEvents = unacknowledgedEvents;
+ this.resetRequests = resetRequests;
+ }
+
+ public Set<MCMPServerState> getStates()
+ {
+ return this.states;
+ }
+
+ public List<MCMPServerDiscoveryEvent> getUnacknowledgedEvents()
+ {
+ return this.unacknowledgedEvents;
+ }
+
+ public List<MCMPRequest> getResetRequests()
+ {
+ return this.resetRequests;
+ }
+
+ public int getLoadBalanceFactor()
+ {
+ return this.loadBalanceFactor;
+ }
+
+}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import java.util.List;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.modcluster.mcmp.MCMPRequest;
-
-/**
- * A {@link GroupRpcResponse} that wraps a List<MCMPRequest> return value.
- *
- * @author Brian Stansberry
- *
- */
-public class ResetRequestGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final List<MCMPRequest> value;
-
- public ResetRequestGroupRpcResponse(ClusterNode sender, List<MCMPRequest>
value)
- {
- super(sender);
- this.value = value;
- }
-
- public List<MCMPRequest> getValue()
- {
- return this.value;
- }
-
-}
Copied: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/RpcResponseFilter.java
(from rev 2349,
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/GroupRpcResponseFilter.java)
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/RpcResponseFilter.java
(rev 0)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/RpcResponseFilter.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.modcluster.ha.rpc;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+
+/**
+ * A {@link ResponseFilter} that accepts any GroupRpcResponse and doesn't
+ * need any further responses after receiving the first.
+ *
+ * @author Brian Stansberry
+ *
+ */
+public class RpcResponseFilter implements ResponseFilter
+{
+ private boolean stillNeed = true;
+
+ public boolean isAcceptable(Object response, ClusterNode responder)
+ {
+ boolean acceptable = (response instanceof RpcResponse);
+ if (acceptable)
+ {
+ this.stillNeed = false;
+ }
+ return acceptable;
+ }
+
+ public boolean needMoreResponses()
+ {
+ return this.stillNeed;
+ }
+}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/StringGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/StringGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/StringGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A {@link GroupRpcResponse} that wraps a String return value.
- *
- * @author Brian Stansberry
- *
- */
-public class StringGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final String value;
-
- public StringGroupRpcResponse(ClusterNode sender, String value)
- {
- super(sender);
- this.value = value;
- }
-
- public String getValue()
- {
- return this.value;
- }
-
-}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ThrowableGroupRpcResponse.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ThrowableGroupRpcResponse.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ThrowableGroupRpcResponse.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.modcluster.ha.rpc;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-
-/**
- * A {@link GroupRpcResponse} that wraps a String return value.
- *
- * @author Brian Stansberry
- *
- */
-public class ThrowableGroupRpcResponse extends GroupRpcResponse
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8932443264578153750L;
-
- private final Throwable value;
-
- public ThrowableGroupRpcResponse(ClusterNode sender, Throwable value)
- {
- super(sender);
- this.value = value;
- }
-
- public Throwable getValue()
- {
- return this.value;
- }
-
- public RuntimeException getValueAsRuntimeException()
- {
- if (this.value instanceof RuntimeException)
- {
- return (RuntimeException) this.value;
- }
-
- return new RuntimeException("Group RPC returned exception", this.value);
- }
-}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPHandler.java 2009-04-07
16:43:49 UTC (rev 2389)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPHandler.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -26,6 +26,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -47,7 +48,7 @@
*
* @param request the request. Cannot be <code>null</code>
**/
- void sendRequest(MCMPRequest request);
+ Map<MCMPServerState, String> sendRequest(MCMPRequest request);
/**
* Send a list of requests to all healthy proxies, with all requests
@@ -55,7 +56,7 @@
*
* @param requests the requests. Cannot be <code>null</code>
*/
- void sendRequests(List<MCMPRequest> requests);
+ Map<MCMPServerState, List<String>> sendRequests(List<MCMPRequest>
requests);
/**
* Add a proxy to the list of those with which this handler communicates.
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -678,8 +678,10 @@
* @param parameters
* @return the response body as a String; null if in error state or a normal error
occurs
*/
- public void sendRequest(MCMPRequest request)
+ public Map<MCMPServerState, String> sendRequest(MCMPRequest request)
{
+ Map<MCMPServerState, String> map = new HashMap<MCMPServerState,
String>();
+
Lock lock = this.proxiesLock.readLock();
lock.lock();
@@ -687,17 +689,21 @@
{
for (Proxy proxy: this.proxies)
{
- this.sendRequest(request, proxy);
+ map.put(proxy, this.sendRequest(request, proxy));
}
}
finally
{
lock.unlock();
}
+
+ return map;
}
- public void sendRequests(List<MCMPRequest> requests)
+ public Map<MCMPServerState, List<String>>
sendRequests(List<MCMPRequest> requests)
{
+ Map<MCMPServerState, List<String>> map = new
HashMap<MCMPServerState, List<String>>();
+
Lock lock = this.proxiesLock.readLock();
lock.lock();
@@ -705,16 +711,22 @@
{
for (Proxy proxy: this.proxies)
{
+ List<String> list = new ArrayList<String>(requests.size());
+
for (MCMPRequest request: requests)
{
- this.sendRequest(request, proxy);
+ list.add(this.sendRequest(request, proxy));
}
+
+ map.put(proxy, list);
}
}
finally
{
lock.unlock();
}
+
+ return map;
}
// ---------------------------------------------------------------- Private
@@ -821,40 +833,40 @@
throw new IllegalArgumentException(e);
}
+ // Then, connect to the proxy
+ // Generate and write request
+ StringBuilder builder = new StringBuilder();
+
+ builder.append(command).append(" ");
+
+ String proxyURL = this.config.getProxyURL();
+
+ if (proxyURL != null)
+ {
+ builder.append(proxyURL);
+ }
+
+ if (builder.charAt(builder.length() - 1) != '/')
+ {
+ builder.append('/');
+ }
+
+ if (wildcard)
+ {
+ builder.append('*');
+ }
+
+ builder.append(" HTTP/1.0");
+
+ String head = builder.toString();
+ int length = encoder.getLength();
+ char[] body = encoder.getBuffer();
+
// Require exclusive access to proxy socket
synchronized (proxy)
{
try
{
- // Then, connect to the proxy
- // Generate and write request
- StringBuilder builder = new StringBuilder();
-
- builder.append(command).append(" ");
-
- String proxyURL = this.config.getProxyURL();
-
- if (proxyURL != null)
- {
- builder.append(proxyURL);
- }
-
- if (builder.charAt(builder.length() - 1) != '/')
- {
- builder.append('/');
- }
-
- if (wildcard)
- {
- builder.append('*');
- }
-
- builder.append(" HTTP/1.0");
-
- String head = builder.toString();
- int length = encoder.getLength();
- char[] body = encoder.getBuffer();
-
String line = null;
try
{
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -315,6 +315,7 @@
Context context = EasyMock.createStrictMock(Context.class);
Host host = EasyMock.createStrictMock(Host.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -332,7 +333,7 @@
EasyMock.expect(this.requestFactory.createEnableRequest(context)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, context, host);
@@ -389,6 +390,7 @@
Context context = EasyMock.createStrictMock(Context.class);
Host host = EasyMock.createStrictMock(Host.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -404,7 +406,7 @@
EasyMock.expect(this.requestFactory.createEnableRequest(context)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, context, host);
@@ -461,6 +463,7 @@
Context context = EasyMock.createStrictMock(Context.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
Host host = EasyMock.createStrictMock(Host.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -476,7 +479,7 @@
EasyMock.expect(this.requestFactory.createStopRequest(context)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, context, host);
@@ -559,6 +562,7 @@
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -579,7 +583,7 @@
EasyMock.expect(this.requestFactory.createRemoveRequest(context)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, context, engine, host);
@@ -616,6 +620,7 @@
{
Engine engine = EasyMock.createStrictMock(Engine.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -629,7 +634,7 @@
EasyMock.expect(this.requestFactory.createStatusRequest("host1",
10)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, this.lbfProvider, engine);
@@ -670,6 +675,7 @@
Host host = EasyMock.createStrictMock(Host.class);
Context context = EasyMock.createStrictMock(Context.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
Connector connector = new Connector("AJP/1.3");
init();
@@ -689,7 +695,7 @@
EasyMock.expect(this.requestFactory.createConfigRequest(engine, this.nodeConfig,
this.balancerConfig)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.expect(engine.findChildren()).andReturn(new Container[] { host });
EasyMock.expect(host.findChildren()).andReturn(new Container[] { context });
@@ -741,6 +747,7 @@
Context context = EasyMock.createStrictMock(Context.class);
MCMPRequest contextRequest = EasyMock.createStrictMock(MCMPRequest.class);
MCMPRequest engineRequest = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
init();
@@ -767,7 +774,7 @@
EasyMock.expect(this.requestFactory.createRemoveRequest(context)).andReturn(contextRequest);
- this.mcmpHandler.sendRequest(contextRequest);
+ EasyMock.expect(this.mcmpHandler.sendRequest(contextRequest)).andReturn(emptyMap);
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
@@ -776,7 +783,7 @@
EasyMock.expect(this.requestFactory.createRemoveRequest(engine)).andReturn(engineRequest);
- this.mcmpHandler.sendRequest(engineRequest);
+ EasyMock.expect(this.mcmpHandler.sendRequest(engineRequest)).andReturn(emptyMap);
EasyMock.replay(this.mcmpHandler, this.requestFactory, server, service, engine,
host, context);
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterListenerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterListenerTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterListenerTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -22,6 +22,8 @@
package org.jboss.modcluster;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
import org.apache.catalina.Engine;
import org.apache.catalina.Lifecycle;
@@ -37,6 +39,7 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
+import org.jboss.modcluster.mcmp.MCMPServerState;
import org.junit.Assert;
import org.junit.Test;
@@ -186,6 +189,7 @@
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
EasyMock.expect(this.serverProvider.getServer()).andReturn(server);
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
@@ -193,7 +197,7 @@
EasyMock.expect(this.requestFactory.createEnableRequest(engine)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.expect(this.mcmpHandler.isProxyHealthOK()).andReturn(true);
@@ -214,6 +218,7 @@
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
EasyMock.expect(this.serverProvider.getServer()).andReturn(server);
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
@@ -221,7 +226,7 @@
EasyMock.expect(this.requestFactory.createDisableRequest(engine)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.expect(this.mcmpHandler.isProxyHealthOK()).andReturn(true);
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -172,7 +172,7 @@
EasyMock.expect(this.requestFactory.createEnableRequest(engine)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(null);
EasyMock.expect(this.mcmpHandler.isProxyHealthOK()).andReturn(true);
@@ -200,7 +200,7 @@
EasyMock.expect(this.requestFactory.createDisableRequest(engine)).andReturn(request);
- this.mcmpHandler.sendRequest(request);
+ EasyMock.expect(this.mcmpHandler.sendRequest(request)).andReturn(null);
EasyMock.expect(this.mcmpHandler.isProxyHealthOK()).andReturn(true);
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -26,8 +26,10 @@
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.easymock.Capture;
@@ -36,11 +38,9 @@
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
import org.jboss.ha.framework.interfaces.HASingletonMBean;
-import org.jboss.modcluster.ha.rpc.BooleanGroupRpcResponse;
-import org.jboss.modcluster.ha.rpc.GroupRpcResponse;
-import org.jboss.modcluster.ha.rpc.GroupRpcResponseFilter;
+import org.jboss.modcluster.ha.rpc.RpcResponseFilter;
import org.jboss.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
-import org.jboss.modcluster.ha.rpc.StringGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponse;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPServer;
@@ -87,6 +87,9 @@
// Test non-master case
Capture<List<InetSocketAddress>> capturedList = new
Capture<List<InetSocketAddress>>();
Capture<Object[]> capturedEvents = new Capture<Object[]>();
+ RpcResponse<Void> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Void> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Void>> responses = new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
@@ -98,13 +101,14 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.localHandler, this.singleton, this.keyProvider,
this.partition);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+ EasyMock.replay(this.localHandler, this.singleton, this.keyProvider,
this.partition, response1, response2);
+
this.handler.init(list);
- EasyMock.verify(this.localHandler, this.singleton, this.keyProvider,
this.partition);
Assert.assertNotNull(capturedList.getValue());
Assert.assertTrue(capturedList.getValue().isEmpty());
@@ -126,7 +130,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.localHandler, this.singleton, this.keyProvider,
this.partition);
+ EasyMock.reset(this.localHandler, this.singleton, this.keyProvider, this.partition,
response1, response2);
}
@Test
@@ -230,6 +234,9 @@
String key = "key";
Capture<Object[]> capturedEvents = new Capture<Object[]>();
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<Void> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Void> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Void>> responses = new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2));
// Test MCMPHandler.addProxy(String)
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
@@ -240,13 +247,15 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
this.handler.addProxy(address.getHostName() + ":" + port);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
List<MCMPServerDiscoveryEvent> events =
this.handler.getPendingDiscoveryEvents();
@@ -265,7 +274,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
// Test MCMPHandler.addProxy(String, int)
@@ -277,13 +286,15 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2)));
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
this.handler.addProxy(address.getHostName(), port);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
events = this.handler.getPendingDiscoveryEvents();
@@ -302,7 +313,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
// Test MCMPHandler.addProxy(InetAddress, int)
@@ -314,13 +325,15 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2)));
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
this.handler.addProxy(address, port);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
events = this.handler.getPendingDiscoveryEvents();
@@ -339,7 +352,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
// Test MCMPHandler.addProxy(InetAddress, int, boolean)
@@ -390,6 +403,9 @@
String key = "key";
Capture<Object[]> capturedEvents = new Capture<Object[]>();
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<Void> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Void> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Void>> responses = new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2));
// Test MCMPHandler.removeProxy(String, int)
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
@@ -400,13 +416,15 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
this.handler.removeProxy(address.getHostName(), port);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
List<MCMPServerDiscoveryEvent> events =
this.handler.getPendingDiscoveryEvents();
@@ -425,7 +443,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
// Test MCMPHandler.removeProxy(InetAddress, int)
@@ -437,13 +455,15 @@
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq(key),
EasyMock.eq("mcmpServerDiscoveryEvent"), EasyMock.capture(capturedEvents),
EasyMock.aryEq(new Class[] { MCMPServerDiscoveryEvent.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
this.handler.removeProxy(address, port);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
events = this.handler.getPendingDiscoveryEvents();
@@ -462,7 +482,7 @@
Assert.assertEquals(1, capturedEvents.getValue().length);
Assert.assertSame(event, capturedEvents.getValue()[0]);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
@@ -525,23 +545,28 @@
// Test non-master use case
String key = "key";
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<String> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<String> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<String>> responses = new
ArrayList<RpcResponse<String>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("getProxyConfiguration"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new StringGroupRpcResponse(node,
configuration))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("getProxyConfiguration"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(configuration);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
result = this.handler.getProxyConfiguration();
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
Assert.assertSame(configuration, result);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
@@ -566,23 +591,28 @@
// Test non-master use case
String key = "key";
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<Boolean> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Boolean> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Boolean>> responses = new
ArrayList<RpcResponse<Boolean>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("isProxyHealthOk"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new BooleanGroupRpcResponse(node,
true))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("isProxyHealthOk"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(true);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
result = this.handler.isProxyHealthOK();
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
Assert.assertTrue(result);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
@@ -604,20 +634,25 @@
// Test non-master use case
String key = "key";
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<Void> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Void> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Void>> responses = new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("markProxiesInError"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new BooleanGroupRpcResponse(node,
true))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("markProxiesInError"), EasyMock.aryEq(new Object[0]),
EasyMock.aryEq(new Class[0]), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
this.handler.markProxiesInError();
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
@@ -639,37 +674,46 @@
// Test non-master use case
String key = "key";
ClusterNode node = EasyMock.createMock(ClusterNode.class);
+ RpcResponse<Void> response1 = EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Void> response2 = EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Void>> responses = new
ArrayList<RpcResponse<Void>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("reset"), EasyMock.aryEq(new Object[0]), EasyMock.aryEq(new
Class[0]), EasyMock.eq(false), EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new BooleanGroupRpcResponse(node,
true))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("reset"), EasyMock.aryEq(new Object[0]), EasyMock.aryEq(new
Class[0]), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(null);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
this.handler.reset();
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
public void sendRequest() throws Exception
{
MCMPRequest request = EasyMock.createMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
// Test master use case
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
- this.localHandler.sendRequest(EasyMock.same(request));
+
EasyMock.expect(this.localHandler.sendRequest(EasyMock.same(request))).andReturn(emptyMap);
EasyMock.replay(this.localHandler, this.singleton);
- this.handler.sendRequest(request);
+ Map<MCMPServerState, String> result = this.handler.sendRequest(request);
EasyMock.verify(this.localHandler, this.singleton);
+
+ Assert.assertSame(emptyMap, result);
+
EasyMock.reset(this.localHandler, this.singleton);
@@ -678,42 +722,52 @@
ClusterNode node = EasyMock.createMock(ClusterNode.class);
Capture<Object[]> captured = new Capture<Object[]>();
+ RpcResponse<Map<MCMPServerState, String>> response1 =
EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Map<MCMPServerState, String>> response2 =
EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Map<MCMPServerState, String>>> responses =
new ArrayList<RpcResponse<Map<MCMPServerState,
String>>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("sendRequest"), EasyMock.capture(captured), EasyMock.aryEq(new
Class[] { MCMPRequest.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("sendRequest"), EasyMock.capture(captured), EasyMock.aryEq(new
Class[] { MCMPRequest.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(emptyMap);
- this.handler.sendRequest(request);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ result = this.handler.sendRequest(request);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
Assert.assertNotNull(captured.getValue());
Assert.assertEquals(1, captured.getValue().length);
Assert.assertSame(request, captured.getValue()[0]);
+ Assert.assertSame(emptyMap, result);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
public void sendRequests() throws Exception
{
List<MCMPRequest> requests = Collections.emptyList();
+ Map<MCMPServerState, List<String>> emptyMap = Collections.emptyMap();
// Test master use case
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
- this.localHandler.sendRequests(EasyMock.same(requests));
+
EasyMock.expect(this.localHandler.sendRequests(EasyMock.same(requests))).andReturn(emptyMap);
EasyMock.replay(this.localHandler, this.singleton);
- this.handler.sendRequests(requests);
+ Map<MCMPServerState, List<String>> result =
this.handler.sendRequests(requests);
EasyMock.verify(this.localHandler, this.singleton);
+
+ Assert.assertSame(emptyMap, result);
+
EasyMock.reset(this.localHandler, this.singleton);
@@ -722,25 +776,31 @@
ClusterNode node = EasyMock.createMock(ClusterNode.class);
Capture<Object[]> captured = new Capture<Object[]>();
+ RpcResponse<Map<MCMPServerState, List<String>>> response1 =
EasyMock.createMock(RpcResponse.class);
+ RpcResponse<Map<MCMPServerState, List<String>>> response2 =
EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<Map<MCMPServerState, List<String>>>>
responses = new ArrayList<RpcResponse<Map<MCMPServerState,
List<String>>>>(Arrays.asList(response1, response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
EasyMock.expect(this.keyProvider.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.keyProvider.getHAServiceKey()).andReturn(key);
- EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("sendRequests"), EasyMock.capture(captured), EasyMock.aryEq(new
Class[] { List.class }), EasyMock.eq(false),
EasyMock.isA(GroupRpcResponseFilter.class))).andReturn(new
ArrayList<GroupRpcResponse>(Collections.singleton(new GroupRpcResponse(node))));
+ EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.same(key),
EasyMock.eq("sendRequests"), EasyMock.capture(captured), EasyMock.aryEq(new
Class[] { List.class }), EasyMock.eq(false),
EasyMock.isA(RpcResponseFilter.class))).andReturn(responses);
- EasyMock.replay(this.keyProvider, this.partition, this.singleton);
+ EasyMock.expect(response1.getResult()).andReturn(emptyMap);
- this.handler.sendRequests(requests);
+ EasyMock.replay(this.keyProvider, this.partition, this.singleton, response1,
response2);
- EasyMock.verify(this.keyProvider, this.partition, this.singleton);
+ result = this.handler.sendRequests(requests);
+ EasyMock.verify(this.keyProvider, this.partition, this.singleton, response1,
response2);
+
Assert.assertNotNull(captured.getValue());
Assert.assertEquals(1, captured.getValue().length);
Assert.assertSame(requests, captured.getValue()[0]);
+ Assert.assertSame(emptyMap, result);
- EasyMock.reset(this.keyProvider, this.partition, this.singleton);
+ EasyMock.reset(this.keyProvider, this.partition, this.singleton, response1,
response2);
}
@Test
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HAModClusterServiceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HAModClusterServiceTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HAModClusterServiceTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -21,6 +21,9 @@
*/
package org.jboss.modcluster.ha;
+import java.util.Collections;
+import java.util.Map;
+
import org.apache.catalina.Engine;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
@@ -40,6 +43,7 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
+import org.jboss.modcluster.mcmp.MCMPServerState;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -203,6 +207,7 @@
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
MCMPRequest request = EasyMock.createMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
EasyMock.expect(this.serverProvider.getServer()).andReturn(server);
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
@@ -210,7 +215,7 @@
EasyMock.expect(this.requestFactory.createEnableRequest(engine)).andReturn(request);
- this.clusteredMCMPHandler.sendRequest(request);
+
EasyMock.expect(this.clusteredMCMPHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.expect(this.clusteredMCMPHandler.isProxyHealthOK()).andReturn(true);
@@ -230,6 +235,7 @@
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
MCMPRequest request = EasyMock.createMock(MCMPRequest.class);
+ Map<MCMPServerState, String> emptyMap = Collections.emptyMap();
EasyMock.expect(this.serverProvider.getServer()).andReturn(server);
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
@@ -237,7 +243,7 @@
EasyMock.expect(this.requestFactory.createDisableRequest(engine)).andReturn(request);
- this.clusteredMCMPHandler.sendRequest(request);
+
EasyMock.expect(this.clusteredMCMPHandler.sendRequest(request)).andReturn(emptyMap);
EasyMock.expect(this.clusteredMCMPHandler.isProxyHealthOK()).andReturn(true);
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2009-04-07
16:43:49 UTC (rev 2389)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2009-04-07
17:19:12 UTC (rev 2390)
@@ -35,14 +35,13 @@
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.easymock.EasyMock;
-import org.jboss.ha.framework.interfaces.ClusterNode;
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
import org.jboss.ha.framework.interfaces.HASingletonMBean;
import org.jboss.modcluster.ServerProvider;
import org.jboss.modcluster.config.BalancerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
-import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
+import org.jboss.modcluster.ha.rpc.RpcResponse;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -94,26 +93,30 @@
MCMPRequest request1 = EasyMock.createMock(MCMPRequest.class);
MCMPRequest request2 = EasyMock.createMock(MCMPRequest.class);
- ResetRequestGroupRpcResponse response1 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request1));
- ResetRequestGroupRpcResponse response2 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request2));
+ RpcResponse<List<MCMPRequest>> response1 =
EasyMock.createMock(RpcResponse.class);
+ RpcResponse<List<MCMPRequest>> response2 =
EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<List<MCMPRequest>>> responses = new
ArrayList<RpcResponse<List<MCMPRequest>>>(Arrays.asList(response1,
response2));
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
EasyMock.expect(this.key.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.key.getHAServiceKey()).andReturn("service:domain");
-
EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"),
EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap
}), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(new
ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
+
EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"),
EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap
}), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(responses);
- EasyMock.replay(this.key, this.singleton, this.partition);
+
EasyMock.expect(response1.getResult()).andReturn(Collections.singletonList(request1));
+
EasyMock.expect(response2.getResult()).andReturn(Collections.singletonList(request2));
+ EasyMock.replay(this.key, this.singleton, this.partition, response1, response2);
+
List<MCMPRequest> results = source.getResetRequests(emptyResponseMap);
- EasyMock.verify(this.key, this.singleton, this.partition);
+ EasyMock.verify(this.key, this.singleton, this.partition, response1, response2);
Assert.assertEquals(2, results.size());
Assert.assertSame(request1, results.get(0));
Assert.assertSame(request2, results.get(1));
- EasyMock.reset(this.key, this.singleton, this.partition);
+ EasyMock.reset(this.key, this.singleton, this.partition, response1, response2);
}
@Test
@@ -125,10 +128,10 @@
Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
MCMPRequest request1 = EasyMock.createMock(MCMPRequest.class);
MCMPRequest request2 = EasyMock.createMock(MCMPRequest.class);
+ RpcResponse<List<MCMPRequest>> response1 =
EasyMock.createMock(RpcResponse.class);
+ RpcResponse<List<MCMPRequest>> response2 =
EasyMock.createMock(RpcResponse.class);
+ ArrayList<RpcResponse<List<MCMPRequest>>> responses = new
ArrayList<RpcResponse<List<MCMPRequest>>>(Arrays.asList(response1,
response2));
- ResetRequestGroupRpcResponse response1 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request1));
- ResetRequestGroupRpcResponse response2 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request2));
-
Server server = EasyMock.createStrictMock(Server.class);
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
@@ -161,20 +164,23 @@
EasyMock.expect(this.key.getHAPartition()).andReturn(this.partition);
EasyMock.expect(this.key.getHAServiceKey()).andReturn("service:domain");
-
EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"),
EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap
}), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(new
ArrayList<ResetRequestGroupRpcResponse>(Arrays.asList(response1, response2)));
+
EasyMock.expect(this.partition.callMethodOnCluster(EasyMock.eq("service:domain"),
EasyMock.eq("getResetRequests"), EasyMock.aryEq(new Object[] { emptyResponseMap
}), EasyMock.aryEq(new Class[] { Map.class }), EasyMock.eq(true))).andReturn(responses);
- EasyMock.replay(this.serverProvider, this.key, this.singleton, this.partition,
this.requestFactory, server, service, engine, host, context);
+
EasyMock.expect(response1.getResult()).andReturn(Collections.singletonList(request1));
+
EasyMock.expect(response2.getResult()).andReturn(Collections.singletonList(request2));
- List<MCMPRequest> requests = source.getResetRequests(emptyResponseMap);
+ EasyMock.replay(this.serverProvider, this.key, this.singleton, this.partition,
this.requestFactory, server, service, engine, host, context, response1, response2);
- EasyMock.verify(this.serverProvider, this.key, this.singleton, this.partition,
this.requestFactory, server, service, engine, host, context);
+ List<MCMPRequest> result = source.getResetRequests(emptyResponseMap);
- Assert.assertEquals(4, requests.size());
+ EasyMock.verify(this.serverProvider, this.key, this.singleton, this.partition,
this.requestFactory, server, service, engine, host, context, response1, response2);
- Assert.assertSame(configRequest, requests.get(0));
- Assert.assertSame(contextRequest, requests.get(1));
- Assert.assertSame(request1, requests.get(2));
- Assert.assertSame(request2, requests.get(3));
+ Assert.assertEquals(4, result.size());
+
+ Assert.assertSame(configRequest, result.get(0));
+ Assert.assertSame(contextRequest, result.get(1));
+ Assert.assertSame(request1, result.get(2));
+ Assert.assertSame(request2, result.get(3));
}
@Test