@Override public void add(final K k, final V v, final Handler<AsyncResult<Void>> completionHandler) { final ContextInternal ctx = FakeClusterManager.this.vertx.getOrCreateContext(); ctx.executeBlocking(fut -> { ChoosableSet<V> vals = this.map.get(k); if (vals == null) { vals = new ChoosableSet<>(1); final ChoosableSet<V> prevVals = this.map.putIfAbsent(k, vals); if (prevVals != null) { vals = prevVals; } } vals.add(v); fut.complete(); }, this.taskQueue, completionHandler); }
@Override public void remove(final K k, final V v, final Handler<AsyncResult<Boolean>> completionHandler) { final ContextInternal ctx = FakeClusterManager.this.vertx.getOrCreateContext(); ctx.executeBlocking(fut -> { final ChoosableSet<V> vals = this.map.get(k); boolean found = false; if (vals != null) { final boolean removed = vals.remove(v); if (removed) { if (vals.isEmpty()) { this.map.remove(k); } found = true; } } fut.complete(found); }, this.taskQueue, completionHandler); }
@Override public void removeAllMatching(final Predicate<V> p, final Handler<AsyncResult<Void>> completionHandler) { final ContextInternal ctx = FakeClusterManager.this.vertx.getOrCreateContext(); ctx.executeBlocking(fut -> { final Iterator<Entry<K, ChoosableSet<V>>> mapIter = this.map.entrySet().iterator(); while (mapIter.hasNext()) { final Entry<K, ChoosableSet<V>> entry = mapIter.next(); final ChoosableSet<V> vals = entry.getValue(); final Iterator<V> iter = vals.iterator(); while (iter.hasNext()) { final V val = iter.next(); if (p.test(val)) { iter.remove(); } } if (vals.isEmpty()) { mapIter.remove(); } } fut.complete(); }, this.taskQueue, completionHandler); }
JDBCSQLRowStream(ContextInternal ctx, TaskQueue statementsQueue, Statement st, ResultSet rs, int fetchSize) throws SQLException { this.ctx = ctx; this.st = st; this.fetchSize = fetchSize; this.rs = rs; this.statementsQueue = statementsQueue; accumulator = new ArrayDeque<>(fetchSize); metaData = rs.getMetaData(); cols = metaData.getColumnCount(); paused.set(true); stClosed.set(false); rsClosed.set(false); // the first rs is populated in the constructor more.set(true); }
@Override public void get(final K k, final Handler<AsyncResult<ChoosableIterable<V>>> asyncResultHandler) { final ContextInternal ctx = FakeClusterManager.this.vertx.getOrCreateContext(); ctx.executeBlocking(fut -> { ChoosableIterable<V> it = this.map.get(k); if (it == null) { it = new ChoosableSet<>(0); } fut.complete(it); }, this.taskQueue, asyncResultHandler); }
private JDBCBatch(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, Type type, List<String> sql, List<JsonArray> in, List<JsonArray> out) { super(vertx, helper, options, ctx); this.type = type; this.sql = sql; this.in = in; this.out = out; }
public JDBCConnectionImpl(Context context, JDBCStatementHelper helper, Connection conn, PoolMetrics metrics, Object metric) { this.vertx = context.owner(); this.helper = helper; this.conn = conn; this.metrics = metrics; this.metric = metric; this.ctx = (ContextInternal) context; }
public VertxIoHandlerBridge(ContextInternal context) { this.context = context; }
@Before public void before() { super.before(); vertx = Vertx.vertx(); context = (ContextInternal) vertx.getOrCreateContext(); }
boolean onContextEventLoop() { return ((ContextInternal) bridgeContext).nettyEventLoop().inEventLoop(); }
@Override public JDBCClient update(String sql, Handler<AsyncResult<UpdateResult>> resultHandler) { ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext(); executeDirect(ctx, new JDBCUpdate(vertx, helper, null, ctx, sql, null), resultHandler); return this; }
@Override public JDBCClient updateWithParams(String sql, JsonArray in, Handler<AsyncResult<UpdateResult>> resultHandler) { ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext(); executeDirect(ctx, new JDBCUpdate(vertx, helper, null, ctx, sql, in), resultHandler); return this; }
@Override public JDBCClient query(String sql, Handler<AsyncResult<ResultSet>> resultHandler) { ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext(); executeDirect(ctx, new JDBCQuery(vertx, helper, null, ctx, sql, null), resultHandler); return this; }
@Override public JDBCClient queryWithParams(String sql, JsonArray in, Handler<AsyncResult<ResultSet>> resultHandler) { ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext(); executeDirect(ctx, new JDBCQuery(vertx, helper, null, ctx, sql, in), resultHandler); return this; }
public JDBCExecute(Vertx vertx, SQLOptions options, ContextInternal ctx, String sql) { super(vertx, options, ctx); this.sql = sql; }
public StreamQuery(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, TaskQueue statementsQueue, String sql, JsonArray in) { super(vertx, helper, options, ctx); this.sql = sql; this.in = in; this.statementsQueue = statementsQueue; }
public JDBCUpdate(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, String sql, JsonArray in) { super(vertx, helper, options, ctx); this.sql = sql; this.in = in; }
public JDBCCallable(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, String sql, JsonArray in, JsonArray out) { super(vertx, helper, options, ctx); this.sql = sql; this.in = in; this.out = out; }
public JDBCBatch(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, List<String> sql) { this(vertx, helper, options, ctx, Type.STATEMENT, sql, null, null); }
public JDBCBatch(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, String sql, List<JsonArray> in) { this(vertx, helper, options, ctx, Type.PREPARED, Collections.singletonList(sql), in, null); }
public JDBCBatch(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, String sql, List<JsonArray> in, List<JsonArray> out) { this(vertx, helper, options, ctx, Type.CALLABLE, Collections.singletonList(sql), in, out); }
public JDBCQuery(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx, String sql, JsonArray in) { super(vertx, helper, options, ctx); this.sql = sql; this.in = in; }
public JDBCClose(Vertx vertx, SQLOptions options, ContextInternal ctx) { super(vertx, options, ctx); }
public JDBCAutoCommit(Vertx vertx, SQLOptions options, ContextInternal ctx, boolean autoCommit) { super(vertx, options, ctx); this.autoCommit = autoCommit; }
public JDBCCommit(Vertx vertx, SQLOptions options, ContextInternal ctx) { super(vertx, options, ctx); }
protected AbstractJDBCAction(Vertx vertx, SQLOptions options, ContextInternal ctx) { this(vertx, null, options, ctx); }
protected AbstractJDBCAction(Vertx vertx, JDBCStatementHelper helper, SQLOptions options, ContextInternal ctx) { this.vertx = vertx; this.options = options; this.ctx = ctx; this.helper = helper; }
public JDBCRollback(Vertx vertx, SQLOptions options, ContextInternal ctx) { super(vertx, options, ctx); }