[ https://issues.apache.org/jira/browse/GEODE-9576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17408735#comment-17408735 ]
ASF GitHub Bot commented on GEODE-9576: --------------------------------------- pivotal-jbarrett commented on a change in pull request #864: URL: https://github.com/apache/geode-native/pull/864#discussion_r700973535 ########## File path: tests/javaobject/MultiGetAllFunctionNonHA.java ########## @@ -0,0 +1,70 @@ +/* + * 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 javaobject; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; +import java.util.Vector; +import java.util.List; +import java.util.Set; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheClosedException; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Declarable; +import org.apache.geode.cache.execute.FunctionAdapter; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.ResultSender; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.Function; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.execute.RegionFunctionContext; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.InternalDistributedSystem; +import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException; + +public class MultiGetAllFunctionNonHA extends FunctionAdapter implements Declarable{ Review comment: `FunctionAdapter` is deprecated and should not be used. `Function` has generic type parameters that should be declared. ########## File path: cppcache/integration/test/FunctionExecutionTest.cpp ########## @@ -175,6 +181,58 @@ TEST(FunctionExecutionTest, cache.close(); } +void populateRegion(const std::shared_ptr<Region> ®ion) { + for (int i = 0; i < 113; i++) { + region->put("KEY--" + std::to_string(i), "VALUE--" + std::to_string(i)); + } +} + +TEST(FunctionExecutionTest, FunctionExecutionSingleHopNonHA) { + Cluster cluster{ + LocatorCount{1}, ServerCount{3}, + CacheXMLFiles( + {std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) + + "/func_cacheserver1_pool_nonHA.xml", + std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) + + "/func_cacheserver2_pool_nonHA.xml", + std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) + + "/func_cacheserver3_pool_nonHA.xml"})}; + + cluster.start([&]() { + cluster.getGfsh() + .deploy() + .jar(getFrameworkString(FrameworkVariable::JavaObjectJarPath)) + .execute(); + }); + + auto cache = CacheFactory().create(); + auto poolFactory = cache.getPoolManager().createFactory(); + + cluster.applyLocators(poolFactory); + + auto pool = + poolFactory.setPRSingleHopEnabled(true).setRetryAttempts(0).create( + "pool"); + + auto region = cache.createRegionFactory(RegionShortcut::PROXY) + .setPoolName("pool") + .create("partition_region"); + + populateRegion(region); + + for (int i = 0; i < 30; i++) { + auto functionService = FunctionService::onRegion(region); + auto rc = + functionService.withCollector(std::make_shared<TestResultCollector>()) Review comment: How is this test asserting that the PR metadata is not complete for region prior to and during the execution of this function? ########## File path: tests/javaobject/MultiGetAllFunctionNonHA.java ########## @@ -0,0 +1,70 @@ +/* + * 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 javaobject; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; +import java.util.Vector; +import java.util.List; +import java.util.Set; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheClosedException; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Declarable; +import org.apache.geode.cache.execute.FunctionAdapter; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.ResultSender; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.Function; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.execute.RegionFunctionContext; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.InternalDistributedSystem; +import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException; + +public class MultiGetAllFunctionNonHA extends FunctionAdapter implements Declarable{ + + public void execute(FunctionContext context) { Review comment: This and other methods should be declared as `@Override`. ########## File path: tests/javaobject/MultiGetAllFunctionNonHA.java ########## @@ -0,0 +1,70 @@ +/* + * 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 javaobject; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; +import java.util.Vector; +import java.util.List; +import java.util.Set; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheClosedException; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Declarable; +import org.apache.geode.cache.execute.FunctionAdapter; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.ResultSender; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.execute.Function; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.execute.RegionFunctionContext; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.InternalDistributedSystem; +import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException; + +public class MultiGetAllFunctionNonHA extends FunctionAdapter implements Declarable{ + + public void execute(FunctionContext context) { + RegionFunctionContext regionContext = (RegionFunctionContext) context; + final Region<String, String> region = + PartitionRegionHelper.getLocalDataForContext(regionContext); + + Set<String> keys = region.keySet(); + List<String> listKey = new ArrayList<>(); Review comment: Why and intermediate list since `ResultSender` can send multiple results, just iterate until you are at the last key and send that using `lastResult`. ########## File path: cppcache/src/ClientMetadataService.cpp ########## @@ -578,12 +577,10 @@ ClientMetadataService::pruneNodes( const auto locations = metadata->adviseServerLocations(bucketId); if (locations.size() == 0) { LOGDEBUG( - "ClientMetadataService::pruneNodes Since no server location " - "available for bucketId = %d putting it into " - "bucketSetWithoutServer ", + "ClientMetadataService::pruneNodes Use non single-hop path " Review comment: These changes strike me as unit testable. Please produce a unit test for these changes. ########## File path: cppcache/integration/test/FunctionExecutionTest.cpp ########## @@ -175,6 +181,58 @@ TEST(FunctionExecutionTest, cache.close(); } +void populateRegion(const std::shared_ptr<Region> ®ion) { + for (int i = 0; i < 113; i++) { + region->put("KEY--" + std::to_string(i), "VALUE--" + std::to_string(i)); + } +} + +TEST(FunctionExecutionTest, FunctionExecutionSingleHopNonHA) { + Cluster cluster{ + LocatorCount{1}, ServerCount{3}, + CacheXMLFiles( + {std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) + + "/func_cacheserver1_pool_nonHA.xml", Review comment: We should be leveraging modern configuration APIs, not the legacy cache.xml, whenever possible. This may mean providing `gfsh` commands to configure the servers via cluster config. At the very least the cache.xml files should be located in the new integration tests as resources and not the old tests. -- 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. To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org > InternalFunctionInvocationTargetException when executing single hop function > all buckets > ---------------------------------------------------------------------------------------- > > Key: GEODE-9576 > URL: https://issues.apache.org/jira/browse/GEODE-9576 > Project: Geode > Issue Type: Bug > Components: native client > Reporter: Jakov Varenina > Assignee: Jakov Varenina > Priority: Major > Labels: pull-request-available > > *InternalFunctionInvocationTargetException: Multiple target nodes found for > single hop operation* occurs on native client when executing function in a > single hop manner for all buckets during the period when client bucket > metadata doesn't contain all buckets locations. > Java client in this case executes functions in non single hop manner until it > receives locations of all buckets on servers. The solution in native client > would be to implement the same handling as in java client. -- This message was sent by Atlassian Jira (v8.3.4#803005)