org.sdnplatform.sync.internal.rpc
Class TProtocolUtil

java.lang.Object
  extended by org.sdnplatform.sync.internal.rpc.TProtocolUtil

public class TProtocolUtil
extends java.lang.Object

Some utility methods for constructing Thrift messages

Author:
readams

Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
TProtocolUtil()
           
 
Method Summary
static ISyncService.Scope getScope(org.sdnplatform.sync.thrift.Scope tScope)
          Convert a org.sdnplatform.sync.thrift.Scope into a ISyncService.Scope
static KeyedValues getTKeyedValues(ByteArray key, java.lang.Iterable<Versioned<byte[]>> values)
          Construct a thrift org.sdnplatform.sync.thrift.KeyedValues
static KeyedValues getTKeyedValues(ByteArray key, Versioned<byte[]>... value)
          Construct a thrift org.sdnplatform.sync.thrift.KeyedValues
static KeyedVersions getTKeyedVersions(ByteArray key, java.util.List<Versioned<byte[]>> values)
          Construct a thrift org.sdnplatform.sync.thrift.KeyedValues
static org.sdnplatform.sync.thrift.Scope getTScope(ISyncService.Scope Scope)
          Convert a ISyncService.Scope into a org.sdnplatform.sync.thrift.Scope
static org.sdnplatform.sync.thrift.Store getTStore(java.lang.String storeName, ISyncService.Scope scope, boolean persist)
          Allocate a thrift org.sdnplatform.sync.thrift.Store object for the current store
static org.sdnplatform.sync.thrift.Store getTStore(java.lang.String storeName, org.sdnplatform.sync.thrift.Scope scope, boolean persist)
          Allocate a thrift org.sdnplatform.sync.thrift.Store object for the current store
static SyncMessage getTSyncOfferMessage(java.lang.String storeName, ISyncService.Scope scope, boolean persist)
          Get a partially-initialized SyncOfferMessage wrapped with a SyncMessage.
static SyncMessage getTSyncValueMessage(Store store)
          Get a partially-initialized SyncValueMessage wrapped with a SyncMessage.
static SyncMessage getTSyncValueMessage(java.lang.String storeName, ISyncService.Scope scope, boolean persist)
          Get a partially-initialized SyncValueMessage wrapped with a SyncMessage.
static org.sdnplatform.sync.thrift.VectorClock getTVectorClock(VectorClock vc)
          Convert a VectorClock into a org.sdnplatform.sync.thrift.VectorClock
static org.sdnplatform.sync.thrift.VersionedValue getTVersionedValue(Versioned<byte[]> value)
          Allocate a thrift org.sdnplatform.sync.thrift.VersionedValue object wrapping a Versioned object
static VectorClock getVersion(org.sdnplatform.sync.thrift.VectorClock tvc)
          Convert a thrift org.sdnplatform.sync.thrift.VectorClock into a VectorClock.
static java.util.List<Versioned<byte[]>> getVersionedList(java.util.List<VersionedValue> tvv)
          Convert from a list of VersionedValue to a list of Versioned
static Versioned<byte[]> getVersionedValued(VersionedValue tvv)
          Convert a thrift VersionedValue into a Versioned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.slf4j.Logger logger
Constructor Detail

TProtocolUtil

public TProtocolUtil()
Method Detail

getTVectorClock

public static org.sdnplatform.sync.thrift.VectorClock getTVectorClock(VectorClock vc)
Convert a VectorClock into a org.sdnplatform.sync.thrift.VectorClock

Parameters:
vc - the input clock
Returns:
the output thrift object

getTVersionedValue

public static org.sdnplatform.sync.thrift.VersionedValue getTVersionedValue(Versioned<byte[]> value)
Allocate a thrift org.sdnplatform.sync.thrift.VersionedValue object wrapping a Versioned object

Parameters:
value - the value to wrap
Returns:
the thrift object

getTKeyedValues

public static KeyedValues getTKeyedValues(ByteArray key,
                                          Versioned<byte[]>... value)
Construct a thrift org.sdnplatform.sync.thrift.KeyedValues

