Search in sources :

Example 6 with NoOpFieldNameValidator

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();
        }
    }
}
Also used : ServerSelector(com.mongodb.selector.ServerSelector) ReadPreferenceServerSelector(com.mongodb.internal.selector.ReadPreferenceServerSelector) NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator) MongoException(com.mongodb.MongoException) BsonDocument(org.bson.BsonDocument) ServerDescription(com.mongodb.connection.ServerDescription) BsonArray(org.bson.BsonArray) Connection(com.mongodb.internal.connection.Connection) ReadPreferenceServerSelector(com.mongodb.internal.selector.ReadPreferenceServerSelector) ClusterDescription(com.mongodb.connection.ClusterDescription) BsonDocumentCodec(org.bson.codecs.BsonDocumentCodec)

Example 7 with NoOpFieldNameValidator

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);
}
Also used : NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator)

Example 8 with NoOpFieldNameValidator

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);
}
Also used : NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator)

Example 9 with NoOpFieldNameValidator

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);
}
Also used : NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator)

Example 10 with NoOpFieldNameValidator

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);
}
Also used : NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator) HashMap(java.util.HashMap) MappedFieldNameValidator(com.mongodb.internal.validator.MappedFieldNameValidator) UpdateFieldNameValidator(com.mongodb.internal.validator.UpdateFieldNameValidator) CollectibleDocumentFieldNameValidator(com.mongodb.internal.validator.CollectibleDocumentFieldNameValidator) NoOpFieldNameValidator(com.mongodb.internal.validator.NoOpFieldNameValidator) MappedFieldNameValidator(com.mongodb.internal.validator.MappedFieldNameValidator) FieldNameValidator(org.bson.FieldNameValidator)

Aggregations

NoOpFieldNameValidator (com.mongodb.internal.validator.NoOpFieldNameValidator)19 MappedFieldNameValidator (com.mongodb.internal.validator.MappedFieldNameValidator)6 HashMap (java.util.HashMap)6 FieldNameValidator (org.bson.FieldNameValidator)6 UpdateFieldNameValidator (com.mongodb.internal.validator.UpdateFieldNameValidator)5 BsonString (org.bson.BsonString)5 CollectibleDocumentFieldNameValidator (com.mongodb.internal.validator.CollectibleDocumentFieldNameValidator)4 BsonDocument (org.bson.BsonDocument)4 BsonDocumentCodec (org.bson.codecs.BsonDocumentCodec)4 ReplacingDocumentFieldNameValidator (com.mongodb.internal.validator.ReplacingDocumentFieldNameValidator)2 MongoException (com.mongodb.MongoException)1 ServerAddress (com.mongodb.ServerAddress)1 DeleteRequest (com.mongodb.bulk.DeleteRequest)1 UpdateRequest (com.mongodb.bulk.UpdateRequest)1 ClusterDescription (com.mongodb.connection.ClusterDescription)1 ServerDescription (com.mongodb.connection.ServerDescription)1 Connection (com.mongodb.internal.connection.Connection)1 ReadPreferenceServerSelector (com.mongodb.internal.selector.ReadPreferenceServerSelector)1 ServerAddressSelector (com.mongodb.internal.selector.ServerAddressSelector)1 ServerSelector (com.mongodb.selector.ServerSelector)1