org.apache.axis2.clustering.ClusteringMessage Java Examples

The following examples show how to use org.apache.axis2.clustering.ClusteringMessage. 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: PolicySearchCache.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Send out policy status change notification to other nodes.
 *
 * @param clusterMessage
 * @param isSync
 */
private void sendClusterMessage(ClusteringMessage clusterMessage, boolean isSync) {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Sending cluster message to all other nodes");
        }
        ClusteringAgent clusteringAgent = EntitlementConfigHolder.getInstance().getConfigurationContextService()
                .getServerConfigContext().getAxisConfiguration().getClusteringAgent();
        if (clusteringAgent != null) {
            clusteringAgent.sendMessage(clusterMessage, isSync);
        } else {
            log.error("Clustering Agent not available.");
        }
    } catch (ClusteringFault clusteringFault) {
        log.error("Error while sending cluster message", clusteringFault);
    }
}
 
Example #2
Source File: TenantLoadMessageSender.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Send the {@link TenantLoadMessage} message
 *
 * @param clusteringAgent {@link ClusteringAgent} object
 * @param tenantId        tenant id
 * @param tenantDomain    tenant domain
 * @param retryCount      retry count if cluster message sending fails
 * @throws ClusteringFault id cluster message sending fails
 */
void sendTenantLoadMessage(ClusteringAgent clusteringAgent, int tenantId, String tenantDomain, int retryCount)
        throws ClusteringFault {
    // need to re-try if the initial message fails.
    int numberOfRetries = 0;
    ClusteringMessage request = new TenantLoadMessage(tenantId, tenantDomain);
    while (numberOfRetries < retryCount) {
        try {
            clusteringAgent.sendMessage(request, true);
            log.info("Sent [" + request.toString() + "]");
            break;

        } catch (ClusteringFault e) {
            numberOfRetries++;
            if (numberOfRetries < retryCount) {
                log.warn("Could not send TenantRegistryLoadMessage for tenant " + tenantId
                        + ". Retry will be attempted in 2s. Request: " + request, e);
            } else {
                // cluster message sending failed, throw
                throw e;
            }
            try {
                Thread.sleep(2000);
            } catch (InterruptedException ignored) {
            }
        }
    }
}
 
Example #3
Source File: TenantLoadMessageSenderTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendTenantRegistryLoadMessage() throws ClusteringFault {
    ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
    ClusteringMessage request = new TenantLoadMessage(1, "a.com");
    ClusteringCommand command = PowerMockito.mock(ClusteringCommand.class);
    List<ClusteringCommand> commandList = new ArrayList<ClusteringCommand>();
    commandList.add(command);
    PowerMockito.when(clusteringAgent.sendMessage(request, true)).thenReturn(commandList);
    tenantLoadMessageSender.sendTenantLoadMessage(clusteringAgent, 1, "a.com", 1);
}
 
Example #4
Source File: PrivatePaaSBasedMembershipScheme.java    From product-private-paas with Apache License 2.0 5 votes vote down vote up
public PrivatePaaSBasedMembershipScheme(Map<String, Parameter> parameters,
                                        String primaryDomain,
                                        Config config,
                                        HazelcastInstance primaryHazelcastInstance,
                                        List<ClusteringMessage> messageBuffer) {
    this.parameters = parameters;
    this.primaryHazelcastInstance = primaryHazelcastInstance;
    this.messageBuffer = messageBuffer;
    this.nwConfig = config.getNetworkConfig();
}
 
Example #5
Source File: KubernetesMembershipScheme.java    From product-private-paas with Apache License 2.0 5 votes vote down vote up
public KubernetesMembershipScheme(Map<String, Parameter> parameters,
                                  String primaryDomain,
                                  Config config,
                                  HazelcastInstance primaryHazelcastInstance,
                                  List<ClusteringMessage> messageBuffer) {
    this.parameters = parameters;
    this.primaryHazelcastInstance = primaryHazelcastInstance;
    this.messageBuffer = messageBuffer;
    this.nwConfig = config.getNetworkConfig();
}
 
Example #6
Source File: MesosBasedKubernetesMembershipScheme.java    From product-private-paas with Apache License 2.0 4 votes vote down vote up
public MesosBasedKubernetesMembershipScheme(Map<String, Parameter> parameters, String primaryDomain,
                                            Config config, HazelcastInstance primaryHazelcastInstance,
                                            List<ClusteringMessage> messageBuffer) {
    super(parameters, primaryDomain, config, primaryHazelcastInstance, messageBuffer);
}