@Override public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { super.init(synapseEnvironment); if (algorithmContext == null) { algorithmContext = new AlgorithmContext(isClusteringEnabled, cc, getName()); } // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cc); } } log.info("Dynamic load balance endpoint initialized"); }
@Override public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { super.init(synapseEnvironment); if (algorithmContext == null) { algorithmContext = new AlgorithmContext(isClusteringEnabled, cc, getName()); } // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cc); } } log.info("Dynamic load balance endpoint initialized"); }
@Override public void init(SynapseEnvironment synapseEnvironment) { if (!initialized) { super.init(synapseEnvironment); ConfigurationContext cfgCtx = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); ClusteringAgent clusteringAgent = cfgCtx.getAxisConfiguration().getClusteringAgent(); if (clusteringAgent == null) { throw new SynapseException("Axis2 ClusteringAgent not defined in axis2.xml"); } // Add the Axis2 GroupManagement agents for (String domain : hostDomainMap.values()) { if (clusteringAgent.getGroupManagementAgent(domain) == null) { clusteringAgent.addGroupManagementAgent(new DefaultGroupManagementAgent(), domain); } } slbMembershipHandler = new ServiceLoadBalanceMembershipHandler(hostDomainMap, getAlgorithm(), cfgCtx, isClusteringEnabled, getName()); // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cfgCtx); } initialized = true; log.info("ServiceDynamicLoadbalanceEndpoint initialized"); } }
@Override public void init(SynapseEnvironment synapseEnvironment) { if (!initialized) { super.init(synapseEnvironment); ConfigurationContext cfgCtx = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); ClusteringAgent clusteringAgent = cfgCtx.getAxisConfiguration().getClusteringAgent(); if (clusteringAgent == null) { throw new SynapseException("Axis2 ClusteringAgent not defined in axis2.xml"); } // Add the Axis2 GroupManagement agents for (String domain : hostDomainMap.values()) { if (clusteringAgent.getGroupManagementAgent(domain) == null) { clusteringAgent.addGroupManagementAgent(new DefaultGroupManagementAgent(), domain); } } slbMembershipHandler = new ServiceLoadBalanceMembershipHandler(hostDomainMap, getAlgorithm(), cfgCtx, isClusteringEnabled, getName()); // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cfgCtx); } initialized = true; log.info("ServiceDynamicLoadbalanceEndpoint initialized"); } }
public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { super.init(synapseEnvironment); // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cc); } //For each root level SAL endpoints , all children are registered // This is for cluttering as in clustering only endpoint names are replicated // and it needs way to pick endpoints by name if (isClusteringEnabled && (this.getParentEndpoint() == null || !(this.getParentEndpoint() instanceof SALoadbalanceEndpoint))) { SALSessions.getInstance().registerChildren(this, getChildren()); } } }
public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { super.init(synapseEnvironment); // Initialize the SAL Sessions if already has not been initialized. SALSessions salSessions = SALSessions.getInstance(); if (!salSessions.isInitialized()) { salSessions.initialize(isClusteringEnabled, cc); } //For each root level SAL endpoints , all children are registered // This is for cluttering as in clustering only endpoint names are replicated // and it needs way to pick endpoints by name if (isClusteringEnabled && (this.getParentEndpoint() == null || !(this.getParentEndpoint() instanceof SALoadbalanceEndpoint))) { SALSessions.getInstance().registerChildren(this, getChildren()); } } }
salSessions.initialize(isClusteringEnabled, cfgCtx);
salSessions.initialize(false, cfgCtx);
/** * Test updating session with session id * * @throws Exception */ @Test public void testUpdateWithId() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); salSessions.updateSession(messageContext, "testSession"); SessionInformation sessionInformation = salSessions.getSession("testSession"); Assert.assertEquals("Session not updated!", "testSession", sessionInformation.getId()); }
/** * Test updating session with session id and old session * * @throws Exception */ @Test public void testUpdateWithOldSession() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession2"); SessionInformation sessionInformation = salSessions.getSession("testSession2"); Assert.assertEquals("Session not updated!", "testSession2", sessionInformation.getId()); }
salSessions.initialize(false, cfgCtx);
/** * Test updating session with session id and old session where the old session id is same as current session id * * @throws Exception */ @Test public void testUpdateWithOldSessionSameName() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("testSession3", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession3"); SessionInformation sessionInformation = salSessions.getSession("testSession3"); Assert.assertEquals("Session not updated!", "testSession3", sessionInformation.getId()); }
/** * Test updating session with cookie * * @throws Exception */ @Test public void testUpdateWithCookie() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionCookie sessionCookie = new SessionCookie(); sessionCookie.setSessionId("testCookie"); salSessions.updateSession(messageContext, sessionCookie); SessionInformation sessionInformation = salSessions.getSession("testCookie"); Assert.assertEquals("Session not updated!", "testCookie", sessionInformation.getId()); }