timoninmaxim commented on a change in pull request #9768:
URL: https://github.com/apache/ignite/pull/9768#discussion_r831129605



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServiceConfiguration.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.platform.services;
+
+import org.apache.ignite.services.ServiceConfiguration;
+
+/**
+ * Extended service configuration. Keeps known method names of service to 
build proper service statistics.
+ */
+public class PlatformServiceConfiguration extends ServiceConfiguration {
+    /** */
+    private static final long serialVersionUID = 1L;
+
+    /** Known method names of platform service. */
+    private String[] mtdNames;
+
+    /**
+     * Constr.
+     */
+    PlatformServiceConfiguration() {
+        setMtdNames(null);
+    }
+
+    /**
+     * @return Known method names of platform service.
+     */
+    public String[] mtdNames() {
+        return mtdNames;
+    }
+
+    /**
+     * Sets known method names of platform service.
+     */
+    void setMtdNames(String[] mtdNames) {

Review comment:
       By Ignite coding guidelines it's not recommended to use `set` or `get` 
prefixes for classes in internal package. Let's replace it with just `mtdNames`

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServiceConfiguration.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.platform.services;
+
+import org.apache.ignite.services.ServiceConfiguration;
+
+/**
+ * Extended service configuration. Keeps known method names of service to 
build proper service statistics.
+ */
+public class PlatformServiceConfiguration extends ServiceConfiguration {
+    /** */
+    private static final long serialVersionUID = 1L;
+
+    /** Known method names of platform service. */
+    private String[] mtdNames;
+
+    /**
+     * Constr.
+     */
+    PlatformServiceConfiguration() {
+        setMtdNames(null);
+    }
+
+    /**
+     * @return Known method names of platform service.
+     */
+    public String[] mtdNames() {
+        return mtdNames;
+    }
+
+    /**
+     * Sets known method names of platform service.
+     */
+    void setMtdNames(String[] mtdNames) {
+        this.mtdNames = mtdNames == null ? new String[0] : mtdNames;

Review comment:
       Looks like, it should be a `null` if statistics is disabled, or this 
`String[0]` should be a static variable shared between all configurations.

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServiceConfiguration.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.platform.services;
+
+import org.apache.ignite.services.ServiceConfiguration;
+
+/**
+ * Extended service configuration. Keeps known method names of service to 
build proper service statistics.
+ */
+public class PlatformServiceConfiguration extends ServiceConfiguration {
+    /** */
+    private static final long serialVersionUID = 1L;
+
+    /** Known method names of platform service. */
+    private String[] mtdNames;
+
+    /**
+     * Constr.
+     */
+    PlatformServiceConfiguration() {
+        setMtdNames(null);
+    }
+
+    /**
+     * @return Known method names of platform service.
+     */
+    public String[] mtdNames() {
+        return mtdNames;
+    }
+
+    /**
+     * Sets known method names of platform service.
+     */
+    void setMtdNames(String[] mtdNames) {
+        this.mtdNames = mtdNames == null ? new String[0] : mtdNames;

Review comment:
       Why do we actually need `String[0]` here?

##########
File path: 
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
##########
@@ -1330,6 +1411,91 @@ private void DoTestBinary(IJavaService svc, IJavaService 
binSvc, bool isPlatform
                     .GetField<int>("Field"));
         }
 
+        /// <summary>
+        /// Tests platform service statistics.
+        /// </summary>
+        private void DoTestMetrics(IServices producer, IServices consumer, 
IServiceCallContext callCtx, bool dyn)

Review comment:
       Are there tests for services deployed from Java side, but invoked from 
.Net code? If no, should we add such test?

##########
File path: 
modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceConfiguration.cs
##########
@@ -83,6 +91,29 @@ internal void Write(IBinaryRawWriter w)
                 w.WriteObject(NodeFilter);
             else
                 w.WriteObject<object>(null);
+
+            w.WriteBoolean(StatisticsEnabled);
+
+            WriteExtraDescription(w);
+        }
+
+        /// <summary>
+        /// Provides extra intel about platform service to avoid on-demand 
creation of service statistics on any

Review comment:
       `intel` --> `info`?

##########
File path: 
modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
##########
@@ -671,10 +681,101 @@ public void sleep(long delayMs) {
             }
         }
 
+        /**
+         * Calculates number of registered values among the service statistics.
+         *
+         * @return Number of registered values among the service statistics. 
Or {@code null} if no statistics found
+         * for this service.
+         */
+        public int testNumberOfInvocations(String svcName, String histName) {
+            return ignite.compute().execute(new CountServiceMetricsTask(), new 
IgnitePair<>(svcName, histName));
+        }
+
         /** */
         public Object contextAttribute(String name) {
             return svcCtx.currentCallContext().attribute(name);
         }
+
+        /**
+         * Calculates number of registered values among the service 
statistics. Can process all service metrics or
+         * certain named one.
+         */
+        private static class CountServiceMetricsTask extends 
ComputeTaskSplitAdapter<IgnitePair<String>, Integer> {
+            /** {@inheritDoc} */
+            @Override public Integer reduce(List<ComputeJobResult> results) 
throws IgniteException {
+                long cnt = 0;
+
+                for (ComputeJobResult res : results) {
+                    if (res.isCancelled()) {
+                        throw new IgniteException("Unable to count invocations 
in service metrics. Job was canceled " +
+                            "on node [" + res.getNode() + "].");
+                    }
+
+                    if (res.getException() != null) {
+                        throw new IgniteException("Unable to count invocations 
in service metrics. Job failed on " +
+                            "node [" + res.getNode() + "]: " + 
res.getException().getMessage(), res.getException());
+                    }
+
+                    if (res.getData() == null)
+                        continue;
+
+                    cnt += (Long)res.getData();

Review comment:
       Obsolete cast to `Long`.

##########
File path: 
modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
##########
@@ -671,10 +681,101 @@ public void sleep(long delayMs) {
             }
         }
 
+        /**
+         * Calculates number of registered values among the service statistics.
+         *
+         * @return Number of registered values among the service statistics. 
Or {@code null} if no statistics found

Review comment:
       It never returns `null`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to