Author: dkulp
Date: Mon Apr 4 19:24:26 2011
New Revision: 1088745
URL: http://svn.apache.org/viewvc?rev=1088745&view=rev
Log:
Merged revisions 1088303 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1088303 | dkulp | 2011-04-03 09:54:38 -0400 (Sun, 03 Apr 2011) | 2 lines
[CXF-3424] LoadDistributingConduitSelector
Patch from Jim Talbut applied
........
Added:
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/LoadDistributorFeature.java
- copied unchanged from r1088303,
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/LoadDistributorFeature.java
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
- copied unchanged from r1088303,
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/LoadDistributorTargetSelector.java
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/LoadDistributorBeanDefinitionParser.java
- copied unchanged from r1088303,
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/spring/LoadDistributorBeanDefinitionParser.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorAddressOverrideTest.java
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorAddressOverrideTest.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorSequentialStrategy.java
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorSequentialStrategy.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorStaticStrategy.java
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorStaticStrategy.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorTest.java
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/LoadDistributorTest.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/load_distributor.xml
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/load_distributor.xml
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/load_distributor_address_override.xml
- copied unchanged from r1088303,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/load_distributor_address_override.xml
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/NamespaceHandler.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverAddressOverrideTest.java
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverTest.java
Propchange: cxf/branches/2.3.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java?rev=1088745&r1=1088744&r2=1088745&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
Mon Apr 4 19:24:26 2011
@@ -41,13 +41,15 @@ import org.apache.cxf.transport.Conduit;
* Implements a target selection strategy based on failover to an
* alternate target endpoint when a transport level failure is
* encountered.
+ * Note that this feature changes the conduit on the fly and thus makes
+ * the Client not thread safe.
*/
public class FailoverTargetSelector extends AbstractConduitSelector {
private static final Logger LOG =
LogUtils.getL7dLogger(FailoverTargetSelector.class);
- private Map<InvocationKey, InvocationContext> inProgress;
- private FailoverStrategy failoverStrategy;
+ protected Map<InvocationKey, InvocationContext> inProgress;
+ protected FailoverStrategy failoverStrategy;
/**
* Normal constructor.
@@ -101,7 +103,7 @@ public class FailoverTargetSelector exte
}
/**
- * Called on completion of the MEP for which the Condit was required.
+ * Called on completion of the MEP for which the Conduit was required.
*
* @param exchange represents the completed MEP
*/
@@ -191,7 +193,7 @@ public class FailoverTargetSelector exte
* @param exchange the current Exchange
* @return boolean true if a failover should be attempted
*/
- private boolean requiresFailover(Exchange exchange) {
+ protected boolean requiresFailover(Exchange exchange) {
Message outMessage = exchange.getOutMessage();
Exception ex = outMessage.get(Exception.class) != null
? outMessage.get(Exception.class)
@@ -218,7 +220,7 @@ public class FailoverTargetSelector exte
* @param invocation the current InvocationContext
* @return a failover endpoint if one is available
*/
- private Endpoint getFailoverTarget(Exchange exchange,
+ protected Endpoint getFailoverTarget(Exchange exchange,
InvocationContext invocation) {
List<String> alternateAddresses = null;
if (!invocation.hasAlternates()) {
@@ -259,7 +261,7 @@ public class FailoverTargetSelector exte
*
* @param context the request context
*/
- private void overrideAddressProperty(Map<String, Object> context) {
+ protected void overrideAddressProperty(Map<String, Object> context) {
Map<String, Object> requestContext =
CastUtils.cast((Map)context.get(Client.REQUEST_CONTEXT));
if (requestContext != null) {
@@ -273,10 +275,10 @@ public class FailoverTargetSelector exte
/**
* Used to wrap an Exchange for usage as a Map key. The raw Exchange
* is not a suitable key type, as the hashCode is computed from its
- * current contents, which may obvioulsy change over the lifetime of
+ * current contents, which may obviously change over the lifetime of
* an invocation.
*/
- private static class InvocationKey {
+ protected static class InvocationKey {
private Exchange exchange;
InvocationKey(Exchange ex) {
@@ -299,7 +301,7 @@ public class FailoverTargetSelector exte
/**
* Records the context of an invocation.
*/
- private class InvocationContext {
+ protected class InvocationContext {
private Endpoint originalEndpoint;
private String originalAddress;
private BindingOperationInfo bindingOperationInfo;
Modified:
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/NamespaceHandler.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/NamespaceHandler.java?rev=1088745&r1=1088744&r2=1088745&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/NamespaceHandler.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/clustering/spring/NamespaceHandler.java
Mon Apr 4 19:24:26 2011
@@ -24,5 +24,7 @@ public class NamespaceHandler extends Na
public void init() {
registerBeanDefinitionParser("failover",
new FailoverBeanDefinitionParser());
+ registerBeanDefinitionParser("loadDistributor",
+ new
LoadDistributorBeanDefinitionParser());
}
}
Modified:
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverAddressOverrideTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverAddressOverrideTest.java?rev=1088745&r1=1088744&r2=1088745&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverAddressOverrideTest.java
(original)
+++
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverAddressOverrideTest.java
Mon Apr 4 19:24:26 2011
@@ -63,14 +63,14 @@ public class FailoverAddressOverrideTest
protected static final String REPLICA_D =
"http://localhost:9054/SoapContext/ReplicatedPortD";
private static final Logger LOG =
- LogUtils.getLogger(FailoverTest.class);
+ LogUtils.getLogger(FailoverAddressOverrideTest.class);
private static final String FAILOVER_CONFIG =
"org/apache/cxf/systest/clustering/failover_address_override.xml";
- private Bus bus;
+ protected Bus bus;
+ protected Greeter greeter;
+ protected List<String> targets;
private Control control;
- private Greeter greeter;
- private List<String> targets;
private MAPAggregator mapAggregator;
private MAPCodec mapCodec;
@@ -80,12 +80,16 @@ public class FailoverAddressOverrideTest
assertTrue("server did not launch correctly",
launchServer(Server.class));
}
+
+ protected String getConfig() {
+ return FAILOVER_CONFIG;
+ }
@Before
public void setUp() {
targets = new ArrayList<String>();
SpringBusFactory bf = new SpringBusFactory();
- bus = bf.createBus(FAILOVER_CONFIG);
+ bus = bf.createBus(getConfig());
BusFactory.setDefaultBus(bus);
}
@@ -152,7 +156,7 @@ public class FailoverAddressOverrideTest
}
- private void startTarget(String address) {
+ protected void startTarget(String address) {
ControlService cs = new ControlService();
control = cs.getControlPort();
@@ -162,7 +166,7 @@ public class FailoverAddressOverrideTest
targets.add(address);
}
- private void stopTarget(String address) {
+ protected void stopTarget(String address) {
if (control != null
&& targets.contains(address)) {
LOG.info("starting replicated target: " + address);
@@ -171,38 +175,38 @@ public class FailoverAddressOverrideTest
}
}
- private void verifyCurrentEndpoint(String replica) {
+ protected void verifyCurrentEndpoint(String replica) {
assertEquals("unexpected current endpoint",
replica,
getCurrentEndpoint(greeter));
}
- private String getCurrentEndpoint(Object proxy) {
+ protected String getCurrentEndpoint(Object proxy) {
return
ClientProxy.getClient(proxy).getEndpoint().getEndpointInfo().getAddress();
}
- private void setupGreeterA() {
+ protected void setupGreeterA() {
greeter = new ClusteredGreeterService().getReplicatedPortA();
verifyConduitSelector(greeter);
}
- private void setupGreeterB() {
+ protected void setupGreeterB() {
greeter = new ClusteredGreeterService().getReplicatedPortB();
verifyConduitSelector(greeter);
}
- private void setupGreeterC() {
+ protected void setupGreeterC() {
greeter = new ClusteredGreeterService().getReplicatedPortC();
verifyConduitSelector(greeter);
}
- private void verifyConduitSelector(Greeter g) {
+ protected void verifyConduitSelector(Greeter g) {
assertTrue("unexpected conduit slector",
ClientProxy.getClient(g).getConduitSelector()
instanceof FailoverTargetSelector);
}
- private void verifyStrategy(Object proxy, Class clz, int count) {
+ protected void verifyStrategy(Object proxy, Class clz, int count) {
ConduitSelector conduitSelector =
ClientProxy.getClient(proxy).getConduitSelector();
if (conduitSelector instanceof FailoverTargetSelector) {
Modified:
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverTest.java?rev=1088745&r1=1088744&r2=1088745&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverTest.java
(original)
+++
cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/FailoverTest.java
Mon Apr 4 19:24:26 2011
@@ -67,10 +67,10 @@ public class FailoverTest extends Abstra
private static final String FAILOVER_CONFIG =
"org/apache/cxf/systest/clustering/failover.xml";
- private Bus bus;
- private Control control;
- private Greeter greeter;
- private List<String> targets;
+ protected Bus bus;
+ protected Greeter greeter;
+ protected List<String> targets;
+ protected Control control;
private MAPAggregator mapAggregator;
private MAPCodec mapCodec;
@@ -81,11 +81,15 @@ public class FailoverTest extends Abstra
launchServer(Server.class));
}
+ protected String getConfig() {
+ return FAILOVER_CONFIG;
+ }
+
@Before
public void setUp() {
targets = new ArrayList<String>();
SpringBusFactory bf = new SpringBusFactory();
- bus = bf.createBus(FAILOVER_CONFIG);
+ bus = bf.createBus(getConfig());
BusFactory.setDefaultBus(bus);
}
@@ -296,7 +300,7 @@ public class FailoverTest extends Abstra
strategyTest(REPLICA_A, REPLICA_B, REPLICA_C, true);
}
- private void strategyTest(String activeReplica1,
+ protected void strategyTest(String activeReplica1,
String activeReplica2,
String inactiveReplica,
boolean expectRandom) {
@@ -328,7 +332,7 @@ public class FailoverTest extends Abstra
randomized);
}
- private void startTarget(String address) {
+ protected void startTarget(String address) {
ControlService cs = new ControlService();
control = cs.getControlPort();
@@ -337,7 +341,7 @@ public class FailoverTest extends Abstra
targets.add(address);
}
- private void stopTarget(String address) {
+ protected void stopTarget(String address) {
if (control != null
&& targets.contains(address)) {
LOG.info("starting replicated target: " + address);
@@ -346,17 +350,17 @@ public class FailoverTest extends Abstra
}
}
- private void verifyCurrentEndpoint(String replica) {
+ protected void verifyCurrentEndpoint(String replica) {
assertEquals("unexpected current endpoint",
replica,
getCurrentEndpoint(greeter));
}
- private String getCurrentEndpoint(Object proxy) {
+ protected String getCurrentEndpoint(Object proxy) {
return
ClientProxy.getClient(proxy).getEndpoint().getEndpointInfo().getAddress();
}
- private void setupGreeter() {
+ protected void setupGreeter() {
ClusteredGreeterService cs = new ClusteredGreeterService();
// REVISIT: why doesn't the generic (i.e. non-Port-specific)
// Service.getPort() load the <jaxws:client> configuration?
@@ -367,7 +371,7 @@ public class FailoverTest extends Abstra
instanceof FailoverTargetSelector);
}
- private void verifyStrategy(Object proxy, Class clz) {
+ protected void verifyStrategy(Object proxy, Class clz) {
ConduitSelector conduitSelector =
ClientProxy.getClient(proxy).getConduitSelector();
if (conduitSelector instanceof FailoverTargetSelector) {