Skip to content

Commit

Permalink
bumped mongo driver to 2.7.1
Browse files Browse the repository at this point in the history
and fixed some problems it introduced. replica set authentication working again. fixes #SERVER-61
  • Loading branch information
Lennart Koopmann committed Nov 24, 2011
1 parent b73b4c7 commit 941395b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.6.5</version>
<version>2.7.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/graylog2/database/MongoBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void setSimpleServerValue(String key, Object value) {
coll.update(query, update, true, false);
}

public void writeMessageCounts(int total, Map<ObjectId, Integer> streams, Map<String, Integer> hosts) {
public void writeMessageCounts(int total, Map<String, Integer> streams, Map<String, Integer> hosts) {
BasicDBObject obj = new BasicDBObject();
obj.put("timestamp", Tools.getUTCTimestamp());
obj.put("total", total);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class MessageCounter {
private static MessageCounter instance;

private int total;
private Map<ObjectId, Integer> streams;
private Map<String, Integer> streams;
private Map<String, Integer> hosts;

private int fiveSecondThroughput = 0;
Expand All @@ -63,7 +63,7 @@ public int getTotalCount() {
return this.total;
}

public Map<ObjectId, Integer> getStreamCounts() {
public Map<String, Integer> getStreamCounts() {
return this.streams;
}

Expand All @@ -90,7 +90,7 @@ public void resetHostCounts() {
}

public void resetStreamCounts() {
this.streams = new HashMap<ObjectId, Integer>();
this.streams = new HashMap<String, Integer>();
}

public void resetTotal() {
Expand Down Expand Up @@ -154,13 +154,13 @@ public void incrementStream(ObjectId streamId) {
* @param x The value to add on top of the current stream count.
*/
public void countUpStream(ObjectId streamId, int x) {
if (this.streams.containsKey(streamId)) {
if (this.streams.containsKey(streamId.toString())) {
// There already is an entry. Increment.
int oldCount = this.streams.get(streamId);
this.streams.put(streamId, oldCount+x); // Overwrites old entry.
int oldCount = this.streams.get(streamId.toString());
this.streams.put(streamId.toString(), oldCount+x); // Overwrites old entry.
} else {
// First entry for this stream.
this.streams.put(streamId, x);
this.streams.put(streamId.toString(), x);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public void testGetStreamCounts() {
ObjectId stream2 = new ObjectId();
ObjectId stream3 = new ObjectId();

Map expected = new HashMap<ObjectId, Integer>();
expected.put(stream1, 1);
expected.put(stream2, 5);
expected.put(stream3, 2);
Map expected = new HashMap<String, Integer>();
expected.put(stream1.toString(), 1);
expected.put(stream2.toString(), 5);
expected.put(stream3.toString(), 2);

counter.countUpStream(stream1, 1);
counter.countUpStream(stream2, 3);
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testIncrementStream() {
counter.countUpStream(streamId, 100);
counter.incrementStream(streamId);

int res = counter.getStreamCounts().get(streamId);
int res = counter.getStreamCounts().get(streamId.toString());
assertEquals(101, res);
}

Expand All @@ -143,7 +143,7 @@ public void testCountUpStream() {
counter.countUpStream(streamId, 100);
counter.countUpStream(streamId, 150);

int res = counter.getStreamCounts().get(streamId);
int res = counter.getStreamCounts().get(streamId.toString());
assertEquals(250, res);
}

Expand Down

0 comments on commit 941395b

Please sign in to comment.