Class MongoDataConnection
- java.lang.Object
-
- com.hazelcast.dataconnection.DataConnectionBase
-
- com.hazelcast.jet.mongodb.dataconnection.MongoDataConnection
-
- All Implemented Interfaces:
DataConnection
public class MongoDataConnection extends DataConnectionBase
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
Fields Modifier and Type Field Description static java.lang.String
AUTH_DB_PROPERTY
Name of the property holding the name of the database in which user is created.static java.lang.String
CONNECTION_POOL_MAX
Name of the property holding the maximum size of Mongo Client connection pool.static java.lang.String
CONNECTION_POOL_MIN
Name of the property holding the minimum size of Mongo Client connection pool.static java.lang.String
CONNECTION_STRING_PROPERTY
Name of a property which holds connection string to the mongodb instance.static java.lang.String
DATABASE_PROPERTY
Name of a property with a database name hint.static java.lang.String
HOST_PROPERTY
Name of a property which holds host:port address of the mongodb instance.static java.lang.String
PASSWORD_PROPERTY
Name of the property holding user password.static java.lang.String
USERNAME_PROPERTY
Name of the property holding username.
-
Constructor Summary
Constructors Constructor Description MongoDataConnection(DataConnectionConfig config)
Creates a new data connection based on given config.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Closes underlying client.com.mongodb.client.MongoClient
getClient()
Returns an instance ofMongoClient
.java.lang.String
getDatabaseName()
Returns the database name hint.java.util.List<DataConnectionResource>
listResources()
Lists all MongoDB collections in all databases.static DataConnectionConfig
mongoDataConnectionConf(java.lang.String name, java.lang.String connectionString)
Helper method to create newMongoDataConnection
with given name and connection string.java.util.Collection<java.lang.String>
resourceTypes()
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 Detail
-
CONNECTION_STRING_PROPERTY
public static final java.lang.String CONNECTION_STRING_PROPERTY
Name of a property which holds connection string to the mongodb instance.- See Also:
- Constant Field Values
-
DATABASE_PROPERTY
public static final java.lang.String 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:
- Constant Field Values
-
USERNAME_PROPERTY
public static final java.lang.String USERNAME_PROPERTY
Name of the property holding username.- See Also:
- Constant Field Values
-
PASSWORD_PROPERTY
public static final java.lang.String PASSWORD_PROPERTY
Name of the property holding user password.- See Also:
- Constant Field Values
-
HOST_PROPERTY
public static final java.lang.String HOST_PROPERTY
Name of a property which holds host:port address of the mongodb instance.- See Also:
- Constant Field Values
-
AUTH_DB_PROPERTY
public static final java.lang.String AUTH_DB_PROPERTY
Name of the property holding the name of the database in which user is created. Default value isadmin
.- See Also:
- Constant Field Values
-
CONNECTION_POOL_MIN
public static final java.lang.String CONNECTION_POOL_MIN
Name of the property holding the minimum size of Mongo Client connection pool. Default is 10.- Since:
- 5.4
- See Also:
- Constant Field Values
-
CONNECTION_POOL_MAX
public static final java.lang.String CONNECTION_POOL_MAX
Name of the property holding the maximum size of Mongo Client connection pool. Default is 10.- Since:
- 5.4
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MongoDataConnection
public MongoDataConnection(DataConnectionConfig config)
Creates a new data connection based on given config.
-
-
Method Detail
-
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
public java.lang.String getDatabaseName()
Returns the database name hint.
-
listResources
@Nonnull public java.util.List<DataConnectionResource> listResources()
Lists all MongoDB collections in all databases.
-
resourceTypes
@Nonnull public java.util.Collection<java.lang.String> 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(java.lang.String name, java.lang.String connectionString)
Helper method to create newMongoDataConnection
with given name and connection string.
-
-