Sets and flushes the water marks of a source.

@param source - the source
@param lwmScn - the low water mark SCN
@param hwmScn - the high water mark SCN
@return <tt>true</tt> if flush is successful.
434945
public boolean syncWaterMarks(String source, long lwmScn, long hwmScn) {
        setWaterMarks(source, lwmScn, hwmScn);
        return flush();
    }
436901
public static void copyBackRouteHeader(byte[] source, byte[] dest) {
        int thisPointCode = getFromSif_DPC(source, 1);
        int remotePointCode = getFromSif_OPC(source, 1);
        int sls = getFromSif_SLS(source, 1);
        int si = getFromSif_SI(source);
        int ssi = getFromSif_SSI(source);
        writeRoutingLabel(dest, si, ssi, sls, remotePointCode, thisPointCode);
    }
659038
public void update(CmsClientSitemapEntry source) {

        copyMembers(source);
        // position values < 0 are considered as not set
        if (source.getPosition() >= 0) {
            setPosition(source.getPosition());
        }
    }
373631
private void maybeAddWatermarkInputs(ComponentCommon common, IRichBolt bolt) {
        if (bolt instanceof WindowedBoltExecutor) {
            Set<String> comps = new HashSet<>();
            for (GlobalStreamId globalStreamId : common.get_inputs().keySet()) {
                comps.add(globalStreamId.get_componentId());
            }

            for (String comp : comps) {
                common.put_to_inputs(
                        new GlobalStreamId(comp, Common.WATERMARK_STREAM_ID),
                        Grouping.all(new NullStruct()));
            }
        }
    }
541936
public boolean isFilterMatch(BaseMessageHeader messageHeader)
    {
        boolean bMatch = true;
        if (messageHeader != null)
        {
            if (this.getQueueName() != null)
                if (!this.getQueueName().equals(messageHeader.getQueueName()))
                    return false;   // No match
            if (this.getQueueType() != null)
                if (!this.getQueueType().equals(messageHeader.getQueueType()))
                    return false;   // No match
            if (this.getMessageSource() != null)
                if (this.getMessageSource() == messageHeader.getMessageSource())
                    return false;   // If the source codes are the same object, don't echo!
            Object[][] mxMessageHeader = messageHeader.getNameValueTree();
            Object[][] mxMessageFilter = this.getNameValueTree();
            bMatch = this.compareTrees(mxMessageHeader, mxMessageFilter, false);
            if (bMatch)
                if (messageHeader.getRegistryIDMatch() != null)
                    if (!messageHeader.getRegistryIDMatch().equals(this.getRegistryID()))
                        bMatch = false;
        }
        return bMatch;    // MATCH!!!
    }
160359
public void saveHWMark(String source, long hwm) {
        WaterMarkEntry wmEntry = sourceWaterMarkMap.get(source);
        if (wmEntry != null) {
            wmEntry.setHWMScn(Math.max(hwm, wmEntry.getHWMScn()));
        } else {
            wmEntry = new WaterMarkEntry(source);
            wmEntry.setHWMScn(hwm);

            sourceWaterMarkMap.put(source, wmEntry);
        }
    }
615350
public void moveResource(String source, String destination) {

        CmsLock lock = OpenCms.getMemoryMonitor().getCachedLock(source);
        if (lock != null) {
            OpenCms.getMemoryMonitor().uncacheLock(lock.getResourceName());
            CmsLock newLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType());
            lock = lock.getRelatedLock();
            if ((lock != null) && !lock.isNullLock()) {
                CmsLock relatedLock = new CmsLock(destination, lock.getUserId(), lock.getProject(), lock.getType());
                newLock.setRelatedLock(relatedLock);
            }
            OpenCms.getMemoryMonitor().cacheLock(newLock);
        }
    }
757930
public static synchronized void setStderr(OutputStream os)
  {
    if (_stderrStream == null) {
      initStderr();
    }

    if (os == _systemErr || os == _systemOut) {
      return;
    }

    if (os instanceof WriteStream) {
      WriteStream out = (WriteStream) os;

      /*
      if (out.getSource() == StdoutStream.create()
          || out.getSource() == StderrStream.create()) {
        return;
      }
      */
    }

    _stderrStream.setStream(os);
  }
790843
@Override
    public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
        internalStmt.setAsciiStream(parameterIndex, x, length);
    }
1313291
public static <T> long drain(Source<T> source) throws IOException {
        return drain(source, new AbstractSink<T>() {
            @Override
            public void put(T item) { }
        });
    }
