org.apache.axis2.clustering.state.Replicator Java Examples

The following examples show how to use org.apache.axis2.clustering.state.Replicator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelloService.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public String greet(String name) {
    ServiceContext serviceContext =
            MessageContext.getCurrentMessageContext().getServiceContext();
    serviceContext.setProperty(HELLO_SERVICE_NAME, name);
    try {
        Replicator.replicate(serviceContext, new String[]{HELLO_SERVICE_NAME});
    } catch (ClusteringFault clusteringFault) {
        clusteringFault.printStackTrace();
    }

    if (name != null) {
        return "Hello World, " + name + " !!!";
    } else {
        return "Hello World !!!";
    }
}
 
Example #2
Source File: HelloService.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public String greet(String name) {
    ServiceContext serviceContext =
            MessageContext.getCurrentMessageContext().getServiceContext();
    serviceContext.setProperty(HELLO_SERVICE_NAME, name);
    try {
        Replicator.replicate(serviceContext, new String[]{HELLO_SERVICE_NAME});
    } catch (ClusteringFault clusteringFault) {
        clusteringFault.printStackTrace();
    }

    if (name != null) {
        return "Hello World, " + name + " !!!";
    } else {
        return "Hello World !!!";
    }
}
 
Example #3
Source File: HelloService.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public String greet(String name) {
    ServiceContext serviceContext =
            MessageContext.getCurrentMessageContext().getServiceContext();
    serviceContext.setProperty(HELLO_SERVICE_NAME, name);
    try {
        Replicator.replicate(serviceContext, new String[]{HELLO_SERVICE_NAME});
    } catch (ClusteringFault clusteringFault) {
        clusteringFault.printStackTrace();
    }

    if (name != null) {
        return "Hello World, " + name + " !!!";
    } else {
        return "Hello World !!!";
    }
}
 
Example #4
Source File: HelloService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public String greet(String name) {
    ServiceContext serviceContext = MessageContext.getCurrentMessageContext().getServiceContext();
    serviceContext.setProperty(HELLO_SERVICE_NAME, name);
    try {
        Replicator.replicate(serviceContext, new String[] { HELLO_SERVICE_NAME });
    } catch (ClusteringFault clusteringFault) {
        clusteringFault.printStackTrace();
    }

    if (name != null) {
        return "Hello World, " + name + " !!!";
    } else {
        return "Hello World !!!";
    }
}
 
Example #5
Source File: APIThrottleHandler.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
private boolean doThrottle(MessageContext messageContext) {
    boolean isResponse = messageContext.isResponse();
    org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext).
            getAxis2MessageContext();
    ConfigurationContext cc = axis2MC.getConfigurationContext();

    ThrottleDataHolder dataHolder = null;
    if (cc == null) {
        handleException("Error while retrieving ConfigurationContext from messageContext");
    }

    synchronized (cc) {
        dataHolder = (ThrottleDataHolder) cc.getProperty(ThrottleConstants.THROTTLE_INFO_KEY);
        if (dataHolder == null) {
            dataHolder = new ThrottleDataHolder();
            cc.setNonReplicableProperty(ThrottleConstants.THROTTLE_INFO_KEY, dataHolder);
        }
    }

    if ((throttle == null && !isResponse) || (isResponse && concurrentAccessController == null)) {
        isClusteringEnable = isClusteringEnabled();
    }

    if (!isResponse) {
        //check the availability of the ConcurrentAccessController
        //if this is a clustered environment
        if (isClusteringEnable) {
            concurrentAccessController = (ConcurrentAccessController) cc.getProperty(key);
        }
        initThrottle(messageContext, cc);
    } else {
        // if the message flow path is OUT , then must lookup from ConfigurationContext -
        // never create ,just get the existing one
        concurrentAccessController = (ConcurrentAccessController) cc.getProperty(key);
    }


    // perform concurrency throttling
    boolean canAccess = doThrottleByConcurrency(isResponse);
    // if the access is success through concurrency throttle and if this is a request message
    // then do access rate based throttling
    if (canAccess && !isResponse && throttle != null) {
        canAccess = throttleByAccessRate(axis2MC, cc) &&
                doRoleBasedAccessThrottling(messageContext, cc);
    }

    // All the replication functionality of the access rate based throttling handled by itself
    // Just replicate the current state of ConcurrentAccessController
    if (isClusteringEnable && concurrentAccessController != null) {

        try {
            Replicator.replicate(cc);
        } catch (ClusteringFault clusteringFault) {
            handleException("Error during the replicating  states ", clusteringFault);
        }

    }

    if (!canAccess) {
        handleThrottleOut(messageContext);
        return false;
    }
    return true;
}