Skip to content

Commit 23ed93e

Browse files
committed
Update Java version to Java11.
1 parent 92331ad commit 23ed93e

File tree

28 files changed

+710
-678
lines changed

28 files changed

+710
-678
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,25 @@
22

33
#### 概述
44
Granite XMPP Server是一个实现XMPP协议的IM服务器,具备以下特征:
5-
65
* 标准兼容
76
* 高度模块化
87
* 高可用性和高扩展性
98
* 易于扩展和集成
109

1110
##### 标准兼容
12-
1311
* 实现互联网标准RFC3920、RFC3921,以及多种XEP扩展协议。
1412
* 实现TLS(SSL)、SASL等标准安全协议。
1513

1614
##### 高度模块化
17-
1815
* 所有XEP通讯协议都被封装成了插件。
19-
* 支持在运行时,动态部署和卸载协议模块。
2016

2117
##### 高可用性和高扩展性
22-
2318
* Granite集群提供高可用性支持,在部分节点宕机的情况下,依然可以持续为应用提供服务。
2419
* Granite集群通过简单的增加集群节点,就可以扩展应用服务能力。
2520

2621
##### 易于扩展和集成
27-
* 无缝集成SpringFramework,可在Granite Component中直接注入Spring Bean,使得开发XMPP协议扩展更为简单。
22+
* 通过Pipeline Extenders扩展点来灵活扩展系统能力。
23+
* 无缝集成SpringFramework,可在Granite Component中直接注入Spring Bean,使得开发XMPP扩展协议更为简单。
2824
* Jabber Component Protocol(XEP-0114)协议支持,易于和第三方系统集成。
2925

3026
#### 使用

cluster/node/appnode/src/main/java/com/thefirstlineofcode/granite/cluster/node/appnode/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static void main(String[] args) {
2828
}
2929

3030
// set log directory for logback(see logback.xml)
31-
System.setProperty("appnode.log.dir", options.getHomeDir() + "/log");
31+
System.setProperty("appnode.logs.dir", options.getHomeDir() + "/logs");
3232

