Table of Contents

Class KNetRocksDBConfigSetter

Namespace
Org.Apache.Kafka.Streams.State
Assembly
MASES.KNet.dll
public class KNetRocksDBConfigSetter : RocksDBConfigSetter, IDynamicMetaObjectProvider, IJVMBridgeCore, IEquatable<IJVMBridgeBase>, IDisposable, IJVMBridgeBaseStatic, IJVMBridgeBase, IJVMBridgeDefinition, IRocksDBConfigSetter
Inheritance
KNetRocksDBConfigSetter
Implements
Inherited Members

Constructors

KNetRocksDBConfigSetter()

Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge

[Obsolete("KNetRocksDBConfigSetter class represents, in .NET, an instance of a JVM interface or abstract class. This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public KNetRocksDBConfigSetter()

KNetRocksDBConfigSetter(IJVMBridgeBaseInitializer)

Internal constructor: used internally from JCOBridge

[Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public KNetRocksDBConfigSetter(IJVMBridgeBaseInitializer initializer)

Parameters

initializer IJVMBridgeBaseInitializer

KNetRocksDBConfigSetter(params object[])

Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class

[Obsolete("KNetRocksDBConfigSetter class represents, in .NET, an instance of a JVM interface or abstract class. This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public KNetRocksDBConfigSetter(params object[] args)

Parameters

args object[]

Properties

BridgeClassName

Java class name to be instantiated

public override string BridgeClassName { get; }

Property Value

string

IsBridgeAbstract

true if the BridgeClassName is an abstract class, i.e. cannot be created an instance

public override bool IsBridgeAbstract { get; }

Property Value

bool

IsBridgeInterface

true if the BridgeClassName is an interface, i.e. does not have any public constructor

public override bool IsBridgeInterface { get; }

Property Value

bool

KNetRocksDBConfigSetterClass

public static Class KNetRocksDBConfigSetterClass { get; }

Property Value

Class

RegisteredStorageId

Current registered storage id, i.e. the list of storages where it was invoked Register(string, IRocksDbLifecycleHandler, bool)

public static IReadOnlyList<string> RegisteredStorageId { get; }

Property Value

IReadOnlyList<string>

RocksDBConfigSetterCallbackSet

public static bool RocksDBConfigSetterCallbackSet { get; }

Property Value

bool

Methods

Register(string, IRocksDbLifecycleHandler, bool)

Register handler associated to storageId

public static bool Register(string storageId, IRocksDbLifecycleHandler handler = null, bool silent = false)

Parameters

storageId string

The id used when the RocksDb storage was requested

handler IRocksDbLifecycleHandler

The IRocksDbLifecycleHandler will be invoked or null to use defaults

silent bool

true to silently bypass the condition of previous registration of storageId

Returns

bool

true if the operation succeded, false otherwise if silent is true

Remarks

This method works only in conjunction with SetRocksDBConfigSetterCallbackDefault(), which is the default one.

Exceptions

InvalidOperationException

If storageId is already registered

ResetRocksDBConfigSetterCallback()

public static void ResetRocksDBConfigSetterCallback()

SetCallback(KNetRocksDBConfigSetterCallback)

Set the KNetRocksDBConfigSetterCallback used from the instances of KNetRocksDBConfigSetter

public static void SetCallback(KNetRocksDBConfigSetterCallback callback)

Parameters

callback KNetRocksDBConfigSetterCallback

The allocated KNetRocksDBConfigSetterCallback

SetRocksDBConfigSetterCallback(Action<string, Options, IKNetConfigurationFromMap, IDictionary<string, object>>, Action<string, Options, IDictionary<string, object>>)

Sets the global KNetRocksDBConfigSetterCallback will be shared across all requests of KNetRocksDBConfigSetter

public static void SetRocksDBConfigSetterCallback(Action<string, Options, IKNetConfigurationFromMap, IDictionary<string, object>> onSetConfig, Action<string, Options, IDictionary<string, object>> onClose)

Parameters

onSetConfig Action<string, Options, IKNetConfigurationFromMap, IDictionary<string, object>>

Invoked when a new KNetRocksDBConfigSetter is requested and needs to be configured: the parameters are the same of SetConfig(String, Options, Map<String, object>) with an extra parameter can be filled in with used specific information will be received back on onClose invocation

onClose Action<string, Options, IDictionary<string, object>>

Invoked when a previously configured instance of KNetRocksDBConfigSetter shall be closed: the parameters are the same of Close(String, Options) with an extra parameter filled in when onSetConfig was invoked

Remarks

The callbacks will be in effect only registering KNetRocksDBConfigSetter as Class used from RocksDbConfigSetterClass or a property associated to ROCKSDB_CONFIG_SETTER_CLASS_CONFIG:

<pre><code class="lang-csharp">StreamsConfigBuilder builder = StreamsConfigBuilder.Create();

builder.RocksDbConfigSetterClass = KNetRocksDBConfigSetter.KNetRocksDBConfigSetterClass; ... builder.Build();

In general the fourth parameter of <code class="paramref">onSetConfig</code> can be used to store the reference to objects needs to be closed when <code class="paramref">onClose</code> is invoked.
The example in <a href="https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter">https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter</a> translates into:

<pre><code class="lang-csharp">void OnSetConfig(string store, Org.Rocksdb.Options options, IKNetConfigurationFromMap configs, IDictionary<string, object> data)

{ Org.Rocksdb.Cache cache = new Org.Rocksdb.LRUCache(16 * 1024L * 1024L); data.Add("cache", cache); // See #1 in https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter. BlockBasedTableConfig tableConfig = options.TableFormatConfig().Cast<BlockBasedTableConfig>(); tableConfig.SetBlockCache(cache); // See #2 in https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter. tableConfig.SetBlockSize(16 * 1024L); // See #3 in https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter. tableConfig.SetCacheIndexAndFilterBlocks(true); options.SetTableFormatConfig(tableConfig); // See #4 in https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter. options.SetMaxWriteBufferNumber(2); }

void OnClose(string store, Org.Rocksdb.Options options, IDictionary<string, object> data) { if (data.TryGetValue("cache", out var obj) && obj is Org.Rocksdb.Cache cache) { // See #5 in https://docs.confluent.io/platform/current/streams/developer-guide/config-streams.html#rocksdb-config-setter. cache.Close(); } }

Exceptions

InvalidOperationException

If SetRocksDBConfigSetterCallback(Action<string, Options, IKNetConfigurationFromMap, IDictionary<string, object>>, Action<string, Options, IDictionary<string, object>>) is invoked twice without an invocation to ResetRocksDBConfigSetterCallback()

SetRocksDBConfigSetterCallbackDefault()

Set the default behavior; the user shall not invoked this method directly, see remarks.

public static void SetRocksDBConfigSetterCallbackDefault()

Remarks

Default behavior is set by default; this method can be used if the user invoked ResetRocksDBConfigSetterCallback() and needs to return to the default

Unregister(string, bool)

Unregister the IRocksDbLifecycleHandler associated to storageId

public static bool Unregister(string storageId, bool silent = false)

Parameters

storageId string

The id used when the RocksDb storage was requested

silent bool

true to silently bypass the condition of missing registration of storageId

Returns

bool

true if the operation succeded, false otherwise if silent is true

Remarks

This method works only in conjunction with SetRocksDBConfigSetterCallbackDefault(), which is the default one.

Exceptions

InvalidOperationException

If storageId is not available