/** * Create a MySQL client which shares its data source with any other MySQL clients created with the same * data source name * @param vertx the Vert.x instance * @param config the configuration * @param poolName the pool name * @return the client */ public static io.vertx.rxjava.ext.asyncsql.AsyncSQLClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config, String poolName) { io.vertx.rxjava.ext.asyncsql.AsyncSQLClient ret = io.vertx.rxjava.ext.asyncsql.AsyncSQLClient.newInstance(io.vertx.ext.asyncsql.MySQLClient.createShared(vertx.getDelegate(), config, poolName)); return ret; }
/** * Like {@link io.vertx.rxjava.ext.asyncsql.MySQLClient#createShared} but with the default pool name * @param vertx the Vert.x instance * @param config the configuration * @return the client */ public static io.vertx.rxjava.ext.asyncsql.AsyncSQLClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { io.vertx.rxjava.ext.asyncsql.AsyncSQLClient ret = io.vertx.rxjava.ext.asyncsql.AsyncSQLClient.newInstance(io.vertx.ext.asyncsql.MySQLClient.createShared(vertx.getDelegate(), config)); return ret; }
private static void initInternal(final Vertx vertx, final String name) { Fn.pool(CLIENTS, name, () -> Infix.init(Plugins.Infix.MYSQL, (config) -> MySQLClient.createShared(vertx, config, name), MongoInfix.class)); }
public static io.vertx.ext.asyncsql.AsyncSQLClient createShared(io.vertx.ext.asyncsql.MySQLClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config, java.lang.String poolName) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.asyncsql.MySQLClient.createShared(vertx, config != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(config) : null, poolName)); } public static io.vertx.ext.asyncsql.AsyncSQLClient createShared(io.vertx.ext.asyncsql.MySQLClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config) {
private static void initInternal(final Vertx vertx, final String name) { Fn.pool(CLIENTS, name, () -> Infix.init(Plugins.Infix.MYSQL, (config) -> MySQLClient.createShared(vertx, config, name), MongoInfix.class)); }
public static io.vertx.ext.asyncsql.AsyncSQLClient createShared(io.vertx.ext.asyncsql.MySQLClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.asyncsql.MySQLClient.createShared(vertx, config != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(config) : null)); } }
@Override protected void internalInit(Handler<AsyncResult<IDataStore>> handler) { try { mySQLClient = shared ? MySQLClient.createShared(vertx, getConfig()) : MySQLClient.createNonShared(vertx, getConfig()); datastore = new MySqlDataStore(vertx, mySQLClient, getConfig()); handler.handle(Future.succeededFuture(datastore)); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } }
@Test public void testSharedDefault() throws Exception { LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); client1.close(); assertEquals(1, map.size()); client2.close(); assertEquals(1, map.size()); client3.close(); assertWaitUntil(() -> map.size() == 0); assertWaitUntil(() -> map != getLocalMap()); // Map has been closed }
@Test public void testSharedDefault() throws Exception { LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); client1.close(); assertEquals(1, map.size()); client2.close(); assertEquals(1, map.size()); client3.close(); assertWaitUntil(() -> map.size() == 0); assertWaitUntil(() -> map != getLocalMap()); // Map has been closed }
@Test public void testSharedDefault() throws Exception { LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config); assertEquals(1, map.size()); client1.close(); assertEquals(1, map.size()); client2.close(); assertEquals(1, map.size()); client3.close(); assertWaitUntil(() -> map.size() == 0); assertWaitUntil(() -> map != getLocalMap()); // Map has been closed }
LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client4 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client5 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client6 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size());
LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client4 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client5 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client6 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size());
LocalMap<String, Object> map = getLocalMap(); JsonObject config = new JsonObject(); SQLClient client1 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client2 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client3 = MySQLClient.createShared(vertx, config, "ds1"); assertEquals(1, map.size()); SQLClient client4 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client5 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size()); SQLClient client6 = MySQLClient.createShared(vertx, config, "ds2"); assertEquals(2, map.size());