Package io.pravega.client.control.impl
Class ModelHelper
- java.lang.Object
-
- io.pravega.client.control.impl.ModelHelper
-
public final class ModelHelper extends java.lang.Object
Provides translation (encode/decode) between the Model classes and its gRPC representation. NOTE: For some unknown reason all methods that encode data to go over the wire are called "decode" and all method that take the wire format an instantiate java objects are called "encode".
-
-
Constructor Summary
Constructors Constructor Description ModelHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableInfo
createKeyValueTableInfo(java.lang.String scope, java.lang.String kvtName)
static io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo
createReaderGroupInfo(java.lang.String scope, java.lang.String readerGroup, java.lang.String readerGroupId, long generation)
static io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo
createScopeInfo(java.lang.String scope)
static io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId
createSegmentId(java.lang.String scope, java.lang.String stream, long segmentId)
static io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange
createSegmentRange(java.lang.String scope, java.lang.String stream, long segmentId, double rangeMinKey, double rangeMaxKey)
static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut
createStreamCut(Stream stream, WriterPosition position)
Builds a stream cut, mapping the segments of a stream to their offsets from a writer position object.static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse
createStreamCutRangeResponse(java.lang.String scope, java.lang.String stream, java.util.List<io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId> segments, java.lang.String delegationToken)
static io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo
createStreamInfo(java.lang.String scope, java.lang.String stream)
static io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo
createStreamInfo(java.lang.String scope, java.lang.String stream, io.pravega.shared.security.auth.AccessOperation accessOperation)
static io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse.Builder
createSuccessorResponse(java.util.Map<io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange,java.util.List<java.lang.Long>> segments)
static io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId
decode(Segment segment)
Decodes segment and returns an instance of SegmentId.static io.pravega.controller.stream.api.grpc.v1.Controller.RetentionPolicy
decode(RetentionPolicy policyModel)
Decodes RetentionPolicy and returns an instance of Retention Policy impl.static io.pravega.controller.stream.api.grpc.v1.Controller.ScalingPolicy
decode(ScalingPolicy policyModel)
Decodes ScalingPolicy and returns an instance of Scaling Policy impl.static io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri
decode(io.pravega.shared.protocol.netty.PravegaNodeUri uri)
Converts PravegaNodeURI into NodeURI.static io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration
decode(java.lang.String scope, java.lang.String groupName, ReaderGroupConfig config)
static io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration
decode(java.lang.String scope, java.lang.String groupName, ReaderGroupConfig config, java.util.UUID readerGroupId)
static io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig
decode(java.lang.String scope, java.lang.String streamName, StreamConfiguration configModel)
Converts StreamConfiguration into StreamConfig.static io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig
decode(java.lang.String scopeName, java.lang.String kvtName, KeyValueTableConfiguration config)
Helper to convert KeyValueTableConfiguration object into KeyValueTableConfig Impl.static io.pravega.controller.stream.api.grpc.v1.Controller.StreamSubscriberInfo
decode(java.lang.String scope, java.lang.String streamName, java.lang.String subscriber, long generation)
Converts StreamConfiguration into StreamConfig.static io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut
decode(java.lang.String scope, java.lang.String streamName, java.lang.String subscriber, java.util.UUID readerGroupId, long generation, java.util.Map<java.lang.Long,java.lang.Long> streamCut)
Converts Subscriber and StreamCut information into SubscriberStreamCut.static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut
decode(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> streamCut)
Creates a stream cut object.static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRange
decode(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> from, java.util.Map<java.lang.Long,java.lang.Long> to)
static io.pravega.controller.stream.api.grpc.v1.Controller.TxnId
decode(java.util.UUID txnId)
Returns TxnId object instance for a given transaction with UUID.static KeyValueTableConfiguration
encode(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig config)
Helper to convert KeyValueTableConfig object into KeyValueTableConfiguration Impl.static io.pravega.shared.protocol.netty.PravegaNodeUri
encode(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri uri)
Helper to convert NodeURI into PravegaNodeURI.static Transaction.PingStatus
encode(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus.Status status, java.lang.String logString)
Returns the status of Ping Transaction.static ReaderGroupConfig
encode(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration rgConfig)
Helper method to convert stream cut to map of segment to position.static RetentionPolicy
encode(io.pravega.controller.stream.api.grpc.v1.Controller.RetentionPolicy policy)
Helper to convert retention policy from RPC call to internal representation.static ScalingPolicy
encode(io.pravega.controller.stream.api.grpc.v1.Controller.ScalingPolicy policy)
static Segment
encode(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId segment)
Helper to convert Segment Id into Segment object.static SegmentWithRange
encode(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange segmentRange)
Helper to convert SegmentRange to SegmentWithRange.static StreamConfiguration
encode(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig config)
Helper to convert StreamConfig into Stream Configuration Impl.static java.util.Map<java.lang.Long,java.lang.Long>
encode(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut streamCut)
Helper method to convery stream cut to map of segment to position.static java.util.UUID
encode(io.pravega.controller.stream.api.grpc.v1.Controller.TxnId txnId)
Returns UUID of transaction with given TxnId.static Transaction.Status
encode(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState.State state, java.lang.String logString)
Returns actual status of given transaction status instance.static java.util.List<java.util.Map.Entry<java.lang.Double,java.lang.Double>>
encode(java.util.Map<java.lang.Double,java.lang.Double> keyRanges)
Return list of key ranges available.static StreamCut
generateStreamCut(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> cutMap)
static java.util.Map<Segment,java.lang.Long>
getSegmentOffsetMap(java.lang.String scopeName, java.lang.String streamName, java.util.Map<java.lang.Long,java.lang.Long> streamCutMap)
static com.google.common.collect.ImmutableMap<java.lang.Long,java.lang.Long>
getStreamCutMap(StreamCut streamCut)
-
-
-
Method Detail
-
encode
public static final java.util.UUID encode(io.pravega.controller.stream.api.grpc.v1.Controller.TxnId txnId)
Returns UUID of transaction with given TxnId.- Parameters:
txnId
- The Transaction Id.- Returns:
- UUID of the transaction.
-
encode
public static final Segment encode(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId segment)
Helper to convert Segment Id into Segment object.- Parameters:
segment
- The Segment Id.- Returns:
- New instance of Segment.
-
encode
public static final ScalingPolicy encode(io.pravega.controller.stream.api.grpc.v1.Controller.ScalingPolicy policy)
-
encode
public static final RetentionPolicy encode(io.pravega.controller.stream.api.grpc.v1.Controller.RetentionPolicy policy)
Helper to convert retention policy from RPC call to internal representation.- Parameters:
policy
- The retention policy from RPC interface.- Returns:
- New instance of RetentionPolicy.
-
encode
public static final StreamConfiguration encode(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig config)
Helper to convert StreamConfig into Stream Configuration Impl.- Parameters:
config
- The StreamConfig- Returns:
- New instance of StreamConfiguration Impl.
-
encode
public static final KeyValueTableConfiguration encode(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig config)
Helper to convert KeyValueTableConfig object into KeyValueTableConfiguration Impl.- Parameters:
config
- The KeyValueTable Config- Returns:
- New instance of KeyValueTableConfiguration Impl.
-
encode
public static final io.pravega.shared.protocol.netty.PravegaNodeUri encode(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri uri)
Helper to convert NodeURI into PravegaNodeURI.- Parameters:
uri
- Node URI.- Returns:
- PravegaNodeURI.
-
encode
public static final java.util.List<java.util.Map.Entry<java.lang.Double,java.lang.Double>> encode(java.util.Map<java.lang.Double,java.lang.Double> keyRanges)
Return list of key ranges available.- Parameters:
keyRanges
- List of Key Value pairs.- Returns:
- Collection of key ranges available.
-
encode
public static final Transaction.Status encode(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState.State state, java.lang.String logString)
Returns actual status of given transaction status instance.- Parameters:
state
- TxnState object instance.logString
- Description text to be logged when transaction status is invalid.- Returns:
- Transaction.Status
-
encode
public static final Transaction.PingStatus encode(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus.Status status, java.lang.String logString) throws PingFailedException
Returns the status of Ping Transaction.- Parameters:
status
- PingTxnStatus object instance.logString
- Description text to be logged when ping transaction status is invalid.- Returns:
- Transaction.PingStatus
- Throws:
PingFailedException
- if status of Ping transaction operations is not successful.
-
encode
public static final SegmentWithRange encode(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange segmentRange)
Helper to convert SegmentRange to SegmentWithRange.- Parameters:
segmentRange
- segmentRange- Returns:
- SegmentWithRange
-
encode
public static java.util.Map<java.lang.Long,java.lang.Long> encode(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut streamCut)
Helper method to convery stream cut to map of segment to position.- Parameters:
streamCut
- Stream cut- Returns:
- map of segment to position
-
encode
public static ReaderGroupConfig encode(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration rgConfig)
Helper method to convert stream cut to map of segment to position.- Parameters:
rgConfig
- Reader Group configuration object.- Returns:
- map of segment to position
-
generateStreamCut
public static StreamCut generateStreamCut(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> cutMap)
-
getSegmentOffsetMap
public static java.util.Map<Segment,java.lang.Long> getSegmentOffsetMap(java.lang.String scopeName, java.lang.String streamName, java.util.Map<java.lang.Long,java.lang.Long> streamCutMap)
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.TxnId decode(java.util.UUID txnId)
Returns TxnId object instance for a given transaction with UUID.- Parameters:
txnId
- UUID- Returns:
- Instance of TxnId.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId decode(Segment segment)
Decodes segment and returns an instance of SegmentId.- Parameters:
segment
- The segment.- Returns:
- Instance of SegmentId.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.ScalingPolicy decode(ScalingPolicy policyModel)
Decodes ScalingPolicy and returns an instance of Scaling Policy impl.- Parameters:
policyModel
- The Scaling Policy.- Returns:
- Instance of Scaling Policy Impl.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.RetentionPolicy decode(RetentionPolicy policyModel)
Decodes RetentionPolicy and returns an instance of Retention Policy impl.- Parameters:
policyModel
- The Retention Policy.- Returns:
- Instance of Retention Policy Impl.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig decode(java.lang.String scope, java.lang.String streamName, StreamConfiguration configModel)
Converts StreamConfiguration into StreamConfig.- Parameters:
scope
- the stream's scopestreamName
- The Stream NameconfigModel
- The stream configuration.- Returns:
- StreamConfig instance.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.StreamSubscriberInfo decode(java.lang.String scope, java.lang.String streamName, java.lang.String subscriber, long generation)
Converts StreamConfiguration into StreamConfig.- Parameters:
scope
- the stream's scopestreamName
- The Stream Namesubscriber
- Id of the subscriber for this stream.generation
- generation of the subscriber operation.- Returns:
- StreamSubscriberInfo instance.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut decode(java.lang.String scope, java.lang.String streamName, java.lang.String subscriber, java.util.UUID readerGroupId, long generation, java.util.Map<java.lang.Long,java.lang.Long> streamCut)
Converts Subscriber and StreamCut information into SubscriberStreamCut.- Parameters:
scope
- the stream's scopestreamName
- The Stream Namesubscriber
- subscriber for this stream.readerGroupId
- Reader Group Id.generation
- subscriber generation.streamCut
- truncationStreamCut for this subscriber for this stream.- Returns:
- SubscriberStreamCut instance.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig decode(java.lang.String scopeName, java.lang.String kvtName, KeyValueTableConfiguration config)
Helper to convert KeyValueTableConfiguration object into KeyValueTableConfig Impl.- Parameters:
scopeName
- Name for scope for KVTable.kvtName
- KeyValueTable Name.config
- The KeyValueTable Configuration object.- Returns:
- New instance of KeyValueTableConfig.
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri decode(io.pravega.shared.protocol.netty.PravegaNodeUri uri)
Converts PravegaNodeURI into NodeURI.- Parameters:
uri
- The PravegaNodeURI string.- Returns:
- Node URI string.
-
decode
public static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut decode(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> streamCut)
Creates a stream cut object.- Parameters:
scope
- scopestream
- streamstreamCut
- map of segment to position- Returns:
- stream cut
-
decode
public static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRange decode(java.lang.String scope, java.lang.String stream, java.util.Map<java.lang.Long,java.lang.Long> from, java.util.Map<java.lang.Long,java.lang.Long> to)
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration decode(java.lang.String scope, java.lang.String groupName, ReaderGroupConfig config)
-
decode
public static final io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration decode(java.lang.String scope, java.lang.String groupName, ReaderGroupConfig config, java.util.UUID readerGroupId)
-
getStreamCutMap
public static com.google.common.collect.ImmutableMap<java.lang.Long,java.lang.Long> getStreamCutMap(StreamCut streamCut)
-
createScopeInfo
public static final io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo createScopeInfo(java.lang.String scope)
-
createStreamInfo
public static final io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo createStreamInfo(java.lang.String scope, java.lang.String stream, io.pravega.shared.security.auth.AccessOperation accessOperation)
-
createStreamInfo
public static final io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo createStreamInfo(java.lang.String scope, java.lang.String stream)
-
createReaderGroupInfo
public static final io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo createReaderGroupInfo(java.lang.String scope, java.lang.String readerGroup, java.lang.String readerGroupId, long generation)
-
createKeyValueTableInfo
public static final io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableInfo createKeyValueTableInfo(java.lang.String scope, java.lang.String kvtName)
-
createSegmentId
public static final io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId createSegmentId(java.lang.String scope, java.lang.String stream, long segmentId)
-
createSegmentRange
public static final io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange createSegmentRange(java.lang.String scope, java.lang.String stream, long segmentId, double rangeMinKey, double rangeMaxKey)
-
createStreamCutRangeResponse
public static final io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse createStreamCutRangeResponse(java.lang.String scope, java.lang.String stream, java.util.List<io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId> segments, java.lang.String delegationToken)
-
createStreamCut
public static io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut createStreamCut(Stream stream, WriterPosition position)
Builds a stream cut, mapping the segments of a stream to their offsets from a writer position object.- Parameters:
stream
- The stream the cut is on.position
- The position object to take the offsets from.- Returns:
- a StreamCut.
-
createSuccessorResponse
public static final io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse.Builder createSuccessorResponse(java.util.Map<io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange,java.util.List<java.lang.Long>> segments)
-
-