You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2021/12/21 18:40:36 UTC
[ignite] branch master updated: IGNITE-13359 .NET: Add GetServiceDescriptor (#9678)
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new c67df98 IGNITE-13359 .NET: Add GetServiceDescriptor (#9678)
c67df98 is described below
commit c67df985eb9abb6edb5c88be74f44204ddf7d609
Author: Nikolay <ni...@apache.org>
AuthorDate: Tue Dec 21 21:39:50 2021 +0300
IGNITE-13359 .NET: Add GetServiceDescriptor (#9678)
---
.../Client/Services/ServicesClientTest.cs | 34 +++++++++++
.../Services/ServiceProxyTest.cs | 2 +-
.../Client/Services/IClientServiceDescriptor.cs | 71 ++++++++++++++++++++++
.../Client/Services/IServicesClient.cs | 15 +++++
.../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 2 +
.../Client/Services/ClientServiceDescriptor.cs | 68 +++++++++++++++++++++
.../Impl/Client/Services/ServicesClient.cs | 28 +++++++++
.../Impl/Services/ServiceDescriptor.cs | 4 +-
.../Impl/Services/ServiceProxySerializer.cs | 2 +-
.../Apache.Ignite.Core/Impl/Services/Services.cs | 1 +
.../{Impl/Common => Platform}/PlatformType.cs | 8 +--
11 files changed, 227 insertions(+), 8 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
index e6cf99e..57396ef 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Tests.Client.Services
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Client;
using Apache.Ignite.Core.Client.Services;
+ using Apache.Ignite.Core.Platform;
using Apache.Ignite.Core.Services;
using Apache.Ignite.Core.Tests.Client.Cache;
using Apache.Ignite.Core.Tests.Services;
@@ -567,6 +568,39 @@ namespace Apache.Ignite.Core.Tests.Client.Services
Assert.AreEqual(1, task.Result);
}
+ [Test]
+ public void TestGetServiceDescriptors()
+ {
+ DeployAndGetTestService();
+
+ var svcs = Client.GetServices().GetServiceDescriptors();
+
+ Assert.AreEqual(1, svcs.Count);
+
+ var svc = svcs.First();
+
+ Assert.AreEqual(ServiceName, svc.Name);
+ Assert.AreEqual(
+ "org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetServiceImpl",
+ svc.ServiceClass
+ );
+ Assert.AreEqual(1, svc.TotalCount);
+ Assert.AreEqual(1, svc.MaxPerNodeCount);
+ Assert.IsNull(svc.CacheName);
+ Assert.AreEqual(Ignition.GetIgnite().GetCluster().GetLocalNode().Id, svc.OriginNodeId);
+ Assert.AreEqual(PlatformType.DotNet, svc.PlatformType);
+
+ var svc1 = Client.GetServices().GetServiceDescriptor(ServiceName);
+
+ Assert.AreEqual(svc.Name, svc1.Name);
+ Assert.AreEqual(svc.ServiceClass, svc1.ServiceClass);
+ Assert.AreEqual(svc.TotalCount, svc1.TotalCount);
+ Assert.AreEqual(svc.MaxPerNodeCount, svc1.MaxPerNodeCount);
+ Assert.AreEqual(svc.CacheName, svc1.CacheName);
+ Assert.AreEqual(svc.OriginNodeId, svc1.OriginNodeId);
+ Assert.AreEqual(svc.PlatformType, svc1.PlatformType);
+ }
+
/// <summary>
/// Deploys test service and returns client-side proxy.
/// </summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index bc6ec70..72d961c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -24,9 +24,9 @@ namespace Apache.Ignite.Core.Tests.Services
using System.Reflection;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Memory;
using Apache.Ignite.Core.Impl.Services;
+ using Apache.Ignite.Core.Platform;
using Apache.Ignite.Core.Services;
using NUnit.Framework;
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IClientServiceDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IClientServiceDescriptor.cs
new file mode 100644
index 0000000..82e0a37
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IClientServiceDescriptor.cs
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Client.Services
+{
+ using System;
+ using Apache.Ignite.Core.Platform;
+
+ /// <summary>
+ /// Descriptor of Service.
+ /// </summary>
+ public interface IClientServiceDescriptor
+ {
+ /// <summary>
+ /// Gets service name.
+ /// </summary>
+ /// <returns>Service name.</returns>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets service class name.
+ /// </summary>
+ /// <returns>Service class name.</returns>
+ string ServiceClass { get; }
+
+ /// <summary>
+ /// Gets maximum allowed total number of deployed services in the grid, 0 for unlimited.
+ /// </summary>
+ /// <returns>Maximum allowed total number of deployed services in the grid, 0 for unlimited.</returns>
+ int TotalCount { get; }
+
+ /// <summary>
+ /// Gets maximum allowed number of deployed services on each node, {@code 0} for unlimited.
+ /// </summary>
+ /// <returns>Maximum allowed total number of deployed services on each node, {@code 0} for unlimited.</returns>
+ int MaxPerNodeCount { get; }
+
+ /// <summary>
+ /// Gets cache name used for key-to-node affinity calculation.
+ /// This parameter is optional and is set only when key-affinity service was deployed.
+ /// </summary>
+ /// <returns>Cache name, possibly null.</returns>
+ string CacheName { get; }
+
+ /// <summary>
+ /// Gets ID of grid node that initiated the service deployment.
+ /// </summary>
+ /// <returns>ID of grid node that initiated the service deployment.</returns>
+ Guid? OriginNodeId { get; }
+
+ /// <summary>
+ /// Platform type.
+ /// </summary>
+ /// <returns>Platform type.</returns>
+ PlatformType PlatformType { get; }
+ }
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
index 49c64fd..0d20bb0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
@@ -17,6 +17,8 @@
namespace Apache.Ignite.Core.Client.Services
{
+ using System.Collections.Generic;
+
/// <summary>
/// Ignite distributed services client.
/// </summary>
@@ -39,6 +41,19 @@ namespace Apache.Ignite.Core.Client.Services
T GetServiceProxy<T>(string serviceName) where T : class;
/// <summary>
+ /// Gets metadata about all deployed services in the grid.
+ /// </summary>
+ /// <returns>Metadata about all deployed services in the grid.</returns>
+ ICollection<IClientServiceDescriptor> GetServiceDescriptors();
+
+ /// <summary>
+ /// Gets metadata about service deployed in the grid.
+ /// </summary>
+ /// <param name="serviceName">Service name.</param>
+ /// <returns>Metadata about all deployed services in the grid.</returns>
+ IClientServiceDescriptor GetServiceDescriptor(string serviceName);
+
+ /// <summary>
/// Returns an instance with binary mode enabled.
/// Service method results will be kept in binary form.
/// </summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
index 87b4718..0745d7c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
@@ -92,6 +92,8 @@ namespace Apache.Ignite.Core.Impl.Client
// Services.
ServiceInvoke = 7000,
+ ServiceGetDescriptors = 7001,
+ ServiceGetDescriptor = 7002,
// Data Streamer.
DataStreamerStart = 8000,
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ClientServiceDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ClientServiceDescriptor.cs
new file mode 100644
index 0000000..fe09f3c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ClientServiceDescriptor.cs
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client.Services
+{
+ using System;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Client.Services;
+
+ /// <summary>
+ /// Implementation of client service descriptor.
+ /// </summary>
+ internal class ClientServiceDescriptor : IClientServiceDescriptor
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ClientServiceDescriptor" /> class.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ public ClientServiceDescriptor(IBinaryRawReader reader)
+ {
+ if (reader == null)
+ throw new ArgumentNullException(nameof(reader));
+
+ Name = reader.ReadString();
+ ServiceClass = reader.ReadString();
+ TotalCount = reader.ReadInt();
+ MaxPerNodeCount = reader.ReadInt();
+ CacheName = reader.ReadString();
+ OriginNodeId = reader.ReadGuid();
+ PlatformType = (Platform.PlatformType) reader.ReadByte();
+ }
+
+ /** <inheritdoc /> */
+ public string Name { get; private set; }
+
+ /** <inheritdoc /> */
+ public string ServiceClass { get; private set; }
+
+ /** <inheritdoc /> */
+ public int TotalCount { get; private set; }
+
+ /** <inheritdoc /> */
+ public int MaxPerNodeCount { get; private set; }
+
+ /** <inheritdoc /> */
+ public string CacheName { get; private set; }
+
+ /** <inheritdoc /> */
+ public Guid? OriginNodeId { get; private set; }
+
+ /** <inheritdoc /> */
+ public Platform.PlatformType PlatformType { get; private set; }
+ }
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
index a650b21..9e1ab13 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Client.Services
{
using System;
+ using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using Apache.Ignite.Core.Client;
@@ -90,6 +91,33 @@ namespace Apache.Ignite.Core.Impl.Client.Services
}
/** <inheritdoc /> */
+ public ICollection<IClientServiceDescriptor> GetServiceDescriptors()
+ {
+ return _ignite.Socket.DoOutInOp(
+ ClientOp.ServiceGetDescriptors,
+ ctx => { },
+ ctx =>
+ {
+ var cnt = ctx.Reader.ReadInt();
+ var res = new List<IClientServiceDescriptor>(cnt);
+
+ for (var i = 0; i < cnt; i++)
+ res.Add(new ClientServiceDescriptor(ctx.Reader));
+
+ return res;
+ });
+ }
+
+ /** <inheritdoc /> */
+ public IClientServiceDescriptor GetServiceDescriptor(string serviceName)
+ {
+ return _ignite.Socket.DoOutInOp(
+ ClientOp.ServiceGetDescriptor,
+ ctx => ctx.Writer.WriteString(serviceName),
+ ctx => new ClientServiceDescriptor(ctx.Reader));
+ }
+
+ /** <inheritdoc /> */
public IServicesClient WithKeepBinary()
{
return new ServicesClient(_ignite, _clusterGroup, true, _serverKeepBinary, _timeout);
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
index 6bf5c0c..b7b6e69 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
@@ -22,7 +22,7 @@ namespace Apache.Ignite.Core.Impl.Services
using System.Diagnostics;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Collections;
- using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Platform;
using Apache.Ignite.Core.Services;
/// <summary>
@@ -110,4 +110,4 @@ namespace Apache.Ignite.Core.Impl.Services
/** <inheritdoc /> */
public IDictionary<Guid, int> TopologySnapshot { get; private set; }
}
-}
\ No newline at end of file
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
index e17f9ad..f69d90a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
@@ -25,7 +25,7 @@ namespace Apache.Ignite.Core.Impl.Services
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
- using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Platform;
using Apache.Ignite.Core.Services;
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index 7ec4b3a..657aa02 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Core.Impl.Services
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Platform;
using Apache.Ignite.Core.Services;
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Platform/PlatformType.cs
similarity index 89%
rename from modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformType.cs
rename to modules/platforms/dotnet/Apache.Ignite.Core/Platform/PlatformType.cs
index e09e31b..cb3adae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Platform/PlatformType.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-namespace Apache.Ignite.Core.Impl.Common
+namespace Apache.Ignite.Core.Platform
{
/// <summary>
- /// Represents an Ignite platform.
+ /// Interop platform type.
/// </summary>
- internal enum PlatformType
+ public enum PlatformType
{
/// <summary>
/// Java platform.