ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [01/44] ignite git commit: IGNITE-4896 Rewored GridClientNodeBean serialization.
Date Fri, 14 Apr 2017 15:27:26 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4986 8586e7773 -> 2a4e5a7c1


IGNITE-4896 Rewored GridClientNodeBean serialization.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a025268d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a025268d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a025268d

Branch: refs/heads/ignite-4986
Commit: a025268da2d138ef146226b0d6f10eea8af84631
Parents: 7e8d9e8
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Apr 14 18:18:23 2017 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Apr 14 18:18:23 2017 +0700

----------------------------------------------------------------------
 .../rest/client/message/GridClientNodeBean.java |   2 +-
 .../top/GridTopologyCommandHandler.java         |   4 +
 ...ryConfigurationCustomSerializerSelfTest.java | 147 +++++++++++++++++++
 .../IgniteBinaryObjectsTestSuite.java           |   2 +
 4 files changed, 154 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a025268d/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java
index ca82608..f1848df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java
@@ -250,7 +250,7 @@ public class GridClientNodeBean implements Externalizable {
 
         U.writeUuid(out, nodeId);
 
-        out.writeObject(consistentId);
+        out.writeObject(String.valueOf(consistentId));
         out.writeObject(metrics);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a025268d/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index 297785e..536ec88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -52,7 +52,9 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.IgnitePortProtocol;
 
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CACHE;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_TCP_ADDRS;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_TCP_HOST_NAMES;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_TCP_PORT;
@@ -291,6 +293,8 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter
{
             attrs.remove(ATTR_TX_CONFIG);
             attrs.remove(ATTR_SECURITY_SUBJECT);
             attrs.remove(ATTR_SECURITY_CREDENTIALS);
+            attrs.remove(ATTR_BINARY_CONFIGURATION);
+            attrs.remove(ATTR_NODE_CONSISTENT_ID);
 
             for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator();
i.hasNext();) {
                 Map.Entry<String, Object> e = i.next();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a025268d/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java
new file mode 100644
index 0000000..1da2967
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java
@@ -0,0 +1,147 @@
+/*
+ * 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.binary;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.client.GridClientFactory;
+import org.apache.ignite.internal.client.GridClientProtocol;
+import org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer;
+import org.apache.ignite.internal.visor.VisorTaskArgument;
+import org.apache.ignite.internal.visor.node.VisorNodePingTask;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests that node will start with custom binary serializer and thin client will connect
to such node.
+ */
+public class BinaryConfigurationCustomSerializerSelfTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        BinaryConfiguration binaryCfg = new BinaryConfiguration();
+
+        BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
+
+        btc.setIdMapper(BinaryContext.defaultIdMapper());
+        btc.setEnum(false);
+
+        // Set custom serializer that is unknown for Optimized marshaller.
+        btc.setSerializer(new MyBinarySerializer());
+
+        binaryCfg.setTypeConfigurations(Collections.singletonList(btc));
+
+        cfg.setBinaryConfiguration(binaryCfg);
+
+        // Set custom consistent ID that unknown for Optimized marshaller.
+        cfg.setConsistentId(new MyConsistentId("test"));
+
+        cfg.setCacheConfiguration(new CacheConfiguration("TEST"));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGrids(2);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Test that thin client will be able to connect to node with custom binary serializer
and custom consistent ID.
+     *
+     * @throws Exception If failed.
+     */
+    public void testThinClientConnected() throws Exception {
+        UUID nid = ignite(0).cluster().localNode().id();
+
+        GridClientConfiguration clnCfg = new GridClientConfiguration();
+
+        clnCfg.setProtocol(GridClientProtocol.TCP);
+        clnCfg.setServers(Collections.singleton("127.0.0.1:11211"));
+        clnCfg.setBalancer(new GridClientRoundRobinBalancer());
+
+        // Start client.
+        GridClient client = GridClientFactory.start(clnCfg);
+
+        // Execute some task.
+        client.compute().execute(VisorNodePingTask.class.getName(), new VisorTaskArgument<>(nid,
nid, false));
+
+        GridClientFactory.stop(client.id(), false);
+    }
+
+    /**
+     * Custom consistent ID.
+     */
+    private static class MyConsistentId implements Serializable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Actual ID. */
+        private String id;
+
+        /**
+         * @param id Actual ID.
+         */
+        MyConsistentId(String id) {
+            this.id = id;
+        }
+
+        /**
+         * @return Consistent ID.
+         */
+        public String getId() {
+            return id;
+        }
+    }
+
+    /**
+     * Custom BinarySerializer.
+     */
+    private static class MyBinarySerializer implements BinarySerializer {
+        /** {@inheritDoc} */
+        @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException
{
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException
{
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a025268d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 5cecfac..c8f0ebe 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.binary.BinaryArrayIdentityResolverSelfTest;
 import org.apache.ignite.internal.binary.BinaryBasicIdMapperSelfTest;
 import org.apache.ignite.internal.binary.BinaryBasicNameMapperSelfTest;
 import org.apache.ignite.internal.binary.BinaryConfigurationConsistencySelfTest;
+import org.apache.ignite.internal.binary.BinaryConfigurationCustomSerializerSelfTest;
 import org.apache.ignite.internal.binary.BinaryEnumsSelfTest;
 import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest;
 import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest;
@@ -92,6 +93,7 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
         suite.addTestSuite(BinaryArrayIdentityResolverSelfTest.class);
 
         suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class);
+        suite.addTestSuite(BinaryConfigurationCustomSerializerSelfTest.class);
         suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class);
         suite.addTestSuite(BinaryObjectBuilderDefaultMappersSelfTest.class);
         suite.addTestSuite(BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.class);


Mime
View raw message