You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/06/10 17:21:30 UTC

[GitHub] [ignite] alex-plekhanov commented on a change in pull request #7908: IGNITE-13033 Java thin client: Service invocation

alex-plekhanov commented on a change in pull request #7908:
URL: https://github.com/apache/ignite/pull/7908#discussion_r438287901



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.client.thin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.UUID;
+import org.apache.ignite.client.ClientClusterGroup;
+import org.apache.ignite.client.ClientException;
+import org.apache.ignite.client.ClientServices;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.platform.PlatformServiceMethod;
+
+/**
+ * Implementation of {@link ClientServices}.
+ */
+class ClientServicesImpl implements ClientServices {
+    /** Channel. */
+    private final ReliableChannel ch;
+
+    /** Binary marshaller. */
+    private final ClientBinaryMarshaller marsh;
+
+    /** Utils for serialization/deserialization. */
+    private final ClientUtils utils;
+
+    /** Cluster group. */
+    private final ClientClusterGroupImpl grp;
+
+    /** Constructor. */
+    ClientServicesImpl(ReliableChannel ch, ClientBinaryMarshaller marsh, ClientClusterGroupImpl grp) {
+        this.ch = ch;
+        this.marsh = marsh;
+        this.grp = grp;
+
+        utils = new ClientUtils(marsh);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ClientClusterGroup clusterGroup() {
+        return grp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T serviceProxy(String name, Class<? super T> svcItf) {
+        return serviceProxy(name, svcItf, 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T serviceProxy(String name, Class<? super T> svcItf, long timeout) {
+        A.notNullOrEmpty(name, "name");
+        A.notNull(svcItf, "svcItf");
+
+        Collection<UUID> nodeIds = grp.nodeIds();

Review comment:
       `nodeIds()` can make up to 2 server calls, so every invocation, in this case, will send up to 3 requests instead of 1. I think there will be a significant negative performance impact.
   To overcome this we can send topology version additionally to nodeIds, check this version on server-side and throw an error with some predefined error code if topology changed. On the client-side, such an error can be checked and failover automatically. WDYT?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org