Package com.linkedin.databus.client

Examples of com.linkedin.databus.client.DbusEventAvroDecoder


    _schema = Schema.parse(schemaRegistry.fetchLatestSchemaBySourceName(_queryStaticConfig.getSourceName()));
    VersionedSchema vs = new VersionedSchema(_schema.getFullName(), (short)1, _schema, null);

    VersionedSchemaSet schemaSet = new VersionedSchemaSet();
    schemaSet.add(vs);
    _decoder = new DbusEventAvroDecoder(schemaSet);
  }
View Full Code Here


  {
    super();
    _log = null != log ? log : Logger.getLogger(BootstrapTableReaderV2.class);
    _metadataFilters = metadataFilters;
    _tableName = tableName;
    _decoder = new DbusEventAvroDecoder(schemaSet);
    _eventFactory  = new DbusEventV1Factory();
    _eventHandler = eventHandler;
    _eventFilters = new ArrayList<BootstrapReaderFilter>(eventFilters);
    _bstConfig = bstConfig;
    _bootstrapConn = createBstConnection();
View Full Code Here

        {
          throw new Exception(
              "Unable to get the primary key for schema. Schema is :" + schema);
        }

        DbusEventAvroDecoder decoder = new DbusEventAvroDecoder(vSchemaSet);

        BootstrapAuditTester auditor = new BootstrapAuditTester(schema, BootstrapSrcDBEventReader.getTableName(source));
        List<BootstrapAuditTester> auditors = new ArrayList<BootstrapAuditTester>();
        auditors.add(auditor);
View Full Code Here

                               String phase) {
    if (eventDecoder instanceof DbusEventAvroDecoder)
    {
      try
      {
        DbusEventAvroDecoder avroDecoder = (DbusEventAvroDecoder)eventDecoder;
        ByteArrayOutputStream stringOut = new ByteArrayOutputStream();
        stringOut.write(phase.getBytes("UTF-8"));
        avroDecoder.dumpEventValueInJSON(e, stringOut);
        stringOut.flush();

        _log.log(rtConfig.getLogLevel(), stringOut.toString("UTF-8"));
      }
      catch (IOException ex)
View Full Code Here

   */
  @Override
  public ConsumerCallbackResult printEvent(DbusEventInternalReadable e,
                                           DbusEventDecoder eventDecoder)
  {
    DbusEventAvroDecoder avroDecoder = (DbusEventAvroDecoder)eventDecoder;
    switch (_metadataOutput)
    {
    case NONE:
      GenericRecord payload = eventDecoder.getGenericRecord(e, null);
      return payload != null ? printGenericRecord(payload) : ConsumerCallbackResult.SUCCESS;
    case ONLY:
      GenericRecord metadata = avroDecoder.getMetadata(e, null);
      return null != metadata ? printGenericRecord(metadata) : ConsumerCallbackResult.SUCCESS;
    case INCLUDE:
      GenericRecord payload1 = avroDecoder.getGenericRecord(e, null);
      GenericRecord metadata1 = avroDecoder.getMetadata(e, null);

      Schema pschema = Schema.createUnion(Arrays.asList(avroDecoder.getPayloadSchema(e).getSchema(),
                                                        Schema.create(Type.NULL)));
      Field pfield = new Field("payload", pschema, "payload", null);
      VersionedSchema metaschema = avroDecoder.getMetadataSchema(e);
      Schema mschema = null != metaschema ?
          Schema.createUnion(Arrays.asList(metaschema.getSchema(), Schema.create(Type.NULL))) :
          Schema.createUnion(Arrays.asList(Schema.create(Type.INT), Schema.create(Type.NULL)));
      Field mfield = new Field("metadata", mschema, "metadata", null);
      Schema combined = Schema.createRecord(Arrays.asList(pfield, mfield));
View Full Code Here

   */
  @Override
  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 DbusEventAvroDecoder createDecoder(VersionedSchemaSet metadataSchemaSet)
  {
    VersionedSchemaSet sourceSchemaSet = new VersionedSchemaSet()// empty is OK for our purposes
    return new DbusEventAvroDecoder(sourceSchemaSet, metadataSchemaSet);
  }
View Full Code Here

                          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);
    try
    {
      GenericRecord reuse = null;
      GenericRecord decodedMetadata = eventDecoder.getMetadata(event, reuse);
      Assert.assertNotNull(decodedMetadata, "getMetadata() returned null GenericRecord;");

      Utf8 etag = (Utf8)decodedMetadata.get("etag");
      Assert.assertEquals(etag.toString(), "dunno what an etag is");
View Full Code Here

    // create an empty metadata schema set
    VersionedSchemaSet metadataSchemaSet = new VersionedSchemaSet();

    // now create the decoder and attempt to use it to extract and decode the event's metadata
    DbusEventAvroDecoder eventDecoder = createDecoder(metadataSchemaSet);
    try
    {
      GenericRecord reuse = null;
      GenericRecord decodedMetadata = eventDecoder.getMetadata(event, reuse);
      Assert.fail("getMetadata() should have thrown exception");
    }
    catch (Exception ex)
    {
      // expected case:  event had metadata, but schema to decode it was missing
View Full Code Here

                          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);
    try
    {
      GenericRecord reuse = null;
      GenericRecord decodedMetadata = eventDecoder.getMetadata(event, reuse);
      Assert.assertNull(decodedMetadata, "getMetadata() should have returned null;");
    }
    catch (Exception ex)
    {
      Assert.fail("getMetadata() should not have thrown exception: " + ex);
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.DbusEventAvroDecoder

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.