[geode] branch feature/GEODE-9081-BufferPool-allocations updated (5e933bb -> 6ce19ab)

2021-03-27 Thread jbarrett
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a change to branch feature/GEODE-9081-BufferPool-allocations
in repository https://gitbox.apache.org/repos/asf/geode.git.


 discard 5e933bb  GEODE-9081: Remove transient allocation.
 add 6ce19ab  GEODE-9081: Remove transient allocation.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5e933bb)
\
 N -- N -- N   refs/heads/feature/GEODE-9081-BufferPool-allocations 
(6ce19ab)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 .../src/main/java/org/apache/geode/internal/net/BufferPool.java | 6 +++---
 .../apache/geode/unsafe/internal/sun/nio/ch/DirectBufferTest.java   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)


[geode] 01/01: GEODE-9081: Remove transient allocation.

2021-03-27 Thread jbarrett
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch feature/GEODE-9081-BufferPool-allocations
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 5e933bb38c9b3dbcb7e82f46d1726442531ed564
Author: Jacob Barrett 
AuthorDate: Sat Mar 27 10:02:35 2021 -0700

GEODE-9081: Remove transient allocation.

* New geode-unsafe access to non-SDK API for DirectBuffer.
* Use geode-unsafe to access DirectBuffer.attachment().
* Removes latency of reflection.
* Removes transient Object[] allocation in Method.invoke().
---
 .../org/apache/geode/internal/net/BufferPool.java  | 60 --
 .../unsafe/internal/sun/nio/ch/DirectBuffer.java   | 36 +
 .../internal/sun/nio/ch/DirectBufferTest.java  | 47 +
 3 files changed, 103 insertions(+), 40 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java 
b/geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java
index 74a2e4d..ae1cbf2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java
@@ -12,15 +12,15 @@
  * or implied. See the License for the specific language governing permissions 
and limitations under
  * the License.
  */
+
 package org.apache.geode.internal.net;
 
 import java.lang.ref.SoftReference;
-import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
 import java.util.IdentityHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
-import org.apache.logging.log4j.Logger;
+import org.apache.geode.unsafe.internal.sun.nio.ch.DirectBuffer;
 
 import org.apache.geode.InternalGemFireException;
 import org.apache.geode.annotations.VisibleForTesting;
@@ -28,14 +28,10 @@ import org.apache.geode.distributed.internal.DMStats;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.Assert;
 import org.apache.geode.internal.tcp.Connection;
