Method reallocateTransmissionStreams
@param ignoredStream
961882
public void reallocateTransmissionStreams(PtoPXmitMsgsItemStream ignoredStream)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "reallocateTransmissionStreams", ignoredStream);

    if(_xmitQueuePoints != null )
    {
      LockManager lockManager = _baseDestinationHandler.getReallocationLockManager();
      lockManager.lockExclusive();
      try
      {
        if (_xmitQueuePoints != null)
        {
          //PK57432 Cant hold queuePoints lock while we call reallocate
          HashMap clonedXmitQueuePoints;
          synchronized(_xmitQueuePoints)
          {
            // It's possible that while we're iterating over the existing xmit streams and
            // their messages that we inadvertently create a new xmit stream (while in
            // searchForPtoPOutputHandler). This obviously invalidates the list, so instead
            // we take a copy up front, safe in the knowledge that any newly created xmit
            // stream can't possibly need its messages reallocated.
            clonedXmitQueuePoints =
                     (HashMap)_xmitQueuePoints.clone();
          }

          Iterator itr = clonedXmitQueuePoints.values().iterator();
          while(itr.hasNext())
          {
            PtoPXmitMsgsItemStream xmitQueue = (PtoPXmitMsgsItemStream)itr.next();
            if (xmitQueue != ignoredStream)
              xmitQueue.reallocateMsgs();
          }
        }
      }
      finally
      {
        lockManager.unlockExclusive();
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "reallocateTransmissionStreams");
  }
261241
@GuardedBy("lock")
  private PendingStream createPendingStream(PickSubchannelArgs args) {
    PendingStream pendingStream = new PendingStream(args);
    pendingStreams.add(pendingStream);
    if (getPendingStreamsCount() == 1) {
      syncContext.executeLater(reportTransportInUse);
    }
    return pendingStream;
  }
679905
static public void copyStream(Reader reader, Writer writer) throws IOException {
		copyStream(reader, writer, DEFAULT_TRANSFER_BUFFER_SIZE);
	}
377240
@SuppressWarnings("unchecked")
  @GwtIncompatible("ObjectInputStream")
  public void restoreContents(ObjectInputStream in) throws IOException, ClassNotFoundException {
    eachRefTypeIndexedByProperty = (Map<String, Map<String, ObjectType>>) in.readObject();
    interfaceToImplementors = (Multimap<String, FunctionType>) in.readObject();
    typesIndexedByProperty = (Multimap<String, JSType>) in.readObject();
  }
123624
public void sendFlushedMessage(SIBUuid8 ignore, SIBUuid12 streamID) throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
       SibTr.entry(tc, "sendFlushedMessage", new Object[]{ignore, streamID});
       
    ControlFlushed flushMsg = createControlFlushed(_targetMEUuid, streamID);
    
    // If the destination in a Link add Link specific properties to message
    if( _isLink )
    {
      flushMsg = (ControlFlushed)addLinkProps(flushMsg);
    }
    
    _mpio.sendToMe(_targetMEUuid, SIMPConstants.MSG_HIGH_PRIORITY, flushMsg);   
   
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "sendFlushedMessage");
  }
747826
void unregisterOutputStream(OutStream stream) {
		lock.lock();
		try {
			// only decrement if we actually remove the stream
			if (openOutputStreams.remove(stream)) {
				numReservedOutputStreams--;
				available.signalAll();
			}
		}
		finally {
			lock.unlock();
		}
	}
1277739
protected void restoreSystemStreams() {
        if (System.out == teeOut)
            System.setOut(systemOut.getOriginalStream());
        if (System.err == teeErr)
            System.setErr(systemErr.getOriginalStream());
    }
803954
public static InputStream getBoundedStream(final InputStream stream, final int from, final int to)
            throws IOException {
        final long skipped = stream.skip(from);
        LOGGER.debug("Skipped {} bytes", skipped);
        return new BoundedInputStream(stream, (long) to - from);
    }
1068325
private void resubscribeChannels() throws InterruptedException, BitfinexClientException {
		final Map<Integer, ChannelCallbackHandler> oldChannelIdSymbolMap = new HashMap<>();

		synchronized (channelIdToHandlerMap) {
			oldChannelIdSymbolMap.putAll(channelIdToHandlerMap);
			channelIdToHandlerMap.clear();
			channelIdToHandlerMap.notifyAll();
			
			// Implicit channel account info channel
			channelIdToHandlerMap.put(ACCCOUNT_INFO_CHANNEL, oldChannelIdSymbolMap.get(ACCCOUNT_INFO_CHANNEL));
		}
		
		// Resubscribe channels
		for(final ChannelCallbackHandler handler : oldChannelIdSymbolMap.values()) {
			final BitfinexStreamSymbol symbol = handler.getSymbol();
			if(symbol instanceof BitfinexTickerSymbol) {
				sendCommand(new SubscribeTickerCommand((BitfinexTickerSymbol) symbol));
			} else if(symbol instanceof BitfinexExecutedTradeSymbol) {
				sendCommand(new SubscribeTradesCommand((BitfinexExecutedTradeSymbol) symbol));
			} else if(symbol instanceof BitfinexCandlestickSymbol) {
				sendCommand(new SubscribeCandlesCommand((BitfinexCandlestickSymbol) symbol));
			} else if(symbol instanceof BitfinexOrderBookSymbol) {
				sendCommand(new SubscribeOrderbookCommand((BitfinexOrderBookSymbol) symbol));
			} else if(symbol instanceof BitfinexAccountSymbol) {
				// This symbol does not need to be resubscribed
			} else {
				logger.error("Unknown stream symbol: {}", symbol);
			}
		}
		
		waitForChannelResubscription(oldChannelIdSymbolMap);		
	}
