You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nr...@apache.org on 2018/01/11 23:01:08 UTC

[geode] branch feature/GEODE-3583-storage updated: GEODE-4212: ClientExporter should not invoke GemFireCacheImpl.getExisting

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

nreich pushed a commit to branch feature/GEODE-3583-storage
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-3583-storage by this push:
     new e0bc918  GEODE-4212: ClientExporter should not invoke GemFireCacheImpl.getExisting
e0bc918 is described below

commit e0bc918ba37f98681ca1acbd003c863d79c77705
Author: Nick Reich <nr...@pivotal.io>
AuthorDate: Thu Jan 11 15:00:33 2018 -0800

    GEODE-4212: ClientExporter should not invoke GemFireCacheImpl.getExisting
---
 .../internal/cache/snapshot/ClientExporter.java    |  7 ++-
 .../cache/snapshot/ClientExporterTest.java         | 52 ++++++++++++++++++++++
 2 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
index 482f890..de26fb4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
@@ -86,7 +86,7 @@ public class ClientExporter<K, V> implements Exporter<K, V> {
    * @param <K> the key type
    * @param <V> the value type
    */
-  private static class ClientArgs<K, V> implements Serializable {
+  static class ClientArgs<K, V> implements Serializable {
     private static final long serialVersionUID = 1;
 
     private final String region;
@@ -118,7 +118,7 @@ public class ClientExporter<K, V> implements Exporter<K, V> {
    * @param <K> the key type
    * @param <V> the value type
    */
-  private static class ProxyExportFunction<K, V> implements Function {
+  static class ProxyExportFunction<K, V> implements Function {
     private static final long serialVersionUID = 1L;
 
     @Override
@@ -132,8 +132,7 @@ public class ClientExporter<K, V> implements Exporter<K, V> {
       ResultSender rs = context.getResultSender();
       ExportSink sink = new ResultSenderSink(rs);
 
-      Region<K, V> region =
-          GemFireCacheImpl.getExisting("Exporting snapshot").getRegion(args.getRegion());
+      Region<K, V> region = context.getCache().getRegion(args.getRegion());
       Exporter<K, V> exp = args.isPRSingleHop() ? new LocalExporter<K, V>()
           : RegionSnapshotServiceImpl.<K, V>createExporter(region, args.options);
 
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/snapshot/ClientExporterTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/snapshot/ClientExporterTest.java
new file mode 100644
index 0000000..8a81d3b
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/snapshot/ClientExporterTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.snapshot;
+
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.internal.cache.execute.FunctionContextImpl;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class ClientExporterTest {
+
+  @Test
+  public void proxyExportFunctionGetsRequestedRegion() {
+    Cache cache = spy(new CacheFactory().create());
+    cache.createRegionFactory(RegionShortcut.PARTITION).create("testRegion");
+    ResultSender resultSender = mock(ResultSender.class);
+    ClientExporter.ClientArgs<String, String> args = mock(ClientExporter.ClientArgs.class);
+    when(args.isPRSingleHop()).thenReturn(true);
+    when(args.getRegion()).thenReturn("testRegion");
+    FunctionContext context = new FunctionContextImpl(cache, "id", args, resultSender);
+
+    new ClientExporter.ProxyExportFunction<String, String>().execute(context);
+    verify(cache).getRegion(any());
+    cache.close();
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].