@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"); }
public SessionInformation getSession(MessageContext synCtx) { return SALSessions.getInstance().getSession( extractSessionID(synCtx.getEnvelope().getHeader(), CSID_QNAME)); }
/** * Searches for "Set-Cookie" HTTP header in the message context. If found and that given * session ID is not already in the session map update the session map by mapping the cookie * to the endpoint. * * @param synCtx MessageContext possibly containing the "Set-Cookie" HTTP header. */ public void updateSession(MessageContext synCtx) { String sessionId = extractSessionID(synCtx, SET_COOKIE); if (sessionId != null) { if (log.isDebugEnabled()) { log.debug("Found the HTTP header 'Set-Cookie: " + sessionId + "' for updating the session"); log.debug("Using the session id '" + sessionId + "' extracted from the Set-Cookie header "); } SALSessions.getInstance().updateSession(synCtx, sessionId); } }
public List<Endpoint> getEndpoints(SessionInformation sessionInformation) { return SALSessions.getInstance().getChildEndpoints(sessionInformation); }
public void unbind(MessageContext synCtx) { SALSessions.getInstance().removeSession(extractSessionID(synCtx, COOKIE)); }
@Override public void applicationMemberRemoved(Member member) { // remove the sessions bound with this member SALSessions.getInstance().removeSessionsOfMember(member); String subDomain = member.getProperties().getProperty("subDomain"); if ((subDomain == null && Constants.DEFAULT_SUB_DOMAIN.equals(this.subDomain)) || subDomain.equals(this.subDomain)) { super.applicationMemberRemoved(member); } } }
/** * 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()); }
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.getInstance().reset(); DataSourceRepositoryHolder.getInstance().getDataSourceRepositoryManager().clear(); } catch (Throwable ignored) {}
SALSessions.getInstance().clearSessions();
String oldSessionID = oldSession.getId(); if (!sessionId.equals(oldSessionID) && pathMatches(path, oldSession.getPath())) { removeSession(oldSessionID); endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); SessionInformation information = getSessionInformation(oldSessionID); if (information == null) { newInformation = createSessionInformation(synCtx, sessionId, endpoints, paths); } else { newInformation = createSessionInformation(synCtx, sessionId, currentMember, paths);
oldSessionID + " new session id :" + sessionID); removeSession(oldSessionID); endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); SessionInformation information = getSessionInformation(oldSessionID); if (information == null) { SessionInformation newInformation; if(currentMember == null){ newInformation = createSessionInformation(synCtx, sessionID, endpoints); } else { newInformation = createSessionInformation(synCtx, sessionID, currentMember);
/** * 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()); }
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 unbind(MessageContext synCtx) { SALSessions.getInstance().removeSession(extractSessionID(synCtx, COOKIE)); }
public List<Endpoint> getEndpoints(SessionInformation sessionInformation) { return SALSessions.getInstance().getChildEndpoints(sessionInformation); }
SALSessions.getInstance().reset(); DataSourceRepositoryHolder.getInstance().getDataSourceRepositoryManager().clear(); } catch (Throwable ignored) {
private void processCallbacks() { SALSessions.getInstance().clearSessions();
oldSessionID + " new session id :" + sessionID); removeSession(oldSessionID); endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); SessionInformation information = getSessionInformation(oldSessionID); if (information == null) { SessionInformation newInformation; if(currentMember == null){ newInformation = createSessionInformation(synCtx, sessionID, endpoints); } else { newInformation = createSessionInformation(synCtx, sessionID, currentMember, null);
/** * 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()); }