[ https://issues.apache.org/jira/browse/GEODE-7845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17212724#comment-17212724 ]
ASF GitHub Bot commented on GEODE-7845: --------------------------------------- jinmeiliao commented on a change in pull request #5577: URL: https://github.com/apache/geode/pull/5577#discussion_r503580065 ########## File path: geode-core/src/main/java/org/apache/geode/cache/ServerVersionMismatchException.java ########## @@ -0,0 +1,33 @@ +/* + * 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.cache; + +import java.util.List; + +/** + * Indicates a failure to perform an operation on a Partitioned Region due to + * server versions not meeting requirements. + * + * @since GemFire 5.1 Review comment: this is not correct since this is a new exception ########## File path: geode-core/src/main/java/org/apache/geode/cache/ServerVersionMismatchException.java ########## @@ -0,0 +1,33 @@ +/* + * 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.cache; + +import java.util.List; + +/** + * Indicates a failure to perform an operation on a Partitioned Region due to + * server versions not meeting requirements. + * + * @since GemFire 5.1 + */ +public class ServerVersionMismatchException extends CacheRuntimeException { + private static final long serialVersionUID = -3004093739855972548L; + + public ServerVersionMismatchException(List<String> members, String featureName, + String version) { + super("A server's " + members + " version was too old (< " + version + ") for : " + featureName); Review comment: probably would be a good idea for this exception to only take a string message as an argument. Then situations using this exception is free to construct their own messages. ########## File path: geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionClear.java ########## @@ -288,8 +292,13 @@ protected void releaseClearLockLocal() { return bucketsOperated; } + if (!partitionedRegion.allServerVersionsSupportPartitionRegionClear()) { + throw new PartitionedRegionVersionException(); Review comment: this is still throwing the old exception? ########## File path: geode-core/src/upgradeTest/java/org/apache/geode/internal/cache/rollingupgrade/RollingUpgradePartitionRegionClearMixedServerPartitionedRegion.java ########## @@ -0,0 +1,410 @@ +/* + * 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.rollingupgrade; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Properties; + +import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.Logger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +import org.junit.runners.Parameterized.UseParametersRunnerFactory; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.GemFireCache; +import org.apache.geode.cache.PartitionedRegionVersionException; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionFactory; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.cache.client.ClientRegionShortcut; +import org.apache.geode.cache.client.ServerOperationException; +import org.apache.geode.cache.server.CacheServer; +import org.apache.geode.distributed.DistributedSystem; +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.internal.AvailablePortHelper; +import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.PartitionedRegion; +import org.apache.geode.logging.internal.log4j.api.LogService; +import org.apache.geode.test.dunit.DistributedTestUtils; +import org.apache.geode.test.dunit.Host; +import org.apache.geode.test.dunit.IgnoredException; +import org.apache.geode.test.dunit.Invoke; +import org.apache.geode.test.dunit.NetworkUtils; +import org.apache.geode.test.dunit.VM; +import org.apache.geode.test.dunit.internal.DUnitLauncher; +import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; +import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; +import org.apache.geode.test.version.VersionManager; + +@RunWith(Parameterized.class) +@UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class) +public class RollingUpgradePartitionRegionClearMixedServerPartitionedRegion + extends JUnit4DistributedTestCase { + + protected static final Logger logger = LogService.getLogger(); + protected static GemFireCache cache; + protected static ClientCache clientcache; + + @Parameter + public String oldVersion; + + @Parameters(name = "from_v{0}") + public static Collection<String> data() { + List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); + if (result.size() < 1) { + throw new RuntimeException("No older versions of Geode were found to test against"); + } else { + System.out.println("running against these versions: " + result); + } + return result; + } + + @Test + public void testPutAndGetMixedServerPartitionedRegion() throws Exception { + doTestPutAndGetMixedServers(oldVersion); + } + + /** + * This test starts up multiple servers from the current code base and multiple servers from the + * old version and executes puts and gets on a new server and old server and verifies that the + * results are present. Note that the puts have overlapping region keys just to test new puts and + * replaces + */ + void doTestPutAndGetMixedServers(String oldVersion) + throws Exception { + VM currentServer1 = VM.getVM(VersionManager.CURRENT_VERSION, 0); + VM oldServerAndLocator = VM.getVM(oldVersion, 1); + VM currentServer2 = VM.getVM(VersionManager.CURRENT_VERSION, 2); + VM oldServer2 = VM.getVM(oldVersion, 3); + + String regionName = "aRegion"; + + final String serverHostName = NetworkUtils.getServerHostName(); + final int port = AvailablePortHelper.getRandomAvailableTCPPort(); + oldServerAndLocator.invoke(() -> DistributedTestUtils.deleteLocatorStateFile(port)); + try { + final Properties props = getSystemProperties(); + props.remove(DistributionConfig.LOCATORS_NAME); + + // Fire up the locator and server + oldServerAndLocator.invoke(() -> { + props.put(DistributionConfig.START_LOCATOR_NAME, + "" + serverHostName + "[" + port + "]"); + props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false"); + cache = createCache(props); + Thread.sleep(5000); // bug in 1.0 - cluster config service not immediately available + }); + + props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); + + // create the cache in all the server VMs. + for (VM vm : Arrays.asList(oldServer2, currentServer1, currentServer2)) { + vm.invoke(() -> { + cache = createCache(props); + }); + } + // spin up current version servers + for (VM vm : Arrays.asList(currentServer1, currentServer2)) { + vm.invoke( + () -> assertVersion(cache, VersionManager.getInstance().getCurrentVersionOrdinal())); + } + + // create region + for (VM vm : Arrays.asList(currentServer1, currentServer2, oldServerAndLocator, oldServer2)) { + vm.invoke(() -> createRegion(cache, regionName)); + } + + // put some data in the region to make sure there is something to clear. + putDataSerializableAndVerify(currentServer1, regionName, currentServer2, oldServerAndLocator, + oldServer2); + + // invoke Partition Region Clear and verify we didn't touch the old servers. + + currentServer1.invoke(() -> { + assertRegionExists(cache, regionName); + PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName); + + Throwable thrown = catchThrowable(region::clear); Review comment: would be a good idea to verify that the message contains those two server names that has the old version. ---------------------------------------------------------------- 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: us...@infra.apache.org > Rollingupgrade should not conflict with the new ClearPRMessage > --------------------------------------------------------------- > > Key: GEODE-7845 > URL: https://issues.apache.org/jira/browse/GEODE-7845 > Project: Geode > Issue Type: Improvement > Components: core > Reporter: Xiaojian Zhou > Assignee: Mark Hanson > Priority: Major > Labels: GeodeCommons, pull-request-available > > PartitionedRegion clear introduced a new ClearPRMessage. In case of doing > rolling upgrade, the user called PR.clear. The new ClearPRMessage should not > fail. It should not be sent to the old members. -- This message was sent by Atlassian Jira (v8.3.4#803005)