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 2021/02/24 18:34:31 UTC

[GitHub] [geode] DonalEvans commented on a change in pull request #6051: GEODE-8862: Uses another thread to process DistributedCacheOperation

DonalEvans commented on a change in pull request #6051:
URL: https://github.com/apache/geode/pull/6051#discussion_r582199184



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/DistributedCacheOperationTest.java
##########
@@ -72,11 +114,112 @@ public void endOperationIsInvokedOnDistributionError() {
     assertTrue(operation.endOperationInvoked);
   }
 
+  @Test
+  public void processReplacesVersionTagNullIDs() {
+    message.process(dm);
+
+    verify(versionTag).replaceNullIDs(sender);
+  }
+
+  @Test
+  public void processSendsReplyIfAdminDM() {
+    when(dm.getDMType()).thenReturn(ClusterDistributionManager.ADMIN_ONLY_DM_TYPE);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfLocalRegionIsNull() {
+    doReturn(null).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),

Review comment:
       It's not necessary to wrap the arguments here with `eq()`, so this can be simplified.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/DistributedCacheOperationTest.java
##########
@@ -72,11 +114,112 @@ public void endOperationIsInvokedOnDistributionError() {
     assertTrue(operation.endOperationInvoked);
   }
 
+  @Test
+  public void processReplacesVersionTagNullIDs() {
+    message.process(dm);
+
+    verify(versionTag).replaceNullIDs(sender);
+  }
+
+  @Test
+  public void processSendsReplyIfAdminDM() {
+    when(dm.getDMType()).thenReturn(ClusterDistributionManager.ADMIN_ONLY_DM_TYPE);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),

Review comment:
       It's not necessary to wrap the arguments here with `eq()`, so this can be simplified.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/DistributedCacheOperationTest.java
##########
@@ -72,11 +114,112 @@ public void endOperationIsInvokedOnDistributionError() {
     assertTrue(operation.endOperationInvoked);
   }
 
+  @Test
+  public void processReplacesVersionTagNullIDs() {
+    message.process(dm);
+
+    verify(versionTag).replaceNullIDs(sender);
+  }
+
+  @Test
+  public void processSendsReplyIfAdminDM() {
+    when(dm.getDMType()).thenReturn(ClusterDistributionManager.ADMIN_ONLY_DM_TYPE);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfLocalRegionIsNull() {
+    doReturn(null).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfGotCacheClosedException() {
+    CacheClosedException cacheClosedException = new CacheClosedException();
+    doThrow(cacheClosedException).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();

Review comment:
       This would be simpler as `assertTrue()`.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/DistributedCacheOperationTest.java
##########
@@ -72,11 +114,112 @@ public void endOperationIsInvokedOnDistributionError() {
     assertTrue(operation.endOperationInvoked);
   }
 
+  @Test
+  public void processReplacesVersionTagNullIDs() {
+    message.process(dm);
+
+    verify(versionTag).replaceNullIDs(sender);
+  }
+
+  @Test
+  public void processSendsReplyIfAdminDM() {
+    when(dm.getDMType()).thenReturn(ClusterDistributionManager.ADMIN_ONLY_DM_TYPE);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfLocalRegionIsNull() {
+    doReturn(null).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfGotCacheClosedException() {
+    CacheClosedException cacheClosedException = new CacheClosedException();
+    doThrow(cacheClosedException).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyExceptionIfGotRuntimeException() {
+    RuntimeException exception = new RuntimeException();
+    doThrow(exception).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    ArgumentCaptor<ReplyException> captor = ArgumentCaptor.forClass(ReplyException.class);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        captor.capture(),
+        eq(dm));
+    assertThat(captor.getValue().getCause()).isSameAs(exception);
+  }
+
+  @Test
+  public void processPerformsBasicProcessIfNotDistributedNoAck() {
+    when(scope.isDistributedNoAck()).thenReturn(false);
+
+    message.process(dm);
+
+    verify(message).basicProcess(dm, region);
+    verify(executors, never()).getWaitingThreadPool();
+  }
+
+  @Test
+  public void processUsesWaitingThreadPoolIfDistributedNoAck() {
+    when(scope.isDistributedNoAck()).thenReturn(true);
+
+    message.process(dm);
+
+    verify(executors).getWaitingThreadPool();
+  }
+
+  @Test
+  public void processDoesNotSendReplyIfDistributedNoAck() {
+    when(scope.isDistributedNoAck()).thenReturn(true);
+
+    message.process(dm);
+
+    verify(message, never()).sendReply(
+        eq(sender),

Review comment:
       It's not necessary to use `eq()` for these arguments.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/DistributedCacheOperationTest.java
##########
@@ -72,11 +114,112 @@ public void endOperationIsInvokedOnDistributionError() {
     assertTrue(operation.endOperationInvoked);
   }
 
+  @Test
+  public void processReplacesVersionTagNullIDs() {
+    message.process(dm);
+
+    verify(versionTag).replaceNullIDs(sender);
+  }
+
+  @Test
+  public void processSendsReplyIfAdminDM() {
+    when(dm.getDMType()).thenReturn(ClusterDistributionManager.ADMIN_ONLY_DM_TYPE);
+
+    message.process(dm);
+
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfLocalRegionIsNull() {
+    doReturn(null).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),
+        eq(processorId),
+        eq(null),
+        eq(dm));
+  }
+
+  @Test
+  public void processSendsReplyIfGotCacheClosedException() {
+    CacheClosedException cacheClosedException = new CacheClosedException();
+    doThrow(cacheClosedException).when(message).getLocalRegionForProcessing(dm);
+
+    message.process(dm);
+
+    assertThat(message.closed).isTrue();
+    verify(message, never()).basicProcess(dm, region);
+    verify(message).sendReply(
+        eq(sender),

Review comment:
       It's not necessary to use `eq()` 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