Synchronized method to handle the arrival of an Ack.
@param blockIndex The index of the block that is being acked.
423072
@Override
    public synchronized void receiveAck(int blockIndex) {
        SendWork work = m_outstandingWork.get(blockIndex);

        // releases the BBContainers and cleans up
        if (work == null || work.m_ackCounter == null) {
            rejoinLog.warn("Received invalid blockIndex ack for targetId " + m_targetId +
                    " for index " + String.valueOf(blockIndex) +
                    ((work == null) ? " already removed the block." : " ack counter haven't been initialized."));
            return;
        }
        if (work.receiveAck()) {
            rejoinLog.trace("Received ack for targetId " + m_targetId +
                    " removes block for index " + String.valueOf(blockIndex));
            m_outstandingWorkCount.decrementAndGet();
            m_outstandingWork.remove(blockIndex);
            work.discard();
        }
        else {
            rejoinLog.trace("Received ack for targetId " + m_targetId +
                    " decrements counter for block index " + String.valueOf(blockIndex));
        }
    }
134747
def notifyBlock(self, queue, blocked):
        '''
        
        '''
        if blocked:
            if self.prioritySet[-1] == queue.priority:
                self.prioritySet.pop()
            else:
                pindex = bisect_left(self.prioritySet, queue.priority)
                if pindex < len(self.prioritySet) and self.prioritySet[pindex] == queue.priority:
                    del self.prioritySet[pindex]
        else:
            if queue.canPop():
                pindex = bisect_left(self.prioritySet, queue.priority)
                if pindex >= len(self.prioritySet) or self.prioritySet[pindex] != queue.priority:
                    self.prioritySet.insert(pindex, queue.priority)
        newblocked =  not self.canPop()
        if newblocked != self.blocked:
            self.blocked = newblocked
            if self.parent is not None:
                self.parent.notifyBlock(self, newblocked)
1136976
final void ensureNodeIndex(int nodeIndex) {
        if (!initialized)
            throw new AssertionError("The graph has not yet been initialized.");

        if (nodeIndex < nodeCount)
            return;

        long oldNodes = nodeCount;
        nodeCount = nodeIndex + 1;
        boolean capacityIncreased = nodes.ensureCapacity((long) nodeCount * nodeEntryBytes);
        if (capacityIncreased) {
            long newBytesCapacity = nodes.getCapacity();
            initNodeRefs(oldNodes * nodeEntryBytes, newBytesCapacity);
        }
    }
179254
private void persistBlocksAndTransactions(EthBlock block)
    {
        Block blk = EtherObjectConverterUtil.convertEtherBlockToKunderaBlock(block, false);
        try
        {
            em.persist(blk);
            LOGGER.debug("Block number " + getBlockNumberWithRawData(blk.getNumber()) + " is stored!");
        }
        catch (Exception ex)
        {
            LOGGER.error("Block number " + getBlockNumberWithRawData(blk.getNumber()) + " is not stored. ", ex);
            throw new KunderaException("Block number " + getBlockNumberWithRawData(blk.getNumber())
                    + " is not stored. ", ex);
        }
        for (TransactionResult tx : block.getResult().getTransactions())
        {
            persistTransactions(EtherObjectConverterUtil.convertEtherTxToKunderaTx(tx), blk.getNumber());
        }
        em.clear();
    }
1294482
@Override public boolean block() throws InterruptedException {
    while( !isDone() ) {
      try { get(); }
      catch(ExecutionException eex) { // skip the execution part
        Throwable tex = eex.getCause();
        if( tex instanceof                 Error) throw (                Error)tex;
        if( tex instanceof  DistributedException) throw ( DistributedException)tex;
        if( tex instanceof JobCancelledException) throw (JobCancelledException)tex;
        throw new RuntimeException(tex);
      }
      catch(CancellationException cex) { Log.errRTExcept(cex); }
    }
    return true;
  }
397713
private void logBlock(int blockIndex, int startIndex, int blockLength)
   {
      if (m_log != null)
      {
         m_log.println("Block Index: " + blockIndex);
         m_log.println("Length: " + blockLength + " (" + Integer.toHexString(blockLength) + ")");
         m_log.println();
         m_log.println(FastTrackUtility.hexdump(m_buffer, startIndex, blockLength, true, 16, ""));
         m_log.flush();
      }
   }
