新增:1、ZhubClient 构造方法,支持 new 的方式初始化实例(一般在测试时使用)2、initClient 方法逻辑微调,确保实例完成初始化在执行队列数据处理
This commit is contained in:
parent
8316fce151
commit
318a8ff299
@ -3,8 +3,6 @@ package com.zdemo.cachex;
|
||||
import org.redkale.convert.json.JsonFactory;
|
||||
import org.redkale.util.AnyValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class RedisTest {
|
||||
|
||||
static MyRedisCacheSource<String> source = new MyRedisCacheSource();
|
||||
@ -115,9 +113,14 @@ public class RedisTest {
|
||||
System.out.println(source.getCollectionSize("sk")); // 2*/
|
||||
|
||||
|
||||
Map<String, String> hms = source.getHms("supportusers", "5-kfeu0f", "xxxx", "3-0kbt7u8t", "95q- ");
|
||||
/*Map<String, String> hms = source.getHms("supportusers", "5-kfeu0f", "xxxx", "3-0kbt7u8t", "95q- ");
|
||||
hms.forEach((k, v) -> {
|
||||
System.out.println(k + " : " + v);
|
||||
});*/
|
||||
|
||||
source.queryKeysStartsWith("ywb:").forEach(x -> {
|
||||
System.out.println(x);
|
||||
source.remove(x);
|
||||
});
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
|
||||
private String auth = "";
|
||||
private String groupid = "";
|
||||
|
||||
//private ReentrantLock lock = new ReentrantLock();
|
||||
private Socket client;
|
||||
private OutputStream writer;
|
||||
private BufferedReader reader;
|
||||
@ -41,16 +40,21 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
|
||||
private final LinkedBlockingQueue<Event<String>> rpcCallQueue = new LinkedBlockingQueue<>(); // RPC CALL MSG
|
||||
private final LinkedBlockingQueue<String> sendMsgQueue = new LinkedBlockingQueue<>(); // SEND MSG
|
||||
|
||||
/*private BiConsumer<Runnable, Integer> threadBuilder = (r, n) -> {
|
||||
for (int i = 0; i < n; i++) {
|
||||
new Thread(() -> r.run()).start();
|
||||
}
|
||||
};*/
|
||||
|
||||
/*private static boolean isFirst = true;
|
||||
private boolean isMain = false;*/
|
||||
private static Map<String, ZHubClient> mainHub = new HashMap<>(); // 127.0.0.1:1216 - ZHubClient
|
||||
|
||||
public ZHubClient() {
|
||||
|
||||
}
|
||||
|
||||
public ZHubClient(String name, Map<String, String> attr) {
|
||||
this.APP_NAME = name;
|
||||
this.addr = attr.get("addr");
|
||||
this.groupid = attr.get("groupid");
|
||||
this.auth = attr.get("auth");
|
||||
|
||||
this.init(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(AnyValue config) {
|
||||
if (!preInit()) {
|
||||
|
Loading…
Reference in New Issue
Block a user