[geode] branch develop updated: GEODE-9808: Throw appropriate exception in AutoConnectionSourceImpl (#7143)
This is an automated email from the ASF dual-hosted git repository. donalevans pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/develop by this push: new 1e66771 GEODE-9808: Throw appropriate exception in AutoConnectionSourceImpl (#7143) 1e66771 is described below commit 1e66771a546462e89b6e11aaef294fb0e05d524c Author: Donal Evans AuthorDate: Wed Dec 8 17:10:09 2021 -0800 GEODE-9808: Throw appropriate exception in AutoConnectionSourceImpl (#7143) - Throw NoServersFoundException instead of NoLocatorsFoundException in AutoConnectionSourceImpl if queryLocators() returns a response with no result - Refactor and fix up AutoConnectionSourceImplJUnitTest - Modify tests in AutoConnectionSourceImplJUnitTest to cover new behaviour Authored-by: Donal Evans --- .../AutoConnectionSourceImplJUnitTest.java | 118 ++--- .../client/internal/AutoConnectionSourceImpl.java | 32 -- 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java index 979bc50..dd3e1d5 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java @@ -18,10 +18,8 @@ package org.apache.geode.cache.client.internal; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; @@ -43,7 +41,6 @@ import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -57,6 +54,7 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.NoSubscriptionServersAvailableException; import org.apache.geode.cache.client.NoAvailableLocatorsException; +import org.apache.geode.cache.client.NoAvailableServersException; import org.apache.geode.cache.client.SocketFactory; import org.apache.geode.cache.client.SubscriptionNotEnabledException; import org.apache.geode.cache.client.internal.locator.ClientConnectionRequest; @@ -85,14 +83,13 @@ import org.apache.geode.management.membership.ClientMembershipListener; import org.apache.geode.test.junit.categories.ClientServerTest; import org.apache.geode.util.internal.GeodeGlossary; -@SuppressWarnings("deprecation") @Category(ClientServerTest.class) public class AutoConnectionSourceImplJUnitTest { private Cache cache; private int port; private FakeHandler handler; - private FakePool pool = new FakePool(); + private final FakePool pool = new FakePool(); private AutoConnectionSourceImpl source; private TcpServer server; private ScheduledExecutorService background; @@ -107,9 +104,9 @@ public class AutoConnectionSourceImplJUnitTest { props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); -DistributedSystem ds = DistributedSystem.connect(props); -cache = CacheFactory.create(ds); -poolStats = new PoolStats(ds, "pool"); +cache = new CacheFactory(props).create(); +DistributedSystem distributedSystem = cache.getDistributedSystem(); +poolStats = new PoolStats(distributedSystem, "pool"); port = AvailablePortHelper.getRandomAvailableTCPPort(); handler = new FakeHandler(); @@ -119,13 +116,10 @@ public class AutoConnectionSourceImplJUnitTest { background = Executors.newSingleThreadScheduledExecutor(); -List locators = new ArrayList<>(); -InetAddress ia = InetAddress.getLocalHost(); -InetSocketAddress isa = new InetSocketAddress(ia, port); -locators.add(isa); -List la = new ArrayList<>(); -la.add(new HostAndPort(ia.getHostName(), port)); -source = new AutoConnectionSourceImpl(la, "", 60 * 1000, SocketFactory.DEFAULT); +InetAddress inetAddress = InetAddress.getLocalHost(); +List hostAndPortList = new ArrayList<>(); +hostAndPortList.add(new HostAndPort(inetAddress.getHostName(), port)); +source =
[geode] branch develop updated (d093b73 -> bc18f5e)
This is an automated email from the ASF dual-hosted git repository. jinmeiliao pushed a change to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git. from d093b73 GEODE-9831: support SISMEMBER support command (#7164) add bc18f5e GEODE-9875: client operation should not send in invalid userId. (#7173) No new revisions were added by this update. Summary of changes: .../geode/cache/client/internal/AbstractOp.java| 4 ++ .../cache/client/internal/EndpointManagerImpl.java | 27 + .../cache/client/internal/AbstractOpTest.java | 66 +++--- 3 files changed, 54 insertions(+), 43 deletions(-)
[geode-native] 01/02: Modify tests for generics (wip)
This is an automated email from the ASF dual-hosted git repository. mmartell pushed a commit to branch GEODE-9712-genericize-netcore in repository https://gitbox.apache.org/repos/asf/geode-native.git commit a5fc92096f969326da2edb10c2d81dce615d571b Author: Mike Martell AuthorDate: Wed Dec 8 15:14:07 2021 -0800 Modify tests for generics (wip) --- netcore/netcore-integration-test/CacheTest.cs | 2 +- .../netcore-integration-test/RegionFactoryTest.cs | 34 -- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/netcore/netcore-integration-test/CacheTest.cs b/netcore/netcore-integration-test/CacheTest.cs index f35d181..ececc4f 100644 --- a/netcore/netcore-integration-test/CacheTest.cs +++ b/netcore/netcore-integration-test/CacheTest.cs @@ -80,7 +80,7 @@ namespace Apache.Geode.Client.IntegrationTests { cacheFactory.PdxIgnoreUnreadFields = true; using var cache = cacheFactory.CreateCache(); Assert.NotNull(cache); - using var regionFactory = cache.CreateRegionFactory( + var regionFactory = cache.CreateRegionFactory( RegionShortcut.Proxy); // lgtm[cs / useless - assignment - to - local] Assert.NotNull(regionFactory); } diff --git a/netcore/netcore-integration-test/RegionFactoryTest.cs b/netcore/netcore-integration-test/RegionFactoryTest.cs index edac8ad..a995547 100644 --- a/netcore/netcore-integration-test/RegionFactoryTest.cs +++ b/netcore/netcore-integration-test/RegionFactoryTest.cs @@ -57,38 +57,41 @@ namespace Apache.Geode.Client.IntegrationTests { poolFactory.CreatePool("myPool"); // lgtm[cs / useless - assignment - to - local] } -private void doPutsAndGets(Region region) { +private void doPutsAndGets(IRegion region) { var fullname1 = "Robert Timmons"; var fullname2 = "Sylvia Charles"; + var car = new Dictionary() { { 1, "Ford" }, { 2, "Chevy" } }; - region.PutString(Username1, fullname1); - region.PutString(Username2, fullname2); + region.Put(Username1, fullname1); + region.Put(777, fullname2); + region.Put(888, car); - var user1 = region.GetString(Username1); - var user2 = region.GetString(Username2); + var user1 = region.Get(Username1); + var user2 = region.Get(777); + var car1 = region.Get(888); Assert.Equal(user1, fullname1); Assert.Equal(user2, fullname2); } -private void DoRemoves(Region region) { - region.Remove(Username1); - region.Remove(Username2); +private void DoRemoves(IRegion region) { + //region.Remove(Username1); + //region.Remove(Username2); - var hasUser1 = region.ContainsValueForKey(Username1); - var hasUser2 = region.ContainsValueForKey(Username2); + //var hasUser1 = region.ContainsValueForKey(Username1); + //var hasUser2 = region.ContainsValueForKey(Username2); - Assert.False(hasUser1); - Assert.False(hasUser2); + //Assert.False(hasUser1); + //Assert.False(hasUser2); } private void CreateRegionAndDoWork(IGeodeCache cache, string regionName, RegionShortcut regionType) { - using var regionFactory = cache.CreateRegionFactory(regionType); - using var region = regionFactory.CreateRegion(regionName); + var regionFactory = cache.CreateRegionFactory(regionType); + var region = regionFactory.Create(regionName); doPutsAndGets(region); - DoRemoves(region); + //DoRemoves(region); } [Fact] @@ -102,6 +105,7 @@ namespace Apache.Geode.Client.IntegrationTests { .CreatePool("myPool"); CreateRegionAndDoWork(cache, "exampleRegion", RegionShortcut.Proxy); + } [Fact]
[geode-native] 02/02: Genericize netcore-lib
This is an automated email from the ASF dual-hosted git repository. mmartell pushed a commit to branch GEODE-9712-genericize-netcore in repository https://gitbox.apache.org/repos/asf/geode-native.git commit 2503eedd75c8ee9320cf48a4d01af6b4d5d65815 Author: Mike Martell AuthorDate: Wed Dec 8 15:15:39 2021 -0800 Genericize netcore-lib --- netcore/netcore-lib/Cache.cs | 113 ++-- netcore/netcore-lib/{Cache.cs => CacheInterop.cs} | 8 +- .../netcore-lib/{IRegionService.cs => IRegion.cs} | 12 ++- netcore/netcore-lib/IRegionService.cs | 8 +- netcore/netcore-lib/PoolManager.cs | 7 ++ netcore/netcore-lib/Region.cs | 117 +++-- netcore/netcore-lib/RegionFactory.cs | 44 +--- .../{RegionFactory.cs => RegionFactoryInterop.cs} | 10 +- .../netcore-lib/{Region.cs => RegionInterop.cs}| 69 +--- 9 files changed, 206 insertions(+), 182 deletions(-) diff --git a/netcore/netcore-lib/Cache.cs b/netcore/netcore-lib/Cache.cs index 200e740..064b963 100644 --- a/netcore/netcore-lib/Cache.cs +++ b/netcore/netcore-lib/Cache.cs @@ -20,59 +20,29 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Apache.Geode.Client { - public class Cache : GeodeNativeObject, IGeodeCache { + public class Cache : IGeodeCache { +private IntPtr _cacheFactory; +private CacheInterop _cacheInterop; private static string _name = String.Empty; private PoolManager _poolManager = null; private PoolFactory _poolFactory = null; private IAuthInitialize _authInitialize; private GetCredentialsDelegateInternal _getCredentialsDelegate; private CloseDelegateInternal _closeDelegate; +private bool disposedValue; internal delegate void GetCredentialsDelegateInternal(IntPtr cache); internal delegate void CloseDelegateInternal(); -[DllImport(Constants.libPath, CallingConvention = CallingConvention.Cdecl)] -private static extern void apache_geode_CacheFactory_SetAuthInitialize( -IntPtr factory, GetCredentialsDelegateInternal getCredentials, -CloseDelegateInternal close); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern IntPtr apache_geode_CacheFactory_CreateCache(IntPtr factory); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern bool apache_geode_Cache_GetPdxIgnoreUnreadFields(IntPtr cache); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern bool apache_geode_Cache_GetPdxReadSerialized(IntPtr cache); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern IntPtr apache_geode_Cache_GetName(IntPtr cache); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern void apache_geode_Cache_Close(IntPtr cache, bool keepalive); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern bool apache_geode_Cache_IsClosed(IntPtr cache); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern bool apache_geode_AuthInitialize_AddProperty(IntPtr properties, - IntPtr key, - IntPtr value); - -[DllImport(Constants.libPath, CharSet = CharSet.Auto)] -private static extern void apache_geode_DestroyCache(IntPtr cache); - internal Cache(IntPtr cacheFactory, IAuthInitialize authInitialize) { _authInitialize = authInitialize; + _cacheFactory = cacheFactory; + _cacheInterop = new CacheInterop(cacheFactory, authInitialize); if (_authInitialize != null) { _getCredentialsDelegate = new GetCredentialsDelegateInternal(AuthGetCredentials); _closeDelegate = new CloseDelegateInternal(AuthClose); - -apache_geode_CacheFactory_SetAuthInitialize(cacheFactory, _getCredentialsDelegate, -_closeDelegate); } - _containedObject = apache_geode_CacheFactory_CreateCache(cacheFactory); } internal void AuthGetCredentials(IntPtr properties) { @@ -87,7 +57,7 @@ namespace Apache.Geode.Client { Console.WriteLine("Found credential: (k, v) = ({0}, {1})", entry.Key, entry.Value); var keyPtr = Marshal.StringToCoTaskMemUTF8(entry.Key); var valuePtr = Marshal.StringToCoTaskMemUTF8(entry.Value); -apache_geode_AuthInitialize_AddProperty(properties, keyPtr, valuePtr); +//apache_geode_AuthInitialize_AddProperty(properties, keyPtr, valuePtr); Marshal.FreeCoTaskMem(keyPtr); Marshal.FreeCoTaskMem(valuePtr); } @@ -98,25 +68,33 @@ namespace Apache.Geode.Client { } public void Close() { - apache_geode_Cache_Close(_containedObject, false); + _cacheIn
[geode-native] branch GEODE-9712-genericize-netcore created (now 2503eed)
This is an automated email from the ASF dual-hosted git repository. mmartell pushed a change to branch GEODE-9712-genericize-netcore in repository https://gitbox.apache.org/repos/asf/geode-native.git. at 2503eed Genericize netcore-lib This branch includes the following new commits: new a5fc920 Modify tests for generics (wip) new 2503eed Genericize netcore-lib The 2 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-examples] branch feature/GEODE-9814-redis-example updated (8c67008 -> cdef9dc)
This is an automated email from the ASF dual-hosted git repository. dbarnes pushed a change to branch feature/GEODE-9814-redis-example in repository https://gitbox.apache.org/repos/asf/geode-examples.git. from 8c67008 Change wording in README add cdef9dc Update README.md No new revisions were added by this update. Summary of changes: geodeForRedis/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[geode] branch develop updated: GEODE-9831: support SISMEMBER support command (#7164)
This is an automated email from the ASF dual-hosted git repository. jensdeppe pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/develop by this push: new d093b73 GEODE-9831: support SISMEMBER support command (#7164) d093b73 is described below commit d093b73cafeeb7b40e9156f3a3a85bb706881a98 Author: Kris10 AuthorDate: Wed Dec 8 08:34:06 2021 -0800 GEODE-9831: support SISMEMBER support command (#7164) * Update geode-docs/tools_modules/geode_for_redis.html.md.erb --- .../tools_modules/geode_for_redis.html.md.erb | 1 + geode-for-redis/README.md | 1 + .../server/AbstractHitsMissesIntegrationTest.java | 10 +-- .../set/AbstractSIsMemberIntegrationTest.java | 78 ++ .../redis/internal/commands/RedisCommandType.java | 2 +- 5 files changed, 57 insertions(+), 35 deletions(-) diff --git a/geode-docs/tools_modules/geode_for_redis.html.md.erb b/geode-docs/tools_modules/geode_for_redis.html.md.erb index 91c6c16..06d9d8d 100644 --- a/geode-docs/tools_modules/geode_for_redis.html.md.erb +++ b/geode-docs/tools_modules/geode_for_redis.html.md.erb @@ -113,6 +113,7 @@ If the server is functioning properly, you should see a response of `PONG`. - SADD - SCARD - SDIFF + - SISMEMBER - SET - SETNX - SLOWLOG **[3]** diff --git a/geode-for-redis/README.md b/geode-for-redis/README.md index 82d452e..1f4d70f 100644 --- a/geode-for-redis/README.md +++ b/geode-for-redis/README.md @@ -199,6 +199,7 @@ Geode for Redis implements a subset of the full Redis command set. - SADD - SCARD - SDIFF +- SISMEMBER - SET - SETEX - SETNX diff --git a/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/server/AbstractHitsMissesIntegrationTest.java b/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/server/AbstractHitsMissesIntegrationTest.java index 511e9fc..0dc3084 100644 --- a/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/server/AbstractHitsMissesIntegrationTest.java +++ b/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/server/AbstractHitsMissesIntegrationTest.java @@ -384,6 +384,11 @@ public abstract class AbstractHitsMissesIntegrationTest implements RedisIntegrat } @Test + public void testSismember() { +runCommandAndAssertHitsAndMisses(SET_KEY, k -> jedis.sismember(k, "member")); + } + + @Test public void testSmembers() { runCommandAndAssertHitsAndMisses(SET_KEY, k -> jedis.smembers(k)); } @@ -524,11 +529,6 @@ public abstract class AbstractHitsMissesIntegrationTest implements RedisIntegrat } @Test - public void testSismember() { -runCommandAndAssertHitsAndMisses(SET_KEY, k -> jedis.sismember(k, "member")); - } - - @Test public void testSrandmember() { runCommandAndAssertHitsAndMisses(SET_KEY, k -> jedis.srandmember(k)); } diff --git a/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java b/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java index 2b1b2b7..2a62305 100755 --- a/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java +++ b/geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java @@ -15,10 +15,11 @@ package org.apache.geode.redis.internal.commands.executor.set; import static org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertExactNumberOfArgs; +import static org.apache.geode.redis.internal.RedisConstants.ERROR_WRONG_TYPE; +import static org.apache.geode.test.dunit.rules.RedisClusterStartupRule.BIND_ADDRESS; +import static org.apache.geode.test.dunit.rules.RedisClusterStartupRule.REDIS_CLIENT_TIMEOUT; import static org.assertj.core.api.Assertions.assertThat; - -import java.util.HashSet; -import java.util.Set; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.After; import org.junit.Before; @@ -27,19 +28,16 @@ import redis.clients.jedis.HostAndPort; import redis.clients.jedis.JedisCluster; import redis.clients.jedis.Protocol; -import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator; import org.apache.geode.redis.RedisIntegrationTest; -import org.apache.geode.test.awaitility.GeodeAwaitility; public abstract class AbstractSIsMemberIntegrationTest implements RedisIntegrationTest { private JedisCluster jedis; - private static final ThreePhraseGenerator generator = new ThreePhraseGenerator(); - private static final int REDIS_CLIENT_TIMEOUT = - Math.toIntExact(GeodeAwaitility.getTimeout().toMillis()); +