org.apache.axis2.clustering.ClusteringAgent Java Examples

The following examples show how to use org.apache.axis2.clustering.ClusteringAgent. 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: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static Boolean deleteServiceMappingToCluster(String mapping) throws AxisFault {
    Boolean isMappingAdded = false;
    try {
        ClusteringAgent agent = getClusteringAgent();
        if(agent != null) {
            agent.sendMessage(new ServiceMappingDeleteRequest(mapping), true);
            isMappingAdded = true;
        }
        if (log.isDebugEnabled()) {
            log.debug("sent cluster command to to get Active tenants on cluster");
        }
    } catch (AxisFault f) {
        String msg = "Error in getting active tenant by cluster commands";
        log.error(msg, f);
        throw new AxisFault(msg);
    }
    return isMappingAdded;
}
 
Example #2
Source File: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static Boolean addVirtualHostsToCluster(String hostName, String uri, String webappPath) throws AxisFault {
    Boolean isMappingAdded = false;
    try {
        ClusteringAgent agent = getClusteringAgent();
        if(agent != null) {
            agent.sendMessage(new VirtualHostAddRequest(hostName, uri, webappPath), true);
            isMappingAdded = true;
        }
        if (log.isDebugEnabled()) {
            log.debug("sent cluster command to to get Active tenants on cluster");
        }
    } catch (AxisFault f) {
        String msg = "Error in getting active tenant by cluster commands";
        log.error(msg, f);
        throw new AxisFault(msg);
    }
    return isMappingAdded;
}
 
Example #3
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 #4
Source File: PolicyCache.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(PolicyStatusClusterMessage clusterMessage, boolean isSync) {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Sending policy status change 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 policy status change cluster message", clusteringFault);
    }
}
 
Example #5
Source File: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static Boolean addServiceMappingToCluster(String mapping, String epr) throws AxisFault {
    Boolean isMappingAdded = false;
    try {
        ClusteringAgent agent = getClusteringAgent();
        if(agent != null) {
            agent.sendMessage(new ServiceMappingAddRequest(mapping, epr), true);
            isMappingAdded = true;
        }
        if (log.isDebugEnabled()) {
            log.debug("sent cluster command to to get Active tenants on cluster");
        }
    } catch (AxisFault f) {
        String msg = "Error in getting active tenant by cluster commands";
        log.error(msg, f);
        throw new AxisFault(msg);
    }
    return isMappingAdded;
}
 
Example #6
Source File: OpenIDAssociationReplicationManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void replicateAssociationInfo(AssociationClusterMessage associationInfoData) {
    if (log.isDebugEnabled()) {
        log.debug("Starting to replicate association : " + associationInfoData.getAssociation().getHandle());
    }

    ClusteringAgent agent = IdentityProviderServiceComponent.getConfigContext().getAxisConfiguration().getClusteringAgent();
    if (log.isDebugEnabled()) {
        log.debug("Clustering Agent: " + agent);
    }

    if (agent != null) {
        try {
            agent.sendMessage(associationInfoData, true);
        } catch (ClusteringFault e) {
            log.error("Unable to send cluster message :" + e.getMessage(), e);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("Completed replicating association : " + associationInfoData.getAssociation().getHandle());
    }
}
 
Example #7
Source File: TenantLoadMessageSenderTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetClusteringAgent() {
    PowerMockito.mockStatic(ServiceReferenceHolder.class);
    ConfigurationContextService configurationContextService = PowerMockito.mock(ConfigurationContextService.class);
    PowerMockito.when(ServiceReferenceHolder.getContextService()).thenReturn(configurationContextService);
    ConfigurationContext serverConfigContext = PowerMockito.mock(ConfigurationContext.class);
    PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext())
            .thenReturn(serverConfigContext);
    AxisConfiguration axisConfiguration = PowerMockito.mock(AxisConfiguration.class);
    PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration())
            .thenReturn(axisConfiguration);
    ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
    PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration()
            .getClusteringAgent()).thenReturn(clusteringAgent);
    tenantLoadMessageSender.getClusteringAgent();
}
 
