public class

ZNRecord

extends Object
java.lang.Object
   ↳ org.apache.helix.ZNRecord
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Generic Record Format to store data at a Node This can be used to store simpleFields mapFields listFields

Summary

Constants
String LIST_FIELD_BOUND
int SIZE_LIMIT
Public Constructors
ZNRecord(String id)
Initialize with an identifier
ZNRecord(ZNRecord record)
Initialize with a pre-populated ZNRecord
ZNRecord(ZNRecord record, String id)
Initialize with a pre-populated ZNRecord, overwriting the identifier
Public Methods
boolean equals(Object obj)
boolean getBooleanField(String k, boolean defaultValue)
Get a single boolean field
long getCreationTime()
Get the time that this record was created
List<ZNRecordDelta> getDeltaList()
Get the list of updates to this ZNRecord
double getDoubleField(String k, double defaultValue)
Get a single double field
<T extends Enum<T>> T getEnumField(String k, Class<T> enumType, T defaultValue)
Get a single Enum field
String getId()
int getIntField(String k, int defaultValue)
Get a single int field
List<String> getListField(String k)
Get a single List field
Map<StringList<String>> getListFields()
Get all fields whose values are a list of values
long getLongField(String k, long defaultValue)
Get a single long field
Map<StringString> getMapField(String k)
Get a single Map field
Map<StringMap<StringString>> getMapFields()
Get all fields whose values are key, value properties
long getModifiedTime()
Get the time that this record was last modified
<T> T getPayload(Class<T> clazz)
Get a typed deserialized payload
PayloadSerializer getPayloadSerializer()
Get the PayloadSerializer that will serialize/deserialize the payload
byte[] getRawPayload()
Get arbitrary data serialized as a byte array payload.
String getSimpleField(String k)
Get a single String field
Map<StringString> getSimpleFields()
Get all plain key, value fields
String getStringField(String k, String defaultValue)
Get a single String field
int getVersion()
Get the version of this record
void merge(ZNRecord record)
merge functionality is used to merge multiple znrecord into a single one.
void setBooleanField(String k, boolean v)
Set a single simple boolean field
void setCreationTime(long creationTime)
Set the time that this record was created
void setDeltaList(List<ZNRecordDelta> deltaList)
Set the list of updates to this ZNRecord
void setDoubleField(String k, double v)
Set a single simple double field
<T extends Enum<T>> void setEnumField(String k, T v)
Set a single simple Enum field
void setIntField(String k, int v)
Set a single simple int field
void setListField(String k, List<String> v)
Set a single String --> List field
void setListFields(Map<StringList<String>> listFields)
Set all fields whose values are a list of values
void setLongField(String k, long v)
Set a single simple long field
void setMapField(String k, Map<StringString> v)
Set a single String --> Map field
void setMapFields(Map<StringMap<StringString>> mapFields)
Set all fields whose values are key, value properties
void setModifiedTime(long modifiedTime)
Set the time that this record was last modified
<T> void setPayload(T payload)
Set a typed payload that will be serialized and persisted.
void setPayloadSerializer(PayloadSerializer serializer)
Set a custom PayloadSerializer to allow including arbitrary data
void setRawPayload(byte[] payload)
Set arbitrary data serialized as a byte array payload.
void setSimpleField(String k, String v)
Set a simple key, value field
void setSimpleFields(Map<StringString> simpleFields)
Set all plain key, value fields
void setVersion(int version)
Set the version of this record
void subtract(ZNRecord value)
Subtract value from this ZNRecord Note: does not support subtract in each list in list fields or map in mapFields
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String LIST_FIELD_BOUND

Constant Value: "listField.bound"

public static final int SIZE_LIMIT

Constant Value: 1024000 (0x000fa000)

Public Constructors

public ZNRecord (String id)

Initialize with an identifier

public ZNRecord (ZNRecord record)

Initialize with a pre-populated ZNRecord

public ZNRecord (ZNRecord record, String id)

