Package com.linkedin.databus.core

Examples of com.linkedin.databus.core.DbusEventPart


   *         allocated object.
   * @throws DatabusRuntimeException if event contains metadata but schema to decode it is missing
   */
  public GenericRecord getMetadata(DbusEvent e, GenericRecord reuse)
  {
    DbusEventPart metadataPart = e.getPayloadMetadataPart();
    ByteBuffer dataBuffer = null;
    if (null == metadataPart || null == (dataBuffer = metadataPart.getData()) || dataBuffer.remaining() <= 0)
    {
      LOG.debug("No metadata for event " + e);
      return null;
    }

View Full Code Here


   *         metadata-schema-id; null if event contains no metadata
   * @throws DatabusRuntimeException if event contains metadata but schema to decode it is missing
   */
  public VersionedSchema getMetadataSchema(DbusEvent e)
  {
    DbusEventPart metadataPart = e.getPayloadMetadataPart();
    if (null == metadataPart)
    {
      LOG.debug("No metadata for event " + e);
      return null;
    }
View Full Code Here

            keyStr = Long.toString(e.key());
          }
          else if (e.isKeySchema())
          {
            // TODO Fix to use a decoder (DDSDBUS-2076)
            DbusEventPart keyPart = e.getKeyPart();
            keyStr = keyPart.toString();
          }
        }
        catch (UnsupportedEncodingException e1)
        {
          keyStr = "unsupported key encoding";
View Full Code Here

  public ConsumerCallbackResult printEvent(DbusEventInternalReadable e,
                                           DbusEventDecoder eventDecoder)
  {
    DbusEventAvroDecoder avroDecoder = (DbusEventAvroDecoder)eventDecoder;
    byte[] payloadSchemaDigest = e.schemaId();
    DbusEventPart metadataPart = e.getPayloadMetadataPart();
    String s = String.format("format=%s opcode=%s partition=%d scn=%d ts=%d (%s.%d) srcid=%d extRepl=%s schema=%s " +
                         "payload_schema_digest=%s metadata_schema=%s metadata_schema_digest=%s",
                             e.getClass().getSimpleName(),
                             e.getOpcode(),
                             e.getPartitionId(),
                             e.sequence(),
                             e.timestampInNanos(),
                             EVENT_TS_FORMAT.format(new Date(e.timestampInNanos() / 1000000)),
                             e.timestampInNanos() % 1000000000,
                             e.getSourceId(),
                             e.isExtReplicatedEvent(),
                             versionedSchemaId(eventDecoder.getPayloadSchema(e)),
                             null != payloadSchemaDigest ? Hex.encodeHexString(payloadSchemaDigest) : "null",
                             null != metadataPart ? versionedSchemaId(avroDecoder.getMetadataSchema(e)) : "null",
                             null != metadataPart ? Hex.encodeHexString(metadataPart.getSchemaDigest()) : "null");
    try
    {
      _out.write(s.getBytes("UTF-8"));
      _out.write('\n');
    }
View Full Code Here

  private static final int maxEventLen = 1000;

  private DbusEventPart createMetadataPart()
  {
    return new DbusEventPart(DbusEvent.SchemaDigestType.CRC32,
                             METADATA_SCHEMA_CHECKSUM,
                             METADATA_SCHEMA_VERSION,
                             ByteBuffer.wrap(METADATA_BYTES));
  }
View Full Code Here

  throws Exception
  {
    LOG.info("starting testGetMetadata_HappyPath()");

    // build the event's metadata and then the event
    DbusEventPart metadataPart = createMetadataPart();
    DbusEvent event = createEvent(metadataPart);

    // create a metadata schema set that correctly corresponds to the metadata
    VersionedSchemaSet metadataSchemaSet = new VersionedSchemaSet();
    metadataSchemaSet.add(SchemaRegistryService.DEFAULT_METADATA_SCHEMA_SOURCE,
                          metadataPart.getSchemaVersion(),              // METADATA_SCHEMA_VERSION
                          new SchemaId(metadataPart.getSchemaDigest()), // METADATA_SCHEMA_CHECKSUM
                          CORRECT_METADATA_SCHEMA,
                          true)// preserve original string

    // now create the decoder and use it to extract and decode the event's metadata
    DbusEventAvroDecoder eventDecoder = createDecoder(metadataSchemaSet);
View Full Code Here

  throws Exception
  {
    LOG.info("starting testGetMetadata_UnhappyPath_MissingSchema()");

    // build the event's metadata and then the event
    DbusEventPart metadataPart = createMetadataPart();
    DbusEvent event = createEvent(metadataPart);

    // create an empty metadata schema set
    VersionedSchemaSet metadataSchemaSet = new VersionedSchemaSet();
View Full Code Here

  throws Exception
  {
    LOG.info("starting testGetMetadata_UnhappyPath_BadSchema()");

    // build the event's metadata and then the event
    DbusEventPart metadataPart = createMetadataPart();
    DbusEvent event = createEvent(metadataPart);

    // create a metadata schema set with a schema that claims to match the event's
    // metadata but doesn't actually
    VersionedSchemaSet metadataSchemaSet = new VersionedSchemaSet();
    metadataSchemaSet.add(SchemaRegistryService.DEFAULT_METADATA_SCHEMA_SOURCE,
                          metadataPart.getSchemaVersion(),              // METADATA_SCHEMA_VERSION
                          new SchemaId(metadataPart.getSchemaDigest()), // METADATA_SCHEMA_CHECKSUM
                          INCORRECT_METADATA_SCHEMA,
                          true)// preserve original string

    // now create the decoder and attempt to use it to extract and decode the event's metadata
    DbusEventAvroDecoder eventDecoder = createDecoder(metadataSchemaSet);
View Full Code Here

TOP

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

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.