Example #8
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public GroupMember[] getMembers(String groupName) throws Exception {
    ClusteringAgent clusteringAgent = getClusteringAgent();
    GroupManagementAgent groupManagementAgent =
            clusteringAgent.getGroupManagementAgent(groupName);
    if (groupManagementAgent == null) {
        handleException("No GroupManagementAgent defined for domain " + groupName);
        return null;
    }
    List<Member> members = groupManagementAgent.getMembers();
    GroupMember[] groupMembers = new GroupMember[members.size()];
    int i = 0;
    for (Member member : members) {
        GroupMember groupMember = new GroupMember();
        groupMember.setHostName(member.getHostName());
        groupMember.setHttpPort(member.getHttpPort());
        groupMember.setHttpsPort(member.getHttpsPort());
        Properties properties = member.getProperties();
        groupMember.setBackendServerURL(properties.getProperty("backendServerURL"));
        groupMember.setMgConsoleURL(properties.getProperty("mgtConsoleURL"));
        groupMembers[i] = groupMember;
        i++;
    }

    return groupMembers;
}
 
Example #9
Source File: GatewayUtilsTestCase.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testIsClusteringEnabled() {
    ConfigurationContext configurationContext = Mockito.mock(ConfigurationContext.class);
    AxisConfiguration axisConfiguration = Mockito.mock(AxisConfiguration.class);
    ClusteringAgent clusteringAgent = Mockito.mock(ClusteringAgent.class);
    Member member = Mockito.mock(Member.class);
    List<Member> memberList = new ArrayList<>(1);
    memberList.add(member);
    clusteringAgent.setMembers(new ArrayList<Member>());
    Mockito.when(serviceReferenceHolder.getServerConfigurationContext()).thenReturn(configurationContext);
    Mockito.when(configurationContext.getAxisConfiguration()).thenReturn(axisConfiguration);

    //test when clusteringAgent is null
    Mockito.when(axisConfiguration.getClusteringAgent()).thenReturn(null);
    GatewayUtils.isClusteringEnabled();

    // test when clusteringAgent is set
    Mockito.when(axisConfiguration.getClusteringAgent()).thenReturn(clusteringAgent);
    Mockito.when(clusteringAgent.getMembers()).thenReturn(memberList);
    GatewayUtils.isClusteringEnabled();
    Assert.assertEquals(1, clusteringAgent.getMembers().size());
}
 
Example #10
Source File: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static Boolean deleteVirtualHostsToCluster(String hostName) throws AxisFault {
    Boolean isMappingAdded = false;
    try {
        ClusteringAgent agent = getClusteringAgent();
        if(agent != null) {
            agent.sendMessage(new VirtualHostDeleteMapping(hostName), true);
            isMappingAdded = true;
        }
        if (log.isDebugEnabled()) {
            log.debug("sent cluster command to to get Active tenants on cluster");
        }
    } catch (AxisFault f) {
        String msg = "Error in getting active tenant by cluster commands";
        log.error(msg, f);
        throw new AxisFault(msg);
    }
    return isMappingAdded;
}
 
Example #11
Source File: RemoteTaskManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private TaskState getTaskStateFromLocalCluster(String taskName) throws TaskException {
    /* first check local server */
    if (this.isTaskRunning(taskName)) {
        return TaskState.BLOCKED;
    }
    ClusteringAgent agent = this.getClusteringAgent();
    if (agent == null) {
        return TaskState.UNKNOWN;
    }
    TaskStatusMessage msg = new TaskStatusMessage();
    msg.setTaskName(taskName);
    msg.setTaskType(this.getTaskType());
    msg.setTenantId(this.getTenantId());
    try {
        List<ClusteringCommand> result = agent.sendMessage(msg, true);
        TaskStatusResult status;
        for (ClusteringCommand entry : result) {
            status = (TaskStatusResult) entry;
            if (status.isRunning()) {
                return TaskState.BLOCKED;
            }
        }
        return TaskState.NORMAL;
    } catch (ClusteringFault e) {
        throw new TaskException(e.getMessage(), Code.UNKNOWN, e);
    }
}
 
