Helper method used by AOStream to persistently record that flush has been started
@param t the transaction
@param stream the stream making this call
@return the Item written
@throws Exception
326434
public final Item writeStartedFlush(TransactionCommon t, AOStream stream) throws Exception
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "writeStartedFlush");

    String key = 
      SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
    StreamInfo sinfo = streamTable.get(key);
    if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
    {
      AOStartedFlushItem item = new AOStartedFlushItem(key, stream.streamId);
      Transaction msTran = mp.resolveAndEnlistMsgStoreTransaction(t);
      this.containerItemStream.addItem(item, msTran);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "writeStartedFlush", item);

      return item;
    }

    // this should not occur
    // log error and throw exception
    SIErrorException e = new SIErrorException(
      nls.getFormattedMessage(
        "INTERNAL_MESSAGING_ERROR_CWSIP0001",
        new Object[] { "com.ibm.ws.sib.processor.impl.AnycastOutputHandler", "1:2810:1.89.4.1" },
        null));

    // FFDC
    FFDCFilter.processException(
      e,
      "com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writeStartedFlush",
      "1:2817:1.89.4.1",
      this);

    SibTr.exception(tc, e);
    SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
    new Object[] { "com.ibm.ws.sib.processor.impl.AnycastOutputHandler", "1:2822:1.89.4.1" });

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "writeStartedFlush", e);
    throw e;
  }
1327957
@Override
    public final void flush()
        throws IOException
    {
        _flushBuffer();
        if (_writer != null) {
            if (isEnabled(Feature.FLUSH_PASSED_TO_STREAM)) {
                _writer.flush();
            }
        }
    }
590156
public void write(InputStream stream) throws IOException {
        onNewLine = false;
        try (ReadableByteChannel readable = Channels.newChannel(stream)) {
            flush();
            while (readable.read(buffer) != -1) {
                flush();
            }
        }
    }
1319800
void flush(OutputStream out, String encoding)
         throws IOException
    {
        flush(new OutputStreamWriter(out,encoding));
    }
416068
public static void exception(TraceComponent tc, Throwable t) {
    if(isTracing()) SibTr.exception(tc, t);

  }
735689
private synchronized OutputStream getSocketInputOutputStream(int stream) {
    if (!pipedOutput.containsKey(stream)) {
      try {
        PipedInputStream pipeIn = new PipedInputStream();
        PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);
        pipedOutput.put(stream, pipeOut);
        input.put(stream, pipeIn);
      } catch (IOException ex) {
        // This is _very_ unlikely, as it requires the above constructor to fail.
        // don't force callers to catch, but still throw
        throw new IllegalStateException(ex);
      }
    }
    return pipedOutput.get(stream);
  }
149149
protected void attemptFlush() throws SIRollbackException, SIConnectionLostException, SIResourceException, SIErrorException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc,"attemptFlush");

    //The FlushComplete callback
    FlushComplete callback = null;
    //The old set of streams which has just been flushed
    StreamSet oldStreamSet = null;

    // Actions for a flushable stream.  Note that we synchronize
    // up to step 4 to avoid races with threads handling control
    // messages.
    // 1. Cache and unset flushInProgress.
    // 2. Create a new stream ID
    // 3. Remove any data structures associated with the stream.
    // 4. Invoke the callback on the cached FlushComplete reference.
    synchronized (this)
    {
      // Resolve race between control message handlers who both
      // see a flushable stream.
      // flushInProgress was set by startFlush
      if (flushInProgress == null)
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "attemptFlush");
        return;
      }

      // Also verify that the stream really is flushable in case
      // a thread handling a control message called us with a
      // stale source stream reference.
      if (!flushable())
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "attemptFlush");
        return;
      }

      // Now cache the callback.  When we exit the synchronize block,
      // the flush will have officially ended.
      callback = flushInProgress;
      flushInProgress = null;

      // Cleanup the data structures and null out the
      // existing streamSet so we force creation of a new
      // set on the next message.
      oldStreamSet = streamSet;
      streamSet = null;

      if(oldStreamSet != null)
      {
        oldStreamSet.remove();
      }
    }

    // Send out a flushed message.  If this fails, make sure we get
    // to at least invoke the callback.
    try
    {
      // The Cellule argument is null as it is ignored by our parent handler
      // this flush message should be broadcast downstream.
      if (oldStreamSet != null)
        downControl.sendFlushedMessage(null, oldStreamSet.getStreamID());
    }
    catch (Exception e)
    {
      // FFDC
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.gd.SourceStreamManager.attemptFlush",
        "1:1158:1.102",
        this);

      // Note that it doesn't make much sense to throw an exception here since
      // this is a callback from stream array map.
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "attemptFlush", e);
      return;
    }
    finally
    {
      // Invoke the calback in the finally clause so we don't holdup
      // whoever's waiting for the flush to complete.
      callback.flushComplete(destinationHandler);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "attemptFlush");
  }
