Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #89 from jochenberger/update-libraries
Browse files Browse the repository at this point in the history
update libraries, replace some (but not all) deprecated method calls
  • Loading branch information
michaelklishin committed Mar 19, 2015
2 parents 4823183 + 115492d commit b149a76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
11 changes: 6 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
:min-lein-version "2.4.2"
:license {:name "Apache License 2.0"}
:dependencies [[org.quartz-scheduler/quartz "2.1.7"]
[org.mongodb/mongo-java-driver "2.12.3"]
[joda-time/joda-time "2.4"]]
[org.mongodb/mongo-java-driver "2.13.0"]
[joda-time/joda-time "2.7"]
[commons-codec/commons-codec "1.10"]]
:java-source-paths ["src/main/java"]
:test-paths ["src/test/clojure"]
:test-selectors {:all (constantly true)
Expand All @@ -15,9 +16,9 @@
:dependencies [[org.clojure/clojure "1.6.0"]
[clojurewerkz/quartzite "1.3.0"]
[com.novemberain/monger "1.7.0"]
[org.clojure/tools.logging "0.2.3" :exclusions [org.clojure/clojure]]
[org.slf4j/slf4j-simple "1.6.2"]
[org.slf4j/slf4j-api "1.6.2"]]}}
[org.clojure/tools.logging "0.3.1" :exclusions [org.clojure/clojure]]
[org.slf4j/slf4j-simple "1.7.10"]
[org.slf4j/slf4j-api "1.7.10"]]}}
:repositories {"sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
:snapshots false
:releases {:checksum :fail :update :always}}
Expand Down
27 changes: 13 additions & 14 deletions src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
package com.novemberain.quartz.mongodb;

import com.mongodb.*;
import com.mongodb.MongoException.DuplicateKey;
import com.mongodb.util.Base64Codec;

import org.apache.commons.codec.binary.Base64;
import org.bson.types.ObjectId;
import org.quartz.Calendar;
import org.quartz.*;
Expand Down Expand Up @@ -642,7 +641,7 @@ private void doAcquireNextTriggers(Map<TriggerKey, OperableTrigger> triggers, Da
log.debug("Aquired trigger {}", trigger.getKey());
triggers.put(trigger.getKey(), trigger);

} catch (DuplicateKey e) {
} catch (DuplicateKeyException e) {

// someone else acquired this lock. Move on.
log.debug("Failed to acquire trigger {} due to a lock", trigger.getKey());
Expand Down Expand Up @@ -719,7 +718,7 @@ false, new Date(), trigger.getPreviousFireTime(), prevFireTime,
results.add(new TriggerFiredResult(bndle));
storeTrigger(trigger, true);
}
catch (DuplicateKey dk) {
catch (DuplicateKeyException dk) {

log.debug("Job disallows concurrent execution and is already running {}", job.getKey());

Expand Down Expand Up @@ -1124,27 +1123,27 @@ private void ensureIndexes() throws SchedulerConfigException {
BasicDBObject keys = new BasicDBObject();
keys.put(KEY_GROUP, 1);
keys.put(KEY_NAME, 1);
jobCollection.ensureIndex(keys, null, true);
jobCollection.createIndex(keys, new BasicDBObject("unique", Boolean.TRUE));

keys = new BasicDBObject();
keys.put(KEY_GROUP, 1);
keys.put(KEY_NAME, 1);
triggerCollection.ensureIndex(keys, null, true);
triggerCollection.createIndex(keys, new BasicDBObject("unique", Boolean.TRUE));

keys = new BasicDBObject();
keys.put(KEY_GROUP, 1);
keys.put(KEY_NAME, 1);
locksCollection.ensureIndex(keys, null, true);
locksCollection.createIndex(keys, new BasicDBObject("unique", Boolean.TRUE));

// Need this to stop table scan when removing all locks
locksCollection.ensureIndex(LOCK_INSTANCE_ID);
locksCollection.createIndex(new BasicDBObject(LOCK_INSTANCE_ID, 1));

// remove all locks for this instance on startup
locksCollection.remove(new BasicDBObject(LOCK_INSTANCE_ID, instanceId));

keys = new BasicDBObject();
keys.put(CALENDAR_NAME, 1);
calendarCollection.ensureIndex(keys, null, true);
calendarCollection.createIndex(keys, new BasicDBObject("unique", Boolean.TRUE));

try
{
Expand All @@ -1153,7 +1152,7 @@ private void ensureIndexes() throws SchedulerConfigException {
triggerCollection.dropIndex("keyName_1_keyGroup_1");
locksCollection.dropIndex("keyName_1_keyGroup_1");
}
catch (CommandFailureException cfe)
catch (MongoCommandException cfe)
{
// Ignore, the old indexes have already been removed
}
Expand Down Expand Up @@ -1194,7 +1193,7 @@ protected void storeTrigger(OperableTrigger newTrigger, ObjectId jobId, boolean

try {
triggerCollection.insert(trigger);
} catch (DuplicateKey key) {
} catch (DuplicateKeyException key) {
if (replaceExisting) {
trigger.remove("_id");
triggerCollection.update(keyToDBObject(newTrigger.getKey()), trigger);
Expand Down Expand Up @@ -1228,7 +1227,7 @@ protected ObjectId storeJobInMongo(JobDetail newJob, boolean replaceExisting) th
try {
jobCollection.insert(job);
objectId = (ObjectId) job.get("_id");
} catch (DuplicateKey e) {
} catch (DuplicateKeyException e) {
// Fine, find it and get its id.
object = jobCollection.findOne(keyDbo);
objectId = (ObjectId) object.get("_id");
Expand Down Expand Up @@ -1370,7 +1369,7 @@ protected void jobDataMapFromString(JobDataMap jobDataMap, String clob)
throws IOException {

try {
byte[] bytes = new Base64Codec().decode(clob);
byte[] bytes = Base64.decodeBase64(clob);

Map<String, ?> map = (Map<String, ?>) stringMapFromBytes(bytes);

Expand Down Expand Up @@ -1407,7 +1406,7 @@ protected String jobDataToString(JobDataMap jobDataMap)

try {
byte[] bytes = stringMapToBytes(jobDataMap.getWrappedMap());
return new Base64Codec().encode(bytes);
return Base64.encodeBase64String(bytes);
} catch (NotSerializableException e) {
throw new NotSerializableException(
"Unable to serialize JobDataMap for insertion into " +
Expand Down

0 comments on commit b149a76

Please sign in to comment.