-import org.apache.geode.logging.internal.log4j.api.LogService;
 import org.apache.geode.util.internal.GeodeGlossary;
 
 public class BufferPool {
   private final DMStats stats;
-  private static final Logger logger = LogService.getLogger();
-
-  private Method parentOfSliceMethod;
 
   /**
* Buffers may be acquired from the Buffers pool
@@ -325,40 +321,24 @@ public class BufferPool {
* If we hand out a buffer that is larger than the requested size we create a
* "slice" of the buffer having the requested capacity and hand that out 
instead.
* When we put the buffer back in the pool we need to find the original, 
non-sliced,
-   * buffer. This is held in DirectBuffer in its "attachment" field, which is 
a public
-   * method, though DirectBuffer is package-private. This method is visible 
for use
-   * in debugging and testing. For debugging, invoke this method if you need 
to see
-   * the non-sliced buffer for some reason, such as logging its hashcode.
+   * buffer. This is held in DirectBuffer in its "attachment" field.
+   *
+   * This method is visible for use in debugging and testing. For debugging, 
invoke this method if
+   * you need to see the non-sliced buffer for some reason, such as logging 
its hashcode.
*/
   @VisibleForTesting
-  public ByteBuffer getPoolableBuffer(ByteBuffer buffer) {
-if (!buffer.isDirect()) {
+  ByteBuffer getPoolableBuffer(final ByteBuffer buffer) {
+final Object attachment = DirectBuffer.attachment(buffer);
+
+if (null == attachment) {
   return buffer;
 }
-ByteBuffer result = buffer;
-if (parentOfSliceMethod == null) {
-  Class clazz = buffer.getClass();
-  try {
-Method method = clazz.getMethod("attachment");
-method.setAccessible(true);
-parentOfSliceMethod = method;
-  } catch (Exception e) {
-throw new InternalGemFireException("unable to retrieve underlying byte 
buffer", e);
-  }
-}
-try {
-  Object attachment = parentOfSliceMethod.invoke(buffer);
-  if (attachment instanceof ByteBuffer) {
-result = (ByteBuffer) attachment;
-  } else if (attachment != null) {
-throw new InternalGemFireException(
-"direct byte buffer attachment was not a byte buffer but a " +
-attachment.getClass().getName());
-  }
-} catch (Exception e) {
-  throw new InternalGemFireException("unable to retrieve underlying byte 
buffer", e);
+
+if (attachment instanceof ByteBuffer) {
+  return (ByteBuffer) attachment;
 }
-return result;
+
+throw new InternalGemFireException("direct byte buffer attachment was not 
a byte buffer but a " + attachment.getClass().getName());
   }
 
   /**
@@ -383,22 +363,22 @@ public class BufferPool {
 
 BBSoftReference(ByteBuffer bb, boolean send) {
   super(bb);
-  this.size = bb.capacity();
+  size = bb.capacity();
   this.send = send;
 }
 
  

[geode] branch feature/GEODE-9081-BufferPool-allocations created (now 5e933bb)

2021-03-27 Thread jbarrett
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a change to branch feature/GEODE-9081-BufferPool-allocations
in repository https://gitbox.apache.org/repos/asf/geode.git.


  at 5e933bb  GEODE-9081: Remove transient allocation.

This branch includes the following new commits:

 new 5e933bb  GEODE-9081: Remove transient allocation.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode-native] branch develop updated: GEODE-8925: port singleHop tests to new framework (#760)

2021-03-27 Thread mmartell
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/develop by this push:
 new 7e3a013  GEODE-8925: port singleHop tests to new framework (#760)
7e3a013 is described below

commit 7e3a01343d13758a957357cc593d7dbf0d131773
Author: Michael Martell 
AuthorDate: Sat Mar 27 06:47:35 2021 -0700

GEODE-8925: port singleHop tests to new framework (#760)

* Fix logging error in TcrMessage (metadata size not printing)
* Enhance singleHop support in PartitionRegionOpsTest
   - support for getAll and putAll
   - reduce redundant operations by combining puts/get in each test
* GEODE-8925: Refactor per review feedback
* Remove reliance on logfile.
* Remove the old singleHop tests
---
 cppcache/integration-test/CMakeLists.txt   |2 -
 .../integration-test/testThinClientPRSingleHop.cpp | 1180 
 .../testThinClientPutAllPRSingleHop.cpp|  421 ---
 .../integration/test/PartitionRegionOpsTest.cpp|  225 ++--
 cppcache/src/TcrMessage.cpp|2 +-
 5 files changed, 122 insertions(+), 1708 deletions(-)

diff --git a/cppcache/integration-test/CMakeLists.txt 
b/cppcache/integration-test/CMakeLists.txt
index efc7f43..7e3be0c 100644
--- a/cppcache/integration-test/CMakeLists.txt
+++ b/cppcache/integration-test/CMakeLists.txt
@@ -215,7 +215,6 @@ set_tests_properties(
 testThinClientPoolRedundancy
 testThinClientPoolServer
 testThinClientPutAll
-testThinClientPutAllPRSingleHop
 testThinClientPutAllWithCallBackArgWithoutConcurrency
 testThinClientSecurityCQAuthorizationMU
 testThinClientTXFailover
@@ -226,7 +225,6 @@ set_tests_properties(
 testThinClientCqDurable
 testThinClientGatewayTest
 testThinClientHAFailoverRegex
-testThinClientPRSingleHop
 testThinClientPoolAttrTest
 testThinClientPoolLocator
 testThinClientRemoteQueryTimeout
diff --git a/cppcache/integration-test/testThinClientPRSingleHop.cpp 
b/cppcache/integration-test/testThinClientPRSingleHop.cpp
deleted file mode 100644
index ed8d4a1..000
--- a/cppcache/integration-test/testThinClientPRSingleHop.cpp
+++ /dev/null
@@ -1,1180 +0,0 @@
-/*
- * 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.
- */
-
-#define ROOT_NAME "testThinClientPRSingleHop"
-#define ROOT_SCOPE DISTRIBUTED_ACK
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#include 
-
-#include "fw_dunit.hpp"
-#include "BuiltinCacheableWrappers.hpp"
-#include "Utils.hpp"
-
-#include "CacheHelper.hpp"
-
-// Include these 2 headers for access to CacheImpl for test hooks.
-#include "CacheImplHelper.hpp"
-#include "testUtils.hpp"
-
-#include "ThinClientHelper.hpp"
-
-#define CLIENT1 s1p1
-#define SERVER1 s2p1
-#define SERVER2 s1p2
-#define SERVER3 s2p2
-
-using apache::geode::client::CacheServerException;
-using apache::geode::client::CacheWriterException;
-using apache::geode::client::Exception;
-using apache::geode::client::internal::DSCode;
-
-using apache::geode::client::testing::CacheableWrapper;
-using apache::geode::client::testing::CacheableWrapperFactory;
-
-bool isLocalServer = false;
-const std::string endPoints = CacheHelper::getTcrEndpoints(isLocalServer, 3);
-
-static bool isLocator = false;
-const std::string locatorsG =
-CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-
-template 
-T randomValue(T maxValue) {
-  static thread_local std::default_random_engine generator(
-  std::random_device{}());
-  return std::uniform_int_distribution{0, maxValue}(generator);
-}
-
-class putThread : public ACE_Task_Base {
- private:
-  std::shared_ptr regPtr;
-  int m_min;
-  int m_max;
-  bool m_isWarmUpTask;
-  int m_failureCount;
-
- public:
-  putThread(const char *name, int min, int max, bool isWarmUpTask)
-  : regPtr(getHelper()->getRegion(name)),
-m_min(min),
-m_max(max),
-m_isWarmUpTask(isWarmUpTask),
-m_failureCount(0) {}
-
-  int getFailureCount() { return m_failureCount; }
-
-  int svc(void) override {
-std::shared_ptr keyPtr;
-for (int i