You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2008/05/06 20:25:21 UTC
svn commit: r653872 [2/2] - in
/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse:
config/xml/ config/xml/endpoints/ endpoints/ endpoints/dispatch/
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java?rev=653872&r1=653871&r2=653872&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java Tue May 6 11:25:19 2008
@@ -35,7 +35,8 @@
* endpoint as a private variable as it could expire. Therefore, it only stores the key and gets the
* actual endpoint from the synapse configuration.
* <p/>
- * As this is also an instance of endpoint, this can be used any place, where a normal endpoint is used.
+ * As this is also an instance of endpoint, this can be used any place, where a normal endpoint is
+ * used.
*/
public class IndirectEndpoint implements Endpoint {
@@ -44,14 +45,12 @@
private String name = null;
private String key = null;
- private boolean active = true;
private Endpoint parentEndpoint = null;
/**
* This should have a reference to the current message context as it gets the referred endpoint
* from it.
*/
- private MessageContext currentMsgCtx = null;
private final EndpointContext endpointContext = new EndpointContext();
public void send(MessageContext synMessageContext) {
@@ -95,7 +94,7 @@
}
}
-
+ assert endpoint != null;
if (endpoint.isActive(synMessageContext)) {
endpoint.send(synMessageContext);
@@ -148,6 +147,7 @@
handleException("Reference to non-existent endpoint for key : " + key);
}
+ assert endpoint != null;
return endpoint.isActive(synMessageContext);
}
@@ -164,6 +164,7 @@
handleException("Reference to non-existent endpoint for key : " + key);
}
+ assert endpoint != null;
endpoint.setActive(active, synMessageContext);
}
@@ -211,12 +212,9 @@
endptDefn = wsdlEndpt.getEndpoint();
}
- if (endptDefn != null) {
- return (endptDefn.getTraceState() == SynapseConstants.TRACING_ON) ||
- (endptDefn.getTraceState() == SynapseConstants.TRACING_UNSET &&
- synCtx.getTracingState() == SynapseConstants.TRACING_ON);
- }
- return false;
+ return endptDefn != null && ((endptDefn.getTraceState() == SynapseConstants.TRACING_ON) ||
+ (endptDefn.getTraceState() == SynapseConstants.TRACING_UNSET &&
+ synCtx.getTracingState() == SynapseConstants.TRACING_ON));
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java?rev=653872&r1=653871&r2=653872&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java Tue May 6 11:25:19 2008
@@ -34,12 +34,12 @@
/**
* Load balance endpoint can have multiple endpoints. It will route messages according to the
- * specified load balancing algorithm. This will assume that all immediate child endpoints are identical
- * in state (state is replicated) or state is not maintained at those endpoints. If an endpoint is
- * failing, the failed endpoint is marked as inactive and the message to the next endpoint obtained
- * using the load balancing algorithm. If all the endpoints have failed and the parent endpoint is
- * available, onChildEndpointFail(...) method of parent endpoint is called. If parent is not
- * available, this will call next FaultHandler for the message context.
+ * specified load balancing algorithm. This will assume that all immediate child endpoints are
+ * identical in state (state is replicated) or state is not maintained at those endpoints. If an
+ * endpoint is failing, the failed endpoint is marked as inactive and the message to the next
+ * endpoint obtained using the load balancing algorithm. If all the endpoints have failed and the
+ * parent endpoint is available, onChildEndpointFail(...) method of parent endpoint is called. If
+ * parent is not available, this will call next FaultHandler for the message context.
*/
public class LoadbalanceEndpoint implements Endpoint {
@@ -135,8 +135,8 @@
if (endpoint != null) {
// We have to build the envelop if we are supporting failover.
- // Failover should sent the original message multiple times if failures occur. So we have to
- // access the envelop multiple times.
+ // Failover should sent the original message multiple times if failures occur. So we
+ // have to access the envelop multiple times.
if (failover) {
synMessageContext.getEnvelope().build();
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java?rev=653872&r1=653871&r2=653872&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java Tue May 6 11:25:19 2008
@@ -45,16 +45,16 @@
* session -> endpoint map. To update sessions for response messages, all SALoadbalanceEndpoint
* objects are kept in a global property. When a message passes through SALoadbalanceEndpoints, each
* endpoint appends its "Synapse unique ID" to the operation context. Once the response for that
- * message arrives, response sender checks first endpoint of the endpoint sequence from the operation
- * context and get that endpoint from the above mentioned global property. Then it will invoke
- * updateSession(...) method of that endpoint. After that, each endpoint will call updateSession(...)
- * method of their appropriate child endpoint, so that all the sending endpoints for the session will
- * be updated.
+ * message arrives, response sender checks first endpoint of the endpoint sequence from the
+ * operation context and get that endpoint from the above mentioned global property. Then it will
+ * invoke updateSession(...) method of that endpoint. After that, each endpoint will call
+ * updateSession(...) method of their appropriate child endpoint, so that all the sending endpoints
+ * for the session will be updated.
* <p/>
* This endpoint gets the target endpoint first from the dispatch manager, which will ask all listed
- * dispatchers for a matching session. If a matching session is found it will just invoke the send(...)
- * method of that endpoint. If not it will find an endpoint using the load balancing policy and send to
- * that endpoint.
+ * dispatchers for a matching session. If a matching session is found it will just invoke the
+ * send(...) method of that endpoint. If not it will find an endpoint using the load balancing
+ * policy and send to that endpoint.
*/
public class SALoadbalanceEndpoint implements Endpoint {
@@ -78,7 +78,7 @@
* List of endpoints among which the load is distributed. Any object implementing the Endpoint
* interface could be used.
*/
- private List endpoints = null;
+ private List<Endpoint> endpoints = null;
/**
* Algorithm used for selecting the next endpoint to direct the first request of sessions.
@@ -117,7 +117,6 @@
public void send(MessageContext synMessageContext) {
- Endpoint endpoint = null;
if (log.isDebugEnabled()) {
log.debug("Start : Session Affinity Load-balance Endpoint");
}
@@ -169,7 +168,7 @@
// first check if this session is associated with a session. if so, get the endpoint
// associated for that session.
- endpoint = dispatcher.getEndpoint(synMessageContext, dispatcherContext);
+ Endpoint endpoint = dispatcher.getEndpoint(synMessageContext, dispatcherContext);
if (endpoint == null) {
// there is no endpoint associated with this session. get a new endpoint using the
@@ -229,7 +228,7 @@
Object o = opCtx.getProperty(ENDPOINT_LIST);
if (o != null) {
- List endpointList = (List) o;
+ List<Endpoint> endpointList = (List<Endpoint>) o;
endpointList.add(this);
// if the next endpoint is not a session affinity one, endpoint sequence ends
@@ -292,8 +291,11 @@
*
* @param responseMsgCtx
* @param endpointList
+ * @param isClusteringEnable
*/
- public void updateSession(MessageContext responseMsgCtx, List endpointList, boolean isClusteringEnable) {
+ public void updateSession(MessageContext responseMsgCtx, List endpointList,
+ boolean isClusteringEnable) {
+
Endpoint endpoint = null;
if (isClusteringEnable) {
@@ -362,11 +364,11 @@
endpointContext.setActive(active);
}
- public List getEndpoints() {
+ public List<Endpoint> getEndpoints() {
return endpoints;
}
- public void setEndpoints(List endpoints) {
+ public void setEndpoints(List<Endpoint> endpoints) {
this.endpoints = endpoints;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java?rev=653872&r1=653871&r2=653872&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java Tue May 6 11:25:19 2008
@@ -35,9 +35,9 @@
/**
* WSDLEndpoint represents the endpoints built using a wsdl document. It stores the details about
- * the endpoint in a EndpointDefinition object. Once the WSDLEndpoint object is constructed, it should
- * not access the wsdl document at runtime to obtain endpoint information. If it is necessary to
- * create an endpoint using a dynamic wsdl, store the endpoint configuration in the registry and
+ * the endpoint in a EndpointDefinition object. Once the WSDLEndpoint object is constructed, it
+ * should not access the wsdl document at runtime to obtain endpoint information. If it is necessary
+ * to create an endpoint using a dynamic wsdl, store the endpoint configuration in the registry and
* create a dynamic wsdl endpoint using that registry key.
* <p/>
* TODO: This should allow various policies to be applied on fine grained level (e.g. operations).
@@ -62,11 +62,11 @@
private final EndpointContext endpointContext = new EndpointContext();
/**
- * Sends the message through this endpoint. This method just handles statistics related functions
- * and gives the message to the Synapse environment to send. It does not add any endpoint
- * specific details to the message context. These details are added only to the cloned message
- * context by the Axis2FlexibleMepClient. So that we can reuse the original message context for
- * resending through different endpoints.
+ * Sends the message through this endpoint. This method just handles statistics related
+ * functions and gives the message to the Synapse environment to send. It does not add any
+ * endpoint specific details to the message context. These details are added only to the cloned
+ * message context by the Axis2FlexibleMepClient. So that we can reuse the original message
+ * context for resending through different endpoints.
*
* @param synCtx MessageContext sent by client to Synapse
*/
@@ -83,11 +83,9 @@
}
}
- String eprAddress = null;
if (endpoint.getAddress() != null) {
- eprAddress = endpoint.getAddress();
-
+ String eprAddress = endpoint.getAddress();
boolean isClusteringEnable = false;
// get Axis2 MessageContext and ConfigurationContext
org.apache.axis2.context.MessageContext axisMC =
@@ -95,7 +93,6 @@
ConfigurationContext cc = axisMC.getConfigurationContext();
//The check for clustering environment
-
ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
if (clusterManager != null &&
clusterManager.getContextManager() != null) {
@@ -106,9 +103,10 @@
if (endPointName == null) {
if (traceOrDebugOn && isClusteringEnable) {
- log.warn("In a clustering environment , the endpoint name should be specified" +
- "even for anonymous endpoints. Otherwise , the clustering would not be " +
- "functioned correctly if there are more than one anonymous endpoints. ");
+ log.warn("In a clustering environment , the endpoint name should be " +
+ "specified even for anonymous endpoints. Otherwise, the clustering " +
+ "would not be functioned correctly if there are more than one " +
+ "anonymous endpoints. ");
}
endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java?rev=653872&r1=653871&r2=653872&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java Tue May 6 11:25:19 2008
@@ -54,7 +54,8 @@
/* Map to store session -> endpoint mappings. Synchronized map is used as this is accessed by
* multiple threads (e.g. multiple clients different sessions).*/
- private final Map sessionMap = Collections.synchronizedMap(new HashMap());
+ private final Map<String, Endpoint> sessionMap
+ = Collections.synchronizedMap(new HashMap<String, Endpoint>());
/*The axis configuration context- this will hold the all callers states
*when doing throttling in a clustered environment. */
@@ -67,7 +68,7 @@
private String keyPrefix;
/*To keep all defined child endpoints */
- private final Map endpointsMap = new HashMap();
+ private final Map<String, Endpoint> endpointsMap = new HashMap<String, Endpoint>();
/**
* return the endpoint for the given session.
@@ -87,13 +88,13 @@
// gets the value from configuration context (The shared state across all instances )
Object value = this.configCtx.getPropertyNonReplicable(this.keyPrefix + sessionID);
if (value != null && value instanceof String) {
- return (Endpoint) endpointsMap.get(value);
+ return endpointsMap.get(value.toString());
}
} else {
synchronized (sessionMap) {
- return (Endpoint) sessionMap.get(sessionID);
+ return sessionMap.get(sessionID);
}
}
@@ -299,31 +300,24 @@
*
* @param endpoints The endpoint list
*/
- public void setEndpoints(List endpoints) {
+ public void setEndpoints(List<Endpoint> endpoints) {
if (endpoints != null) {
- for (int i = 0; i < endpoints.size(); i++) {
- Object e = endpoints.get(i);
-
- if (e != null && e instanceof Endpoint) {
- Endpoint endpoint = (Endpoint) e;
-
- String endPointName = endpoint.getName();
- if (endPointName == null) {
-
- if (log.isDebugEnabled() && isClusteringEnable()) {
- log.warn("In a clustering environment , the endpoint name should be" +
- " specified even for anonymous endpoints. Otherwise , the " +
- "clustering would not be functioned correctly if there are" +
- " more than one anonymous endpoints. ");
- }
- endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
+ for (Endpoint endpoint : endpoints) {
+ String endPointName = endpoint.getName();
+ if (endPointName == null) {
+ if (log.isDebugEnabled() && isClusteringEnable()) {
+ log.warn("In a clustering environment , the endpoint name should be" +
+ " specified even for anonymous endpoints. Otherwise , the " +
+ "clustering would not be functioned correctly if there are" +
+ " more than one anonymous endpoints. ");
}
-
- endpointsMap.put(endPointName, endpoint);
+ endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
+ endpointsMap.put(endPointName, endpoint);
+
}
}
}