コード例 #1
0
  @Override
  public void encode(ByteBuffer buf) {
    TimeZoneCalculator.instance().utcFullTimeToLocal(buf, _time);

    int bufCapacity = (buf.capacity() - buf.position()) - MAGIC_SPARE;

    final byte[] levelHdr = _level.getLogHdr();

    final int msgLen = levelHdr.length + _buf.length();

    if (msgLen > bufCapacity) {
      int copyBytes = bufCapacity - TRUNCATED.length - levelHdr.length;
      buf.put(levelHdr, 0, levelHdr.length);
      buf.put(_buf.getBytes(), 0, copyBytes);
      buf.put(TRUNCATED, 0, TRUNCATED.length);
    } else {
      buf.put(levelHdr, 0, levelHdr.length);
      buf.put(_buf.getBytes(), 0, _buf.length());
    }
  }
コード例 #2
0
 private void validateAge(int transactTime, long now) {
   if ((TimeZoneCalculator.instance().getTimeUTC(now) - transactTime) > _maxAgeMS) {
     delim().append(REQ_TOO_OLD).append(_maxAgeMS / 1000);
   }
 }