10000 Add gprc support-> server push ack by shiyiyue1102 · Pull Request #3521 · alibaba/nacos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add gprc support-> server push ack #3521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ public String getTenant() {
public void setTenant(String tenant) {
this.tenant = tenant;
}

@Override
public String toString() {
return "ConfigChangeNotifyResponse{" + "dataId='" + dataId + '\'' + ", group='" + group + '\'' + ", tenant='"
+ tenant + '\'' + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface PushCallBack {

public void onSuccess();

public void onFail();
public void onFail(Exception e);

public void onTimeout();

Expand Down
26 changes: 23 additions & 3 deletions client/src/main/resources/nacos-log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,23 @@

<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}"/>
</RollingFile>


<RollingFile name="REMOTE_LOG_FILE" fileName="${sys:nacos.logging.path}/rpc.log"
filePattern="${sys:nacos.logging.path}/rpc.log.%d{yyyy-MM-dd}.%i">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%-5t:%c{2}] %m%n</Pattern>
</PatternLayout>

<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="${sys:JM.LOG.FILE.SIZE:-10MB}"/>
</Policies>

<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}"/>
</RollingFile>

<RollingFile name="GRPC_LOG_FILE" fileName="${sys:nacos.logging.path}/grpc.log"
filePattern="${sys:nacos.logging.path}/grpcgrpc.log.%d{yyyy-MM-dd}.%i">
filePattern="${sys:nacos.logging.path}/grpc.log.%d{yyyy-MM-dd}.%i">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%-5t:%c{2}] %m%n</Pattern>
</PatternLayout>
Expand Down Expand Up @@ -66,7 +80,13 @@
additivity="false">
<AppenderRef ref="CONFIG_LOG_FILE"/>
</Logger>


<Logger name="com.alibaba.nacos.common.remote.client" level="${sys:com.alibaba.nacos.config.log.level:-info}"
additivity="false">
<AppenderRef ref="REMOTE_LOG_FILE"/>
</Logger>


<Logger name="com.alibaba.nacos.client.grpc" level="${sys:com.alibaba.nacos.grpc.log.level:-info}"
additivity="false">
<AppenderRef ref="GRPC_LOG_FILE"/>
Expand Down
24 changes: 24 additions & 0 deletions client/src/main/resources/nacos-logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,36 @@
</encoder>
</appender>

<appender name="REMOTE_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${nacos.logging.path}/rpc.log</file>

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${nacos.logging.path}/rpc.log.%i</fileNamePattern>
<maxIndex>${JM.LOG.RETAIN.COUNT:-7}</maxIndex>
</rollingPolicy>

<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${JM.LOG.FILE.SIZE:-10MB}</maxFileSize>
</triggeringPolicy>

<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%-5t:%c{2}] %m%n</pattern>
</encoder>
</appender>


<logger name="com.alibaba.nacos.client" level="${com.alibaba.nacos.config.log.level:-info}"
additivity="false">
<appender-ref ref="CONFIG_LOG_FILE"/>
</logger>


<Logger name="com.alibaba.nacos.common.remote.client" level="${sys:com.alibaba.nacos.config.log.level:-info}"
additivity="false">
<AppenderRef ref="REMOTE_LOG_FILE"/>
</Logger>