892368
private void sendClearPing() {
        Ping eof = new Ping();
        eof.setEventType(Ping.STREAM_PLAYBUFFER_CLEAR);
        eof.setValue2(streamId);
        // eos 
        RTMPMessage eofMsg = RTMPMessage.build(eof);
        doPushMessage(eofMsg);
    }
543324
private void sendNotModified(ChannelHandlerContext ctx) {
        FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED);
        setDateHeader(response);

        this.sendAndCleanupConnection(ctx, response);
    }
146177
public void putContentStream(MIMETypedStream stream) throws StreamIOException {

        // TODO: refactor to use proper temp file management - FCREPO-718
        // for now, write to new temp file, clean up existing location
        String oldDSLocation = DSLocation;
        try {
            // note: don't use temp upload dir, use (container's) temp dir (upload dir is for uploads)
            File tempFile = File.createTempFile("managedcontentupdate", null);
            OutputStream os = new FileOutputStream(tempFile);
            StreamUtility.pipeStream(stream.getStream(), os, 32768);
            DSLocation = TEMP_SCHEME + tempFile.getAbsolutePath();
        } catch (Exception e) {
            throw new StreamIOException("Error creating new temp file for updated managed content (existing content is:" + oldDSLocation + ")", e);
        }

        // if old location was a temp location, clean it up
        // (if old location was uploaded, DefaultManagement should do this, but refactor up as part of FCREPO-718)
        if (oldDSLocation != null && oldDSLocation.startsWith(TEMP_SCHEME)) {
            File oldFile;
            try {
                oldFile = new File(oldDSLocation.substring(TEMP_SCHEME.length()));
            } catch (Exception e) {
                throw new StreamIOException("Error removing old temp file while updating managed content (location: " + oldDSLocation + ")", e);
            }
            if (oldFile.exists()) {
                if (!oldFile.delete()) {
                    logger.warn("Failed to delete temp file, marked for deletion when VM closes " + oldFile.getAbsolutePath());
                    oldFile.deleteOnExit();
                }
            } else
                logger.warn("Cannot delete temp file as it no longer exists " + oldFile.getAbsolutePath());
        }
    }
208115
protected void reBuffer()
    {
        resetBuffer();

        try
        {
            int read = buffer.length;
            if (bufferOffset + read > fileLength)
            {
                if (bufferOffset >= fileLength)
                    return;
                read = (int) (fileLength - bufferOffset);
            }

            channel.position(bufferOffset); // setting channel position

            int offset = 0;
            while (read > 0)
            {
                int n = super.read(buffer, offset, read);
                if (n < 0)
                    throw new IllegalStateException();
                read -= n;
                offset += n;
            }

            validBufferBytes = offset;
        }
        catch (IOException e)
        {
            throw new FSReadError(e, filePath);
        }
    }
449872
static public void copyStream(Reader reader, Writer writer, int transferBufferSize) throws IOException {
		if( transferBufferSize < 1 ) {
			throw new IOException("Transfer buffer size can not be smaller than 1");
		}

		char[] buffer = new char[transferBufferSize];

		int bytesRead = reader.read(buffer);
		while( bytesRead >= 0 ) {
			writer.write(buffer, 0, bytesRead);

			bytesRead = reader.read(buffer);
		}
	}
802687
private void copy(final InputStream in, final SeekableByteChannel out) throws IOException {
        assert in != null : "InStream must be specified";
        assert out != null : "Channel must be specified";

        final byte[] backingBuffer = new byte[1024 * 4];
        final ByteBuffer byteBuffer = ByteBuffer.wrap(backingBuffer);
        int bytesRead = 0;
        while ((bytesRead = in.read(backingBuffer, 0, backingBuffer.length)) > -1) {
            // Limit to the amount we've actually read in, so we don't overflow into old data blocks
            byteBuffer.limit(bytesRead);
            out.write(byteBuffer);
            // Position back to 0
            byteBuffer.clear();
        }
    }
1358737
public static void skip(InputStream stream, long skip) throws IOException
   {
      long count = skip;
      while (count > 0)
      {
         count -= stream.skip(count);
      }
   }
993524
public void toStream(boolean skipNonOverrides, OutputStream out)
            throws Exception {
        PrintWriter writer = null;
        try {
            writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
            write(skipNonOverrides, true, writer);
        } finally {
            try {
                writer.close();
            } catch (Throwable th) {
            }
            try {
                out.close();
            } catch (Throwable th) {
            }
        }
    }