Package org.opennms.core.ipc.twin.common
Class AbstractTwinPublisher
- java.lang.Object
-
- org.opennms.core.ipc.twin.common.AbstractTwinPublisher
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,TwinPublisher
- Direct Known Subclasses:
GrpcTwinPublisher
,JmsTwinPublisher
,KafkaTwinPublisher
public abstract class AbstractTwinPublisher extends java.lang.Object implements TwinPublisher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractTwinPublisher.SessionKey
-
Nested classes/interfaces inherited from interface org.opennms.core.ipc.twin.api.TwinPublisher
TwinPublisher.Session<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.ObjectMapper
objectMapper
protected static java.lang.String
TAG_PATCH
protected static java.lang.String
TAG_SESSION_ID
protected static java.lang.String
TAG_TWIN_RPC
protected static java.lang.String
TAG_TWIN_SINK
protected static java.lang.String
TAG_VERSION
-
Constructor Summary
Constructors Constructor Description AbstractTwinPublisher(LocalTwinSubscriber localTwinSubscriber)
AbstractTwinPublisher(LocalTwinSubscriber localTwinSubscriber, TracerRegistry tracerRegistry, com.codahale.metrics.MetricRegistry metricRegistry)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addTracingInfo(io.opentracing.Span span, TwinUpdate twinUpdate)
void
forEachSession(java.util.function.BiConsumer<AbstractTwinPublisher.SessionKey,TwinTracker> consumer)
static java.lang.String
generateTracingOperationKey(java.lang.String location, java.lang.String key)
io.opentracing.Tracer
getTracer()
protected TwinUpdate
getTwin(TwinRequest twinRequest)
protected abstract void
handleSinkUpdate(TwinUpdate sinkUpdate)
protected TwinRequest
mapTwinRequestProto(byte[] twinRequestBytes)
protected TwinResponseProto
mapTwinResponse(TwinUpdate twinUpdate)
<T> TwinPublisher.Session<T>
register(java.lang.String key, java.lang.Class<T> clazz, java.lang.String location)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.core.ipc.twin.api.TwinPublisher
register
-
-
-
-
Field Detail
-
TAG_TWIN_SINK
protected static final java.lang.String TAG_TWIN_SINK
- See Also:
- Constant Field Values
-
TAG_TWIN_RPC
protected static final java.lang.String TAG_TWIN_RPC
- See Also:
- Constant Field Values
-
TAG_VERSION
protected static final java.lang.String TAG_VERSION
- See Also:
- Constant Field Values
-
TAG_SESSION_ID
protected static final java.lang.String TAG_SESSION_ID
- See Also:
- Constant Field Values
-
TAG_PATCH
protected static final java.lang.String TAG_PATCH
- See Also:
- Constant Field Values
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Detail
-
AbstractTwinPublisher
public AbstractTwinPublisher(LocalTwinSubscriber localTwinSubscriber, TracerRegistry tracerRegistry, com.codahale.metrics.MetricRegistry metricRegistry)
-
AbstractTwinPublisher
public AbstractTwinPublisher(LocalTwinSubscriber localTwinSubscriber)
-
-
Method Detail
-
handleSinkUpdate
protected abstract void handleSinkUpdate(TwinUpdate sinkUpdate)
- Parameters:
sinkUpdate
- Handle sink Update from @AbstractTwinPublisher
.
-
register
public <T> TwinPublisher.Session<T> register(java.lang.String key, java.lang.Class<T> clazz, java.lang.String location) throws java.io.IOException
- Specified by:
register
in interfaceTwinPublisher
- Type Parameters:
T
- type of object for replication- Parameters:
key
- unique key for the object.clazz
- a class used for serialization.location
- targeted Minion location for the object, set null for all locations.- Returns:
- Session which provides updates to object.
- Throws:
java.io.IOException
-
getTwin
protected TwinUpdate getTwin(TwinRequest twinRequest)
-
mapTwinResponse
protected TwinResponseProto mapTwinResponse(TwinUpdate twinUpdate)
-
mapTwinRequestProto
protected TwinRequest mapTwinRequestProto(byte[] twinRequestBytes)
-
addTracingInfo
protected void addTracingInfo(io.opentracing.Span span, TwinUpdate twinUpdate)
-
generateTracingOperationKey
public static java.lang.String generateTracingOperationKey(java.lang.String location, java.lang.String key)
-
forEachSession
public void forEachSession(java.util.function.BiConsumer<AbstractTwinPublisher.SessionKey,TwinTracker> consumer)
-
getTracer
public io.opentracing.Tracer getTracer()
-
-