Parameters:
key - the key
value - the versioned values
Returns:
the thrift object

getTKeyedValues

public static KeyedValues getTKeyedValues(ByteArray key,
                                          java.lang.Iterable<Versioned<byte[]>> values)
Construct a thrift org.sdnplatform.sync.thrift.KeyedValues

Parameters:
key - the key
values - the versioned values
Returns:
the thrift object

getTKeyedVersions

public static KeyedVersions getTKeyedVersions(ByteArray key,
                                              java.util.List<Versioned<byte[]>> values)
Construct a thrift org.sdnplatform.sync.thrift.KeyedValues

Parameters:
key - the key
value - the versioned values
Returns:
the thrift object

getTStore

public static org.sdnplatform.sync.thrift.Store getTStore(java.lang.String storeName,
                                                          ISyncService.Scope scope,
                                                          boolean persist)
Allocate a thrift org.sdnplatform.sync.thrift.Store object for the current store

Parameters:
storeName - the name of the store
scope - the scope of the store
persist - whether the store is persistent
Returns:
the object

getTStore

public static org.sdnplatform.sync.thrift.Store getTStore(java.lang.String storeName,
                                                          org.sdnplatform.sync.thrift.Scope scope,
                                                          boolean persist)
Allocate a thrift org.sdnplatform.sync.thrift.Store object for the current store

Parameters:
storeName - the name of the store
scope - the scope of the store
persist - whether the store is persistent
Returns:
the object

getScope

public static ISyncService.Scope getScope(org.sdnplatform.sync.thrift.Scope tScope)
Convert a org.sdnplatform.sync.thrift.Scope into a ISyncService.Scope

Parameters:
tScope - the org.sdnplatform.sync.thrift.Scope to convert
Returns:
the resulting ISyncService.Scope

getTScope

public static org.sdnplatform.sync.thrift.Scope getTScope(ISyncService.Scope Scope)
Convert a ISyncService.Scope into a org.sdnplatform.sync.thrift.Scope

Parameters:
tScope - the ISyncService.Scope to convert
Returns:
the resulting org.sdnplatform.sync.thrift.Scope

getTSyncValueMessage

public static SyncMessage getTSyncValueMessage(java.lang.String storeName,
                                               ISyncService.Scope scope,
                                               boolean persist)
Get a partially-initialized SyncValueMessage wrapped with a SyncMessage. The values will not be set in the SyncValueMessage, and the transaction ID will not be set in the AsyncMessageHeader.

Parameters:
storeName - the store name
scope - the scope
persist - whether the store is persistent
Returns:
the SyncMessage

getTSyncValueMessage

public static SyncMessage getTSyncValueMessage(Store store)
Get a partially-initialized SyncValueMessage wrapped with a SyncMessage. The values will not be set in the SyncValueMessage, and the transaction ID will not be set in the AsyncMessageHeader.

Parameters:
store - the Store associated with the message
Returns:
the SyncMessage

getTSyncOfferMessage

public static SyncMessage getTSyncOfferMessage(java.lang.String storeName,
                                               ISyncService.Scope scope,
                                               boolean persist)
Get a partially-initialized SyncOfferMessage wrapped with a SyncMessage.

Parameters:
storeName - the name of the store associated with the message
scope - the ISyncService.Scope for the store
persist - the scope for the store
Returns:
the SyncMessage

getVersion

public static VectorClock getVersion(org.sdnplatform.sync.thrift.VectorClock tvc)
Convert a thrift org.sdnplatform.sync.thrift.VectorClock into a VectorClock.

Parameters:
tvc - the org.sdnplatform.sync.thrift.VectorClock
the - VectorClock

getVersionedValued

public static Versioned<byte[]> getVersionedValued(VersionedValue tvv)
Convert a thrift VersionedValue into a Versioned.

Parameters:
tvv - the VersionedValue
Returns:
the Versioned

getVersionedList

public static java.util.List<Versioned<byte[]>> getVersionedList(java.util.List<VersionedValue> tvv)
Convert from a list of VersionedValue to a list of Versioned

Parameters:
tvv - the list of versioned values
Returns:
the list of versioned