This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new abd68f9  GEODE-6028: Remove checks that are not necessary (#2827)
abd68f9 is described below

commit abd68f93235b22f412580cb6d8d0978b66e40b4f
Author: Nabarun Nag <nabarun...@users.noreply.github.com>
AuthorDate: Mon Nov 26 17:05:17 2018 -0800

    GEODE-6028: Remove checks that are not necessary (#2827)
---
 .../membership/InternalDistributedMember.java      |  7 +---
 .../org/apache/geode/internal/SystemAdmin.java     |  8 ++---
 .../apache/geode/internal/cache/LocalRegion.java   |  8 ++---
 .../apache/geode/internal/cache/TXEntryState.java  | 41 +++++++++++++++++-----
 .../cache/partitioned/FetchBulkEntriesMessage.java |  2 +-
 .../cache/versions/RegionVersionHolder.java        |  6 ++--
 .../concurrent/CompactConcurrentHashSet2.java      |  9 +----
 .../internal/statistics/StatArchiveWriter.java     | 14 ++------
 .../geode/internal/cache/TXEntryStateUnitTest.java | 37 +++++++++++++++++++
 .../java/batterytest/greplogs/LogConsumer.java     |  2 +-
 .../cache/PartitionedRegionGetSomeKeys.java        |  4 ---
 11 files changed, 85 insertions(+), 53 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
index cb86b02..4d41288 100755
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
@@ -536,12 +536,7 @@ public class InternalDistributedMember implements 
DistributedMember, Externaliza
 
     // Discard null cases
     if (myAddr == null && otherAddr == null) {
-      if (myPort < otherPort)
-        return -1;
-      else if (myPort > otherPort)
-        return 1;
-      else
-        return 0;
+      return 0;
     } else if (myAddr == null) {
       return -1;
     } else if (otherAddr == null)
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java 
b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
index 3ba686f..ac08a2f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
@@ -326,12 +326,12 @@ public class SystemAdmin {
                     Integer.valueOf(pid)));
           }
         }
