You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/04/27 21:17:59 UTC

[GitHub] [geode] yozaner1324 opened a new pull request, #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

yozaner1324 opened a new pull request, #7631:
URL: https://github.com/apache/geode/pull/7631

   <!-- Thank you for submitting a contribution to Apache Geode. -->
   
   <!-- In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken: 
   -->
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   <!-- Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   -->
   


-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861161715


##########
geode-core/src/distributedTest/java/org/apache/geode/management/DiskManagementDUnitTest.java:
##########
@@ -394,7 +394,7 @@ private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
     return service.getMBeanProxy(objectName, MemberMXBean.class);
   }
 
-  private void await(final AsyncInvocation createPersistentRegionAsync)
+  private void await(final AsyncInvocation<?> createPersistentRegionAsync)

Review Comment:
   While it could be, since this method only calls `await(..)`, there is no reason it needs to be `Void` specifically. My preference is to leave method arguments more generic where possible while making return types and variables as specific as possible.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r865306273


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,16 +156,18 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
-        vm0.invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async1 =
+        vm0.<Void>invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async2 =
+        vm0.<Void>invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();

Review Comment:
   Thanks, I fixed it anyway. Might as well clean up while I'm in the area.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] DonalEvans commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861177626


##########
geode-core/src/distributedTest/java/org/apache/geode/management/DiskManagementDUnitTest.java:
##########
@@ -394,7 +394,7 @@ private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
     return service.getMBeanProxy(objectName, MemberMXBean.class);
   }
 
-  private void await(final AsyncInvocation createPersistentRegionAsync)
+  private void await(final AsyncInvocation<?> createPersistentRegionAsync)

Review Comment:
   I'd definitely agree if this was a public method or in product code, but since it's a private method in a test class, we can be pretty certain that the way it's called isn't going to change. In fact, since it's a one-line method, it could probably just be inlined, making this whole discussion moot.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] kirklund commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
kirklund commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r865106529


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,16 +156,18 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
-        vm0.invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async1 =
+        vm0.<Void>invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async2 =
+        vm0.<Void>invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();

Review Comment:
   Note: `join().checkException()` can and should always be replaced with `await()` instead.
   
   I'm not requesting changes... just a comment so you know.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] kirklund commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
kirklund commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r865106529


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,16 +156,18 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
-        vm0.invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async1 =
+        vm0.<Void>invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<Void> async2 =
+        vm0.<Void>invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();

Review Comment:
   Note: `join()` or `join().checkException()` can and should always be replaced with `await()` instead.
   
   I'm not requesting changes... just a comment so you know.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] jmelchio commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
jmelchio commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861185241


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/VMDistributedTest.java:
##########
@@ -89,7 +89,7 @@ public void testReturnValue() throws Exception {
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
     // Assert class static invocation works
-    AsyncInvocation a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
+    AsyncInvocation<?> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);

Review Comment:
   Thanks for the quick turnaround @yozaner1324 👍 



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] DonalEvans merged pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
DonalEvans merged PR #7631:
URL: https://github.com/apache/geode/pull/7631


-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861158048


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/VMDistributedTest.java:
##########
@@ -89,7 +89,7 @@ public void testReturnValue() throws Exception {
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
     // Assert class static invocation works
-    AsyncInvocation a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
+    AsyncInvocation<?> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);

Review Comment:
   Good idea. Doing this 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.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] DonalEvans commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r860339147


##########
geode-core/src/distributedTest/java/org/apache/geode/cache/query/internal/index/InitializeIndexEntryDestroyQueryDUnitTest.java:
##########
@@ -141,7 +141,8 @@ public void testConcurrentRemoveIndexAndQueryOnPR() {
 
   }
 
-  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0, AsyncInvocation asyInvk1) {
+  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0,

Review Comment:
   This first `AsyncInvoaction` can also be `AsyncInvocation<Void>`



##########
geode-core/src/distributedTest/java/org/apache/geode/management/DiskManagementDUnitTest.java:
##########
@@ -394,7 +394,7 @@ private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
     return service.getMBeanProxy(objectName, MemberMXBean.class);
   }
 
-  private void await(final AsyncInvocation createPersistentRegionAsync)
+  private void await(final AsyncInvocation<?> createPersistentRegionAsync)

Review Comment:
   This can be `AsyncInvocation<Void>`



##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,8 +154,9 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
+    AsyncInvocation<?> async1 =
+        vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<?> async2 =

Review Comment:
   This can be:
   ```
       AsyncInvocation<Void> async1 =
           vm0.<Void>invokeAsync(() -> remoteBind(name, value)).join().checkException();
       AsyncInvocation<Void> async2 =
           vm0.<Void>invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
   ```