Initialize with a pre-populated ZNRecord, overwriting the identifier

Public Methods

public boolean equals (Object obj)

public boolean getBooleanField (String k, boolean defaultValue)

Get a single boolean field

Returns
  • the boolean field, or defaultValue if not present

public long getCreationTime ()

Get the time that this record was created

Returns
  • UNIX timestamp

public List<ZNRecordDelta> getDeltaList ()

Get the list of updates to this ZNRecord

Returns

public double getDoubleField (String k, double defaultValue)

Get a single double field

Returns
  • the double value, or defaultValue if not present

public T getEnumField (String k, Class<T> enumType, T defaultValue)

Get a single Enum field

Returns
  • the Enum field of enumType, or defaultValue if not present

public String getId ()

public int getIntField (String k, int defaultValue)

Get a single int field

Returns
  • the int value, or defaultValue if not present

public List<String> getListField (String k)

Get a single List field

Returns
  • String list

public Map<StringList<String>> getListFields ()

Get all fields whose values are a list of values

Returns
  • all list fields

public long getLongField (String k, long defaultValue)

Get a single long field

Returns
  • the long value, or defaultValue if not present

public Map<StringString> getMapField (String k)

Get a single Map field

Returns
  • String --> String map

public Map<StringMap<StringString>> getMapFields ()

Get all fields whose values are key, value properties

Returns
  • all map fields

public long getModifiedTime ()

Get the time that this record was last modified

Returns
  • UNIX timestamp

public T getPayload (Class<T> clazz)

Get a typed deserialized payload

public PayloadSerializer getPayloadSerializer ()

Get the PayloadSerializer that will serialize/deserialize the payload

Returns
  • serializer

public byte[] getRawPayload ()

Get arbitrary data serialized as a byte array payload. Consider using getPayload(Class) instead

public String getSimpleField (String k)

Get a single String field

Returns
  • String field

public Map<StringString> getSimpleFields ()

Get all plain key, value fields

Returns
  • Map of simple fields

public String getStringField (String k, String defaultValue)

Get a single String field

Returns
  • the String value, or defaultValue if not present

public int getVersion ()

Get the version of this record

Returns
  • version number

public void merge (ZNRecord record)

merge functionality is used to merge multiple znrecord into a single one. This will make use of the id of each ZNRecord and append it to every key thus making key unique. This is needed to optimize on the watches.

public void setBooleanField (String k, boolean v)

Set a single simple boolean field

public void setCreationTime (long creationTime)

Set the time that this record was created

public void setDeltaList (List<ZNRecordDelta> deltaList)

Set the list of updates to this ZNRecord

public void setDoubleField (String k, double v)

Set a single simple double field

public void setEnumField (String k, T v)

Set a single simple Enum field

public void setIntField (String k, int v)

Set a single simple int field

public void setListField (String k, List<String> v)

Set a single String --> List field

public void setListFields (Map<StringList<String>> listFields)

Set all fields whose values are a list of values

public void setLongField (String k, long v)

Set a single simple long field

public void setMapField (String k, Map<StringString> v)

Set a single String --> Map field

public void setMapFields (Map<StringMap<StringString>> mapFields)

Set all fields whose values are key, value properties

public void setModifiedTime (long modifiedTime)

Set the time that this record was last modified

public void setPayload (T payload)

Set a typed payload that will be serialized and persisted.

public void setPayloadSerializer (PayloadSerializer serializer)

Set a custom PayloadSerializer to allow including arbitrary data

public void setRawPayload (byte[] payload)

Set arbitrary data serialized as a byte array payload. Consider using setPayload(Object) instead

public void setSimpleField (String k, String v)

Set a simple key, value field

public void setSimpleFields (Map<StringString> simpleFields)

Set all plain key, value fields

public void setVersion (int version)

Set the version of this record

public void subtract (ZNRecord value)

Subtract value from this ZNRecord Note: does not support subtract in each list in list fields or map in mapFields

public String toString ()