<logger name="com.alibaba.nacos.client.config" level="${com.alibaba.nacos.config.log.level:-info}"
additivity="false">
<appender-ref ref="CONFIG_LOG_FILE"/>
Expand Down
130 changes: 108 additions & 22 deletions client/src/test/java/com/alibaba/nacos/client/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import org.junit.Ignore;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import java.util.Scanner;
Expand All @@ -42,7 +45,7 @@ public void before() throws Exception {
properties.setProperty(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:28848");

//properties.setProperty(PropertyKeyConst.SERVER_ADDR, "11.160.144.148:8848");
//"11.239.114.187:8848,11.239.113.204:8848,11.239.112.161:8848");
//"11.239.114.187:8848,,11.239.113.204:8848,11.239.112.161:8848");
//"11.239.114.187:8848");
configService = NacosFactory.createConfigService(properties);
//Thread.sleep(2000L);
Expand All @@ -55,38 +58,103 @@ public void cleanup() throws Exception {

@Test
public void test2() throws Exception {
Properties properties = new Properties();
properties.setProperty(PropertyKeyConst.SERVER_ADDR, "11.160.144.148:8848");
//"
List<ConfigService> configServiceList = new ArrayList<ConfigService>();
for (int i = 0; i < 200; i++) {

ConfigService configService = NacosFactory.createConfigService(properties);
configService.addListener("test", "test", new AbstractListener() {

@Override
public void receiveConfigInfo(String configInfo) {
}
});
configServiceList.add(configService);
}

Thread th = new Thread(new Runnable() {
@Override
public void run() {

Random random = new Random();
int times = 10000;
while (times > 0) {
try {
boolean result = configService
.publishConfig("test", "test", "value" + System.currentTimeMillis());

times--;
Thread.sleep(10000L);
} catch (Exception e) {
e.printStackTrace();

}
}
}

});
th.start();

Thread.sleep(1000000L);
}

@Test
public void test() throws Exception {

final String dataId = "lessspring";
final String group = "lessspring";
Random random = new Random();
final String dataId = "xiaochun.xxc";
final String group = "xiaochun.xxc";
final String content = "lessspring-" + System.currentTimeMillis();

Random random = new Random();
int times = 10000;
while (times > 0) {

boolean result = configService.publishConfig(dataId, group, "value" + System.currentTimeMillis());
times--;
Thread.sleep(2000L);

}
Thread th = new Thread(new Runnable() {
@Override
public void run() {
long start = System.currentTimeMillis();
Random random = new Random();
int times = 1000;
while (times > 0) {
try {

for (int i = 0; i < 20; i++) {
configService.publishConfig(dataId + random.nextInt(20), group,
"value" + System.currentTimeMillis());
}
times--;
Thread.sleep(500L);
} catch (Exception e) {
e.printStackTrace();

}
}

System.out.println(times);
System.out.println("Write Done");
}

boolean result = configService.publishConfig(dataId, group, content);
Assert.assertTrue(result);
});

th.start();

Listener listener = new AbstractListener() {
@Override
public void receiveConfigInfo(String configInfo) {
System.out.println("receiveConfigInfo1 :" + configInfo);
System.out.println(new Date() + "receiveConfigInfo1 :" + configInfo);
}
};
configService.getConfigAndSignListener(dataId, group, 5000, listener);

for (int i = 0; i < 20; i++) {
configService.addListener(dataId + i, group, listener);
}

//configService.getConfigAndSignListener(dataId, group, 5000, listener);

boolean result = configService.publishConfig(dataId, group, content);
Assert.assertTrue(result);

// configService.getConfigAndSignListener(dataId, group, 5000, listener);

//configService.removeListener(dataId, group, listener);
//configService.removeConfig(dataId, group);

Expand Down Expand Up @@ -129,16 +197,34 @@ public void receiveConfigInfo(String configInfo) {
};

configService.getConfigAndSignListener(dataId, group, 5000, listener);
System.out.println("");
Thread.sleep(10000L);
System.out.println("Remove config..");
configService.removeListener(dataId, group, listener);

Thread.sleep(10000L);
System.out.println("Add Listen config..");

configService.getConfigAndSignListener(dataId, group, 5000, listener);
Thread th = new Thread(new Runnable() {
@Override
public void run() {
long start = System.currentTimeMillis();
Random random = new Random();
int times = 100;
while (times > 0) {
try {
configService.publishConfig(dataId, group, "value" + System.currentTimeMillis());

times--;
Thread.sleep(5000L);
} catch (Exception e) {
e.printStackTrace();

}
}

System.out.println(times);
System.out.println("Write Done");
}

});

th.start();
Scanner scanner = new Scanner(System.in);
System.out.println("input content");
while (scanner.hasNextLine()) {
Expand Down
Loading
0