-        if (sleepCount > maxSleepCount && !quiet) {
-          System.out.println(
-              "Locator process has terminated.");
-        } else if (OSProcess.exists(pid)) {
+        if (OSProcess.exists(pid)) {
           System.out
               .println("Locator process did not terminate within " + 
maxSleepCount + " seconds.");
+        } else if (!quiet) {
+          System.out.println(
+              "Locator process has terminated.");
         }
       }
     } catch (UnstartedSystemException ex) {
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 6a8b6ab..90089f4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -6109,11 +6109,9 @@ public class LocalRegion extends AbstractRegion 
implements LoaderHelperFactory,
     }
 
     if (shouldNotifyBridgeClients()) {
-      if (numBS > 0) {
-        if (logger.isDebugEnabled()) {
-          logger.debug("{}: notifying {} cache servers of event: {}", 
this.getName(), numBS,
-              event);
-        }
+      if (logger.isDebugEnabled()) {
+        logger.debug("{}: notifying {} cache servers of event: {}", 
this.getName(), numBS,
+            event);
       }
 
       Operation op = event.getOperation();
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/TXEntryState.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/TXEntryState.java
index ae5085e..7aa3706 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXEntryState.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXEntryState.java
@@ -160,21 +160,44 @@ public class TXEntryState implements Releasable {
 
   private static final byte OP_PUT = 23;
 
+  static byte getOpCreate() {
+    return OP_CREATE;
+  }
+
+  static byte getOpSearchCreate() {
+    return OP_SEARCH_CREATE;
+  }
+
+  static byte getOpLloadCreate() {
+    return OP_LLOAD_CREATE;
+  }
+
+  static byte getOpNloadCreate() {
+    return OP_NLOAD_CREATE;
+  }
+
+  static byte getOpPut() {
+    return OP_PUT;
+  }
+
+  static byte getOpSearchPut() {
+    return OP_SEARCH_PUT;
+  }
+
+  static byte getOpLloadPut() {
+    return OP_LLOAD_PUT;
+  }
+
+  static byte getOpNloadPut() {
+    return OP_NLOAD_PUT;
+  }
+
   private static final byte OP_SEARCH_PUT = 24;
 
   private static final byte OP_LLOAD_PUT = 25;
 
   private static final byte OP_NLOAD_PUT = 26;
 
-  static {
-    Assert.assertTrue(OP_SEARCH_PUT - OP_PUT == OP_SEARCH_CREATE - OP_CREATE,
-        "search offset inconsistent");
-    Assert.assertTrue(OP_LLOAD_PUT - OP_PUT == OP_LLOAD_CREATE - OP_CREATE,
-        "lload offset inconsistent");
-    Assert.assertTrue(OP_NLOAD_PUT - OP_PUT == OP_NLOAD_CREATE - OP_CREATE,
-        "nload offset inconsistent");
-  }
-
   /**
    * System property to be set when read conflicts should be detected. 
Benefits of read conflict
    * detection are at: 
https://wiki.gemstone.com/display/PR/Read+conflict+detection
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchBulkEntriesMessage.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchBulkEntriesMessage.java
index 4bbe77d..144aa37 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchBulkEntriesMessage.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchBulkEntriesMessage.java
@@ -562,7 +562,7 @@ public class FetchBulkEntriesMessage extends 
PartitionMessage {
                 // null should signal the end of the set of keys
                 boolean bucketHasMore = 
DataSerializer.readPrimitiveBoolean(in);
                 synchronized (this.returnValue) {
-                  if (!bucketHasMore && currentId != -1) {
+                  if (!bucketHasMore) {
                     this.receivedBuckets.add(currentId);
                   }
                 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionHolder.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionHolder.java
index 7094c2b..5c51995 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionHolder.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionHolder.java
@@ -195,7 +195,7 @@ public class RegionVersionHolder<T> implements Cloneable, 
DataSerializable {
       if (e.nextVersion <= missingVersion) {
         return; // there is no RVVException for this version
       }
-      if (e.previousVersion < missingVersion && missingVersion < 
e.nextVersion) {
+      if (e.previousVersion < missingVersion) {
         String fine = null;
         if (logger.isTraceEnabled(LogMarker.RVV_VERBOSE)) {
           fine = e.toString();
@@ -491,7 +491,7 @@ public class RegionVersionHolder<T> implements Cloneable, 
DataSerializable {
         if (e.nextVersion <= v) {
           return true; // there is no RVVException for this version
         }
-        if (e.previousVersion < v && v < e.nextVersion) {
+        if (e.previousVersion < v) {
           return e.contains(v);
         }
       }
@@ -521,7 +521,7 @@ public class RegionVersionHolder<T> implements Cloneable, 
DataSerializable {
       if (e.nextVersion <= v) {
         return false; // there is no RVVException for this version
       }
-      if (e.previousVersion < v && v < e.nextVersion) {
+      if (e.previousVersion < v) {
         return !e.contains(v);
       }
     }
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/concurrent/CompactConcurrentHashSet2.java
 
b/geode-core/src/main/java/org/apache/geode/internal/concurrent/CompactConcurrentHashSet2.java
index e75a60b..dc12aab 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/concurrent/CompactConcurrentHashSet2.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/concurrent/CompactConcurrentHashSet2.java
@@ -1205,14 +1205,7 @@ public class CompactConcurrentHashSet2<V> extends 
AbstractSet<V> implements Set<
         break;
       else if (tab == table) {
         int rs = resizeStamp(n);
-        if (sc < 0) {
-          Node<V>[] nt;
-          if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 || sc == rs + 
MAX_RESIZERS
-              || (nt = nextTable) == null || transferIndex <= 0)
-            break;
-          if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))
-            transfer(tab, nt);
-        } else if (U.compareAndSwapInt(this, SIZECTL, sc, (rs << 
RESIZE_STAMP_SHIFT) + 2))
+        if (U.compareAndSwapInt(this, SIZECTL, sc, (rs << RESIZE_STAMP_SHIFT) 
+ 2))
           transfer(tab, null);
       }
     }
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
 
b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
index 2d85d65..c8a8c49 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
@@ -463,12 +463,7 @@ public class StatArchiveWriter implements 
StatArchiveFormat, SampleHandler {
         if (this.trace && (traceResourceInstId == -1 || traceResourceInstId == 
instId)) {
           this.traceDataOut.println("writeResourceInst#writeByte 
INT_RESOURCE_INST_ID_TOKEN: "
               + INT_RESOURCE_INST_ID_TOKEN);
-          if (instId == ILLEGAL_RESOURCE_INST_ID) {
-            this.traceDataOut.println(
-                "writeResourceInst#writeInt ILLEGAL_RESOURCE_INST_ID: " + 
ILLEGAL_RESOURCE_INST_ID);
-          } else {
-            this.traceDataOut.println("writeResourceInst#writeInt instId: " + 
instId);
-          }
+          this.traceDataOut.println("writeResourceInst#writeInt instId: " + 
instId);
         }
       } else {
         this.dataOut.writeByte(SHORT_RESOURCE_INST_ID_TOKEN);
@@ -476,12 +471,7 @@ public class StatArchiveWriter implements 
StatArchiveFormat, SampleHandler {
         if (this.trace && (traceResourceInstId == -1 || traceResourceInstId == 
instId)) {
           this.traceDataOut.println("writeResourceInst#writeByte 
SHORT_RESOURCE_INST_ID_TOKEN: "
               + SHORT_RESOURCE_INST_ID_TOKEN);
-          if (instId == ILLEGAL_RESOURCE_INST_ID) {
-            this.traceDataOut.println("writeResourceInst#writeShort 
ILLEGAL_RESOURCE_INST_ID: "
-                + ILLEGAL_RESOURCE_INST_ID);
-          } else {
-            this.traceDataOut.println("writeResourceInst#writeShort instId: " 
+ instId);
-          }
+          this.traceDataOut.println("writeResourceInst#writeShort instId: " + 
instId);
         }
       }
     } else {
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/cache/TXEntryStateUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/cache/TXEntryStateUnitTest.java
new file mode 100644
index 0000000..24e826e
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/cache/TXEntryStateUnitTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.geode.internal.cache;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+public class TXEntryStateUnitTest {
+
+  @Test
+  public void ensureThatOffsetsAreCorrect() {
+    assertEquals("search offset inconsistent",
+        TXEntryState.getOpSearchPut() - TXEntryState.getOpPut(),
+        TXEntryState.getOpSearchCreate() - TXEntryState.getOpCreate());
+    assertEquals("lload offset inconsistent",
+        TXEntryState.getOpLloadPut() - TXEntryState.getOpPut(),
+        TXEntryState.getOpLloadCreate() - TXEntryState.getOpCreate());
+    assertEquals("nload offset inconsistent",
+        TXEntryState.getOpNloadPut() - TXEntryState.getOpPut(),
+        TXEntryState.getOpNloadCreate() - TXEntryState.getOpCreate());
+  }
+
+}
diff --git a/geode-dunit/src/main/java/batterytest/greplogs/LogConsumer.java 
b/geode-dunit/src/main/java/batterytest/greplogs/LogConsumer.java
index 9ec2b3d..2c382a7 100644
--- a/geode-dunit/src/main/java/batterytest/greplogs/LogConsumer.java
+++ b/geode-dunit/src/main/java/batterytest/greplogs/LogConsumer.java
@@ -258,7 +258,7 @@ public class LogConsumer {
   }
 
   private StringBuilder enforceErrorLimit(int hits, String line, int linenum, 
String filename) {
-    if (hits <= repeatLimit) {
+    if (hits < repeatLimit) {
       StringBuilder buffer = new StringBuilder();
       
buffer.append("-----------------------------------------------------------------------\n")
           .append("Found suspect string in ").append(filename).append(" at 
line ").append(linenum)
diff --git 
a/geode-dunit/src/main/java/org/apache/geode/internal/cache/PartitionedRegionGetSomeKeys.java
 
b/geode-dunit/src/main/java/org/apache/geode/internal/cache/PartitionedRegionGetSomeKeys.java
index a02dedb..b2da8e0 100644
--- 
a/geode-dunit/src/main/java/org/apache/geode/internal/cache/PartitionedRegionGetSomeKeys.java
+++ 
b/geode-dunit/src/main/java/org/apache/geode/internal/cache/PartitionedRegionGetSomeKeys.java
@@ -55,10 +55,6 @@ public class PartitionedRegionGetSomeKeys {
       for (int i = 0; i < bucketIds.length; i++) {
         try {
           int whichBucket = random.nextInt(bucketIds.length);
-          if (whichBucket >= bucketIds.length) {
-            // The GSRandom.nextInt(int) may return a value that includes the 
maximum.
-            whichBucket = bucketIds.length - 1;
-          }
           bucketId = (Integer) bucketIds[whichBucket];
 
           InternalDistributedMember member = 
partitionedRegion.getNodeForBucketRead(bucketId);

Reply via email to