Example #12
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 #13
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public Group[] getGroups() throws Exception {
    ClusteringAgent clusteringAgent = getClusteringAgent();
    List<Group> groups = new ArrayList<Group>();
    Set<String> groupNames = clusteringAgent.getDomains();
    for (String groupName : groupNames) {
        Group group = new Group();
        group.setName(groupName);
        GroupManagementAgent gmAgent = clusteringAgent.getGroupManagementAgent(groupName);
        List<Member> memberList = gmAgent.getMembers();
        group.setDescription(gmAgent.getDescription());
        group.setNumberOfMembers(memberList.size());
        groups.add(group);
    }
    return groups.toArray(new Group[groups.size()]);
}
 
Example #14
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private void sendToCluster(GroupManagementCommand cmd) throws AxisFault {
    ClusteringAgent clusteringAgent = getClusteringAgent();
    Set<String> groupNames = clusteringAgent.getDomains();
    for (String groupName : groupNames) {
        GroupManagementAgent managementAgent =
                clusteringAgent.getGroupManagementAgent(groupName);
        managementAgent.send(cmd);
    }
}
 
Example #15
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private GroupManagementAgent getGroupManagementAgent(String groupName) throws AxisFault {
    ClusteringAgent clusteringAgent = getClusteringAgent();
    GroupManagementAgent groupManagementAgent =
            clusteringAgent.getGroupManagementAgent(groupName);
    if (groupManagementAgent == null) {
        handleException("No GroupManagementAgent defined for domain " + groupName);
    }
    return groupManagementAgent;
}
 
Example #16
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private ClusteringAgent getClusteringAgent() throws AxisFault {
    AxisConfiguration axisConfig =
            MessageContext.getCurrentMessageContext().
                    getConfigurationContext().getAxisConfiguration();
    ClusteringAgent clusterManager = axisConfig.getClusteringAgent();
    if (clusterManager == null) {
        handleException("ClusteringAgent not enabled in axis2.xml file");
    }
    return clusterManager;
}
 
Example #17
Source File: ClusterAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private NodeManager getNodeManager() throws AxisFault {
    NodeManager nodeManager;
    ClusteringAgent clusteringAgent = getClusteringAgent();
    nodeManager = clusteringAgent.getNodeManager();
    if (nodeManager == null) {
        handleException("Cluster NodeManager not enabled in axis2.xml file");
    }
    return nodeManager;
}
 
Example #18
Source File: SharedMemoryCacheUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
    * This is to send clusterMessage to inform other nodes about subscription added to the system, so that everyone can add new one.
    * @param topicName
    * @param subsciptionID
    * @param tenantID
    * @param tenantName
    * @throws ClusteringFault
    */
public static void sendAddSubscriptionClusterMessage(String topicName,String subsciptionID, 
		int tenantID, String tenantName) throws ClusteringFault{
	ConfigurationContextService configContextService = (ConfigurationContextService) PrivilegedCarbonContext
			.getThreadLocalCarbonContext().getOSGiService(ConfigurationContextService.class);
	ConfigurationContext configContext = configContextService.getServerConfigContext();
	ClusteringAgent agent = configContext.getAxisConfiguration().getClusteringAgent();

	agent.sendMessage(new SubscriptionClusterMessage(topicName,subsciptionID,tenantID, tenantName), false);
}
 
Example #19
Source File: RemoteTaskManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private ClusteringAgent getClusteringAgent() throws TaskException {
    ConfigurationContextService configCtxService = TasksDSComponent
            .getConfigurationContextService();
    if (configCtxService == null) {
        throw new TaskException("ConfigurationContextService not available "
                + "for notifying the cluster", Code.UNKNOWN);
    }
    ConfigurationContext configCtx = configCtxService.getServerConfigContext();
    ClusteringAgent agent = configCtx.getAxisConfiguration().getClusteringAgent();
    if (log.isDebugEnabled()) {
        log.debug("Clustering Agent: " + agent);
    }
    return agent;
}
 
