From 0b9e993e3e963e2223b2cf78c1f5a873a1e547f9 Mon Sep 17 00:00:00 2001
From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com>
Date: Tue, 17 May 2022 00:34:10 +0200
Subject: [PATCH 01/13] #65: added some documentation
---
.../Connect/KNetConnectProxy.cs | 29 +++++-
.../BridgedClasses/Connect/KNetConnector.cs | 92 +++++++++++++------
.../Connect/KNetSinkConnector.cs | 13 ++-
.../BridgedClasses/Connect/KNetSinkTask.cs | 15 ++-
.../Connect/KNetSourceConnector.cs | 13 ++-
.../BridgedClasses/Connect/KNetSourceTask.cs | 15 ++-
.../BridgedClasses/Connect/KNetTask.cs | 54 ++++++++---
7 files changed, 178 insertions(+), 53 deletions(-)
diff --git a/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnectProxy.cs b/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnectProxy.cs
index 27213c54b9..9bf07a0dcf 100644
--- a/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnectProxy.cs
+++ b/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnectProxy.cs
@@ -20,6 +20,9 @@
namespace MASES.KNet.Connect
{
+ ///
+ /// Internal class used to proxy and pairs data exchange with Java side
+ ///
public class KNetConnectProxy
{
static readonly object globalInstanceLock = new();
@@ -27,7 +30,9 @@ public class KNetConnectProxy
static KNetConnector SinkConnector = null;
static KNetConnector SourceConnector = null;
-
+ ///
+ /// Register the proxy
+ ///
public static void Register()
{
lock (globalInstanceLock)
@@ -39,7 +44,11 @@ public static void Register()
}
}
}
-
+ ///
+ /// Allocates a sink connector
+ ///
+ /// The class name read from Java within the configuration parameters
+ /// if successfully
public bool AllocateSinkConnector(string connectorClassName)
{
lock (globalInstanceLock)
@@ -57,7 +66,11 @@ public bool AllocateSinkConnector(string connectorClassName)
}
}
}
-
+ ///
+ /// Allocates a source connector
+ ///
+ /// The class name read from Java within the configuration parameters
+ /// if successfully
public bool AllocateSourceConnector(string connectorClassName)
{
lock (globalInstanceLock)
@@ -75,7 +88,10 @@ public bool AllocateSourceConnector(string connectorClassName)
}
}
}
-
+ ///
+ /// Returns the registration name of the sink connector
+ ///
+ /// The content of
public string SinkConnectorName()
{
lock (globalInstanceLock)
@@ -84,7 +100,10 @@ public string SinkConnectorName()
return null;
}
}
-
+ ///
+ /// Returns the registration name of the sourcce connector
+ ///
+ /// The content of
public string SourceConnectorName()
{
lock (globalInstanceLock)
diff --git a/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnector.cs b/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnector.cs
index b764f8aed5..f83ebbcc14 100644
--- a/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnector.cs
+++ b/src/net/KNet/ClientSide/BridgedClasses/Connect/KNetConnector.cs
@@ -26,36 +26,65 @@
namespace MASES.KNet.Connect
{
+ ///
+ /// Specific implementation of to support KNet Connect SDK
+ ///
public interface IKNetConnector : IConnector
{
+ ///
+ /// Allocates a task object based on
+ ///
+ /// The unique id generated from JAva side
+ /// The local .NET object
object AllocateTask(long taskId);
-
+ ///
+ /// The unique name of the connector
+ ///
string ConnectorName { get; }
-
+ ///
+ /// The of task to be allocated, it shall inherits from
+ ///
Type TaskClassType { get; }
+ ///
+ /// Invoked during allocation of tasks from Apache Kafka Connect
+ ///
+ /// The actual index
+ /// The to be filled in with properties for the task: the same will be received from
+ void TaskConfigs(int index, Map config);
}
-
+ ///
+ /// The generic class which is the base of both source or sink connectors
+ ///
public abstract class KNetConnector : IKNetConnector
{
- protected ConnectorContext ctx;
+ ///
+ /// The set of allocated with their associated identifiers
+ ///
protected ConcurrentDictionary taskDictionary = new();
IJavaObject reflectedConnector = null;
-
+ ///
+ /// Initializer
+ ///
public KNetConnector()
{
- KNetCore.GlobalInstance.RegisterCLRGlobal(ReflectedConnectorName, this);
+ KNetCore.GlobalInstance.RegisterCLRGlobal(ReflectedConnectorClassName, this);
}
-
+ ///
+ /// An helper function to read the data from Java side
+ ///
+ /// The expected return
+ /// The
+ ///
protected T DataToExchange()
{
if (reflectedConnector == null)
{
- reflectedConnector = KNetCore.GlobalInstance.GetJVMGlobal(ReflectedConnectorName);
+ reflectedConnector = KNetCore.GlobalInstance.GetJVMGlobal(ReflectedConnectorClassName);
}
- return (reflectedConnector != null) ? reflectedConnector.Invoke("getDataToExchange") : throw new InvalidOperationException($"{ReflectedConnectorName} was not registered in global JVM");
+ return (reflectedConnector != null) ? reflectedConnector.Invoke("getDataToExchange") : throw new InvalidOperationException($"{ReflectedConnectorClassName} was not registered in global JVM");
}
-
+ ///
public object AllocateTask(long taskId)
{
return taskDictionary.GetOrAdd(taskId, (id) =>
@@ -65,53 +94,60 @@ public object AllocateTask(long taskId)
return knetTask;
});
}
-
- public abstract string ReflectedConnectorName { get; }
-
+ ///
+ /// The unique name used to map objects between JVM and .NET
+ ///
+ public abstract string ReflectedConnectorClassName { get; }
+ ///
public abstract string ConnectorName { get; }
-
+ ///
public abstract Type TaskClassType { get; }
public void Initialize(ConnectorContext ctx) => throw new NotImplementedException("Invoked in Java before any initialization.");
public void Initialize(ConnectorContext ctx, List