Ends recording a block.
This method stops output buffering and saves the rendering result as a named block in the view.
@throws Exception
489537
public function run()
    {
        $block = ob_get_clean();
        if ($this->renderInPlace) {
            throw new Exception("not implemented yet ! ");
        }
        $block = trim($block);
        $cssBlockPattern = '|^<style[^>]*>(?P<blockContent>.+?)</style>$|is';
        if (preg_match($cssBlockPattern, $block, $matches)) {
            $block = $matches['blockContent'];
        }
        $this->view->registerCss($block, $this->options, $this->key);
    }
1274864
@Override // FSDatasetInterface
  public void finalizeBlock(int namespaceId, Block b) throws IOException {
    finalizeBlockInternal(namespaceId, b, true);
  }
907639
private void flushBlock(boolean isClose)
    throws IOException
  {
    if (isClose) {
      if (! _isLargeBlob && _offset <= _table.getInlineBlobMax()) {
        return;
      }
    }

    _isLargeBlob = true;
    
    if (_blobOut == null) {
      _blobOut = _table.getTempStore().openWriter();
    }
    
    if (_offset != _bufferEnd && ! isClose) {
      throw new IllegalStateException();
    }
    
    _blobOut.write(_tempBuffer.buffer(), 0, _offset);
    _offset = 0;
    
    if (! isClose) {
      return;
    }
    
    StreamSource ss = _blobOut.getStreamSource();
    _blobOut = null;
      
    int len = (int) ss.getLength();
    int blobPageSizeMax = _table.getBlobPageSizeMax();

    int pid = -1;
    int nextPid = -1;
    int tailLen = len % blobPageSizeMax;
    // long seq = 0;

    PageServiceSync tableService = _table.getTableService();
    
    if (tailLen > 0) {
      int tailOffset = len - tailLen;
      
      pid = tableService.writeBlob(pid, ss.openChild(), 
                                  tailOffset, tailLen);
      
      len -= tailLen;
    }
      
    while (len > 0) {
      int sublen = blobPageSizeMax;
      int offset = len - blobPageSizeMax;
      
      pid = tableService.writeBlob(pid, ss.openChild(), offset, sublen);
      
      len -= sublen;
    }
      
    ss.close();
    
    _blobId = Math.max(pid, 0);
  }
474775
public void stopRecording() {
        IRecordingListener listener = null;
        if (recordingListener != null && (listener = recordingListener.get()).isRecording()) {
            sendRecordStopNotify();
            notifyRecordingStop();
            // remove the listener
            removeStreamListener(listener);
            // stop the recording listener
            listener.stop();
            // clear and null-out the thread local
            recordingListener.clear();
            recordingListener = null;
        }
    }
656655
protected function endRenderBlock($blockName)
    {
        $contents = ob_get_contents();
        ob_end_clean();
        foreach ($this->plugins as $plugin) {
            $blockRenderList = $plugin->getBlockRenderList();
            if (in_array($blockName, $blockRenderList) === true) {
                echo $plugin->callBlockRenderEnd($blockName, $contents);
                return;
            }
        }
        echo $contents;
        throw new JigException("Block $blockName not known for ending block in plugins.");
    }
449058
public void stop() {
        if (tape == null) {
            throw new IllegalStateException("stop called when Recorder is not started");
        }

        for (RecorderListener listener : listeners) {
            listener.onRecorderStop();
        }
        getTapeLoader().writeTape(tape);
        tape = null;
    }
605501
public void abandonBlock(Block b, String src, String holder
      ) throws IOException {
    abandonBlockInternal(b, src, holder);
  }
361050
public void endDocument() throws org.xml.sax.SAXException
    {
        flushPending();
        if (m_doIndent && !m_isprevtext)
        {
            try
            {
            outputLineSep();
            }
            catch(IOException e)
            {
                throw new SAXException(e);
            }
        }

        flushWriter();
        
        if (m_tracer != null)
            super.fireEndDoc();
    }