Example #20
Source File: TenantLoadMessageSenderTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test(expected = ClusteringFault.class)
public void testSendTenantRegistryLoadMessageFail() throws ClusteringFault {
    ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
    ClusteringCommand command = PowerMockito.mock(ClusteringCommand.class);
    List<ClusteringCommand> commandList = new ArrayList<ClusteringCommand>();
    commandList.add(command);
    ClusteringFault clusteringFault = PowerMockito.mock(ClusteringFault.class);
    PowerMockito.when(clusteringAgent.sendMessage(Matchers.any(TenantLoadMessage.class), Matchers.anyBoolean())).
            thenThrow(clusteringFault);
    tenantLoadMessageSender.sendTenantLoadMessage(clusteringAgent, 1, "a.com", 2);
}
 
Example #21
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 #22
Source File: TenantLoadMessageSender.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyTenantLoad() {
    ClusteringAgent clusteringAgent = getClusteringAgent();
    // if clustering is not enabled, the clusteringAgent should be null
    if (clusteringAgent != null) {
        int tenantId = getTenantId();
        String tenantDomain = getTenantDomain();
        try {
            sendTenantLoadMessage(clusteringAgent, tenantId, tenantDomain, 60);
        } catch (ClusteringFault e) {
            log.error("Could not send TenantLoadMessage for tenant domain: " + tenantDomain + ", tenant " + "id: "
                    + tenantId + ". Several retries failed.", e);
        }
    }
}
 
Example #23
Source File: GatewayUtils.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public static boolean isClusteringEnabled() {

        ClusteringAgent agent = ServiceReferenceHolder.getInstance().getServerConfigurationContext().
                getAxisConfiguration().getClusteringAgent();
        if (agent != null) {
            return true;
        }
        return false;
    }
 
Example #24
Source File: SAMLSSORelyingPartyObject.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public void sendSessionInvalidationClusterMessage(String sessionIndex) {

        SessionClusterMessage clusterMessage = new SessionClusterMessage();
        clusterMessage.setMessageId(UUID.randomUUID());
        clusterMessage.setSessionIndex(sessionIndex);
        ClusteringAgent clusteringAgent = SSOHostObjectDataHolder.getInstance()
                .getConfigurationContextService().getServerConfigContext().getAxisConfiguration()
                .getClusteringAgent();
        if (clusteringAgent != null) {
            int numberOfRetries = 0;
            while (numberOfRetries < 60) {
                try {
                    clusteringAgent.sendMessage(clusterMessage, true);
                    log.info("Sent [" + clusterMessage + "]");
                    break;
                } catch (ClusteringFault e) {
                    numberOfRetries++;
                    if (numberOfRetries < 60) {
                        log.warn(
                                "Could not send SSOSessionInvalidationClusterMessage. Retry will be attempted in 2s. Request: "
                                        + clusterMessage, e);
                    } else {
                        log.error("Could not send SSOSessionInvalidationClusterMessage. Several retries failed. Request:"
                                + clusterMessage, e);
                    }
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException ignored) {
                    }
                }
            }
        }
    }
 
Example #25
Source File: SSOSessionManager.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void sendSessionInvalidationClusterMessage(String sessionIndex) {

        SessionClusterMessage clusterMessage = new SessionClusterMessage();
        clusterMessage.setMessageId(UUID.randomUUID());
        clusterMessage.setSessionIndex(sessionIndex);

        ClusteringAgent clusteringAgent = SAML2SSOAuthFEDataHolder.getInstance()
                .getConfigurationContextService().getServerConfigContext().getAxisConfiguration()
                .getClusteringAgent();

        if (clusteringAgent != null) {
            int numberOfRetries = 0;

            while (numberOfRetries < 60) {
                try {
                    clusteringAgent.sendMessage(clusterMessage, true);
                    log.info("Sent [" + clusterMessage + "]");
                    break;
                } catch (ClusteringFault e) {
                    numberOfRetries++;

                    if (numberOfRetries < 60) {
                        log.warn(
                                "Could not send SSOSessionInvalidationClusterMessage. Retry will be attempted in 2s. Request: "
                                        + clusterMessage, e);
                    } else {
                        log.error(
                                "Could not send SSOSessionInvalidationClusterMessage. Several retries failed. Request:"
                                        + clusterMessage, e);
                    }

                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException ignored) {
                    }
                }
            }
        }
    }
 