##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/VMDistributedTest.java:
##########
@@ -89,7 +89,7 @@ public void testReturnValue() throws Exception {
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
     // Assert class static invocation works
-    AsyncInvocation a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
+    AsyncInvocation<?> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);

Review Comment:
   This class is kind of a mess what with all the deprecated calls and use of JUnit assertions rather than AssertJ, but this would probably be better as:
   ```
   
       AsyncInvocation<Integer> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
       a1.join();
       assertEquals(0, (long) a1.getReturnValue());
       // Assert class static invocation with args works
       a1 = vm.invokeAsync(() -> incrementStaticCount(2));
       a1.join();
       assertEquals(3, (long) a1.getReturnValue());
       // Assert that previous values are not returned when invoking method w/ no return val
       a1 = vm.invokeAsync(VMDistributedTest::incStaticCount);
       a1.join();
       assertNull(a1.getReturnValue());
       // Assert that previous null returns are over-written
       a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
       a1.join();
       assertEquals(4, (long) a1.getReturnValue());
   
       // Assert object method invocation works with zero arg method
       final VMTestObject o = new VMTestObject(0);
       a1 = vm.invokeAsync(o, "incrementAndGet", new Object[] {});
       a1.join();
       assertEquals(1, (long) a1.getReturnValue());
   ```
   so that we can use a definite type rather than `<?>`



##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDistributedTest.java:
##########
@@ -123,7 +123,7 @@ public class PersistentColocatedPartitionedRegionDistributedTest implements Seri
   private static volatile InternalCache cache;
   private static volatile CountDownLatch latch;
 
-  private final transient List<AsyncInvocation<Void>> asyncInvocations = new ArrayList<>();
+  private final transient List<AsyncInvocation<?>> asyncInvocations = new ArrayList<>();

Review Comment:
   I don't think the changes from `AsyncInvocation<Void>` to `AsyncInvocation<?>` are necessary here.



##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PutAllGlobalDUnitTest.java:
##########
@@ -159,55 +159,56 @@ public void testputAllGlobalRemoteVM() throws Throwable {
 
     final int socketPort = vm0.invoke(PutAllGlobalDUnitTest::openSocket);
 
-    AsyncInvocation async1 = vm0.invokeAsync(PutAllGlobalDUnitTest::putAllMethod);
-
-    AsyncInvocation async2 = vm1.invokeAsync(new CacheSerializableRunnable("put from another vm") {
-      @Override
-      public void run2() throws CacheException {
-        long endTime = System.currentTimeMillis() + 5000;
-        boolean connected = false;
-        while (!connected && (System.currentTimeMillis() < endTime)) {
-          try {
-            Socket sock = new Socket(InetAddress.getLocalHost(), socketPort);
-            connected = true;
-            sock.close();
-          } catch (IOException ioe) {
-            // ignored - will time out using 'endTime'
+    AsyncInvocation<Void> async1 = vm0.invokeAsync(PutAllGlobalDUnitTest::putAllMethod);
+
+    AsyncInvocation<Void> async2 =
+        vm1.invokeAsync(new CacheSerializableRunnable("put from another vm") {
+          @Override
+          public void run2() throws CacheException {

Review Comment:
   Use of a deprecated class can be avoided here by making this:
   ```
       AsyncInvocation<Void> async2 =
           vm1.invokeAsync("put from another vm", () -> {
             long endTime = System.currentTimeMillis() + 5000;
   ...
   ```
   and removing the extra curly brace on line 210



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861182269


##########
geode-core/src/distributedTest/java/org/apache/geode/management/DiskManagementDUnitTest.java:
##########
@@ -394,7 +394,7 @@ private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
     return service.getMBeanProxy(objectName, MemberMXBean.class);
   }
 
-  private void await(final AsyncInvocation createPersistentRegionAsync)
+  private void await(final AsyncInvocation<?> createPersistentRegionAsync)

Review Comment:
   Fair enough, I'll just inline it.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861158320


##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,8 +154,9 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
+    AsyncInvocation<?> async1 =
+        vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<?> async2 =

Review Comment:
   Done.



-- 
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: notifications-unsubscribe@geode.apache.org

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


[GitHub] [geode] yozaner1324 commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

Posted by GitBox <gi...@apache.org>.
yozaner1324 commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r861158724


##########
geode-core/src/distributedTest/java/org/apache/geode/cache/query/internal/index/InitializeIndexEntryDestroyQueryDUnitTest.java:
##########
@@ -141,7 +141,8 @@ public void testConcurrentRemoveIndexAndQueryOnPR() {
 
   }
 
-  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0, AsyncInvocation asyInvk1) {
+  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0,

Review Comment:
   Good catch, missed that one somehow.



-- 
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: notifications-unsubscribe@geode.apache.org

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