private void delayOperations() { if (closed) { throw new IndexShardClosedException(shardId); } synchronized (this) { assert queuedBlockOperations > 0 || delayedOperations.isEmpty(); queuedBlockOperations++; } }
private void verifyNotClosed(Exception suppressed) throws IllegalIndexShardStateException { IndexShardState state = this.state; // one time volatile read if (state == IndexShardState.CLOSED) { final IllegalIndexShardStateException exc = new IndexShardClosedException(shardId, "operation only allowed when not closed"); if (suppressed != null) { exc.addSuppressed(suppressed); } throw exc; } }
@Override public synchronized void close() throws IOException { if (closed) { assert listeners.isEmpty() : listeners; } closed = true; notifyListeners(UNASSIGNED_SEQ_NO, new IndexShardClosedException(shardId)); }
@Override public synchronized Translog.Operation next() throws IOException { IndexShardState state = indexShard.state(); if (state == IndexShardState.CLOSED) { throw new IndexShardClosedException(shardId); } else { assert state == IndexShardState.STARTED : "resync should only happen on a started shard, but state was: " + state; } return originalSnapshot.next(); } };
private void sendNextChunk(long position, BytesArray content, boolean lastChunk) throws IOException { // Actually send the file chunk to the target node, waiting for it to complete cancellableThreads.executeIO(() -> recoveryTarget.writeFileChunk(md, position, content, lastChunk, translogOps.get()) ); if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us throw new IndexShardClosedException(request.shardId()); } } }
/** Similar to {@link #getRecovery(long)} but throws an exception if no recovery is found */ public RecoveryRef getRecoverySafe(long id, ShardId shardId) { RecoveryRef recoveryRef = getRecovery(id); if (recoveryRef == null) { throw new IndexShardClosedException(shardId); } assert recoveryRef.target().shardId().equals(shardId); return recoveryRef; }
executor.execute(() -> notifyListener(listener, UNASSIGNED_SEQ_NO, new IndexShardClosedException(shardId))); return;
/** * Marks the shard as recovering based on a recovery state, fails with exception is recovering is not allowed to be set. */ public IndexShardState markAsRecovering(String reason, RecoveryState recoveryState) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardRecoveringException, IndexShardClosedException { synchronized (mutex) { if (state == IndexShardState.CLOSED) { throw new IndexShardClosedException(shardId); } if (state == IndexShardState.STARTED) { throw new IndexShardStartedException(shardId); } if (state == IndexShardState.RECOVERING) { throw new IndexShardRecoveringException(shardId); } if (state == IndexShardState.POST_RECOVERY) { throw new IndexShardRecoveringException(shardId); } this.recoveryState = recoveryState; return changeState(IndexShardState.RECOVERING, reason); } }
@Override protected void onCancel(String reason, @Nullable Exception suppressedException) { RuntimeException e; if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us e = new IndexShardClosedException(shard.shardId(), "shard is closed and recovery was canceled reason [" + reason + "]"); } else { e = new ExecutionCancelledException("recovery was canceled reason [" + reason + "]"); } if (suppressedException != null) { e.addSuppressed(suppressedException); } throw e; } };
public IndexShard postRecovery(String reason) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardClosedException { synchronized (mutex) { if (state == IndexShardState.CLOSED) { throw new IndexShardClosedException(shardId); } if (state == IndexShardState.STARTED) { throw new IndexShardStartedException(shardId); } // we need to refresh again to expose all operations that were index until now. Otherwise // we may not expose operations that were indexed with a refresh listener that was immediately // responded to in addRefreshListener. getEngine().refresh("post_recovery"); recoveryState.setStage(RecoveryState.Stage.DONE); changeState(IndexShardState.POST_RECOVERY, reason); } return this; }
while ((operation = snapshot.next()) != null) { if (shard.state() == IndexShardState.CLOSED) { throw new IndexShardClosedException(request.shardId());
throw new IndexShardClosedException(shardId(), "timed out waiting for relocation hand-off to complete");
throws IOException { if (shard.state() == IndexShardState.CLOSED) { throw new IndexShardClosedException(request.shardId());
@Override protected void alreadyClosed() { throw new IndexShardClosedException(shardId, "could not increment operation counter. shard is closed."); } }
private void acquire(final ActionListener<Releasable> onAcquired, final String executorOnDelay, final boolean forceExecution, final Object debugInfo, final StackTraceElement[] stackTrace) { if (closed) { onAcquired.onFailure(new IndexShardClosedException(shardId)); return;
private void delayOperations() { if (closed) { throw new IndexShardClosedException(shardId); } synchronized (this) { assert queuedBlockOperations > 0 || delayedOperations.isEmpty(); queuedBlockOperations++; } }
private void delayOperations() { if (closed) { throw new IndexShardClosedException(shardId); } synchronized (this) { assert queuedBlockOperations > 0 || delayedOperations.isEmpty(); queuedBlockOperations++; } }
public void finalizeRecovery(final long targetLocalCheckpoint) throws IOException { if (shard.state() == IndexShardState.CLOSED) { throw new IndexShardClosedException(request.shardId());
@Override public synchronized void close() throws IOException { if (closed) { assert listeners.isEmpty() : listeners; } closed = true; notifyListeners(UNASSIGNED_SEQ_NO, new IndexShardClosedException(shardId)); }
@Override public synchronized void close() throws IOException { if (closed) { assert listeners.isEmpty() : listeners; } closed = true; notifyListeners(UNASSIGNED_SEQ_NO, new IndexShardClosedException(shardId)); }