ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogWorker.java
private Task addIOTask(Task task) {
    LOG.debug("{} adds IO task {}", name, task);
    try {
      final Timer.Context enqueueTimerContext = raftLogEnqueueingDelayTimer.time();
      for(; !queue.offer(task, ONE_SECOND); ) {
        Preconditions.assertTrue(isAlive(),
            "the worker thread is not alive");
      }
      enqueueTimerContext.stop();
      task.startTimerOnEnqueue(raftLogQueueingTimer);
    } catch (Throwable t) {
      if (t instanceof InterruptedException && !running) {
        LOG.info("Got InterruptedException when adding task " + task
            + ". The SegmentedRaftLogWorker already stopped.");
      } else {
        LOG.error("Failed to add IO task {}", task, t);
        if (server != null) {
          server.shutdown();
        }
      }
    }
    return task;
  }
/**
   * This is protected by the RaftServer and RaftLog's lock.
   */
This is protected by the RaftServer and RaftLog's lock.
This is protected by the RaftServer and RaftLog ' s lock .
private Task addIOTask(Task task) {
    LOG.debug("{} adds IO task {}", name, task);
    try {
      final Timer.Context enqueueTimerContext = raftLogEnqueueingDelayTimer.time();
      for(; !queue.offer(task, ONE_SECOND); ) {
        Preconditions.assertTrue(isAlive(),
            "the worker thread is not alive");
      }
      enqueueTimerContext.stop();
      task.startTimerOnEnqueue(raftLogQueueingTimer);
    } catch (Throwable t) {
      if (t instanceof InterruptedException && !running) {
        LOG.info("Got InterruptedException when adding task " + task
            + ". The SegmentedRaftLogWorker already stopped.");
      } else {
        LOG.error("Failed to add IO task {}", task, t);
        if (server != null) {
          server.shutdown();
        }
      }
    }
    return task;
  }
private Task addIOTask ( Task task ) { LOG . debug ( "{} adds IO task {}" , name , task ) ; try { final Timer . Context enqueueTimerContext = raftLogEnqueueingDelayTimer . time ( ) ; for ( ; ! queue . offer ( task , ONE_SECOND ) ; ) { Preconditions . assertTrue ( isAlive ( ) , "the worker thread is not alive" ) ; } enqueueTimerContext . stop ( ) ; task . startTimerOnEnqueue ( raftLogQueueingTimer ) ; } catch ( Throwable t ) { if ( t instanceof InterruptedException && ! running ) { LOG . info ( "Got InterruptedException when adding task " + task + ". The SegmentedRaftLogWorker already stopped." ) ; } else { LOG . error ( "Failed to add IO task {}" , task , t ) ; if ( server != null ) { server . shutdown ( ) ; } } } return task ; }
This is protected by the RaftServer and RaftLog's lock.
This is protected by the RaftServer and RaftLog ' s lock .