Package org.graylog2.indexer.messages
Class SerializationMemoizingMessage
java.lang.Object
org.graylog2.indexer.messages.SerializationMemoizingMessage
- All Implemented Interfaces:
ImmutableMessage,Indexable,Acknowledgeable
Wraps a
Message by making it immutable and caching the result of serialize(SerializationContext)
calls.
For more details about the caching behavior, see serialize(SerializationContext)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetId()Deprecated.com.google.common.collect.ImmutableSet<IndexSet>Returns the id to address the document in Elasticsearch.org.joda.time.DateTimelonggetSize()com.google.common.collect.ImmutableSet<String>org.joda.time.DateTimeinthashCode()byte[]serialize(SerializationContext context) Serializes a message to JSON and memoizes the result as aSoftReference.booleanGuides the failure handling framework when deciding whether this particular message should be accepted for the further failure processing.toElasticSearchObject(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.codahale.metrics.Meter invalidTimestampMeter)
-
Constructor Details
-
SerializationMemoizingMessage
-
-
Method Details
-
serialize
Serializes a message to JSON and memoizes the result as aSoftReference.As long as the same
SerializationContext.objectMapper()is used in consecutive calls, the result will be memoized. If a context with a different object mapper is used, the memoized serialized byte array will be replaced with a newly serialized value.The serialization result will be maintained as a
SoftReference. If the JVM experiences memory pressure, the memoized value might be cleared, and consecutive calls will cause the serialization operation to execute again. In that case, a warning will be logged.- Specified by:
serializein interfaceIndexable- Parameters:
context- Context required to perform the serialization- Returns:
- The serialized value. May return a memoized value according to the rules described above.
- Throws:
IOException- If serialization goes wrong.
-
hashCode
public int hashCode() -
equals
-
getId
Deprecated.Description copied from interface:IndexableReturns the id to address the document in Elasticsearch. Depending on the implementation this might return aUUIDorULIDThis method should only be used where backwards compatibility is needed. Newer code should useIndexable.getMessageId()instead.- Specified by:
getIdin interfaceImmutableMessage- Specified by:
getIdin interfaceIndexable
-
getMessageId
Description copied from interface:IndexableReturns the id to address the document in Elasticsearch. The message id is represented as aULID- Specified by:
getMessageIdin interfaceIndexable
-
getSize
public long getSize() -
getReceiveTime
public org.joda.time.DateTime getReceiveTime()- Specified by:
getReceiveTimein interfaceIndexable
-
toElasticSearchObject
public Map<String,Object> toElasticSearchObject(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nonnull com.codahale.metrics.Meter invalidTimestampMeter) - Specified by:
toElasticSearchObjectin interfaceIndexable
-
getTimestamp
public org.joda.time.DateTime getTimestamp()- Specified by:
getTimestampin interfaceIndexable
-
supportsFailureHandling
public boolean supportsFailureHandling()Description copied from interface:IndexableGuides the failure handling framework when deciding whether this particular message should be accepted for the further failure processing. By default disabled for all messages.- Specified by:
supportsFailureHandlingin interfaceIndexable
-
getIndexSets
- Specified by:
getIndexSetsin interfaceImmutableMessage
-
getFields
- Specified by:
getFieldsin interfaceImmutableMessage
-
getMessage
- Specified by:
getMessagein interfaceImmutableMessage
-
getField
- Specified by:
getFieldin interfaceImmutableMessage
-
getSource
- Specified by:
getSourcein interfaceImmutableMessage
-
getStreamIds
- Specified by:
getStreamIdsin interfaceImmutableMessage
-
getMessageQueueId
- Specified by:
getMessageQueueIdin interfaceAcknowledgeable
-