399413
public void writeDataBlock( int blockIndex , long blockOffset , byte[] blockData ) throws JournalException
    {
    	// Refuse any further operation in case of previous failure
    	if (failing)
    		throw new JournalException("Store journal is failing");
    	
        synchronized (journalWriteQueue)
        {
        	if (traceEnabled)
        		log.trace("["+baseName+"] #"+currentTransactionId+" Queueing data block write : ["+blockIndex+"] offset="+blockOffset+" size="+blockData.length+" / queueSize="+(journalWriteQueue.size()+1));
        	
        	DataBlockWriteOperation op = 
        		new DataBlockWriteOperation(currentTransactionId,
		        							blockIndex, 
		    		                        blockOffset, 
		    		                        blockData);
            journalWriteQueue.addLast(op);
            unflushedJournalSize += op.size();
            totalPendingOperations++;
        }
    }
777254
protected void blockFinished (SceneBlock block)
    {
        --_pendingBlocks;

        // once all the visible pending blocks have completed their
        // resolution, recompute our visible object set and show ourselves
        if (_visiBlocks.remove(block) && _visiBlocks.size() == 0) {
            allBlocksFinished();
        }
    }
766627
private byte[] blockForWrite(int index) throws IOException {
    if (index >= blockCount) {
      int additionalBlocksNeeded = index - blockCount + 1;
      disk.allocate(this, additionalBlocksNeeded);
    }

    return blocks[index];
  }
536622
protected void buildIndexBlocking()
    {
        logger.info(String.format("Submitting index build of %s for data in %s",
                getIndexName(), StringUtils.join(baseCfs.getSSTables(), ", ")));

        try (Refs<SSTableReader> sstables = baseCfs.selectAndReference(ColumnFamilyStore.CANONICAL_SSTABLES).refs)
        {
            SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs,
                                                                      Collections.singleton(getIndexName()),
                                                                      new ReducingKeyIterator(sstables));
            Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
            FBUtilities.waitOnFuture(future);
            forceBlockingFlush();
            setIndexBuilt();
        }
        logger.info("Index build of {} complete", getIndexName());
    }
1358621
protected final byte[] serializeAllocationBlock( int blockIndex )
    {
    	byte[] allocationBlock = new byte[AT_BLOCK_SIZE];

        // Regroup I/O to improve performance
        allocationBlock[AB_FLAGS_OFFSET]       = flags[blockIndex];
        allocationBlock[AB_ALLOCSIZE_OFFSET]   = (byte)((allocatedSize[blockIndex] >>> 24) & 0xFF);
        allocationBlock[AB_ALLOCSIZE_OFFSET+1] = (byte)((allocatedSize[blockIndex] >>> 16) & 0xFF);
        allocationBlock[AB_ALLOCSIZE_OFFSET+2] = (byte)((allocatedSize[blockIndex] >>>  8) & 0xFF);
        allocationBlock[AB_ALLOCSIZE_OFFSET+3] = (byte)((allocatedSize[blockIndex] >>>  0) & 0xFF);
        allocationBlock[AB_PREVBLOCK_OFFSET]   = (byte)((previousBlock[blockIndex] >>> 24) & 0xFF);
        allocationBlock[AB_PREVBLOCK_OFFSET+1] = (byte)((previousBlock[blockIndex] >>> 16) & 0xFF);
        allocationBlock[AB_PREVBLOCK_OFFSET+2] = (byte)((previousBlock[blockIndex] >>>  8) & 0xFF);
        allocationBlock[AB_PREVBLOCK_OFFSET+3] = (byte)((previousBlock[blockIndex] >>>  0) & 0xFF);
        allocationBlock[AB_NEXTBLOCK_OFFSET]   = (byte)((nextBlock[blockIndex] >>> 24) & 0xFF);
        allocationBlock[AB_NEXTBLOCK_OFFSET+1] = (byte)((nextBlock[blockIndex] >>> 16) & 0xFF);
        allocationBlock[AB_NEXTBLOCK_OFFSET+2] = (byte)((nextBlock[blockIndex] >>>  8) & 0xFF);
        allocationBlock[AB_NEXTBLOCK_OFFSET+3] = (byte)((nextBlock[blockIndex] >>>  0) & 0xFF);
        
        return allocationBlock;
    }
