use of com.mongodb.internal.validator.NoOpFieldNameValidator in project mongo-java-driver by mongodb.
the class ServerSessionPool method endClosedSessions.
private void endClosedSessions(final List<BsonDocument> identifiers) {
if (identifiers.isEmpty()) {
return;
}
final List<ServerDescription> primaryPreferred = new ReadPreferenceServerSelector(ReadPreference.primaryPreferred()).select(cluster.getCurrentDescription());
if (primaryPreferred.isEmpty()) {
return;
}
Connection connection = null;
try {
connection = cluster.selectServer(new ServerSelector() {
@Override
public List<ServerDescription> select(final ClusterDescription clusterDescription) {
for (ServerDescription cur : clusterDescription.getServerDescriptions()) {
if (cur.getAddress().equals(primaryPreferred.get(0).getAddress())) {
return Collections.singletonList(cur);
}
}
return Collections.emptyList();
}
}).getServer().getConnection();
connection.command("admin", new BsonDocument("endSessions", new BsonArray(identifiers)), new NoOpFieldNameValidator(), ReadPreference.primaryPreferred(), new BsonDocumentCodec(), NoOpSessionContext.INSTANCE, serverApi, IgnorableRequestContext.INSTANCE);
} catch (MongoException e) {
// ignore exceptions
} finally {
if (connection != null) {
connection.release();
}
}
}
use of com.mongodb.internal.validator.NoOpFieldNameValidator in project mongo-java-driver by mongodb.
the class InsertMessage method encodeMessageBodyWithMetadata.
@Override
protected EncodingMetadata encodeMessageBodyWithMetadata(final BsonOutput outputStream) {
writeInsertPrologue(outputStream);
int firstDocumentPosition = outputStream.getPosition();
addCollectibleDocument(insertRequest.getDocument(), outputStream, new NoOpFieldNameValidator());
return new EncodingMetadata(firstDocumentPosition);
}
use of com.mongodb.internal.validator.NoOpFieldNameValidator in project mongo-java-driver by mongodb.
the class QueryMessage method encodeMessageBodyWithMetadata.
@Override
protected EncodingMetadata encodeMessageBodyWithMetadata(final BsonOutput bsonOutput) {
writeQueryPrologue(bsonOutput);
int firstDocumentStartPosition = bsonOutput.getPosition();
addDocument(queryDocument, bsonOutput, new NoOpFieldNameValidator());
if (fields != null) {
addDocument(fields, bsonOutput, new NoOpFieldNameValidator());
}
return new EncodingMetadata(firstDocumentStartPosition);
}
use of com.mongodb.internal.validator.NoOpFieldNameValidator in project mongo-java-driver by mongodb.
the class QueryMessage method encodeMessageBodyWithMetadata.
@Override
protected EncodingMetadata encodeMessageBodyWithMetadata(final BsonOutput bsonOutput, final int messageStartPosition) {
writeQueryPrologue(bsonOutput);
int firstDocumentStartPosition = bsonOutput.getPosition();
addDocument(queryDocument, bsonOutput, new NoOpFieldNameValidator());
if (fields != null) {
addDocument(fields, bsonOutput, new NoOpFieldNameValidator());
}
return new EncodingMetadata(null, firstDocumentStartPosition);
}
use of com.mongodb.internal.validator.NoOpFieldNameValidator in project mongo-java-driver by mongodb.
the class UpdateCommandMessage method getFieldNameValidator.
@Override
protected FieldNameValidator getFieldNameValidator() {
Map<String, FieldNameValidator> rootMap = new HashMap<String, FieldNameValidator>();
rootMap.put("updates", new UpdatesValidator());
return new MappedFieldNameValidator(new NoOpFieldNameValidator(), rootMap);
}
Aggregations