3333
try {
3434
new Starter().start(options);

cluster/node/appnode/src/main/java/com/thefirstlineofcode/granite/cluster/node/appnode/Starter.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
import com.thefirstlineofcode.granite.cluster.node.commons.deploying.DeployPlanException;
3030
import com.thefirstlineofcode.granite.cluster.node.commons.deploying.DeployPlanReader;
3131
import com.thefirstlineofcode.granite.cluster.node.commons.deploying.NodeType;
32-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.IoUtils;
33-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.ZipUtils;
32+
import com.thefirstlineofcode.granite.cluster.node.commons.utils.NodeUtils;
3433

3534
public class Starter {
35+
private static final Logger logger = LoggerFactory.getLogger(Starter.class);
36+
3637
private static final String NAME_PREFIX_GRANITE_SERVER = "granite-server";
3738
private static final String NAME_POSTFIX_JAR = ".jar";
3839
private static final String FILE_NAME_DEPLOY_PLAN = "deploy-plan.ini";
3940
private static final String FILE_NAME_DEPLOY_PLAN_CHECKSUM = "deploy-plan-checksum.txt";
40-
private static final Logger logger = LoggerFactory.getLogger(Starter.class);
4141

4242
public void start(Options options) {
4343
MgtnodeIpAndDeployPlanChecksum mgtnodeIpAndDeployPlanChecksum = null;
@@ -179,12 +179,13 @@ private String getNodeType(Options options, DeployPlan plan) {
179179
}
180180

181181
private void startRuntime(Options options, String nodeType, String mgtnodeIp, String runtimeName) {
182+
String javaVersion = System.getProperty("java.version");
183+
if (!javaVersion.startsWith("11.") && !javaVersion.startsWith("17.")) {
184+
throw new RuntimeException(String.format("Only Java11 && Java17 supported. But your Java version is %s", javaVersion));
185+
}
186+
182187
List<String> cmdList = new ArrayList<>();
183188
cmdList.add("java");
184-
if (options.isRtDebug()) {
185-
cmdList.add("-Xdebug");
186-
cmdList.add(String.format("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s", options.getRtDebugPort()));
187-
}
188189

189190
if (options.getRtJvmOptions() != null) {
190191
StringTokenizer st = new StringTokenizer(options.getRtJvmOptions(), " ");
@@ -194,6 +195,8 @@ private void startRuntime(Options options, String nodeType, String mgtnodeIp, St
194195
}
195196
}
196197

198+
NodeUtils.addVmParametersForIgnite(cmdList);
199+
197200
cmdList.add("-Dgranite.deploy.plan.file=" + new File(options.getConfigurationDir(), FILE_NAME_DEPLOY_PLAN).getPath());
198201
cmdList.add("-Dgranite.node.type=" + nodeType);
199202

@@ -209,6 +212,10 @@ private void startRuntime(Options options, String nodeType, String mgtnodeIp, St
209212
cmdList.add("-Dgranite.log.enable.thirdparties=true");
210213
}
211214

215+
if (options.isRtDebug()) {
216+
cmdList.add(String.format("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:%d", options.getRtDebugPort()));
217+
}
218+
212219
cmdList.add("-jar");
213220
File runtimeDir = getRuntimeDir(options.getRuntimesDir(), runtimeName);
214221
if (!runtimeDir.exists()) {
@@ -258,13 +265,13 @@ private String getServerJarName(File runtimeDir) {
258265

259266
private void unzipLocalRuntime(String runtimesDir, String runtimeName) {
260267
File localRuntimeDir = new File(runtimesDir, runtimeName);
261-
if (localRuntimeDir.exists() && !IoUtils.deleteFileRecursively(localRuntimeDir)) {
268+
if (localRuntimeDir.exists() && !NodeUtils.deleteFileRecursively(localRuntimeDir)) {
262269
throw new RuntimeException(String.format("Can't delete local runtime directory %s.",
263270
localRuntimeDir.getPath()));
264271
}
265272

266273
try {
267-
ZipUtils.unzip(new File(runtimesDir, runtimeName + ".zip"), new File(runtimesDir));
274+
NodeUtils.unzip(new File(runtimesDir, runtimeName + ".zip"), new File(runtimesDir));
268275
} catch (IOException e) {
269276
throw new RuntimeException("Can't unzip runtime.", e);
270277
}
@@ -349,8 +356,8 @@ private void downloadRuntimeZip(String address, int port, String runtimesDir, St
349356
}
350357
throw new RuntimeException("Can't download runtime zip.", e);
351358
} finally {
352-
IoUtils.close(in);
353-
IoUtils.close(out);
359+
NodeUtils.close(in);
360+
NodeUtils.close(out);
354361
}
355362
}
356363

@@ -399,7 +406,7 @@ private String getRuntimeName(String checksum) {
399406

400407
private void saveDeployPlanChecksum(String deployPlanChecksum, String configDir) {
401408
try {
402-
IoUtils.writeToFile(deployPlanChecksum, Paths.get(configDir, FILE_NAME_DEPLOY_PLAN_CHECKSUM));
409+
NodeUtils.writeToFile(deployPlanChecksum, Paths.get(configDir, FILE_NAME_DEPLOY_PLAN_CHECKSUM));
403410
} catch (IOException e) {
404411
throw new RuntimeException("Can't save deploy plan checksum.", e);
405412
}
@@ -421,17 +428,17 @@ private void downloadDeployPlanFile(String address, int port, String configDir)
421428
try {
422429
URL url = new URL("HTTP", address, port, "/deploy/" + FILE_NAME_DEPLOY_PLAN);
423430
in = url.openStream();
424-
IoUtils.writeToFile(in, deployPlanFilePath);
431+
NodeUtils.writeToFile(in, deployPlanFilePath);
425432
} finally {
426-
IoUtils.close(in);
433+
NodeUtils.close(in);
427434
}
428435
}
429436

430437
private String getLocalDeployPlanChecksum(String configurationDir) {
431438
Path localDeployPlanChecksumFilePath = Paths.get(configurationDir, FILE_NAME_DEPLOY_PLAN_CHECKSUM);
432439
if (Files.exists(localDeployPlanChecksumFilePath)) {
433440
try {
434-
return IoUtils.readFile(localDeployPlanChecksumFilePath);
441+
return NodeUtils.readFile(localDeployPlanChecksumFilePath);
435442
} catch (IOException e) {
436443
throw new RuntimeException("Can't read local deploy plan checksum file.", e);
437444
}
@@ -459,7 +466,7 @@ private String tryToGetDeployPlanChecksum(String address, int port) {
459466
} catch (Exception e) {
460467
logger.debug("Invalid mgtnode address: {}.", address);
461468
} finally {
462-
IoUtils.close(in);
469+
NodeUtils.close(in);
463470
}
464471

465472
return null;

cluster/node/appnode/src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<configuration>
22
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
33
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
4-
<fileNamePattern>${appnode.log.dir}/appnode.%d{yyyy-MM-dd}.log</fileNamePattern>
4+
<fileNamePattern>${appnode.logs.dir}/appnode.%d{yyyy-MM-dd}.log</fileNamePattern>
55
<maxHistory>30</maxHistory>
66
</rollingPolicy>
77
<encoder>

cluster/node/commons/src/main/java/com/thefirstlineofcode/granite/cluster/node/commons/deploying/DeployPlan.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.StringUtils;
6+
import com.thefirstlineofcode.granite.cluster.node.commons.utils.NodeUtils;
77

88
public class DeployPlan {
99
private Cluster cluster;
@@ -55,15 +55,15 @@ public String getChecksum() {
5555
nodeTypeStrings[i++] = nodeType.toString();
5656
}
5757

58-
String[] sortedNodeTypeStrings = StringUtils.sort(nodeTypeStrings);
58+
String[] sortedNodeTypeStrings = NodeUtils.sort(nodeTypeStrings);
5959

6060
StringBuilder nodeTypesStringBuilder = new StringBuilder();
6161
for (String nodeTypeString : sortedNodeTypeStrings) {
6262
nodeTypesStringBuilder.append(nodeTypeString).append('|');
6363
}
6464
nodeTypesStringBuilder.deleteCharAt(nodeTypesStringBuilder.length() - 1);
6565

66-
return StringUtils.getChecksum(cluster.toString() + "-" + global.toString() + "-" + nodeTypesStringBuilder.toString());
66+
return NodeUtils.getChecksum(cluster.toString() + "-" + global.toString() + "-" + nodeTypesStringBuilder.toString());
6767
}
6868

6969
public String getAppnodeRuntimeString(String nodeTypeName) {
@@ -81,7 +81,7 @@ public String getAppnodeRuntimeString(String nodeTypeName) {
8181
}
8282

8383
public String getChecksum(String nodeTypeName) {
84-
return StringUtils.getChecksum(getAppnodeRuntimeString(nodeTypeName));
84+
return NodeUtils.getChecksum(getAppnodeRuntimeString(nodeTypeName));
8585
}
8686

8787
}

cluster/node/commons/src/main/java/com/thefirstlineofcode/granite/cluster/node/commons/deploying/DeployPlanReader.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
import java.util.ArrayList;
88
import java.util.List;
99
import java.util.Map.Entry;
10-
11-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.SectionalProperties;
12-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.StringUtils;
13-
1410
import java.util.Properties;
1511
import java.util.StringTokenizer;
1612

13+
import com.thefirstlineofcode.granite.cluster.node.commons.utils.NodeUtils;
14+
import com.thefirstlineofcode.granite.cluster.node.commons.utils.SectionalProperties;
15+
1716
public class DeployPlanReader implements IDeployPlanReader {
1817
private static final String SECTION_NAME_GLOBAL = "global";
1918
private static final String PROPERTY_NAME_DB_NAME = "db-name";
@@ -231,9 +230,9 @@ private NodeType readNodeTypeSection(String nodeTypeName, Cluster cluster, Prope
231230
for (Entry<Object, Object> entry : properties.entrySet()) {
232231
String key = (String)entry.getKey();
233232
if (PROPERTY_NAME_ABILITIES.equals(key)) {
234-
nodeType.setAbilities(StringUtils.stringToArray((String)entry.getValue()));
233+
nodeType.setAbilities(NodeUtils.stringToArray((String)entry.getValue()));
235234
} else if (PROPERTY_NAME_PROTOCOLS.equals(key)) {
236-
nodeType.setProtocols(StringUtils.stringToArray((String)entry.getValue()));
235+
nodeType.setProtocols(NodeUtils.stringToArray((String)entry.getValue()));
237236
} else {
238237
throw new DeployPlanException(String.format("Invalid property in 'node' section. Property name: %s.", key));
239238
}
@@ -321,9 +320,9 @@ private Cluster readClusterSection(Properties properties) throws DeployPlanExcep
321320
if (PROPERTY_NAME_DOMAIN_NAME.equals(key)) {
322321
cluster.setDomainName(value);
323322
} else if (PROPERTY_NAME_DOMAIN_ALIAS_NAMES.equals(key)) {
324-
cluster.setDomainAliasNames(StringUtils.stringToArray(value));
323+
cluster.setDomainAliasNames(NodeUtils.stringToArray(value));
325324
} else if (PROPERTY_NAME_NODE_TYPES.equals(key)) {
326-
cluster.setNodeTypes(StringUtils.stringToArray(value));
325+
cluster.setNodeTypes(NodeUtils.stringToArray(value));
327326
} else {
328327
throw new DeployPlanException(String.format("Invalid property in 'cluster' section. Property name: %s.", key));
329328
}

cluster/node/commons/src/main/java/com/thefirstlineofcode/granite/cluster/node/commons/deploying/NodeType.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Properties;
66
import java.util.Set;
77

8-
import com.thefirstlineofcode.granite.cluster.node.commons.utils.StringUtils;
8+
import com.thefirstlineofcode.granite.cluster.node.commons.utils.NodeUtils;
99

1010
public class NodeType {
1111
private String[] abilities;
@@ -66,7 +66,7 @@ private String getNodeTypeString() {
6666
}
6767

6868
private String getProtocolsString() {
69-
String[] sortedProtocols = StringUtils.sort(getProtocols());
69+
String[] sortedProtocols = NodeUtils.sort(getProtocols());
7070
StringBuilder sb = new StringBuilder();
7171
sb.append("protocols[");
7272
for (String protocol : sortedProtocols) {
@@ -96,7 +96,7 @@ private String getConfigurationString(Properties configuration) {
9696

9797
Set<Object> keySet = configuration.keySet();
9898
String[] keys = keySet.toArray(new String[keySet.size()]);
99-
keys = StringUtils.sort(keys);
99+
keys = NodeUtils.sort(keys);
100100

101101
StringBuilder sb = new StringBuilder();
102102
for (String key : keys) {
@@ -114,7 +114,7 @@ private String getConfigurationString(Properties configuration) {
114114
}
115115

116116
private String getAbilitiesString() {
117-
String[] sortedAbilities = StringUtils.sort(getAbilities());
117+
String[] sortedAbilities = NodeUtils.sort(getAbilities());
118118
StringBuilder sb = new StringBuilder();
119119
sb.append("abilities[");
120120
for (String ability : sortedAbilities) {

0 commit comments

Comments
 (0)