Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cd8e3cb
Change way remove on gridfs is performed to improve performances
finalspy Feb 27, 2014
b20ecdb
JAVA-284: Support replica set name in MongoClientURI and MongoClientO…
jyemin Feb 27, 2014
1e9c3ab
JAVA-1005, JAVA-1009: Added support for minPoolSize, maxIdleTimeMS an…
jyemin Feb 27, 2014
1202d5f
JAVA-1126: Fixed infinite loop in OrderedRunGenerator if write count …
jyemin Feb 28, 2014
cd2add3
JAVA-1126: Factored expression into a final field
jyemin Feb 28, 2014
1c85e1a
JAVA-1119: Fixed off-by-one error in UnorderedRunGenerator
jyemin Feb 28, 2014
7beab40
Bumping version to 2.12.0-rc1
jyemin Mar 5, 2014
1c3cf13
Bumping version back 2.12.0-SNAPSHOT
jyemin Mar 5, 2014
1cb24c5
maxTime getMore test
rozza Mar 6, 2014
57959d8
resolves JAVA-1141 DBCollection.createIndex(DBObject, DBObject) does…
Mar 7, 2014
fd3adb2
Updated docs and testcase for ParallelScan
rozza Mar 10, 2014
083109d
Relaxed Codenarc MethodCount rule
jyemin Mar 6, 2014
b201132
Added Fixture methods to determine cluster type
jyemin Mar 6, 2014
17e0d65
JAVA-1140: Implemented BulkWriteError.toString
jyemin Mar 6, 2014
deb591a
JAVA-1040: Added illegal key checks for insert, update, and replace
jyemin Mar 6, 2014
e5b125f
JAVA-1040: Added more bulk write test coverage.
jyemin Mar 6, 2014
5dbb46a
JAVA-1128: Don't apply key checking for inserts into system.indexes. …
jyemin Mar 6, 2014
58feebe
JAVA-1134: Added BulkWriteResult.isModifiedCountAvailable(), which re…
jyemin Mar 10, 2014
222a61c
JAVA-974: Added more explicit tests for addUser and removeUser
jyemin Mar 11, 2014
088b8f8
JAVA-974: Fixing tests for adding admin users
jyemin Mar 12, 2014
f5c2bea
JAVA-1140: Temporarily disabling an ordered bulk write test for repor…
jyemin Mar 12, 2014
74e6055
Added a Fixture method to check if journaling is enabled on the server
jyemin Mar 12, 2014
152bed3
JAVA-1131: With bulk writes in emulation mode, treat GLE failures wit…
jyemin Mar 12, 2014
8b992c8
Bumping version to 2.12.0-rc2
jyemin Mar 12, 2014
043a8d9
Bumping version back to 2.12.0-SNAPSHOT
jyemin Mar 12, 2014
f1a4d39
Added tests of WriteResult returned from DBCollection insert methods
jyemin Mar 13, 2014
5f0bf4c
JAVA-1148: Fixed deadlock between DefaultServer and MultiServerCluste…
jyemin Mar 18, 2014
05f062a
JAVA-1152: For update command, only write multi or upsert field if th…
jyemin Mar 24, 2014
5937722
Added a test for two updates that together exceed 16MB but still woul…
jyemin Mar 24, 2014
96da344
JAVA-1154: Lower GridFS.DEFAULT_CHUNKSIZE from 256K to 255K so that c…
jyemin Mar 24, 2014
ef51ac7
JAVA-1153: Added packages to Import-Package so that GSSAPI will work …
jyemin Mar 24, 2014
b7bda8f
For final release, updating server version checks from 2.5.x dev rele…
jyemin Mar 26, 2014
ccf19b1
Added an explicit test for inserting > maxWriteBatchSize using the bu…
jyemin Mar 26, 2014
b361778
JAVA-1156: Properly ensure that none of the server-defined limits on …
jyemin Mar 26, 2014
401de4e
Added serialVersionUid to DBPointer to remove a compiler warning
jyemin Mar 27, 2014
d21a78a
Added Deprecated annotation to a method which already had a deprecate…
jyemin Mar 27, 2014
a96716c
Bumping version to 2.12.0-rc3
jyemin Mar 27, 2014
dddbd84
Back to 2.12.0-SNAPSHOT
jyemin Apr 1, 2014
9f1833d
JAVA-896: Adding @since Javadoc annotation to new public classes.
jyemin Mar 31, 2014
27eee4d
JAVA-1157: Clean up messaging around server selectors and server sele…
jyemin Apr 1, 2014
c9f8ae6
JAVA-1158: No longer apply read preference server selection logic to …
jyemin Apr 1, 2014
2645c4d
JAVA-925: Deprecate more methods in AggregationOutput. The only unde…
jyemin Apr 2, 2014
06aa7e9
Ignoring a flaky test that fails on Jenkins every so often.
jyemin Apr 2, 2014
ade22d0
Bumping version to 2.12.0!
jyemin Apr 3, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ javac.source=1.5

