Class MongoDataConnection
java.lang.Object
com.hazelcast.dataconnection.DataConnectionBase
com.hazelcast.jet.mongodb.dataconnection.MongoDataConnection
- All Implemented Interfaces:
DataConnection
Creates a MongoDB DataConnection.
According to MongoClient
documentation, the client object is responsible for maintaining connection pool,
so this data connection just returns one, cached client.
- Since:
- 5.3
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the property holding the name of the database in which user is created.static final String
Name of the property holding the maximum size of Mongo Client connection pool.static final String
Name of the property holding the minimum size of Mongo Client connection pool.static final String
Name of a property which holds connection string to the mongodb instance.static final String
Name of a property with a database name hint.static final String
Name of a property which holds host:port address of the mongodb instance.static final String
Name of the property holding user password.static final String
Name of the property holding username. -
Constructor Summary
ConstructorDescriptionCreates a new data connection based on given config. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Closes underlying client.com.mongodb.client.MongoClient
Returns an instance ofMongoClient
.Returns the database name hint.Lists all MongoDB collections in all databases.static DataConnectionConfig
mongoDataConnectionConf
(String name, String connectionString) Helper method to create newMongoDataConnection
with given name and connection string.Returns the list of possible values forDataConnectionResource.type()
, that will be returned whenDataConnection.listResources()
is called.Methods inherited from class com.hazelcast.dataconnection.DataConnectionBase
getConfig, getName, release, retain
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.hazelcast.dataconnection.DataConnection
options
-
Field Details
-
CONNECTION_STRING_PROPERTY
Name of a property which holds connection string to the mongodb instance.- See Also:
-
DATABASE_PROPERTY
Name of a property with a database name hint. This is used as a hint only;listResources()
will return only collection from db with this name, but client is not restricted to this database. It can be used to specify database to which SQL Mappings will point.- See Also:
-
USERNAME_PROPERTY
Name of the property holding username.- See Also:
-
PASSWORD_PROPERTY
Name of the property holding user password.- See Also:
-
HOST_PROPERTY
Name of a property which holds host:port address of the mongodb instance.- See Also:
-
AUTH_DB_PROPERTY
Name of the property holding the name of the database in which user is created. Default value isadmin
.- See Also:
-
CONNECTION_POOL_MIN
Name of the property holding the minimum size of Mongo Client connection pool. Default is 10.- Since:
- 5.4
- See Also:
-
CONNECTION_POOL_MAX
Name of the property holding the maximum size of Mongo Client connection pool. Default is 10.- Since:
- 5.4
- See Also:
-
-
Constructor Details
-
MongoDataConnection
Creates a new data connection based on given config.
-
-
Method Details
-
getClient
@Nonnull public com.mongodb.client.MongoClient getClient()Returns an instance ofMongoClient
. If client is DataConnectionConfig.isShared() and there will be still some usages of given client, the MongoClient.close() method won't take an effect. -
getDatabaseName
Returns the database name hint. -
listResources
Lists all MongoDB collections in all databases. -
resourceTypes
Description copied from interface:DataConnection
Returns the list of possible values forDataConnectionResource.type()
, that will be returned whenDataConnection.listResources()
is called. Returned values are case-insensitive, e.g.DataConnectionResource.type()
may returnMY_RES
and this methodmy_res
. -
destroy
public void destroy()Closes underlying client. -
mongoDataConnectionConf
@Nonnull public static DataConnectionConfig mongoDataConnectionConf(String name, String connectionString) Helper method to create newMongoDataConnection
with given name and connection string.
-