Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-12-17 16:08:13 +0000
committerJan Bartel2014-12-17 16:08:13 +0000
commit5e8e0b11f5c88a0539e0cbec5078f4c0f1fa09ee (patch)
tree5221cdfbce2dc872b6c4e329057a0443e0aeed08
parent89a9aa2472a71b1a19659f0bae2e55ca76717491 (diff)
downloadorg.eclipse.jetty.project-5e8e0b11f5c88a0539e0cbec5078f4c0f1fa09ee.tar.gz
org.eclipse.jetty.project-5e8e0b11f5c88a0539e0cbec5078f4c0f1fa09ee.tar.xz
org.eclipse.jetty.project-5e8e0b11f5c88a0539e0cbec5078f4c0f1fa09ee.zip
455476 MongoSessionManager sessions always expire at create + maxIdle
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java5
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java18
2 files changed, 16 insertions, 7 deletions
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
index 18d44061c3..e517f8aab6 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
@@ -259,6 +259,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
*/
protected void purge()
{
+ __log.debug("PURGING");
BasicDBObject invalidQuery = new BasicDBObject();
invalidQuery.put(MongoSessionManager.__ACCESSED, new BasicDBObject("$lt",System.currentTimeMillis() - _purgeInvalidAge));
@@ -432,6 +433,8 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
_scavengerTask = _scheduler.schedule(new Scavenger(), _scavengePeriod, TimeUnit.MILLISECONDS);
}
+ else if (__log.isDebugEnabled())
+ __log.debug("Scavenger disabled");
//if purging is enabled, setup the purge thread
@@ -444,6 +447,8 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
}
_purgerTask = _scheduler.schedule(new Purger(), _purgeDelay, TimeUnit.MILLISECONDS);
}
+ else if (__log.isDebugEnabled())
+ __log.debug("Purger disabled");
}
}
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
index 48fd1c2f00..3daa0a0d90 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
@@ -42,6 +42,8 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.MongoException;
+import com.mongodb.WriteConcern;
+import com.mongodb.WriteResult;
/**
@@ -268,7 +270,7 @@ public class MongoSessionManager extends NoSqlSessionManager
Long currentExpiry = (Long)o.get(__EXPIRY);
if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle)
sets.put(__MAX_IDLE, getMaxInactiveInterval());
- if (currentExpiry != null && expiry > 0 && expiry < currentExpiry)
+ if (currentExpiry != null && expiry > 0 && expiry != currentExpiry)
sets.put(__EXPIRY, currentExpiry);
}
}
@@ -302,9 +304,11 @@ public class MongoSessionManager extends NoSqlSessionManager
if (!unsets.isEmpty())
update.put("$unset",unsets);
- _dbSessions.update(key,update,upsert,false);
- __log.debug("MongoSessionManager:save:db.sessions.update( {}, {}, true) ", key, update);
+ _dbSessions.update(key,update,upsert,false,WriteConcern.SAFE);
+ if (__log.isDebugEnabled())
+ __log.debug("MongoSessionManager:save:db.sessions.update( {}, {} )", key, update);
+
if (activateAfterSave)
session.didActivate();
@@ -421,7 +425,7 @@ public class MongoSessionManager extends NoSqlSessionManager
update.put("$set",sets);
}
- _dbSessions.update(key,update,false,false);
+ _dbSessions.update(key,update,false,false,WriteConcern.SAFE);
session.didActivate();
@@ -520,7 +524,7 @@ public class MongoSessionManager extends NoSqlSessionManager
BasicDBObject unsets = new BasicDBObject();
unsets.put(getContextKey(),1);
remove.put("$unset",unsets);
- _dbSessions.update(key,remove);
+ _dbSessions.update(key,remove,false,false,WriteConcern.SAFE);
return true;
}
@@ -556,7 +560,7 @@ public class MongoSessionManager extends NoSqlSessionManager
update.put("$set",sets);
BasicDBObject key = new BasicDBObject(__ID,idInCluster);
- _dbSessions.update(key,update);
+ _dbSessions.update(key,update,false,false,WriteConcern.SAFE);
}
}
@@ -573,7 +577,7 @@ public class MongoSessionManager extends NoSqlSessionManager
BasicDBObject sets = new BasicDBObject();
BasicDBObject update = new BasicDBObject(__ID, newClusterId);
sets.put("$set", update);
- _dbSessions.update(key, sets, false, false);
+ _dbSessions.update(key, sets, false, false,WriteConcern.SAFE);
}
/*------------------------------------------------------------ */

Back to the top