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/07/03 13:53:02 UTC

[GitHub] [ignite] alex-plekhanov opened a new pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

alex-plekhanov opened a new pull request #7990:
URL: https://github.com/apache/ignite/pull/7990


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


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



[GitHub] [ignite] alex-plekhanov commented on a change in pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

Posted by GitBox <gi...@apache.org>.
alex-plekhanov commented on a change in pull request #7990:
URL: https://github.com/apache/ignite/pull/7990#discussion_r450067606



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
##########
@@ -378,6 +362,49 @@ private String readString(BinaryInputStream in) throws BinaryObjectException {
             return cache.metadata();
         }
 
+        /**
+         * Request binary metadata from server and add binary type to cache.
+         *
+         * @param typeId Type id.
+         */
+        private BinaryType requestAndCacheBinaryType(int typeId) throws BinaryObjectException {

Review comment:
       I've refactored `metadata` method, so there is only one cast now.




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



[GitHub] [ignite] alex-plekhanov commented on a change in pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

Posted by GitBox <gi...@apache.org>.
alex-plekhanov commented on a change in pull request #7990:
URL: https://github.com/apache/ignite/pull/7990#discussion_r450068057



##########
File path: modules/indexing/src/test/java/org/apache/ignite/client/FunctionalQueryTest.java
##########
@@ -237,6 +237,39 @@ public void testGettingEmptyResultWhenQueryingEmptyTable() throws Exception {
         }
     }
 
+    /** */
+    @Test
+    public void testMixedQueryAndCacheApiOperations() throws Exception {
+        try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
+             IgniteClient client = Ignition.startClient(
+                 new ClientConfiguration().setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true))
+                     .setAddresses(Config.SERVER))
+        ) {
+            String cacheName = "PersonCache";

Review comment:
       I've renamed `id` column to `key`




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



[GitHub] [ignite] ivandasch commented on a change in pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

Posted by GitBox <gi...@apache.org>.
ivandasch commented on a change in pull request #7990:
URL: https://github.com/apache/ignite/pull/7990#discussion_r450035615



##########
File path: modules/indexing/src/test/java/org/apache/ignite/client/FunctionalQueryTest.java
##########
@@ -237,6 +237,39 @@ public void testGettingEmptyResultWhenQueryingEmptyTable() throws Exception {
         }
     }
 
+    /** */
+    @Test
+    public void testMixedQueryAndCacheApiOperations() throws Exception {
+        try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
+             IgniteClient client = Ignition.startClient(
+                 new ClientConfiguration().setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true))
+                     .setAddresses(Config.SERVER))
+        ) {
+            String cacheName = "PersonCache";

Review comment:
       It is not obvious for even Ignite developers that key and id field in Person object
   are different things. Do you think that probably it is better to use another class in this test with additional field, that is not mentioned in DDL and doesn'thave same name and type as key?
   
   This is up to you, of course, but I'd rather do it that way.




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



[GitHub] [ignite] asfgit closed pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #7990:
URL: https://github.com/apache/ignite/pull/7990


   


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



[GitHub] [ignite] ivandasch commented on a change in pull request #7990: IGNITE-13192 Java thin client: Fix binary type schema registration for already cached typeId

Posted by GitBox <gi...@apache.org>.
ivandasch commented on a change in pull request #7990:
URL: https://github.com/apache/ignite/pull/7990#discussion_r449618361



##########
File path: modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
##########
@@ -147,6 +148,44 @@ public void testCompactFooterNestedTypeRegistration() throws Exception {
         }
     }
 
+    /**
+     * Check that binary type schema updates are propogated from client to server and from server to client.
+     */
+    @Test
+    public void testCompactFooterModifiedSchemaRegistration() throws Exception {
+        try (Ignite ignite = Ignition.start(Config.getServerConfiguration())) {
+            ignite.getOrCreateCache(Config.DEFAULT_CACHE_NAME);
+
+            try (IgniteClient client1 = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)
+                .setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)));

Review comment:
       May be better to move ClientConfiguration to separate variable?

##########
File path: modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
##########
@@ -147,6 +148,44 @@ public void testCompactFooterNestedTypeRegistration() throws Exception {
         }
     }
 
+    /**
+     * Check that binary type schema updates are propogated from client to server and from server to client.

Review comment:
       Typo: propagated

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
##########
@@ -378,6 +362,49 @@ private String readString(BinaryInputStream in) throws BinaryObjectException {
             return cache.metadata();
         }
 
+        /**
+         * Request binary metadata from server and add binary type to cache.
+         *
+         * @param typeId Type id.
+         */
+        private BinaryType requestAndCacheBinaryType(int typeId) throws BinaryObjectException {

Review comment:
       I think that it is OK in private method to return BinaryTypeImpl, this can
   eliminate excessive casting in `ClientBinaryMetadataHandler#metadata(int, int)metadata(int typeId, int schemaId) `
   
   I think that
   ``` 
           @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
               BinaryTypeImpl meta = (BinaryTypeImpl)cache.metadata(typeId);
   
               if (meta == null || !meta.metadata().hasSchema(schemaId))
                   meta = requestAndCacheBinaryType(typeId);
   
               return meta != null && meta.metadata().hasSchema(schemaId) ? meta : null;
           }
   ```
   looks a llitle bit nicer.
   
   

##########
File path: modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
##########
@@ -147,6 +148,44 @@ public void testCompactFooterNestedTypeRegistration() throws Exception {
         }
     }
 
