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 TypeMethodDescriptionboolean
getId()
Deprecated.com.google.common.collect.ImmutableSet<IndexSet>
Returns the id to address the document in Elasticsearch.org.joda.time.DateTime
long
getSize()
com.google.common.collect.ImmutableSet<String>
org.joda.time.DateTime
int
hashCode()
byte[]
serialize
(SerializationContext context) Serializes a message to JSON and memoizes the result as aSoftReference
.boolean
Guides 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:
serialize
in 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:Indexable
Returns the id to address the document in Elasticsearch. Depending on the implementation this might return aUUID
orULID
This method should only be used where backwards compatibility is needed. Newer code should useIndexable.getMessageId()
instead.- Specified by:
getId
in interfaceImmutableMessage
- Specified by:
getId
in interfaceIndexable
-
getMessageId
Description copied from interface:Indexable
Returns the id to address the document in Elasticsearch. The message id is represented as aULID
- Specified by:
getMessageId
in interfaceIndexable
-
getSize
public long getSize() -
getReceiveTime
public org.joda.time.DateTime getReceiveTime()- Specified by:
getReceiveTime
in interfaceIndexable
-
toElasticSearchObject
public Map<String,Object> toElasticSearchObject(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nonnull com.codahale.metrics.Meter invalidTimestampMeter) - Specified by:
toElasticSearchObject
in interfaceIndexable
-
getTimestamp
public org.joda.time.DateTime getTimestamp()- Specified by:
getTimestamp
in interfaceIndexable
-
supportsFailureHandling
public boolean supportsFailureHandling()Description copied from interface:Indexable
Guides 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:
supportsFailureHandling
in interfaceIndexable
-
getIndexSets
- Specified by:
getIndexSets
in interfaceImmutableMessage
-
getFields
- Specified by:
getFields
in interfaceImmutableMessage
-
getMessage
- Specified by:
getMessage
in interfaceImmutableMessage
-
getField
- Specified by:
getField
in interfaceImmutableMessage
-
getSource
- Specified by:
getSource
in interfaceImmutableMessage
-
getStreamIds
- Specified by:
getStreamIds
in interfaceImmutableMessage
-
getMessageQueueId
- Specified by:
getMessageQueueId
in interfaceAcknowledgeable
-