All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.rtdi.bigdata.connector.pipeline.foundation.TopicPayload Maven / Gradle / Ivy

package io.rtdi.bigdata.connector.pipeline.foundation;

import java.io.IOException;

import org.apache.avro.Schema;

import com.github.benmanes.caffeine.cache.Cache;

import io.rtdi.bigdata.connector.pipeline.foundation.avro.JexlGenericData.JexlRecord;
import io.rtdi.bigdata.connector.pipeline.foundation.entity.TopicPayloadBinary;

/**
 * The payload with similar fields as coming from Kafka. Hence for Kakfa-less implementations, the queues would actually contain objects 
 * of this type.
 *
 */
public class TopicPayload {

	private long offset;
	private Integer partition;
	private long timestamp;
	private JexlRecord valuerecord;
	private JexlRecord keyrecord;
	private int keyschemaid;
	private int valueschemaid;
	private String topic;

	public TopicPayload() {
	}

	public TopicPayload(TopicName topic, long offset, Integer partition, long timestamp, JexlRecord keyrecord, JexlRecord valuerecord, int keyschemaid, int valueschemaid) {
		this.offset = offset;
		this.partition = partition;
		this.timestamp = timestamp;
		this.keyrecord = keyrecord;
		this.valuerecord = valuerecord;
		this.topic = topic.getName();
		this.keyschemaid = keyschemaid;
		this.valueschemaid = valueschemaid;
	}

	public TopicPayload(TopicPayloadBinary r, ISchemaRegistrySource registry, Cache schemacache) throws IOException {
		this.offset = r.getOffset();
		this.partition = r.getPartition();
		this.timestamp = r.getTimestamp();
		this.keyrecord = AvroDeserialize.deserialize(r.getKeyRecord(), registry, schemacache);
		this.valuerecord = AvroDeserialize.deserialize(r.getValueRecord(), registry, schemacache);
		this.topic = r.getTopic();
		this.keyschemaid = r.getKeySchemaId();
		this.valueschemaid = r.getValueSchemaId();
	}

	public long getOffset() {
		return offset;
	}

	public void setOffset(long offset) {
		this.offset = offset;
	}

	public Integer getPartition() {
		return partition;
	}

	public void setPartition(Integer partition) {
		this.partition = partition;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public JexlRecord getValueRecord() {
		return valuerecord;
	}

	public void setValueRecord(JexlRecord valuerecord) {
		this.valuerecord = valuerecord;
	}

	public JexlRecord getKeyRecord() {
		return keyrecord;
	}

	public void setKeyRecord(JexlRecord keyrecord) {
		this.keyrecord = keyrecord;
	}

	public String getTopic() {
		return topic;
	}
	
	public void setTopic(String topic) {
		this.topic = topic;
	}

	@Override
	public String toString() {
		return "TopicPayload (offset=" + String.valueOf(offset) + ")";
	}

	public int getKeySchemaId() {
		return keyschemaid;
	}

	public void setKeySchemaId(int keyschemaid) {
		this.keyschemaid = keyschemaid;
	}

	public int getValueSchemaId() {
		return valueschemaid;
	}

	public void setValueSchemaId(int valueschemaid) {
		this.valueschemaid = valueschemaid;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy