/** * Returns endpoint sequence related to the given session * * @param information Session information * @return endpoint sequence */ public List<Endpoint> getChildEndpoints(SessionInformation information) { List<Endpoint> endpoints; if (isClustered) { endpoints = getEndpoints(information.getPath(), information.getRootEndpointName()); } else { endpoints = information.getEndpointList(); } if (log.isDebugEnabled()) { log.debug("Retrieving endpoint sequence : " + endpoints + " for session " + information.getId()); } if (endpoints == null || endpoints.isEmpty()) { handleException("Session with id " + information.getId() + " is invalid ." + " A session must have a endpoint sequence associated with it"); } List<Endpoint> toBeSent = new ArrayList<Endpoint>(); toBeSent.addAll(endpoints); //remove the root as only expect children toBeSent.remove(0); return toBeSent; }
SessionInformation information = new SessionInformation(id, endpoints, expiryTime); information.setPath(paths); information.setRootEndpointName(getEndpointName(rootEndpoint));
} else { String oldSessionID = oldSession.getId(); if (!sessionID.equals(oldSessionID)) { endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); createSession = true; log.debug("Recovering lost session information for session id " + sessionID); endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); createSession = true; } else {
/** * Updates sessions corresponds to a particular member from the {@link #establishedSessions} * @param member subjected {@link Member} */ public void removeSessionsOfMember(Member member){ for (Iterator<SessionInformation> iterator = establishedSessions.values().iterator(); iterator.hasNext();) { SessionInformation info = iterator.next(); if (member.equals(info.getMember())) { //We don't want to lose sessions of this member. So we merely set the member to null and //put it back to establishedSessions so that those can be used later. info.setMember(null); iterator.remove(); establishedSessions.put(info.getId(),info); log.debug("Session associated with member " + member.toString() + " is updated ; session id : " + info.getId()); } } }
SessionInformation info = (SessionInformation) configCtx.getProperty(key); if (info != null && info.isExpired()) { if (log.isDebugEnabled()) { log.debug("Clustered Environment :" + for (SessionInformation information : establishedSessions.values()) { if (information != null && information.isExpired()) { String id = information.getId(); if (log.isDebugEnabled()) { log.debug("Expired session with id :" + id);
log.debug("Current session id : " + sessionInformation.getId()); currentMember = sessionInformation.getMember(); synCtx.setProperty( SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_MEMBER, currentMember); if (sessionInformation != null && currentMember != null) { sessionInformation.updateExpiryTime(); sendToApplicationMember(synCtx, currentMember, faultHandler, false); } else {
salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000); List<String> path = new ArrayList<>(); path.add("samplePath"); oldSessionInfo.setPath(path); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); SessionCookie sessionCookie = new SessionCookie(); Assert.assertEquals("Session not updated!", "testCookie2", sessionInformation.getId());
String oldSessionID = oldSession.getId(); if (!sessionId.equals(oldSessionID) && pathMatches(path, oldSession.getPath())) { endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); createSession = true; log.debug("Recovering lost session information for session id " + sessionId); endpoints = oldSession.getEndpointList(); currentMember = oldSession.getMember(); createSession = true; } else {
/** * 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()); }
for (String sessionID : sessionList) { SessionInformation sessionInfoObj = SALSessions.getInstance().getSession(sessionID); if (sessionInfoObj != null && sessionInfoObj.getMember() != null) { Map<String, String> subDomainNames = (Map<String, String>) sessionInfoObj.getMember().getProperties().get(HOSTS); if (log.isDebugEnabled()) { log.debug("Member Domain : " + (subDomainNames != null ? subDomainNames.get(hostName) : null) + && sessionInfoObj.getMember() == null) { log.debug("sessionInfo object[" + sessionInfoObj.getId()+ "] found with a null member. " + "Looks like this is attached to a failed member.");
SessionInformation sessionInformation = new SessionInformation(id, currentMember, expiryTime, expireTimeWindow); if (paths != null) { sessionInformation.setPath(paths);
SessionInformation information = new SessionInformation(id, currentMember, expiryTime, expireTimeWindow); information.setRootEndpointName(getEndpointName(rootEndpoint));
for (String sessionID : sessionList) { SessionInformation sessionInfoObj = SALSessions.getInstance().getSession(sessionID); if (sessionInfoObj != null && sessionInfoObj.getMember() != null) { Map<String, String> subDomainNames = (Map<String, String>) sessionInfoObj.getMember().getProperties().get(HOSTS); if (log.isDebugEnabled()) { log.debug("Member Domain : " + (subDomainNames != null ? subDomainNames.get(hostName) : null) +
if (information.isExpired()) { if (log.isDebugEnabled()) { log.debug("Session has been expired for session with id: " + sessionID);
log.debug("Current session id : " + sessionInformation.getId()); currentMember = sessionInformation.getMember(); synCtx.setProperty( SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_MEMBER, currentMember); if (sessionInformation != null && currentMember != null) { sessionInformation.updateExpiryTime(); sendToApplicationMember(synCtx, currentMember, faultHandler, false); } else {
salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("testCookie3", endpoints, 30000); List<String> path = new ArrayList<>(); path.add("samplePath"); oldSessionInfo.setPath(path); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); SessionCookie sessionCookie = new SessionCookie(); Assert.assertEquals("Session not updated!", "testCookie3", 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()); }
SessionInformation info = (SessionInformation) configCtx.getProperty(key); if (info != null && info.isExpired()) { if (log.isDebugEnabled()) { log.debug("Clustered Environment :" + for (SessionInformation information : establishedSessions.values()) { if (information != null && information.isExpired()) { String id = information.getId(); if (log.isDebugEnabled()) { log.debug("Expired session with id :" + id);