Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mqtt Cluster
Commits
fd9674c7
Commit
fd9674c7
authored
4 years ago
by
luxurong
Browse files
Options
Download
Email Patches
Plain Diff
pom
parent
0c93e9e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smqtt-bootstrap/src/main/java/io/github/quickmsg/AbstractStarter.java
+24
-0
...rap/src/main/java/io/github/quickmsg/AbstractStarter.java
smqtt-common/src/main/java/io/github/quickmsg/common/bootstrap/BootstrapKey.java
+11
-0
...ava/io/github/quickmsg/common/bootstrap/BootstrapKey.java
with
35 additions
and
0 deletions
+35
-0
smqtt-bootstrap/src/main/java/io/github/quickmsg/AbstractStarter.java
+
24
-
0
View file @
fd9674c7
package
io.github.quickmsg
;
import
io.github.quickmsg.common.bootstrap.BootstrapKey
;
import
io.github.quickmsg.common.cluster.ClusterConfig
;
import
io.github.quickmsg.common.config.SslContext
;
import
io.github.quickmsg.common.utils.PropertiesLoader
;
import
io.github.quickmsg.core.Bootstrap
;
...
...
@@ -8,6 +9,7 @@ import io.netty.channel.WriteBufferWaterMark;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.UUID
;
import
java.util.function.Function
;
/**
...
...
@@ -21,6 +23,9 @@ public abstract class AbstractStarter {
private
static
final
Integer
DEFAULT_WEBSOCKET_MQTT_PORT
=
8999
;
private
static
final
Integer
DEFAULT_CLUSTER_PORT
=
4333
;
private
static
final
Integer
DEFAULT_HTTP_PORT
=
12000
;
...
...
@@ -69,6 +74,9 @@ public abstract class AbstractStarter {
Boolean
httpEnable
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_HTTP_ENABLE
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_HTTP_ENABLE
)))
.
map
(
Boolean:
:
parseBoolean
).
orElse
(
false
);
Boolean
clusterEnable
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_ENABLE
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_ENABLE
)))
.
map
(
Boolean:
:
parseBoolean
).
orElse
(
false
);
Bootstrap
.
BootstrapBuilder
builder
=
Bootstrap
.
builder
();
builder
.
port
(
port
)
...
...
@@ -90,6 +98,22 @@ public abstract class AbstractStarter {
builder
.
sslContext
(
new
SslContext
(
sslCrt
,
sslKey
));
}
}
if
(
clusterEnable
)
{
Integer
clusterPort
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_PORT
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_PORT
)))
.
map
(
Integer:
:
parseInt
).
orElse
(
DEFAULT_CLUSTER_PORT
);
String
clusterUrl
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_URL
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_URL
)))
.
map
(
String:
:
valueOf
).
orElse
(
null
);
String
clusterNode
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_NODE
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_CLUSTER_NODE
)))
.
map
(
String:
:
valueOf
).
orElse
(
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
));
ClusterConfig
clusterConfig
=
ClusterConfig
.
builder
()
.
port
(
clusterPort
)
.
clusterUrl
(
clusterUrl
)
.
nodeName
(
clusterNode
)
.
clustered
(
true
)
.
build
();
builder
.
clusterConfig
(
clusterConfig
);
}
if
(
isWebsocket
)
{
Integer
websocketPort
=
Optional
.
ofNullable
(
params
.
getOrDefault
(
BootstrapKey
.
BOOTSTRAP_WEB_SOCKET_PORT
,
function
.
apply
(
BootstrapKey
.
BOOTSTRAP_WEB_SOCKET_PORT
)))
.
map
(
Integer:
:
parseInt
).
orElse
(
DEFAULT_WEBSOCKET_MQTT_PORT
);
...
...
This diff is collapsed.
Click to expand it.
smqtt-common/src/main/java/io/github/quickmsg/common/bootstrap/BootstrapKey.java
+
11
-
0
View file @
fd9674c7
...
...
@@ -44,5 +44,16 @@ public class BootstrapKey {
public
final
static
String
BOOTSTRAP_HTTP_SSL_KEY
=
"smqtt.http.ssl.key"
;
public
final
static
String
BOOTSTRAP_CLUSTER_ENABLE
=
"smqtt.cluster.enable"
;
public
final
static
String
BOOTSTRAP_CLUSTER_URL
=
"smqtt.cluster.url"
;
public
final
static
String
BOOTSTRAP_CLUSTER_PORT
=
"smqtt.cluster.port"
;
public
final
static
String
BOOTSTRAP_CLUSTER_NODE
=
"smqtt.cluster.node"
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help