523583
public void finishSynch() throws IOException {
		if (finishing != null) {
			finishing.blockException(0);
			return;
		}
		finishing = new SynchronizationPoint<>();
		try {
			AsyncWork<Integer, IOException> lastWrite = writeOps.getLastPendingOperation();
			if (lastWrite != null) {
				lastWrite.blockException(0);
			}
			deflater.finish();
			if (!deflater.finished()) {
				byte[] writeBuf = new byte[8192];
				do {
					int nb = deflater.deflate(writeBuf, 0, writeBuf.length);
					if (nb <= 0) break;
					output.writeSync(ByteBuffer.wrap(writeBuf, 0, nb));
				} while (!deflater.finished());
			}
			finishing.unblock();
		} catch (IOException e) {
			finishing.error(e);
			throw e;
		}
	}
582434
protected void finishSendError(Exception e) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "finishSendError(exception): " + getVC());
        }
        WsByteBuffer[] body = (WsByteBuffer[]) getVC().getStateMap().remove(EPS_KEY);
        if (null != body) {
            for (int i = 0; i < body.length && null != body[i]; i++) {
                body[i].release();
            }
        }
        this.myLink.close(getVC(), e);
    }
444014
@Override
  public void onCompleted() {
    RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
      @Override
      public OpenLocalBlockResponse call() throws Exception {
        if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
          mWorker.unlockBlock(mLockId);
          mLockId = BlockLockManager.INVALID_LOCK_ID;
        } else if (mRequest != null) {
          LOG.warn("Close a closed block {}.", mRequest.getBlockId());
        }
        return null;
      }

      @Override
      public void exceptionCaught(Throwable e) {
        mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
        mLockId = BlockLockManager.INVALID_LOCK_ID;
      }
    }, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s",
        mSessionId, mRequest);
  }
1234067
private void closeOutgoingSockets() throws ClientException {

        SocketOperator op = new SocketOperator() {
                public void operate(SocketBox sb) throws Exception {
                    if (((ManagedSocketBox) sb).isReusable()) {
                        Socket s = sb.getSocket();
                        if (s != null) {
                            // write the closing Eblock and close the socket
                            EBlockImageDCWriter.close(
                                  new DataOutputStream(s.getOutputStream()));
                        }
                    }
                }
       };

        try {
            socketPool.applyToAll(op);
        } catch (IOException e) {
            // ignore - sometimes server might close the socket
        } catch (Exception e) {
            ClientException ce =
                new ClientException(ClientException.SOCKET_OP_FAILED);
            ce.setRootCause(e);
            throw ce;
        }
    }
647559
private void endBlocking(boolean completed) throws AsynchronousCloseException {
    synchronized (blockingThreads) {
      blockingThreads.remove(Thread.currentThread());
    }
    end(completed);
  }
1149571
public function endBlock()
    {
        if (!$this->openBlocks) {
            throw new RuntimeException('No block started.');
        }

        $name  = array_pop($this->openBlocks);
        $value = ob_get_clean();

        if ($this->blocks[$name] === null) {
            $this->blocks[$name] = $value;
        }

        return $this->blocks[$name];
    }
535710
public void terminate() throws InterruptedException, IOException {
        final Computer computer = toComputer();
        if (computer != null) {
            computer.recordTermination();
        }
        try {
            // TODO: send the output to somewhere real
            _terminate(new StreamTaskListener(System.out, Charset.defaultCharset()));
        } finally {
            try {
                Jenkins.get().removeNode(this);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Failed to remove "+name,e);
            }
        }
    }
912086
@Override
    public void stopRecording() {
        super.stopRecording();
        mSentBroadcastLiveEvent = false;
        if (mStream != null) {
            if (VERBOSE) Log.i(TAG, "Stopping Stream");
            mKickflip.stopStream(mStream, new KickflipCallback() {
                @Override
                public void onSuccess(Response response) {
                    if (VERBOSE) Log.i(TAG, "Got stop stream response " + response);
                }

                @Override
                public void onError(KickflipException error) {
                    Log.w(TAG, "Error getting stop stream response! " + error);
                }
            });
        }
    }
1122790
protected void stopProxy() throws Exception {
    mProxyProcess.stop();
    if (mProxyThread != null) {
      while (mProxyThread.isAlive()) {
        LOG.info("Stopping thread {}.", mProxyThread.getName());
        mProxyThread.interrupt();
        mProxyThread.join(1000);
      }
      mProxyThread = null;
    }
  }