public void setTimeoutsHolder(TimeoutsHolder timeoutsHolder) { TIMEOUTS_HOLDER_FIELD.set(this, timeoutsHolder); }
@Override public void operationComplete() { // We now have a new ledger where we can write synchronized (pendingMarkDeleteOps) { flushPendingMarkDeletes(); // Resume normal mark-delete operations STATE_UPDATER.set(ManagedCursorImpl.this, State.Open); } }
protected ConnectionHandler(HandlerState state, Backoff backoff, Connection connection) { this.state = state; this.connection = connection; this.backoff = backoff; CLIENT_CNX_UPDATER.set(this, null); }
public HandlerState(PulsarClientImpl client, String topic) { this.client = client; this.topic = topic; STATE_UPDATER.set(this, State.Uninitialized); }
/** * Update the value of this array. * * @param instance the instance holding the field * @param value the new value */ public void set(T instance, V[] value) { updater.set(instance, value); }
/** * Convenience method to set the field value to the empty array. Empty array instances are shared. * * @param instance the instance holding the field */ public void clear(T instance) { updater.set(instance, emptyArray); }
protected void setClientCnx(ClientCnx clientCnx) { CLIENT_CNX_UPDATER.set(this, clientCnx); }
synchronized void setFenced() { STATE_UPDATER.set(this, State.Fenced); }
protected void setState(State s) { STATE_UPDATER.set(this, s); }
@Override public boolean close() { if (allLeaks.remove(this)) { // Call clear so the reference is not even enqueued. clear(); headUpdater.set(this, null); return true; } return false; }
public boolean complete() { if (COMPLETION.compareAndSet(this, ST_PROGRESS, ST_COMPLETED)) { STATE.set(this, State.COMPLETED); return true; } return false; }
DefaultResourceLeak( Object referent, ReferenceQueue<Object> refQueue, Set<DefaultResourceLeak<?>> allLeaks) { super(referent, refQueue); assert referent != null; // Store the hash of the tracked object to later assert it in the close(...) method. // It's important that we not store a reference to the referent as this would disallow it from // be collected via the WeakReference. trackedHash = System.identityHashCode(referent); allLeaks.add(this); // Create a new Record so we always have the creation stacktrace included. headUpdater.set(this, new Record(Record.BOTTOM)); this.allLeaks = allLeaks; }
@Override public boolean close() { if (allLeaks.remove(this)) { // Call clear so the reference is not even enqueued. clear(); headUpdater.set(this, null); return true; } return false; }
DefaultResourceLeak( Object referent, ReferenceQueue<Object> refQueue, Set<DefaultResourceLeak<?>> allLeaks) { super(referent, refQueue); assert referent != null; // Store the hash of the tracked object to later assert it in the close(...) method. // It's important that we not store a reference to the referent as this would disallow it from // be collected via the WeakReference. trackedHash = System.identityHashCode(referent); allLeaks.add(this); // Create a new Record so we always have the creation stacktrace included. headUpdater.set(this, new Record(Record.BOTTOM)); this.allLeaks = allLeaks; }
@Override public void operationComplete() { STATE_UPDATER.set(ManagedCursorImpl.this, State.Open); callback.operationComplete(); }
@Override public boolean close() { // Use the ConcurrentMap remove method, which avoids allocating an iterator. if (allLeaks.remove(this, LeakEntry.INSTANCE)) { // Call clear so the reference is not even enqueued. clear(); headUpdater.set(this, null); return true; } return false; }
@Override public void onError(Throwable t) { ERROR.set(this, t); done = true; drain(); }
@Override public void operationFailed(ManagedLedgerException exception) { log.error("[{}][{}] Metadata ledger creation failed", ledger.getName(), name, exception); synchronized (pendingMarkDeleteOps) { while (!pendingMarkDeleteOps.isEmpty()) { MarkDeleteEntry entry = pendingMarkDeleteOps.poll(); entry.callback.markDeleteFailed(exception, entry.ctx); } // At this point we don't have a ledger ready STATE_UPDATER.set(ManagedCursorImpl.this, State.NoLedger); } } });
@Test public void withFutureDisposed3() { WorkerTask run = new WorkerTask(() -> {}, null); run.dispose(); WorkerTask.THREAD.set(run, Thread.currentThread()); run.setFuture(new FutureTask<Void>(() -> {}, null)); run.call(); }
@Test public void syncDisposeIdempotent() { final WorkerTask run = new WorkerTask(() -> {}, null); WorkerTask.THREAD.set(run, Thread.currentThread()); run.dispose(); assertThat((Future<?>) WorkerTask.FUTURE.get(run)).isEqualTo(WorkerTask.SYNC_CANCELLED); run.dispose(); assertThat((Future<?>) WorkerTask.FUTURE.get(run)).isEqualTo(WorkerTask.SYNC_CANCELLED); run.run(); assertThat((Future<?>) WorkerTask.FUTURE.get(run)).isEqualTo(WorkerTask.SYNC_CANCELLED); }