+    /**
+     * Check that binary type schema updates are propogated from client to server and from server to client.
+     */
+    @Test
+    public void testCompactFooterModifiedSchemaRegistration() throws Exception {
+        try (Ignite ignite = Ignition.start(Config.getServerConfiguration())) {
+            ignite.getOrCreateCache(Config.DEFAULT_CACHE_NAME);
+
+            try (IgniteClient client1 = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)
+                .setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)));
+                 IgniteClient client2 = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)
+                     .setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)))
+            ) {
+                ClientCache<Integer, Object> cache1 = client1.cache(Config.DEFAULT_CACHE_NAME).withKeepBinary();
+                ClientCache<Integer, Object> cache2 = client2.cache(Config.DEFAULT_CACHE_NAME).withKeepBinary();
+
+                String type = "Person";
+
+                // Register type and schema.
+                BinaryObjectBuilder builder1 = client1.binary().builder(type);
+                BinaryObject val1 = builder1.setField("Name", "Person 1").build();
+
+                cache1.put(1, val1);
+
+                assertEquals("Person 1", ((BinaryObject)cache2.get(1)).field("Name"));
+
+                // Update schema.
+                BinaryObjectBuilder builder2 = client1.binary().builder(type);

Review comment:
       Is there any necessity to create two builders from the same client1.binary(). 
   It seems that create one builder per test is absolutely ok (I tried this, tests works ok)
   
   ```
   ClientCache<Integer, Object> cache1 = client1.cache(Config.DEFAULT_CACHE_NAME).withKeepBinary();
   ClientCache<Integer, Object> cache2 = client2.cache(Config.DEFAULT_CACHE_NAME).withKeepBinary();
   BinaryObjectBuilder builder = client1.binary().builder("Person");
   
   // Register type and schema.
   BinaryObject val1 = builder.setField("Name", "Person 1").build();
   
   cache1.put(1, val1);
   
   assertEquals("Person 1", ((BinaryObject)cache2.get(1)).field("Name"));
   
   // Update schema.
   BinaryObject val2 = builder.setField("Name", "Person 2").setField("Age", 2).build();
   
   cache1.put(2, val2);
   
   assertEquals("Person 2", ((BinaryObject)cache2.get(2)).field("Name"));
   assertEquals((Integer)2, ((BinaryObject)cache2.get(2)).field("Age"));
   ```

##########
File path: modules/indexing/src/test/java/org/apache/ignite/client/FunctionalQueryTest.java
##########
@@ -237,6 +237,39 @@ public void testGettingEmptyResultWhenQueryingEmptyTable() throws Exception {
         }
     }
 
+    /** */
+    @Test
+    public void testMixedQueryAndCacheApiOperations() throws Exception {
+        try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
+             IgniteClient client = Ignition.startClient(
+                 new ClientConfiguration().setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true))
+                     .setAddresses(Config.SERVER))
+        ) {
+            String cacheName = "PersonCache";

Review comment:
       It is not obvious for even many IgniteDevelopers that key and id field in Person object
   are different things. Do you think that probably it is better to use another class in this test with additional field, that is not mentioned in DDL and doesn'thave same name and type as key?
   
   This is up to you, of course, but I'd rather do it that way.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
##########
@@ -343,32 +341,18 @@ private String readString(BinaryInputStream in) throws BinaryObjectException {
         @Override public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
             BinaryMetadata meta = cache.metadata0(typeId);
 
-            if (meta == null) {
-                try {
-                    meta = ch.service(
-                        ClientOperation.GET_BINARY_TYPE,
-                        req -> req.out().writeInt(typeId),
-                        res -> {
-                            try {
-                                return res.in().readBoolean() ? serDes.binaryMetadata(res.in()) : null;
-                            }
-                            catch (IOException e) {
-                                throw new BinaryObjectException(e);
-                            }
-                        }
-                    );
-                }
-                catch (ClientException e) {
-                    throw new BinaryObjectException(e);
-                }
-            }
+            if (meta == null)
+                meta = requestBinaryMetadata(typeId);
 
             return meta;
         }
 
         /** {@inheritDoc} */
         @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
-            BinaryType meta = metadata(typeId);
+            BinaryType meta = cache.metadata(typeId);

Review comment:
       May be it is better to cast meta to BinaryTypeImpl right here?




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