# IMPORTANT: MAKE SURE YOU CHANGE BOTH lib.version AND lib.version.osi.compat, ACCORDING TO THIS PATTERN
# lib.version=2.8.0-SNAPSHOT ==> lib.version.osgi.compat=2.8.0.BUILD-SNAPSHOT
# lib.version=2.8.0-RC1 ==> lib.version.osgi.compat=2.8.0.RC1
# lib.version=2.8.0 ==> lib.version.osgi.compat=2.8.0.RELEASE
lib.version=2.12.0-SNAPSHOT
lib.version.osgi.compat=2.12.0.BUILD-SNAPSHOT
# lib.version=2.8.0-rc1 ==> lib.version.osgi.compat=2.8.0.RC1
# lib.version=2.8.0 ==> lib.version.osgi.compat=2.8.0.RELEASE
lib.version=2.12.0
lib.version.osgi.compat=2.12.0.RELEASE

compatibility.baseline.version=2.11.0
url.libbase=http://driver-downloads.mongodb.org/java
7 changes: 5 additions & 2 deletions config/codenarc/codenarc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<ruleset-ref path='rulesets/generic.xml'/>
<ruleset-ref path='rulesets/groovyism.xml'>
<exclude name="ExplicitCallToCompareToMethod"/>
</ruleset-ref>
</ruleset-ref>
<ruleset-ref path='rulesets/junit.xml'/>
<ruleset-ref path='rulesets/logging.xml'/>
<ruleset-ref path='rulesets/naming.xml'>
Expand All @@ -65,10 +65,13 @@
<ruleset-ref path='rulesets/security.xml'/>
<ruleset-ref path='rulesets/serialization.xml'/>
<ruleset-ref path='rulesets/size.xml'>
<rule-config name='MethodCount'>
<property name='maxMethods' value='50'/>
</rule-config>
<exclude name='CrapMetric'/>
</ruleset-ref>
<ruleset-ref path='rulesets/unnecessary.xml'>
<!-- these should be revisted later when we've developed a Groovy style -->
<!-- these should be revisited later when we've developed a Groovy style -->
<exclude name='UnnecessaryGetter'/>
<exclude name='UnnecessarySemicolon'/>
</ruleset-ref>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ driver developers who would rather use Maven than Ant as their build tool.
<artifactId>mongo-java-driver</artifactId>
<packaging>bundle</packaging>
<name>MongoDB Java Driver</name>
<version>2.12.0-SNAPSHOT</version>
<version>2.12.0</version>
<description>The MongoDB Java driver</description>
<url>http://www.mongodb.org</url>

