Package com.linkedin.databus.core

Examples of com.linkedin.databus.core.DbusEventInternalReadable


  {
    if (!(e instanceof DbusEventInternalReadable))
    {
      throw new ClassCastException("DbusEvent not readable");
    }
    DbusEventInternalReadable er = (DbusEventInternalReadable)e;
    return processEvent(er, eventDecoder);
  }
View Full Code Here


  {
    if (!(e instanceof DbusEventInternalReadable))
    {
      throw new ClassCastException("DbusEvent not readable");
    }
    DbusEventInternalReadable er = (DbusEventInternalReadable)e;
    return processEvent(er, eventDecoder);
  }
View Full Code Here

    // suspend pull threads
    _sourcesConn.getConnectionStatus().suspendOnError(exception);

    // send an error event to dispatcher through dbusEventBuffer

    DbusEventInternalReadable errorEvent = null;
    if (exception instanceof BootstrapDatabaseTooOldException)
    {
      errorEvent = _eventFactory.createErrorEvent(
          new DbusErrorEvent(exception, DbusEventInternalWritable.BOOTSTRAPTOOOLD_ERROR_SRCID));
    }
    else if (exception instanceof PullerRetriesExhaustedException)
    {
      errorEvent = _eventFactory.createErrorEvent(
          new DbusErrorEvent(exception, DbusEventInternalWritable.PULLER_RETRIES_EXPIRED));
    }
    else
    {
      throw new InvalidEventException("Got an unrecognizable exception ");
    }
    byte[] errorEventBytes = new byte[errorEvent.getRawBytes().limit()];

    if (LOG.isDebugEnabled())
    {
      LOG.debug("error event size: " + errorEventBytes.length);
      LOG.debug("error event:" + errorEvent.toString());
    }

    errorEvent.getRawBytes().get(errorEventBytes);
    ByteArrayInputStream errIs = new ByteArrayInputStream(errorEventBytes);
    ReadableByteChannel errRbc = Channels.newChannel(errIs);

    boolean success = false;
    int retryCounter = 0;
View Full Code Here

    catch (KeyTypeNotImplementedException e1)
    {
      throw new RuntimeException(e1);
    }
    serBuf.rewind();
    DbusEventInternalReadable e = _eventFactory.createReadOnlyDbusEventFromBuffer(serBuf, serBuf.position());
    return e;
  }
View Full Code Here

  private void doSetResumeCheckpoint(CheckpointMessage cpMessage)
  {
    _resumeCkpt = cpMessage.getCheckpoint();
    if (null != _resumeCkpt)
    {
      DbusEventInternalReadable cpEvent = getEventFactory().createCheckpointEvent(_resumeCkpt);
      boolean success;
      try
      {
        success = _currentState.getDataEventsBuffer().injectEvent(cpEvent);
      }
View Full Code Here

      DbusEventBuffer eventBuffer = curState.getDataEventsBuffer();

      if (debugEnabled) _log.debug("Sending bootstrap events to buffer");

      //eventBuffer.startEvents();
      DbusEventInternalReadable cpEvent = getEventFactory().createCheckpointEvent(cp);
      byte[] cpEventBytes = new byte[cpEvent.size()];

      if (debugEnabled)
      {
        _log.debug("checkpoint event size: " + cpEventBytes.length);
        _log.debug("checkpoint event:" + cpEvent.toString());
      }

      cpEvent.getRawBytes().get(cpEventBytes);
      ByteArrayInputStream cpIs = new ByteArrayInputStream(cpEventBytes);
      ReadableByteChannel cpRbc = Channels.newChannel(cpIs);

      UnifiedClientStats unifiedClientStats = _sourcesConn.getUnifiedClientStats();
      sendHeartbeat(unifiedClientStats);
View Full Code Here

    DbusEventBuffer eventBuffer = curState.getDataEventsBuffer();

    try
    {
      DbusEventInternalReadable cpEvent = getEventFactory().createCheckpointEvent(cp);
      boolean success = eventBuffer.injectEvent(cpEvent);
      if (!success)
      {
        _log.error("Unable to write bootstrap phase marker");
      }
      else
      {
        //TODO need real partition for partitioned bootstrap
        DbusEventInternalReadable eopEvent = curState.createEopEvent(cp, getEventFactory());
        success = eventBuffer.injectEvent(eopEvent);
        if (! success)
        {
          _log.error("Unable to write bootstrap EOP marker");
        }
View Full Code Here

      }
      else
      {
        //no snapshot or catchup source left -- bootstrap complete
        // write endOfPeriodMarker to trigger end sequence callback for bootstrap
        DbusEventInternalReadable eopEvent =
            getEventFactory().createLongKeyEOPEvent(cp.getBootstrapTargetScn(), (short) 0);
        try
        {
          boolean success = curState.getDataEventsBuffer().injectEvent(eopEvent);
          if (success)
View Full Code Here

      LOG.info("Executing query : " + query);
      rs = stmt.executeQuery(query);

      byte[] b1 = new byte[1024 * 1024];
      ByteBuffer buffer = ByteBuffer.wrap(b1);
      DbusEventInternalReadable event = _eventFactory.createReadOnlyDbusEventFromBuffer(buffer, 0);

      int count = 0;
      _eventHandler.onStart(query);

      while (rs.next())
      {
        buffer.clear();
        buffer.put(rs.getBytes("val"));
        event = event.reset(buffer, 0);
        GenericRecord record = _decoder.getGenericRecord(event);
        _eventHandler.onRecord(event, record);
        count++;
      }
      _eventHandler.onEnd(count);
View Full Code Here

    try
    {
      _log.info("Executing query : " + _queryString);
      ByteBuffer buffer = ByteBuffer.allocateDirect(MAX_EVENT_SIZE);
      int count = 0;
      DbusEventInternalReadable event = _eventFactory.createReadOnlyDbusEventFromBuffer(buffer, 0);

      _eventHandler.onStart(_queryString);
      while (hasMore)
      {
        _log.debug("currentId=" + curId);
        _query.setLong(1, curId);
        rs = _query.executeQuery();

        hasMore = false;
        while (rs.next())
        {
          hasMore = true;
          buffer.clear();
          buffer.put(rs.getBytes("val"));
          curId = rs.getLong("id");
          event = event.reset(buffer, 0);
          GenericRecord record = _decoder.getGenericRecord(event);
          if (checkFilters(event, record))
          {
            _eventHandler.onRecord(event, record);
          }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.DbusEventInternalReadable

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.