public void releaseAllResources() throws IOException {
    synchronized (requestLock) {
      if (!isReleased) {
        try {
          LOG.debug("{}: Releasing {}.", owningTaskName, this);

          if (retriggerLocalRequestTimer != null) {
            retriggerLocalRequestTimer.cancel();
          }

          for (InputChannel inputChannel : inputChannels.values()) {
            try {
              inputChannel.releaseAllResources();
            } catch (IOException e) {
              LOG.warn("Error during release of channel resources: " + e.getMessage(), e);
            }
          }

          // The buffer pool can actually be destroyed immediately after the
          // reader received all of the data from the input channels.
          if (bufferPool != null) {
            bufferPool.lazyDestroy();
          }
        } finally {
          isReleased = true;
        }
      }
    }
  }
Esempio n. 2
0
  /**
   * Registers a buffer pool with this result partition.
   *
   * <p>There is one pool for each result partition, which is shared by all its sub partitions.
   *
   * <p>The pool is registered with the partition *after* it as been constructed in order to conform
   * to the life-cycle of task registrations in the {@link TaskManager}.
   */
  public void registerBufferPool(BufferPool bufferPool) {
    checkArgument(
        bufferPool.getNumberOfRequiredMemorySegments() >= getNumberOfSubpartitions(),
        "Bug in result partition setup logic: Buffer pool has not enough guaranteed buffers for this result partition.");

    checkState(
        this.bufferPool == null,
        "Bug in result partition setup logic: Already registered buffer pool.");

    this.bufferPool = checkNotNull(bufferPool);

    // If the partition type is back pressure-free, we register with the buffer pool for
    // callbacks to release memory.
    if (!partitionType.hasBackPressure()) {
      bufferPool.setBufferPoolOwner(this);
    }
  }
  public void setBufferPool(BufferPool bufferPool) {
    // Sanity checks
    checkArgument(
        numberOfInputChannels == bufferPool.getNumberOfRequiredMemorySegments(),
        "Bug in input gate setup logic: buffer pool has not enough guaranteed buffers "
            + "for this input gate. Input gates require at least as many buffers as "
            + "there are input channels.");

    checkState(
        this.bufferPool == null,
        "Bug in input gate setup logic: buffer pool has" + "already been set for this input gate.");

    this.bufferPool = checkNotNull(bufferPool);
  }
Esempio n. 4
0
 public void destroyBufferPool() {
   if (bufferPool != null) {
     bufferPool.lazyDestroy();
   }
 }