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;
}
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;
}
Aggregations