Example #26
Source File: DataSourceRepository.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void notifyClusterDSChange(String dsName) throws DataSourceException {
	if (log.isDebugEnabled()) {
		log.debug("Notifying cluster DS change: " + dsName);
	}
	ConfigurationContextService configCtxService = DataSourceServiceComponent.
	        getConfigContextService();
	if (configCtxService == null) {
		throw new DataSourceException("ConfigurationContextService not available " +
				"for notifying the cluster");
	}
	ConfigurationContext configCtx = configCtxService.getServerConfigContext();
	ClusteringAgent agent = configCtx.getAxisConfiguration().getClusteringAgent();
	if (log.isDebugEnabled()) {
		log.debug("Clustering Agent: " + agent);
	}
	if (agent != null) {
		DataSourceStatMessage msg = new DataSourceStatMessage();
		msg.setTenantId(this.getTenantId());
		msg.setDsName(dsName);
		try {
			agent.sendMessage(msg, true);
		} catch (ClusteringFault e) {
			throw new DataSourceException("Error in sending out cluster message: " +
					e.getMessage(), e);
		}
	}
}
 
Example #27
Source File: LoadBalancerServiceComponent.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
protected void activate(ComponentContext ctxt) {
    if (log.isDebugEnabled()) {
        log.debug("Activating LoadBalancerServiceComponent...");
    }
    try {
        ClusteringAgent clusteringAgent = ServiceReferenceHolder.getInstance().getAxisConfiguration().getClusteringAgent();
        boolean clusteringEnabled = (clusteringAgent != null);
        if (log.isInfoEnabled()) {
            log.info(String.format("Load balancer clustering is %s", (clusteringEnabled ? "enabled" : "disabled")));
        }

        // Register endpoint deployer
        SynapseEnvironmentService synEnvService = ServiceReferenceHolder.getInstance()
                .getSynapseEnvironmentService(MultitenantConstants.SUPER_TENANT_ID);
        registerDeployer(ServiceReferenceHolder.getInstance().getAxisConfiguration(),
                synEnvService.getSynapseEnvironment());

        // Configure synapse settings
        LoadBalancerConfiguration configuration = LoadBalancerConfiguration.getInstance();
        SynapseConfigurator.configure(configuration);

        // Configure cep settings
        CEPConfigurator.configure(configuration);

        // Configure topology filters
        TopologyFilterConfigurator.configure(configuration);

        TopologyProvider topologyProvider = LoadBalancerConfiguration.getInstance().getTopologyProvider();
        if (topologyProvider == null) {
            topologyProvider = new TopologyProvider();
            LoadBalancerConfiguration.getInstance().setTopologyProvider(topologyProvider);
        }

        if (configuration.isMultiTenancyEnabled() || configuration.isDomainMappingEnabled()) {
            // Start tenant & application signup event receivers
            startTenantEventReceiver();
            startApplicationSignUpEventReceiver(topologyProvider);
        }

        if (configuration.isDomainMappingEnabled()) {
            // Start domain mapping event receiver
            startDomainMappingEventReceiver(topologyProvider);
        }

        if (configuration.isTopologyEventListenerEnabled()) {
            // Start topology receiver
            startTopologyEventReceiver(topologyProvider);
        }

        if (configuration.isCepStatsPublisherEnabled()) {
            // Start statistics notifier
            startStatisticsNotifier(topologyProvider);
        }

        activated = true;
        if (log.isInfoEnabled()) {
            log.info("Load balancer service component is activated ");
        }
    } catch (Exception e) {
        if (log.isFatalEnabled()) {
            log.fatal("Failed to activate load balancer service component", e);
        }
    }
}
 
Example #28
Source File: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
private static ClusteringAgent getClusteringAgent() throws AxisFault {

        AxisConfiguration axisConfig =
                DataHolder.getInstance().getConfigurationContextService().getServerConfigContext().getAxisConfiguration();
        return axisConfig.getClusteringAgent();
    }
 