689399
public ByteBuffer fetch(long position) throws InterruptedException, ExecutionException {
    long blockIndex = position / bufSize;
    boolean goingBack = false;
    for (WorkUnit w : full) {
      if (w.blockIndex == blockIndex) {
        ensureFetching(blockIndex + 1);
        nbHit++;
        return w.buf;
      } else if (w.blockIndex > blockIndex) {
        goingBack = true;
      }
    }
    if (goingBack) {
      // user is asking for a block with a lower index than we've already fetched -
      // in other words they are not following the expected pattern of increasing indexes.
      nbGoingBack++;
    }
    if (null == fetching) {
      ensureFetching(blockIndex);
    }
    WorkUnit candidate = fetching;
    // block until we have the buffer
    ByteBuffer buf = candidate.getBuf();
    full.add(candidate);
    fetching = null;
    if (candidate.blockIndex == blockIndex) {
      // this is who we were waiting for
      nbNearHit++;
      ensureFetching(blockIndex + 1);
      return buf;
    } else {
      // wrong block. Let's fetch the right one now.
      nbMiss++;
      ensureFetching(blockIndex);
      candidate = fetching;
      buf = candidate.getBuf();
      full.add(candidate);
      fetching = null;
      ensureFetching(blockIndex + 1);
      return buf;
    }
  }
663666
private void sendNextSketchBlock() {
        byte[] rawBlock = sketchBlocksToSend.get(currSketchBlockNum);
        Buffer block = new Buffer();
        block.write(rawBlock);
        sendMessage(BeanMessageID.BL_FW_BLOCK, block);

        resetSketchBlockSendTimeout();

        int blocksSent = currSketchBlockNum + 1;
        int totalBlocks = sketchBlocksToSend.size();
        onSketchUploadProgress.onResult(UploadProgress.create(blocksSent, totalBlocks));

        currSketchBlockNum++;
        if ( currSketchBlockNum >= sketchBlocksToSend.size() ) {
            resetSketchUploadState();
        }
    }
1207831
private void requestBlock() {
    next = ByteBuffer.allocate(blockSizeBytes);
    long requestTimeout = retryParams.getRequestTimeoutMillisForCurrentAttempt();
    pendingFetch = raw.readObjectAsync(next, filename, fetchPosition, requestTimeout);
  }
354343
def HandleBlockReceived(self, inventory):
        
        block = IOHelper.AsSerializableWithType(inventory, 'neo.Core.Block.Block')
        if not block:
            return

        blockhash = block.Hash.ToBytes()
        try:
            if blockhash in BC.Default().BlockRequests:
                BC.Default().BlockRequests.remove(blockhash)
        except KeyError:
            pass
        try:
            if blockhash in self.myblockrequests:
                # logger.debug(f"{self.prefix} received block: {block.Index}")
                self.heart_beat(HEARTBEAT_BLOCKS)
                self.myblockrequests.remove(blockhash)
        except KeyError:
            pass
        self.leader.InventoryReceived(block)
1169690
private void writeIndex(int entryAddress,
                          byte []entryBuffer, int offset, int length)
  {
    long address = _segment.getAddress() + entryAddress;

    if (_segment.length() < entryAddress + length) {
      throw new IllegalStateException(L.l("offset=0x{0} length={1}", entryAddress, length));
    }
    //try (StoreWrite os = _readWrite.openWrite(address, BLOCK_SIZE)) {
    _sOut.write(address, entryBuffer, offset, length);
    
    _isDirty = true;
    // }
  }
413351
protected function ackOrNackBlock()
    {
        if (! $this->lastDeliveryTag) {
            return;
        }

        $result = $this->flushDeferred();

        switch ($result) {
            case FlushDeferredResult::MSG_ACK():
                $this->ack();
                break;
            case FlushDeferredResult::MSG_REJECT():
                $this->nackAll(false);
                break;
            case FlushDeferredResult::MSG_REJECT_REQUEUE():
                $this->nackAll(true);
                break;
        }
    }