use of com.mongodb.connection.StreamFactory in project mongo-java-driver by mongodb.
the class KeyManagementService method decryptKey.
Mono<Void> decryptKey(final MongoKeyDecryptor keyDecryptor) {
SocketSettings socketSettings = SocketSettings.builder().connectTimeout(timeoutMillis, MILLISECONDS).readTimeout(timeoutMillis, MILLISECONDS).build();
StreamFactory streamFactory = tlsChannelStreamFactoryFactory.create(socketSettings, SslSettings.builder().enabled(true).context(kmsProviderSslContextMap.get(keyDecryptor.getKmsProvider())).build());
ServerAddress serverAddress = new ServerAddress(keyDecryptor.getHostName());
LOGGER.info("Connecting to KMS server at " + serverAddress);
return Mono.<Void>create(sink -> {
Stream stream = streamFactory.create(serverAddress);
stream.openAsync(new AsyncCompletionHandler<Void>() {
@Override
public void completed(final Void ignored) {
streamWrite(stream, keyDecryptor, sink);
}
@Override
public void failed(final Throwable t) {
stream.close();
sink.error(t);
}
});
}).onErrorMap(this::unWrapException);
}
use of com.mongodb.connection.StreamFactory in project mongo-java-driver by mongodb.
the class MongoClients method createWithTlsChannel.
private static MongoClient createWithTlsChannel(final MongoClientSettings settings, @Nullable final MongoDriverInformation mongoDriverInformation) {
TlsChannelStreamFactoryFactory streamFactoryFactory = new TlsChannelStreamFactoryFactory();
StreamFactory streamFactory = streamFactoryFactory.create(settings.getSocketSettings(), settings.getSslSettings());
StreamFactory heartbeatStreamFactory = streamFactoryFactory.create(settings.getHeartbeatSocketSettings(), settings.getSslSettings());
return createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory, streamFactoryFactory);
}
use of com.mongodb.connection.StreamFactory in project mongo-java-driver by mongodb.
the class MongoClients method createWithAsynchronousSocketChannel.
private static MongoClient createWithAsynchronousSocketChannel(final MongoClientSettings settings, @Nullable final MongoDriverInformation mongoDriverInformation) {
StreamFactoryFactory streamFactoryFactory = AsynchronousSocketChannelStreamFactoryFactory.builder().build();
StreamFactory streamFactory = streamFactoryFactory.create(settings.getSocketSettings(), settings.getSslSettings());
StreamFactory heartbeatStreamFactory = streamFactoryFactory.create(settings.getHeartbeatSocketSettings(), settings.getSslSettings());
return createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory, null);
}
use of com.mongodb.connection.StreamFactory in project mongo-java-driver by mongodb.
the class NettyMongoClients method create.
static MongoClient create(final MongoClientSettings settings, final MongoDriverInformation mongoDriverInformation) {
final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
StreamFactory streamFactory = new NettyStreamFactory(settings.getSocketSettings(), settings.getSslSettings(), eventLoopGroup);
StreamFactory heartbeatStreamFactory = new NettyStreamFactory(settings.getHeartbeatSocketSettings(), settings.getSslSettings(), eventLoopGroup);
return MongoClients.createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory, new Closeable() {
@Override
public void close() throws IOException {
eventLoopGroup.shutdownGracefully().awaitUninterruptibly();
}
});
}
use of com.mongodb.connection.StreamFactory in project mongo-java-driver by mongodb.
the class MongoClients method create.
private static MongoClient create(final MongoClientSettings settings, final MongoDriverInformation mongoDriverInformation, final String requestedStreamType) {
String streamType = getStreamType(requestedStreamType);
if (isNetty(streamType) && settings.getStreamFactoryFactory() == null) {
return NettyMongoClients.create(settings, mongoDriverInformation);
} else {
StreamFactory streamFactory = getStreamFactory(settings.getStreamFactoryFactory(), settings.getSocketSettings(), settings.getSslSettings(), streamType);
StreamFactory heartbeatStreamFactory = getStreamFactory(settings.getStreamFactoryFactory(), settings.getHeartbeatSocketSettings(), settings.getSslSettings(), streamType);
return createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory, null);
}
}
Aggregations