Example #29
Source File: SampleAxis2ServerManager.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public void start(String[] args) throws Exception {
    String repoLocation = null;
    String confLocation = null;

    CommandLineOptionParser optionsParser = new CommandLineOptionParser(args);
    List invalidOptionsList = optionsParser.getInvalidOptions(new OptionsValidator() {
        public boolean isInvalid(CommandLineOption option) {
            String optionType = option.getOptionType();
            return !("repo".equalsIgnoreCase(optionType) || "conf"
                .equalsIgnoreCase(optionType));
        }
    });

    if ((invalidOptionsList.size() > 0) || (args.length > 4)) {
        printUsage();
    }

    Map optionsMap = optionsParser.getAllOptions();

    CommandLineOption repoOption = (CommandLineOption) optionsMap
        .get("repo");
    CommandLineOption confOption = (CommandLineOption) optionsMap
        .get("conf");

    log.info("[SimpleAxisServer] Starting");
    if (repoOption != null) {
        repoLocation = repoOption.getOptionValue();
        System.out.println("[SimpleAxisServer] Using the Axis2 Repository : "
            + new File(repoLocation).getAbsolutePath());
    }
    if (confOption != null) {
        confLocation = confOption.getOptionValue();
        System.out
            .println("[SimpleAxisServer] Using the Axis2 Configuration File : "
                + new File(confLocation).getAbsolutePath());
    }
    try {
        configctx = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(repoLocation,
                confLocation);

        configurePort(configctx);

        // Need to initialize the cluster manager at last since we are changing the servers
        // HTTP/S ports above. In the axis2.xml file, we need to set the "AvoidInitiation" param
        // to "true"
        ClusteringAgent clusteringAgent =
                configctx.getAxisConfiguration().getClusteringAgent();
        if(clusteringAgent != null) {
            clusteringAgent.setConfigurationContext(configctx);
            clusteringAgent.init();
        }

        // Finally start the transport listeners
        listenerManager = new ListenerManager();
        listenerManager.init(configctx);
        listenerManager.start();
        log.info("[SimpleAxisServer] Started");
    } catch (Throwable t) {
        log.fatal("[SimpleAxisServer] Shutting down. Error starting SimpleAxisServer", t);
        System.exit(1); // must stop application
    }
}
 
Example #30
Source File: SampleAxis2ServerManager.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public void start(String[] args) throws Exception {
    String repoLocation = null;
    String confLocation = null;

    CommandLineOptionParser optionsParser = new CommandLineOptionParser(args);
    List invalidOptionsList = optionsParser.getInvalidOptions(new OptionsValidator() {
        public boolean isInvalid(CommandLineOption option) {
            String optionType = option.getOptionType();
            return !("repo".equalsIgnoreCase(optionType) || "conf"
                .equalsIgnoreCase(optionType));
        }
    });

    if ((invalidOptionsList.size() > 0) || (args.length > 4)) {
        printUsage();
    }

    Map optionsMap = optionsParser.getAllOptions();

    CommandLineOption repoOption = (CommandLineOption) optionsMap
        .get("repo");
    CommandLineOption confOption = (CommandLineOption) optionsMap
        .get("conf");

    log.info("[SimpleAxisServer] Starting");
    if (repoOption != null) {
        repoLocation = repoOption.getOptionValue();
        System.out.println("[SimpleAxisServer] Using the Axis2 Repository : "
            + new File(repoLocation).getAbsolutePath());
    }
    if (confOption != null) {
        confLocation = confOption.getOptionValue();
        System.out
            .println("[SimpleAxisServer] Using the Axis2 Configuration File : "
                + new File(confLocation).getAbsolutePath());
    }
    try {
        configctx = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(repoLocation,
                confLocation);

        configurePort(configctx);

        // Need to initialize the cluster manager at last since we are changing the servers
        // HTTP/S ports above. In the axis2.xml file, we need to set the "AvoidInitiation" param
        // to "true"
        ClusteringAgent clusteringAgent =
                configctx.getAxisConfiguration().getClusteringAgent();
        if(clusteringAgent != null) {
            clusteringAgent.setConfigurationContext(configctx);
            clusteringAgent.init();
        }

        // Finally start the transport listeners
        listenerManager = new ListenerManager();
        listenerManager.init(configctx);
        listenerManager.start();
        log.info("[SimpleAxisServer] Started");
    } catch (Throwable t) {
        log.fatal("[SimpleAxisServer] Shutting down. Error starting SimpleAxisServer", t);
        System.exit(1); // must stop application
    }
}