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 2020/10/24 01:17:52 UTC
[GitHub] [geode] kirklund opened a new pull request #5667: GEODE-8647: Support multiple instances of DistributedMap
kirklund opened a new pull request #5667:
URL: https://github.com/apache/geode/pull/5667
Includes additional improvements for usage of DistributedMap.
----------------------------------------------------------------
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
[GitHub] [geode] kirklund merged pull request #5667: GEODE-8647: Support multiple instances of DistributedMap
Posted by GitBox <gi...@apache.org>.
kirklund merged pull request #5667:
URL: https://github.com/apache/geode/pull/5667
----------------------------------------------------------------
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
[GitHub] [geode] DonalEvans commented on a change in pull request #5667: GEODE-8647: Support multiple instances of DistributedMap
Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #5667:
URL: https://github.com/apache/geode/pull/5667#discussion_r513070717
##########
File path: geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedMapTest.java
##########
@@ -491,4 +495,162 @@ public void getReturnsSameValueInEveryVmAsPutInOtherVm() {
});
}
}
+
+ @Test
+ public void accessesDistributedMapInEachVm() {
+ runTestWithValidation(HasDistributedMap.class);
+ }
+
+ @Test
+ public void tearsDownDistributedMapInEachVm() {
+ runTestWithValidation(HasDistributedMap.class);
+
+ getController().invoke(() -> {
+ assertThat(HasDistributedMap.map.get()).isEmpty();
+ });
+ }
+
+ @Test
+ public void accessesTwoDistributedMapsInEachVm() {
+ runTestWithValidation(HasTwoDistributedMaps.class);
+ }
+
+ @Test
+ public void tearsDownTwoDistributedMapsInEachVm() {
+ runTestWithValidation(HasTwoDistributedMaps.class);
+
+ getController().invoke(() -> {
+ assertThat(HasTwoDistributedMaps.map1.get()).isEmpty();
+ assertThat(HasTwoDistributedMaps.map2.get()).isEmpty();
+ });
+ }
+
+ @Test
+ public void accessesManyDistributedMapsInEachVm() {
+ runTestWithValidation(HasManyDistributedMaps.class);
+ }
+
+ @Test
+ public void tearsDownManyDistributedMapsInEachVm() {
+ runTestWithValidation(HasManyDistributedMaps.class);
+
+ getController().invoke(() -> {
+ assertThat(HasManyDistributedMaps.map1.get()).isEmpty();
+ assertThat(HasManyDistributedMaps.map2.get()).isEmpty();
+ assertThat(HasManyDistributedMaps.map3.get()).isEmpty();
+ });
+ }
+
+ public static class HasDistributedMap implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map.set(distributedMap.map());
+ distributedMap.put("key1", "value1");
+ });
+ }
+
+ @Test
+ public void distributedMapIsAccessibleInEveryVm() {
+ for (VM vm : asList(getVM(0), getVM(1), getVM(2), getVM(3), getController())) {
+ vm.invoke(() -> {
+ assertThat(distributedMap.map()).isSameAs(map.get());
+ assertThat(distributedMap.get("key1")).isEqualTo("value1");
+ });
+ }
+ }
+ }
+
+ public static class HasTwoDistributedMaps implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map1 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map2 = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap1 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap2 = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map1.set(distributedMap1.map());
+ distributedMap1.put("key1", "value1");
+
+ map2.set(distributedMap2.map());
+ distributedMap2.put("key2", "value2");
+ });
+ }
+
+ @Test
+ public void twoDistributedMapsAreAccessibleInEveryVm() {
+ for (VM vm : asList(getVM(0), getVM(1), getVM(2), getVM(3), getController())) {
+ vm.invoke(() -> {
+ assertThat(distributedMap1.map()).isSameAs(map1.get());
+ assertThat(distributedMap1.get("key1")).isEqualTo("value1");
+ assertThat(distributedMap1.get("key2")).isNull();
+
+ assertThat(distributedMap2.map()).isSameAs(map2.get());
+ assertThat(distributedMap2.get("key1")).isNull();
+ assertThat(distributedMap2.get("key2")).isEqualTo("value2");
+ });
+ }
+ }
+ }
+
+ public static class HasManyDistributedMaps implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map1 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map2 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map3 = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap1 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap2 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap3 = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map1.set(distributedMap1.map());
+ distributedMap1.put("key1", "value1");
+
+ map2.set(distributedMap2.map());
+ distributedMap2.put("key2", "value2");
+
+ map3.set(distributedMap3.map());
+ distributedMap3.put("key3", "value3");
Review comment:
Might it be worth extracting the hardcoded string keys/values in this test to constants?
----------------------------------------------------------------
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
[GitHub] [geode] DonalEvans commented on a change in pull request #5667: GEODE-8647: Support multiple instances of DistributedMap
Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #5667:
URL: https://github.com/apache/geode/pull/5667#discussion_r513070717
##########
File path: geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedMapTest.java
##########
@@ -491,4 +495,162 @@ public void getReturnsSameValueInEveryVmAsPutInOtherVm() {
});
}
}
+
+ @Test
+ public void accessesDistributedMapInEachVm() {
+ runTestWithValidation(HasDistributedMap.class);
+ }
+
+ @Test
+ public void tearsDownDistributedMapInEachVm() {
+ runTestWithValidation(HasDistributedMap.class);
+
+ getController().invoke(() -> {
+ assertThat(HasDistributedMap.map.get()).isEmpty();
+ });
+ }
+
+ @Test
+ public void accessesTwoDistributedMapsInEachVm() {
+ runTestWithValidation(HasTwoDistributedMaps.class);
+ }
+
+ @Test
+ public void tearsDownTwoDistributedMapsInEachVm() {
+ runTestWithValidation(HasTwoDistributedMaps.class);
+
+ getController().invoke(() -> {
+ assertThat(HasTwoDistributedMaps.map1.get()).isEmpty();
+ assertThat(HasTwoDistributedMaps.map2.get()).isEmpty();
+ });
+ }
+
+ @Test
+ public void accessesManyDistributedMapsInEachVm() {
+ runTestWithValidation(HasManyDistributedMaps.class);
+ }
+
+ @Test
+ public void tearsDownManyDistributedMapsInEachVm() {
+ runTestWithValidation(HasManyDistributedMaps.class);
+
+ getController().invoke(() -> {
+ assertThat(HasManyDistributedMaps.map1.get()).isEmpty();
+ assertThat(HasManyDistributedMaps.map2.get()).isEmpty();
+ assertThat(HasManyDistributedMaps.map3.get()).isEmpty();
+ });
+ }
+
+ public static class HasDistributedMap implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map.set(distributedMap.map());
+ distributedMap.put("key1", "value1");
+ });
+ }
+
+ @Test
+ public void distributedMapIsAccessibleInEveryVm() {
+ for (VM vm : asList(getVM(0), getVM(1), getVM(2), getVM(3), getController())) {
+ vm.invoke(() -> {
+ assertThat(distributedMap.map()).isSameAs(map.get());
+ assertThat(distributedMap.get("key1")).isEqualTo("value1");
+ });
+ }
+ }
+ }
+
+ public static class HasTwoDistributedMaps implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map1 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map2 = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap1 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap2 = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map1.set(distributedMap1.map());
+ distributedMap1.put("key1", "value1");
+
+ map2.set(distributedMap2.map());
+ distributedMap2.put("key2", "value2");
+ });
+ }
+
+ @Test
+ public void twoDistributedMapsAreAccessibleInEveryVm() {
+ for (VM vm : asList(getVM(0), getVM(1), getVM(2), getVM(3), getController())) {
+ vm.invoke(() -> {
+ assertThat(distributedMap1.map()).isSameAs(map1.get());
+ assertThat(distributedMap1.get("key1")).isEqualTo("value1");
+ assertThat(distributedMap1.get("key2")).isNull();
+
+ assertThat(distributedMap2.map()).isSameAs(map2.get());
+ assertThat(distributedMap2.get("key1")).isNull();
+ assertThat(distributedMap2.get("key2")).isEqualTo("value2");
+ });
+ }
+ }
+ }
+
+ public static class HasManyDistributedMaps implements Serializable {
+
+ private static final AtomicReference<Map<Object, Object>> map1 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map2 = new AtomicReference<>();
+ private static final AtomicReference<Map<Object, Object>> map3 = new AtomicReference<>();
+
+ @Rule
+ public DistributedMap<Object, Object> distributedMap1 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap2 = new DistributedMap<>();
+ @Rule
+ public DistributedMap<Object, Object> distributedMap3 = new DistributedMap<>();
+
+ @Before
+ public void setUp() {
+ getController().invoke(() -> {
+ map1.set(distributedMap1.map());
+ distributedMap1.put("key1", "value1");
+
+ map2.set(distributedMap2.map());
+ distributedMap2.put("key2", "value2");
+
+ map3.set(distributedMap3.map());
+ distributedMap3.put("key3", "value3");
Review comment:
Might it be worth extracting the hardcoded string keys/values in this test class to constants?
----------------------------------------------------------------
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