Browse Source

无 jira 任务 finekit 适配状态服务器接口重构

pull/35/head
Dylan.Liu 5 years ago
parent
commit
4199182e20
  1. 4
      src/main/java/com/fanruan/api/cluster/state/BaseRedisCollectionsClient.java
  2. 5
      src/main/java/com/fanruan/api/cluster/state/BaseRedisStore.java
  3. 9
      src/main/java/com/fanruan/api/cluster/state/FineJedisPoolKit.java
  4. 8
      src/main/java/com/fanruan/api/cluster/state/StandAloneJedisKit.java
  5. 20
      src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java
  6. 4
      src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java

4
src/main/java/com/fanruan/api/cluster/state/BaseRedisCollectionsClient.java

@ -1,6 +1,6 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.collections.cluster.client.RedisCollectionsClient; import com.fr.collections.cluster.client.StoreCollectionsClient;
import com.fr.collections.config.redis.RedisCollectionConfig; import com.fr.collections.config.redis.RedisCollectionConfig;
/** /**
@ -9,7 +9,7 @@ import com.fr.collections.config.redis.RedisCollectionConfig;
* @version 10.0 * @version 10.0
* Created by Dylan.Liu on 2019/12/3 * Created by Dylan.Liu on 2019/12/3
*/ */
public class BaseRedisCollectionsClient extends RedisCollectionsClient { public class BaseRedisCollectionsClient extends StoreCollectionsClient {
public BaseRedisCollectionsClient() { public BaseRedisCollectionsClient() {

5
src/main/java/com/fanruan/api/cluster/state/BaseRedisStore.java

@ -1,6 +1,7 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.store.RedisStore;
import com.fr.store.StateStore;
/** /**
* Redis Store * Redis Store
@ -8,7 +9,7 @@ import com.fr.store.RedisStore;
* @version 10.0 * @version 10.0
* Created by Dylan.Liu on 2019/12/3 * Created by Dylan.Liu on 2019/12/3
*/ */
public class BaseRedisStore extends RedisStore { public class BaseRedisStore extends StateStore {
public BaseRedisStore(String tableNamePrefix, int expireStateRemoveInterval) { public BaseRedisStore(String tableNamePrefix, int expireStateRemoveInterval) {
super(tableNamePrefix, expireStateRemoveInterval); super(tableNamePrefix, expireStateRemoveInterval);

9
src/main/java/com/fanruan/api/cluster/state/FineJedisPoolKit.java

@ -1,7 +1,8 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.store.impl.redis.accessor.FineJedisPool;
import com.fr.store.impl.redis.accessor.FineJedisWrapper; import com.fr.store.impl.accessor.FineStorePool;
import com.fr.store.impl.accessor.FineStoreWrapper;
/** /**
* @author Dylan.Liu * @author Dylan.Liu
@ -14,8 +15,8 @@ public class FineJedisPoolKit {
* 设置提供真实资源的 Jedis 包装对象 * 设置提供真实资源的 Jedis 包装对象
* @param jedisWrapper Jedis 包装对象 * @param jedisWrapper Jedis 包装对象
*/ */
public static void setRealClient(FineJedisWrapper jedisWrapper) { public static void setRealClient(FineStoreWrapper jedisWrapper) {
FineJedisPool.getInstance().setRealClient(jedisWrapper); FineStorePool.getInstance().setRealClient(jedisWrapper);
} }
} }

8
src/main/java/com/fanruan/api/cluster/state/StandAloneJedisKit.java

@ -1,7 +1,7 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.store.impl.redis.accessor.FineJedis; import com.fr.store.impl.accessor.FineStore;
import com.fr.store.impl.redis.accessor.StandAloneJedis; import com.fr.store.impl.accessor.StandAloneStore;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
/** /**
@ -16,11 +16,11 @@ public class StandAloneJedisKit {
* @param jedis Jedis 资源 * @param jedis Jedis 资源
* @return 单机版 Jedis Api集合 * @return 单机版 Jedis Api集合
*/ */
public static FineJedis createStandAloneJedis(Jedis jedis) { public static FineStore createStandAloneJedis(Jedis jedis) {
if (jedis == null) { if (jedis == null) {
throw new NullPointerException("jedis is null"); throw new NullPointerException("jedis is null");
} }
return new StandAloneJedis(jedis); return new StandAloneStore(jedis);
} }
} }

20
src/test/java/com/fanruan/api/cluster/state/FineJedisPoolKitTest.java

@ -1,8 +1,8 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.store.impl.redis.accessor.FineJedis; import com.fr.store.impl.accessor.FineStore;
import com.fr.store.impl.redis.accessor.FineJedisPool; import com.fr.store.impl.accessor.FineStorePool;
import com.fr.store.impl.redis.accessor.FineJedisWrapper; import com.fr.store.impl.accessor.FineStoreWrapper;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -21,10 +21,10 @@ public class FineJedisPoolKitTest {
@Test @Test
public void TestSetRealClient() { public void TestSetRealClient() {
FineJedisPoolKit.setRealClient(new FineJedisWrapper() { FineJedisPoolKit.setRealClient(new FineStoreWrapper() {
@Override @Override
public FineJedis getResource() { public FineStore getResource() {
return null; return null;
} }
@ -33,16 +33,16 @@ public class FineJedisPoolKitTest {
} }
}); });
Assert.assertNull(FineJedisPool.getInstance().getResource()); Assert.assertNull(FineStorePool.getInstance().getResource());
FineJedis mockFineJedis = mock(FineJedis.class); FineStore mockFineJedis = mock(FineStore.class);
expect(mockFineJedis.type(anyObject())).andReturn("TestFineJedis"); expect(mockFineJedis.type(anyObject())).andReturn("TestFineJedis");
EasyMock.replay(mockFineJedis); EasyMock.replay(mockFineJedis);
FineJedisPoolKit.setRealClient(new FineJedisWrapper() { FineJedisPoolKit.setRealClient(new FineStoreWrapper() {
@Override @Override
public FineJedis getResource() { public FineStore getResource() {
return mockFineJedis; return mockFineJedis;
} }
@ -51,7 +51,7 @@ public class FineJedisPoolKitTest {
} }
}); });
Assert.assertEquals("TestFineJedis", FineJedisPool.getInstance().getResource().type(new byte[]{})); Assert.assertEquals("TestFineJedis", FineStorePool.getInstance().getResource().type(new byte[]{}));
} }
} }

4
src/test/java/com/fanruan/api/cluster/state/StandAloneJedisKitTest.java

@ -1,6 +1,6 @@
package com.fanruan.api.cluster.state; package com.fanruan.api.cluster.state;
import com.fr.store.impl.redis.accessor.FineJedis; import com.fr.store.impl.accessor.FineStore;
import com.fr.third.redis.clients.jedis.Jedis; import com.fr.third.redis.clients.jedis.Jedis;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;
@ -24,7 +24,7 @@ public class StandAloneJedisKitTest {
expect(mockJedis.type(anyObject(byte[].class))).andReturn("test_echo"); expect(mockJedis.type(anyObject(byte[].class))).andReturn("test_echo");
EasyMock.replay(mockJedis); EasyMock.replay(mockJedis);
FineJedis standAloneJedis = StandAloneJedisKit.createStandAloneJedis(mockJedis); FineStore standAloneJedis = StandAloneJedisKit.createStandAloneJedis(mockJedis);
Assert.assertEquals("test_echo", standAloneJedis.type(new byte[]{})); Assert.assertEquals("test_echo", standAloneJedis.type(new byte[]{}));
} }

Loading…
Cancel
Save