Skip to content

Commit

Permalink
Add gprc support-> server push ack (#3521)
Browse files Browse the repository at this point in the history
* Add gprc support->  server push ack

* Add gprc support-> add lost code

* Add gprc support-> disconnect status change bugfix

* Add gprc support-> optimize rpc port
  • Loading branch information
shiyiyue1102 authored Aug 5, 2020
1 parent 3a77745 commit 05bd510
Show file tree
Hide file tree
Showing 19 changed files with 701 additions and 439 deletions.
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 comments on commit 05bd510

Please sign in to comment.