613871
protected void updateWatermarks(long currentDepth)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "updateWatermarks", new Long(currentDepth));

        boolean setWatermarks = false;
        _nextHighWatermark = _nextUpDepthInterval;
        _nextLowWatermark = _nextDownDepthInterval;

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "_destMsgInterval: " + _destMsgInterval +
                            " _destHighMsgs: " + _destHighMsgs +
                            " _destLowMsgs: " + _destLowMsgs +
                            " _nextUpDepthInterval: " + _nextUpDepthInterval +
                            " _nextDownDepthInterval: " + _nextDownDepthInterval);

        if (_destMsgInterval > 0)
            setWatermarks = true;

        if (isThresholdNotificationRequired())
        {
            setWatermarks = true;

            // If message depth interval reporting is enabled, work out from the
            // current depth what are the next interesting watermarks to breach
            // (an interval threshold or a high/low limit?)
            if (_destMsgInterval > 0)
            {
                if ((_nextHighWatermark > _destHighMsgs) &&
                    (currentDepth < _destHighMsgs))
                    _nextHighWatermark = _destHighMsgs;

                if ((_nextLowWatermark < _destLowMsgs) &&
                    (currentDepth > _destLowMsgs))
                    _nextLowWatermark = _destLowMsgs;
            }
            else
            {
                // If we're not reporting depth intervals we'll reset the watermarks to the
                // destination's high and low values.
                _nextHighWatermark = _destHighMsgs;
                _nextLowWatermark = _destLowMsgs;
            }
        }

        if (setWatermarks)
        {
            setWatermarks(_nextLowWatermark, _nextHighWatermark);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "updateWatermarks",
                       new Object[] { new Long(_nextLowWatermark), new Long(_nextHighWatermark) });
    }
133851
protected WsByteBuffer[] flushCache(WsByteBuffer[] buffers) {
        // PK13351 - use the offset/length version to write only what we need
        // to and avoid the extra memory allocation
        int pos = this.bytePosition;
        if (0 == pos) {
            // nothing to write
            return buffers;
        }
        this.bytePosition = 0;
        return GenericUtils.putByteArray(buffers, this.byteCache, 0, pos, this);
    }
414898
protected void setLowWatermark(SourceState state) {
    this.lowWatermark = getWatermarkFromPreviousWorkUnits(state, ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK);
    log.info("Setting low watermark for the job: " + this.lowWatermark);
  }
758481
private void flush(boolean isEnd)
  {
    if (_startOffset == _offset && _bufferSize == 0) {
      if (! isCommitted() || isEnd) {
        flush(null, isEnd);
        _startOffset = bufferStart();
        _offset = _startOffset;
      }
      return;
    }

    int sublen = _offset - _startOffset;
    _tBuf.length(_offset);
    _contentLength += _offset - _startOffset;
    _bufferSize = 0;
    
    if (_startOffset > 0) {
      fillChunkHeader(_tBuf, sublen);
    }
    
    flush(_tBuf, isEnd);

    if (! isEnd) {
      _tBuf = TempBuffer.create();
    
      _startOffset = bufferStart();
      _offset = _startOffset;

      _tBuf.length(_offset);
      
      _buffer = _tBuf.buffer();
    }
    else {
      _tBuf = null;
    }
  }
707360
public synchronized void reset(MemoryIntArray intArray, long maxScn) throws IOException {
      reset(intArray);
      
      _log.info("update hwmScn and lwmScn:" + maxScn);
      writeHwmScn(maxScn);
      writeLwmScn(maxScn);
      flush();
  }
272921
public boolean flush() {
        boolean ret = true;
        PrintWriter out = null;
        
        // Save source water marks
        try {
            // Backup the original file
            if (file.exists()) {
                if (fileOriginal.exists()) {
                    fileOriginal.delete();
                }

                file.renameTo(fileOriginal);
            }

            // Overwrite the existing file
            out = new PrintWriter(new FileOutputStream(file));
            for (String source : sourceWaterMarkMap.keySet()) {
                WaterMarkEntry wmEntry = sourceWaterMarkMap.get(source);
                out.println(wmEntry);
            }
            out.flush();
        } catch (IOException ioe) {
            logger.error("Failed to flush water marks", ioe);
            ret = false;
        } finally {
            if (out != null) {
                out.close();
                out = null;
            }
        }

        return ret;
    }
428809
private long getLowWaterMark(Iterable<WorkUnitState> previousStates, String lowWaterMark) {

    long lowWaterMarkValue = retriever.getWatermarkFromString(lowWaterMark);

    // Find the max HWM from the previous states, this is the new current LWM
    for (WorkUnitState previousState : previousStates) {
      if (previousState.getWorkingState().equals(WorkUnitState.WorkingState.COMMITTED)) {
        long previousHighWaterMark = previousState.getWorkunit().getHighWaterMark();
        if (previousHighWaterMark > lowWaterMarkValue) {
          lowWaterMarkValue = previousHighWaterMark;
        }
      }
    }

    return lowWaterMarkValue + getRetriever().getWatermarkIncrementMs();
  }