66560
public void setInputStream(InputStream stream) {
        try {
            cachedInputStream = new ByteArrayOutputStream();
            IOUtils.copy(stream, cachedInputStream);
        } catch (IOException e) {
            LOG.error("Exception on writing InputStream.", e);
        }
    }
205723
public void flush() throws IOException
    {   
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "flush");
        boolean crlfWrite = false;
        // check for nonblocking
        if(this._listener!= null){
            synchronized(this){

                WebContainerRequestState reqState = WebContainerRequestState.getInstance(false);
                if (reqState!=null && reqState.getAttribute("com.ibm.ws.webcontainer.CRLFWriteinPorgress")!=null){                                      
                    crlfWrite = true;
                }
                if(this.isWriteReadyWork(false) || crlfWrite ){
                    super.flush();
                }
                else{
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(tc, "cannot flush, not write ready");
                    
                    return;
                }
            }
        }
        else{
            super.flush();
        }
    }
844160
@Nonnull
  public static ESuccess flush (@Nullable final Flushable aFlushable)
  {
    if (aFlushable != null)
      try
      {
        aFlushable.flush ();
        return ESuccess.SUCCESS;
      }
      catch (final NullPointerException ex)
      {
        // Happens if a java.io.FilterOutputStream is already closed!
      }
      catch (final IOException ex)
      {
        if (!isKnownEOFException (ex))
          LOGGER.error ("Failed to flush object " + aFlushable.getClass ().getName (),
                        ex instanceof IMockException ? null : ex);
      }
    return ESuccess.FAILURE;
  }
247341
public void writeObject(@NonNull ObjectOutputStream stream) throws IOException {
        stream.writeObject(id);
        stream.writeLong(createdTime);
        stream.writeLong(lastAccessedTime);
        stream.writeInt(maxInactiveInterval);
        stream.writeBoolean(isNew);
        stream.writeBoolean(isValid);
        stream.writeInt(mAttributes.size());
        String keys[] = mAttributes.keySet().toArray(EMPTY_ARRAY);
        for (String key : keys) {
            Object value = mAttributes.get(key);
            if (value != null && value instanceof Serializable) {
                stream.writeObject(key);
                stream.writeObject(value);
            }
        }
    }
297205
public void flush() throws IOException {
        if (unflushed.get() == 0) return;

        synchronized (lock) {
            if (logger.isTraceEnabled()) {
                logger.debug("Flushing log '" + name + "' last flushed: " + getLastFlushedTime() + " current time: " + System
                        .currentTimeMillis());
            }
            segments.getLastView().getMessageSet().flush();
            unflushed.set(0);
            lastflushedTime.set(System.currentTimeMillis());
        }
    }
835786
public static <T, C extends Collection<T>> Stream<T>
    ifExistIntoStream(C collection) {
        return getOptional(collection).map(Collection::stream)
                .orElseGet(Stream::empty);
    }
1312689
@Override
    public void run() throws Exception {
        QueueContainer queueContainer = getContainer();
        if (queueContainer.hasEnoughCapacity(txSize + 1)) {
            response = queueContainer.txnOfferReserve(transactionId);
        }
    }
1175879
@SuppressWarnings("unchecked")
  private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    int capacity = stream.readInt();
    initialize(capacity);
    int size = stream.readInt();
    for (int i = 0; i < size; i++) {
      addEntry((K) stream.readObject(), (V) stream.readObject());
    }
  }
941159
@Override
  public void flush() throws IOException
  {
    if (_os == null || ! _needsFlush)
      return;

    _needsFlush = false;
    try {
      _os.flush();
    } catch (IOException e) {
      try {
        close();
      } catch (IOException e1) {
      }
      
      throw ClientDisconnectException.create(e);
    }
  }
612415
public <T extends Normalizer> T restore(@NonNull InputStream stream) throws Exception {
        Header header = parseHeader(stream);

        //noinspection unchecked
        return (T) getStrategy(header).restore(stream);
    }