Increase Session Expiration Event capture timeout by 5 seconds.
Polish code; edit Javadoc.
This commit is contained in:
@@ -105,7 +105,6 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
System.setProperty("gemfire.Query.VERBOSE", String.valueOf(isQueryDebuggingEnabled()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String buildClassPathContainingJarFiles(String... jarFilenames) {
|
||||
|
||||
StringBuilder classpath = new StringBuilder();
|
||||
@@ -123,7 +122,6 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return classpath.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static Optional<URL> findClassInFileSystem(Class<?> type) {
|
||||
|
||||
return Optional.ofNullable(type)
|
||||
@@ -131,18 +129,15 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
.map(resourceName -> type.getClassLoader().getResource(resourceName));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static Optional<String> findJarInClasspath(String jarFilename) {
|
||||
return stream(nullSafeArray(System.getProperty("java.class.path").split(File.pathSeparator), String.class))
|
||||
.filter(element -> element.contains(jarFilename)).findFirst();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static String getResourceName(Class<?> type) {
|
||||
return type.getName().replaceAll("\\.", "/").concat(".class");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static File createDirectory(String pathname) {
|
||||
|
||||
File directory = new File(WORKING_DIRECTORY, pathname);
|
||||
@@ -155,12 +150,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return directory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static List<String> createJavaProcessCommandLine(Class<?> type, String... args) {
|
||||
return createJavaProcessCommandLine(System.getProperty("java.class.path"), type, args);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static List<String> createJavaProcessCommandLine(String classpath, Class<?> type, String... args) {
|
||||
|
||||
List<String> commandLine = new ArrayList<>();
|
||||
@@ -185,12 +178,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return commandLine;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static List<String> extractJvmArguments(String... args) {
|
||||
return stream(args).filter(arg -> arg.startsWith("-")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static List<String> extractProgramArguments(String... args) {
|
||||
return stream(args).filter(arg -> !arg.startsWith("-")).collect(Collectors.toList());
|
||||
}
|
||||
@@ -234,33 +225,27 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return run(createJavaProcessCommandLine(resolveClasspath(classpath, type), type, args), directory);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static Process run(List<String> command, File directory) throws IOException {
|
||||
return new ProcessBuilder().command(command).directory(directory).inheritIO().redirectErrorStream(true).start();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static void unregisterAllDataSerializers() {
|
||||
stream(nullSafeArray(InternalDataSerializer.getSerializers(), DataSerializer.class))
|
||||
.map(DataSerializer::getId).forEach(InternalDataSerializer::unregister);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer) {
|
||||
return waitForCacheServerToStart(cacheServer, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer, long duration) {
|
||||
return waitForCacheServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), duration);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(String host, int port) {
|
||||
return waitForCacheServerToStart(host, port, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(final String host, final int port, long duration) {
|
||||
|
||||
return waitOnCondition(new Condition() {
|
||||
@@ -291,12 +276,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
// NOTE this method would not be necessary except Spring Sessions' build does not fork
|
||||
// the test JVM
|
||||
// for every test class.
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForClientCacheToClose() {
|
||||
return waitForClientCacheToClose(DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForClientCacheToClose(long duration) {
|
||||
|
||||
try {
|
||||
@@ -314,12 +297,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForProcessToStart(Process process, File directory) {
|
||||
return waitForProcessToStart(process, directory, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
protected static boolean waitForProcessToStart(Process process, File directory, long duration) {
|
||||
|
||||
@@ -334,12 +315,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return process.isAlive();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int waitForProcessToStop(Process process, File directory) {
|
||||
return waitForProcessToStop(process, directory, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int waitForProcessToStop(Process process, File directory, long duration) {
|
||||
|
||||
long timeout = (System.currentTimeMillis() + duration);
|
||||
@@ -358,12 +337,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return (process.isAlive() ? -1 : process.exitValue());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitOnCondition(Condition condition) {
|
||||
return waitOnCondition(condition, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
protected static boolean waitOnCondition(Condition condition, long duration) {
|
||||
|
||||
@@ -383,7 +360,6 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return condition.evaluate();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
protected static File writeProcessControlFile(File path) throws IOException {
|
||||
|
||||
@@ -398,14 +374,12 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return processControl;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertValidSession(Session session) {
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getId()).isNotEmpty();
|
||||
assertThat(session.isExpired()).isFalse();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertRegion(Region<?, ?> actualRegion, String expectedName, DataPolicy expectedDataPolicy) {
|
||||
assertThat(actualRegion).isNotNull();
|
||||
assertThat(actualRegion.getName()).isEqualTo(expectedName);
|
||||
@@ -414,19 +388,16 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
assertThat(actualRegion.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertIndex(Index index, String expectedExpression, String expectedFromClause) {
|
||||
assertThat(index).isNotNull();
|
||||
assertThat(index.getIndexedExpression()).isEqualTo(expectedExpression);
|
||||
assertThat(index.getFromClause()).isEqualTo(expectedFromClause);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertEntryIdleTimeout(Region<?, ?> region, ExpirationAction expectedAction, int expectedTimeout) {
|
||||
assertEntryIdleTimeout(region.getAttributes().getEntryIdleTimeout(), expectedAction, expectedTimeout);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertEntryIdleTimeout(ExpirationAttributes actualExpirationAttributes,
|
||||
ExpirationAction expectedAction, int expectedTimeout) {
|
||||
|
||||
@@ -435,22 +406,18 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
assertThat(actualExpirationAttributes.getTimeout()).isEqualTo(expectedTimeout);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected boolean enableQueryDebugging() {
|
||||
return DEFAULT_ENABLE_QUERY_DEBUGGING;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected boolean isQueryDebuggingEnabled() {
|
||||
return (GEMFIRE_QUERY_DEBUG || enableQueryDebugging());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected List<String> listRegions(GemFireCache gemfireCache) {
|
||||
return gemfireCache.rootRegions().stream().map(Region::getFullPath).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Session> T createSession() {
|
||||
|
||||
@@ -461,7 +428,6 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Session> T createSession(String principalName) {
|
||||
|
||||
@@ -472,32 +438,27 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return (T) session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
protected <T extends Session> T delete(T session) {
|
||||
this.gemfireSessionRepository.delete(session);
|
||||
return session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected <T extends Session> T expire(T session) {
|
||||
session.setLastAccessedTime(Instant.ofEpochMilli(0L));
|
||||
return session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Session> T get(String sessionId) {
|
||||
return (T) this.gemfireSessionRepository.findById(sessionId);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected <T extends Session> T save(T session) {
|
||||
this.gemfireSessionRepository.save(session);
|
||||
return session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected <T extends Session> T touch(T session) {
|
||||
session.setLastAccessedTime(Instant.now());
|
||||
return session;
|
||||
@@ -514,7 +475,6 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
|
||||
private volatile AbstractSessionEvent sessionEvent;
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends AbstractSessionEvent> T getSessionEvent() {
|
||||
|
||||
@@ -525,12 +485,10 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
return sessionEvent;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void onApplicationEvent(AbstractSessionEvent event) {
|
||||
this.sessionEvent = event;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public <T extends AbstractSessionEvent> T waitForSessionEvent(long duration) {
|
||||
|
||||
waitOnCondition(() -> (SessionEventListener.this.sessionEvent != null), duration);
|
||||
|
||||
@@ -65,6 +65,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
/**
|
||||
@@ -227,10 +228,13 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
|
||||
assertThat(savedSession).isEqualTo(expectedSession);
|
||||
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(
|
||||
TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 1));
|
||||
sessionEvent = this.sessionEventListener
|
||||
.waitForSessionEvent(TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 5));
|
||||
|
||||
assertThat(sessionEvent)
|
||||
.describedAs("SessionEvent was type [%s]", ObjectUtils.nullSafeClassName(sessionEvent))
|
||||
.isInstanceOf(SessionExpiredEvent.class);
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionExpiredEvent.class);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSession.getId());
|
||||
|
||||
Session expiredSession = this.gemfireSessionRepository.findById(expectedSession.getId());
|
||||
@@ -304,8 +308,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
@CacheServerApplication(name = "ClientServerGemFireOperationsSessionRepositoryIntegrationTests",
|
||||
logLevel = "warning")
|
||||
@CacheServerApplication(name = "ClientServerGemFireOperationsSessionRepositoryIntegrationTests", logLevel = "warning")
|
||||
@EnableGemFireHttpSession(regionName = TEST_SESSION_REGION_NAME,
|
||||
maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS)
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
|
||||
|
||||
// EXPIRE
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(
|
||||
TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 1));
|
||||
TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 5));
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionExpiredEvent.class);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(session.getId());
|
||||
|
||||
@@ -186,7 +186,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
|
||||
this.sessionEventListener.getSessionEvent();
|
||||
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(
|
||||
TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 1));
|
||||
TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 5));
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionExpiredEvent.class);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSession.getId());
|
||||
|
||||
@@ -299,27 +299,22 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
region.getAttributesMutator().addCacheListener(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
boolean isCreate(EntryEvent<?, ?> event) {
|
||||
return isCreate(event.getOperation()) && isNotUpdate(event) && isSession(event.getNewValue());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isCreate(Operation operation) {
|
||||
return operation.isCreate() && !Operation.LOCAL_LOAD_CREATE.equals(operation);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isNotUpdate(EntryEvent event) {
|
||||
return isNotProxyRegion() || !this.cachedSessionIds.contains(ObjectUtils.nullSafeHashCode(event.getKey()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isNotProxyRegion() {
|
||||
return !isProxyRegion();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isProxyRegion() {
|
||||
return GemFireUtils.isProxy(((GemfireAccessor) getTemplate()).getRegion());
|
||||
}
|
||||
@@ -517,22 +512,18 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
publishEvent(newSessionExpiredEvent(session));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private SessionCreatedEvent newSessionCreatedEvent(Session session) {
|
||||
return new SessionCreatedEvent(this, session);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private SessionDeletedEvent newSessionDeletedEvent(Session session) {
|
||||
return new SessionDeletedEvent(this, session);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private SessionDestroyedEvent newSessionDestroyedEvent(Session session) {
|
||||
return new SessionDestroyedEvent(this, session);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private SessionExpiredEvent newSessionExpiredEvent(Session session) {
|
||||
return new SessionExpiredEvent(this, session);
|
||||
}
|
||||
@@ -588,7 +579,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return new DeltaCapableGemFireSessionAttributes();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void toDelta(DataOutput out) throws IOException {
|
||||
|
||||
out.writeUTF(getId());
|
||||
@@ -598,7 +588,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
clearDelta();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void fromDelta(DataInput in) throws IOException {
|
||||
|
||||
setId(in.readUTF());
|
||||
@@ -636,19 +625,16 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
|
||||
private transient final T sessionAttributes = newSessionAttributes(this);
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected GemFireSession() {
|
||||
this(generateId());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected GemFireSession(String id) {
|
||||
this.id = validateId(id);
|
||||
this.creationTime = Instant.now();
|
||||
this.lastAccessedTime = this.creationTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected GemFireSession(Session session) {
|
||||
|
||||
Assert.notNull(session, "The Session to copy cannot be null");
|
||||
@@ -660,17 +646,14 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
this.sessionAttributes.from(session);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GemFireSession copy(Session session) {
|
||||
return (isUsingDataSerialization() ? new DeltaCapableGemFireSession(session) : new GemFireSession(session));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GemFireSession create() {
|
||||
return create(DEFAULT_MAX_INACTIVE_INTERVAL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GemFireSession create(Duration maxInactiveInterval) {
|
||||
|
||||
GemFireSession session =
|
||||
@@ -681,7 +664,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return session;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends GemFireSession> T from(Session session) {
|
||||
return (T) (session instanceof GemFireSession ? (GemFireSession) session : copy(session));
|
||||
@@ -697,7 +679,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private static String validateId(String id) {
|
||||
return Optional.ofNullable(id).filter(StringUtils::hasText)
|
||||
.orElseThrow(() -> newIllegalArgumentException("ID is required"));
|
||||
@@ -708,7 +689,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return (T) new GemFireSessionAttributes(lock);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public synchronized String changeSessionId() {
|
||||
|
||||
@@ -719,23 +699,19 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return getId();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void clearDelta() {
|
||||
this.delta = false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized boolean hasDelta() {
|
||||
return (this.delta || this.sessionAttributes.hasDelta());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unused")
|
||||
protected void triggerDelta() {
|
||||
triggerDelta(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected synchronized void triggerDelta(boolean condition) {
|
||||
this.delta |= condition;
|
||||
}
|
||||
@@ -744,42 +720,34 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
this.id = validateId(id);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void setAttribute(String attributeName, Object attributeValue) {
|
||||
this.sessionAttributes.setAttribute(attributeName, attributeValue);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void removeAttribute(String attributeName) {
|
||||
this.sessionAttributes.removeAttribute(attributeName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public <T> T getAttribute(String attributeName) {
|
||||
return this.sessionAttributes.getAttribute(attributeName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public Set<String> getAttributeNames() {
|
||||
return this.sessionAttributes.getAttributeNames();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public T getAttributes() {
|
||||
return this.sessionAttributes;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized Instant getCreationTime() {
|
||||
return this.creationTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized boolean isExpired() {
|
||||
|
||||
Instant lastAccessedTime = getLastAccessedTime();
|
||||
@@ -790,44 +758,36 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
&& Instant.now().minus(maxInactiveInterval).isAfter(lastAccessedTime));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isExpirationDisabled(Duration duration) {
|
||||
return (duration == null || duration.isNegative() || duration.isZero());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isExpirationEnabled(Duration duration) {
|
||||
return !isExpirationDisabled(duration);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void setLastAccessedTime(Instant lastAccessedTime) {
|
||||
triggerDelta(!ObjectUtils.nullSafeEquals(this.lastAccessedTime, lastAccessedTime));
|
||||
this.lastAccessedTime = lastAccessedTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized Instant getLastAccessedTime() {
|
||||
return this.lastAccessedTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void setMaxInactiveInterval(Duration maxInactiveIntervalInSeconds) {
|
||||
triggerDelta(!ObjectUtils.nullSafeEquals(this.maxInactiveInterval, maxInactiveIntervalInSeconds));
|
||||
this.maxInactiveInterval = maxInactiveIntervalInSeconds;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized Duration getMaxInactiveInterval() {
|
||||
return Optional.ofNullable(this.maxInactiveInterval).orElse(DEFAULT_MAX_INACTIVE_INTERVAL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized void setPrincipalName(String principalName) {
|
||||
setAttribute(PRINCIPAL_NAME_INDEX_NAME, principalName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public synchronized String getPrincipalName() {
|
||||
|
||||
String principalName = getAttribute(PRINCIPAL_NAME_INDEX_NAME);
|
||||
@@ -847,13 +807,11 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return principalName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
public int compareTo(Session session) {
|
||||
return getCreationTime().compareTo(session.getCreationTime());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
|
||||
@@ -870,7 +828,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return this.getId().equals(that.getId());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
@@ -881,7 +838,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public synchronized String toString() {
|
||||
|
||||
@@ -897,14 +853,12 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
|
||||
private transient final Map<String, Object> sessionAttributeDeltas = new HashMap<>();
|
||||
|
||||
public DeltaCapableGemFireSessionAttributes() {
|
||||
}
|
||||
public DeltaCapableGemFireSessionAttributes() { }
|
||||
|
||||
public DeltaCapableGemFireSessionAttributes(Object lock) {
|
||||
super(lock);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public Object setAttribute(String attributeName, Object attributeValue) {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -925,7 +879,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public Object removeAttribute(String attributeName) {
|
||||
|
||||
@@ -940,7 +893,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void toDelta(DataOutput out) throws IOException {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -956,12 +908,10 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void writeObject(Object value, DataOutput out) throws IOException {
|
||||
DataSerializer.writeObject(value, out);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public boolean hasDelta() {
|
||||
|
||||
@@ -970,7 +920,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void fromDelta(DataInput in) throws InvalidDeltaException, IOException {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -994,12 +943,10 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected <T> T readObject(DataInput in) throws ClassNotFoundException, IOException {
|
||||
return DataSerializer.readObject(in);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public void clearDelta() {
|
||||
|
||||
@@ -1028,32 +975,26 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
|
||||
private transient final Object lock;
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected GemFireSessionAttributes() {
|
||||
this.lock = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected GemFireSessionAttributes(Object lock) {
|
||||
this.lock = (lock != null ? lock : this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GemFireSessionAttributes create() {
|
||||
return new GemFireSessionAttributes();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GemFireSessionAttributes create(Object lock) {
|
||||
return new GemFireSessionAttributes(lock);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected Object getLock() {
|
||||
return this.lock;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public Object setAttribute(String attributeName, Object attributeValue) {
|
||||
synchronized (getLock()) {
|
||||
return (attributeValue != null ? this.sessionAttributes.put(attributeName, attributeValue)
|
||||
@@ -1061,14 +1002,12 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public Object removeAttribute(String attributeName) {
|
||||
synchronized (getLock()) {
|
||||
return this.sessionAttributes.remove(attributeName);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getAttribute(String attributeName) {
|
||||
synchronized (getLock()) {
|
||||
@@ -1076,14 +1015,12 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public Set<String> getAttributeNames() {
|
||||
synchronized (getLock()) {
|
||||
return Collections.unmodifiableSet(new HashSet<>(this.sessionAttributes.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc); NOTE: entrySet implementation is not Thread-safe. */
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Set<Entry<String, Object>> entrySet() {
|
||||
@@ -1103,11 +1040,9 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
};
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void clearDelta() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void from(Session session) {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -1116,7 +1051,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void from(Map<String, Object> map) {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -1124,7 +1058,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public void from(GemFireSessionAttributes sessionAttributes) {
|
||||
|
||||
synchronized (getLock()) {
|
||||
@@ -1133,7 +1066,6 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public boolean hasDelta() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user