Package com.linkedin.databus.core.util

Examples of com.linkedin.databus.core.util.BufferPosition


    _scnIndex = new ScnIndex(maxIndexSize, maxEventBufferSize, _maxBufferSize, _bufferPositionParser,
                             allocationPolicy, restoreBuffers, _mmapSessionDirectory, _assertLevel,
                             enableScnIndex, _eventFactory.getByteOrder());

    _head = new BufferPosition(_bufferPositionParser, _buffers);
    _tail = new BufferPosition(_bufferPositionParser, _buffers);
    _currentWritePosition = new BufferPosition(_bufferPositionParser, _buffers);
    _eventStartIndex = new BufferPosition(_bufferPositionParser, _buffers);

    _rwLockProvider = new RangeBasedReaderWriterLock();

    LOG.info ( "Trace Relay Option : " + traceOption.getOption() + " physicalPartition:" + _physicalPartition.getName() + " pSourceName:" + _physicalPartition );
    if (RelayEventTraceOption.Option.file == traceOption.getOption())
View Full Code Here


    // subsequent call to setNextFreePos(), which calls moveCurrentWritePosition(),
    // blows up.  By normalizing the end position, we effectively block until the
    // head can advance to the same position (or beyond), i.e., until all iterators
    // have caught up, which allows setNextFreePos()/moveCurrentWritePosition() to
    // succeed.  See DDSDBUS-1816 for even more details.
    final BufferPosition normalizedWriteEndPos = new BufferPosition(writeEndPos,
                                                                    _bufferPositionParser,
                                                                    _buffers);
    normalizedWriteEndPos.skipOverFreeSpace();

    boolean interrupted = false;

    if (!empty())
    {
      if (QueuePolicy.BLOCK_ON_WRITE == _queueingPolicy)
      {
        interrupted = waitForReadEventsFreeSpace(logDebugEnabled, writeStartPos,
                                                 normalizedWriteEndPos.getPosition());
      }
      else
      {
        freeUpSpaceForReadEvents(logDebugEnabled, writeStartPos,
                                 normalizedWriteEndPos.getPosition());
      }
    }
    if (logDebugEnabled)
    {
      _log.debug("ensureFreeSpace: writeStart:" + _bufferPositionParser.toString(writeStartPos, _buffers) +
                 "; writeEnd:" + _bufferPositionParser.toString(writeEndPos, _buffers) +
                 "; normalizedWriteEnd:" + normalizedWriteEndPos +
                 "; head:" + _head + "; tail:" + _tail +
                 "; interrupted:" + interrupted);
    }
    assert interrupted || !overwritesHead(writeStartPos, normalizedWriteEndPos.getPosition());

    return interrupted;
  }
View Full Code Here

    protected DbusEventInternalWritable _iteratingEvent;  // TODO Make this readable
    protected String _identifier;

    public BaseEventIterator(long head, long tail, String iteratorName)
    {
      _currentPosition = new BufferPosition(_bufferPositionParser,_buffers);
      _currentPosition.setPosition(head);

      _iteratorTail = new BufferPosition(_bufferPositionParser,_buffers);
      _iteratorTail.setPosition(tail);
      _iteratingEvent = _eventFactory.createWritableDbusEvent();
      reset(head, tail, iteratorName);
      trackIterator(this);
    }
View Full Code Here

    appender.run();

    log.info("Dbus Event Buffer is :" + dbusBuf);
    log.info("SCNIndex is :" + dbusBuf.getScnIndex());

    final BufferPosition headPos = new BufferPosition(dbusBuf.getHead(),
                                                      dbusBuf.getBufferPositionParser(),
                                                      dbusBuf.getBuffer());
    final BufferPosition tailPos = new BufferPosition(dbusBuf.getTail(),
                                                      dbusBuf.getBufferPositionParser(),
                                                      dbusBuf.getBuffer());
    Assert.assertEquals(0, headPos.bufferGenId());
    Assert.assertEquals(0, headPos.bufferIndex());
    Assert.assertEquals(9629, headPos.bufferOffset());
    Assert.assertEquals(1, tailPos.bufferGenId());
    Assert.assertEquals(0, tailPos.bufferIndex());
    Assert.assertEquals(9416, tailPos.bufferOffset());
    Assert.assertEquals(9984, dbusBuf.getBuffer()[0].limit());
    dbusBuf.getScnIndex().assertHeadPosition(dbusBuf.getHead());

    final BufferPosition lastWinStart = new BufferPosition(61 + 22 * 416,
                                                           dbusBuf.getBufferPositionParser(),
                                                           dbusBuf.getBuffer());
    dbusBuf.getScnIndex().assertLastWrittenPos(lastWinStart);

    long lastScn = events.get(events.size() - 1).sequence();
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.util.BufferPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.