Expand Down
8 changes: 7 additions & 1 deletion src/main/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ Bundle-ManifestVersion: 2
Bundle-Name: MongoDB Java Driver
Bundle-SymbolicName: org.mongodb.mongo-java-driver
Bundle-Version: @VERSION@
Import-Package: javax.management, javax.net, javax.net.ssl
Import-Package: javax.management,
javax.net,
javax.net.ssl,
javax.security.sasl,
javax.security.auth.login,
javax.security.auth,
org.ietf.jgss
Export-Package: com.mongodb;version="@VERSION@",
com.mongodb.io;version="@VERSION@",
com.mongodb.util;version="@VERSION@",
Expand Down
27 changes: 19 additions & 8 deletions src/main/com/mongodb/AcknowledgedBulkWriteResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class AcknowledgedBulkWriteResult extends BulkWriteResult {
private int insertedCount;
private int matchedCount;
private int removedCount;
private int modifiedCount;
private Integer modifiedCount;
private final List<BulkWriteUpsert> upserts;

AcknowledgedBulkWriteResult(final int insertedCount, final int matchedCount, final int removedCount,
final int modifiedCount, final List<BulkWriteUpsert> upserts) {
final Integer modifiedCount, final List<BulkWriteUpsert> upserts) {
this.insertedCount = insertedCount;
this.matchedCount = matchedCount;
this.removedCount = removedCount;
Expand All @@ -41,7 +41,7 @@ class AcknowledgedBulkWriteResult extends BulkWriteResult {
this(type, count, 0, upserts);
}

AcknowledgedBulkWriteResult(final WriteRequest.Type type, final int count, final int modifiedCount,
AcknowledgedBulkWriteResult(final WriteRequest.Type type, final int count, final Integer modifiedCount,
final List<BulkWriteUpsert> upserts) {
this(type == WriteRequest.Type.INSERT ? count : 0,
(type == WriteRequest.Type.UPDATE || type == WriteRequest.Type.REPLACE) ? count : 0,
Expand Down Expand Up @@ -69,9 +69,20 @@ public int getRemovedCount() {
return removedCount;
}

@Override
public boolean isModifiedCountAvailable() {
return modifiedCount != null;
}

@Override
public int getModifiedCount() {
if (modifiedCount == null) {
throw new UnsupportedOperationException("The modifiedCount is not available because at least one of the servers that was " +
"updated was not able to provide this information (the server is must be at least " +
"version 2.6");
}
return modifiedCount;

}

@Override
Expand All @@ -93,13 +104,13 @@ public boolean equals(final Object o) {
if (insertedCount != that.insertedCount) {
return false;
}
if (modifiedCount != that.modifiedCount) {
if (matchedCount != that.matchedCount) {
return false;
}
if (removedCount != that.removedCount) {
return false;
}
if (matchedCount != that.matchedCount) {
if (modifiedCount != null ? !modifiedCount.equals(that.modifiedCount) : that.modifiedCount != null) {
return false;
}
if (!upserts.equals(that.upserts)) {
Expand All @@ -111,11 +122,11 @@ public boolean equals(final Object o) {

@Override
public int hashCode() {
int result = upserts.hashCode();
result = 31 * result + insertedCount;
int result = insertedCount;
result = 31 * result + matchedCount;
result = 31 * result + removedCount;
result = 31 * result + modifiedCount;
result = 31 * result + (modifiedCount != null ? modifiedCount.hashCode() : 0);
result = 31 * result + upserts.hashCode();
return result;
}

Expand Down
40 changes: 26 additions & 14 deletions src/main/com/mongodb/AggregationOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,66 @@

package com.mongodb;

@SuppressWarnings("deprecation")
public class AggregationOutput {

/**
* returns an iterator to the results of the aggregation
* @return
* @return the results of the aggregation
*/
public Iterable<DBObject> results() {
return _resultSet;
}

/**
* returns the command result of the aggregation
* @return
* @return the command result
*
* @deprecated there is no replacement for this method
*/
@Deprecated
public CommandResult getCommandResult(){
return _commandResult;
}

/**
* returns the original aggregation command
* @return
* @return the command
*
* @deprecated there is no replacement for this method
*/
@Deprecated
public DBObject getCommand() {
return _cmd;
}

/**
* returns the address of the server used to execute the aggregation
* @return
* @return the server which executed the aggregation
*
* @deprecated there is no replacement for this method
*/
@Deprecated
public ServerAddress getServerUsed() {
return _commandResult.getServerUsed();
}

/**
* string representation of the aggregation command
* Constructs a new instance
*
* @param command the aggregation command
* @param commandResult the aggregation command result
*
* @deprecated there is no replacement for this constructor
*/
public String toString(){
return _commandResult.toString();
}

@SuppressWarnings("unchecked")
public AggregationOutput(DBObject cmd, CommandResult raw) {
_commandResult = raw;
_cmd = cmd;
@Deprecated
public AggregationOutput(DBObject command, CommandResult commandResult) {
_commandResult = commandResult;
_cmd = command;

if(raw.containsField("result"))
_resultSet = (Iterable<DBObject>) raw.get( "result" );
if(commandResult.containsField("result"))
_resultSet = (Iterable<DBObject>) commandResult.get( "result" );
else
throw new IllegalArgumentException("result undefined");
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/com/mongodb/AnyServerSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mongodb;

import java.util.List;

class AnyServerSelector implements ServerSelector {
@Override
public List<ServerDescription> choose(final ClusterDescription clusterDescription) {
return clusterDescription.getAny();
}

@Override
public String toString() {
return "AnyServerSelector{}";
}
}
22 changes: 10 additions & 12 deletions src/main/com/mongodb/BaseCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.logging.Logger;

import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.bson.util.Assertions.isTrue;
import static org.bson.util.Assertions.notNull;
Expand Down Expand Up @@ -76,27 +77,24 @@ public Server getServer(final ServerSelector serverSelector, final long maxWaitT
}

if (!curDescription.isConnecting()) {
throw new MongoServerSelectionException(
format("Unable to connect to any server that satisfies the selector " +
"%s", serverSelector));
throw new MongoServerSelectionException(format("Unable to connect to any server that matches %s", serverSelector));
}

final long timeout = endTime - System.nanoTime();

LOGGER.info(format("No server chosen by %s from cluster description %s. Waiting for %d ms before timing out",
serverSelector, curDescription, TimeUnit.MILLISECONDS.convert(timeout, NANOSECONDS)));
serverSelector, curDescription, MILLISECONDS.convert(timeout, NANOSECONDS)));

if (!currentPhase.await(timeout, NANOSECONDS)) {
throw new MongoTimeoutException(format("Timed out while waiting for a server that satisfies the selector: %s "
+ "after %d %s", serverSelector, timeout, NANOSECONDS));
throw new MongoTimeoutException(format("Timed out while waiting for a server that matches %s after %d ms",
serverSelector, MILLISECONDS.convert(timeout, NANOSECONDS)));
}
currentPhase = phase.get();
curDescription = description;
serverDescriptions = serverSelector.choose(curDescription);
}
} catch (InterruptedException e) {
throw new MongoInterruptedException(format("Interrupted while waiting for a server that satisfies server selector %s ",
serverSelector), e);
throw new MongoInterruptedException(format("Interrupted while waiting for a server that matches %s ", serverSelector), e);
}
}

Expand All @@ -117,18 +115,18 @@ public ClusterDescription getDescription(final long maxWaitTime, final TimeUnit
final long timeout = endTime - System.nanoTime();

LOGGER.info(format("Cluster description not yet available. Waiting for %d ms before timing out",
TimeUnit.MILLISECONDS.convert(timeout, NANOSECONDS)));
MILLISECONDS.convert(timeout, NANOSECONDS)));

if (!currentPhase.await(timeout, NANOSECONDS)) {
throw new MongoTimeoutException(format("Timed out while waiting for the cluster description after waiting %d %s",
timeout, NANOSECONDS));
throw new MongoTimeoutException(format("Timed out while waiting to connect after %d ms",
MILLISECONDS.convert(timeout, NANOSECONDS)));
}
currentPhase = phase.get();
curDescription = description;
}
return curDescription;
} catch (InterruptedException e) {
throw new MongoInterruptedException(format("Interrupted while waiting for the cluster description"), e);
throw new MongoInterruptedException(format("Interrupted while waiting to connect"), e);
}
}

Expand Down
16 changes: 13 additions & 3 deletions src/main/com/mongodb/BaseWriteCommandMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@ private void writeCommandHeader(final OutputBuffer buffer) {
protected abstract BaseWriteCommandMessage writeTheWrites(final OutputBuffer buffer, final int commandStartPosition,
final BSONBinaryWriter writer);

protected boolean maximumCommandDocumentSizeExceeded(final OutputBuffer buffer, final int commandStartPosition) {
// Subtract 2 to account for the trailing 0x0 at the end of the enclosing array and command document
return buffer.getPosition() - commandStartPosition > getSettings().getMaxDocumentSize() + HEADROOM - 2;
protected boolean exceedsLimits(final int batchLength, final int batchItemCount) {
return (exceedsBatchLengthLimit(batchLength, batchItemCount) || exceedsBatchItemCountLimit(batchItemCount));
}

// make a special exception for a command with only a single item added to it. It's allowed to exceed maximum document size so that
// it's possible to, say, send a replacement document that is itself 16MB, which would push the size of the containing command
// document to be greater than the maximum document size.
private boolean exceedsBatchLengthLimit(final int batchLength, final int batchItemCount) {
return batchLength > getSettings().getMaxDocumentSize() && batchItemCount > 1;
}

private boolean exceedsBatchItemCountLimit(final int batchItemCount) {
return batchItemCount > getSettings().getMaxWriteBatchSize();
}

public abstract int getItemCount();
Expand Down
8 changes: 6 additions & 2 deletions src/main/com/mongodb/BulkWriteBatchCombiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BulkWriteBatchCombiner {
private int insertedCount;
private int matchedCount;
private int removedCount;
private int modifiedCount;
private Integer modifiedCount = 0;
private final Set<BulkWriteUpsert> writeUpserts = new TreeSet<BulkWriteUpsert>(new Comparator<BulkWriteUpsert>() {
@Override
public int compare(final BulkWriteUpsert o1, final BulkWriteUpsert o2) {
Expand All @@ -58,7 +58,11 @@ public void addResult(final BulkWriteResult result, final IndexMap indexMap) {
insertedCount += result.getInsertedCount();
matchedCount += result.getMatchedCount();
removedCount += result.getRemovedCount();
modifiedCount += result.getModifiedCount();
if (result.isModifiedCountAvailable() && modifiedCount != null) {
modifiedCount += result.getModifiedCount();
} else {
modifiedCount = null;
}
mergeUpserts(result.getUpserts(), indexMap);
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/com/mongodb/BulkWriteError.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,14 @@ public int hashCode() {
result = 31 * result + details.hashCode();
return result;
}

@Override
public String toString() {
return "BulkWriteError{"
+ "index=" + index
+ ", code=" + code
+ ", message='" + message + '\''
+ ", details=" + details
+ '}';
}
}
19 changes: 19 additions & 0 deletions src/main/com/mongodb/BulkWriteResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,34 @@ public abstract class BulkWriteResult {
*/
public abstract int getRemovedCount();

/**
* Returns true if the server was able to provide a count of modified documents. If this method returns false (which can happen if
* the server is not at least version 2.6) then the {@code getModifiedCount} method will throw {@code UnsupportedOperationException}.
*
* @return true if modifiedCount is available
*
* @throws UnacknowledgedWriteException if the write was unacknowledged.
* @see WriteConcern#UNACKNOWLEDGED
* @see #getModifiedCount()
*/
public abstract boolean isModifiedCountAvailable();

/**
* Returns the number of documents modified by updates or replacements in the write operation. This will only count documents that
* were actually changed; for example, if you set the value of some field, and the field already has that value,
* that will not count as a modification.
* <p>
* If the server is not able to provide a count of modified documents (which can happen if the server is not at least version
* 2.6), then this method will throw an {@code UnsupportedOperationException}
* </p>
*
* @return the number of documents modified by the write operation
*
* @throws UnacknowledgedWriteException if the write was unacknowledged.
* @throws java.lang.UnsupportedOperationException if no modified count is available
* @see WriteConcern#UNACKNOWLEDGED
* @see #isModifiedCountAvailable()
* @mongodb.server.release 2.6
*/
public abstract int getModifiedCount();

Expand Down
Loading