Search in sources :

Example 1 with MongoCompressor

use of com.mongodb.MongoCompressor in project mongo-java-driver by mongodb.

the class InternalStreamConnectionInitializer method createHelloCommand.

private BsonDocument createHelloCommand(final Authenticator authenticator, final InternalConnection connection) {
    BsonDocument helloCommandDocument = new BsonDocument(getHandshakeCommandName(), new BsonInt32(1)).append("helloOk", BsonBoolean.TRUE);
    if (clientMetadataDocument != null) {
        helloCommandDocument.append("client", clientMetadataDocument);
    }
    if (clusterConnectionMode == ClusterConnectionMode.LOAD_BALANCED) {
        helloCommandDocument.append("loadBalanced", BsonBoolean.TRUE);
    }
    if (!requestedCompressors.isEmpty()) {
        BsonArray compressors = new BsonArray(this.requestedCompressors.size());
        for (MongoCompressor cur : this.requestedCompressors) {
            compressors.add(new BsonString(cur.getName()));
        }
        helloCommandDocument.append("compression", compressors);
    }
    if (checkSaslSupportedMechs) {
        MongoCredential credential = authenticator.getMongoCredential();
        helloCommandDocument.append("saslSupportedMechs", new BsonString(credential.getSource() + "." + credential.getUserName()));
    }
    if (authenticator instanceof SpeculativeAuthenticator) {
        BsonDocument speculativeAuthenticateDocument = ((SpeculativeAuthenticator) authenticator).createSpeculativeAuthenticateCommand(connection);
        if (speculativeAuthenticateDocument != null) {
            helloCommandDocument.append("speculativeAuthenticate", speculativeAuthenticateDocument);
        }
    }
    return helloCommandDocument;
}
Also used : BsonInt32(org.bson.BsonInt32) BsonDocument(org.bson.BsonDocument) MongoCredential(com.mongodb.MongoCredential) BsonString(org.bson.BsonString) BsonArray(org.bson.BsonArray) MongoCompressor(com.mongodb.MongoCompressor)

Example 2 with MongoCompressor

use of com.mongodb.MongoCompressor in project mongo-java-driver by mongodb.

the class InternalStreamConnection method createCompressorMap.

private Map<Byte, Compressor> createCompressorMap(final List<MongoCompressor> compressorList) {
    Map<Byte, Compressor> compressorMap = new HashMap<Byte, Compressor>(this.compressorList.size());
    for (MongoCompressor mongoCompressor : compressorList) {
        Compressor compressor = createCompressor(mongoCompressor);
        compressorMap.put(compressor.getId(), compressor);
    }
    return compressorMap;
}
Also used : HashMap(java.util.HashMap) MongoCompressor(com.mongodb.MongoCompressor) MongoCompressor(com.mongodb.MongoCompressor)

Aggregations

MongoCompressor (com.mongodb.MongoCompressor)2 MongoCredential (com.mongodb.MongoCredential)1 HashMap (java.util.HashMap)1 BsonArray (org.bson.BsonArray)1 BsonDocument (org.bson.BsonDocument)1 BsonInt32 (org.bson.BsonInt32)1 BsonString (org.bson.BsonString)1