forked from qunarcorp/qmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zh_yu
committed
Dec 17, 2018
1 parent
2c3507e
commit cc3c7e1
Showing
43 changed files
with
1,744 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,4 @@ Thumbs.db | |
# *.zip | ||
# *.tar | ||
# *.tar.gz | ||
catalina.base_IS_UNDEFINED/ | ||
|
||
qconfig_test | ||
catalina.base_IS_UNDEFINED/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
JAVA_HOME="" | ||
JAVA_OPTS="-Xms512m -Xmx512m" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo off | ||
|
||
setlocal | ||
call "%~dp0base.cmd" | ||
|
||
set MAIN=qunar.tc.qmq.task.Bootstrap | ||
|
||
echo on | ||
"%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
QMQ_BIN="${BASH_SOURCE-$0}" | ||
QMQ_BIN="$(dirname "$QMQ_BIN")" | ||
QMQ_BIN_DIR="$(cd "$QMQ_BIN"; pwd)" | ||
QMQ_META_MAIN="qunar.tc.qmq.task.Bootstrap" | ||
|
||
. "$QMQ_BIN_DIR/base.sh" | ||
. "$QMQ_BIN_DIR/watchdog-env.sh" | ||
|
||
if [[ "$JAVA_HOME" != "" ]]; then | ||
JAVA="$JAVA_HOME/bin/java" | ||
else | ||
JAVA=java | ||
fi | ||
|
||
JAVA_OPTS="$JAVA_OPTS -DQMQ_LOG_DIR=$QMQ_LOG_DIR" | ||
QMQ_PID_FILE="$QMQ_PID_DIR/watchdog.pid" | ||
QMQ_DAEMON_OUT="$QMQ_LOG_DIR/watchdog.out" | ||
|
||
CMD=${1:-} | ||
case ${CMD} in | ||
start) | ||
echo -n "Starting qmq watchdog ... " | ||
if [[ -f "$QMQ_PID_FILE" ]]; then | ||
if kill -0 `cat "$QMQ_PID_FILE"` > /dev/null 2>&1; then | ||
echo already running as process `cat "$QMQ_PID_FILE"`. | ||
exit 0 | ||
fi | ||
fi | ||
nohup "$JAVA" -cp "$CLASSPATH" ${JAVA_OPTS} ${QMQ_META_MAIN} > "$QMQ_DAEMON_OUT" 2>&1 < /dev/null & | ||
if [[ $? -eq 0 ]] | ||
then | ||
/bin/echo -n $! > "$QMQ_PID_FILE" | ||
if [[ $? -eq 0 ]]; | ||
then | ||
sleep 1 | ||
echo STARTED | ||
else | ||
echo FAILED TO WRITE PID | ||
exit 1 | ||
fi | ||
else | ||
echo SERVER DID NOT START | ||
exit 1 | ||
fi | ||
;; | ||
start-foreground) | ||
ZOO_CMD=(exec "$JAVA") | ||
"${ZOO_CMD[@]}" -cp "$CLASSPATH" ${JAVA_OPTS} ${QMQ_META_MAIN} | ||
;; | ||
stop) | ||
echo -n "Stopping qmq watchdog ... " | ||
if [[ ! -f "$QMQ_PID_FILE" ]] | ||
then | ||
echo "no watchdog to stop (could not find file $QMQ_PID_FILE)" | ||
else | ||
kill -9 $(cat "$QMQ_PID_FILE") | ||
rm "$QMQ_PID_FILE" | ||
echo STOPPED | ||
fi | ||
exit 0 | ||
;; | ||
*) | ||
echo "Usage: $0 {start|start-foreground|stop}" >&2 | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# (可选)每次扫描客户db如果超过3分钟则退出,等待下次扫描 | ||
sendMessageTaskExecuteTimeout=180000 | ||
#(可选) 多久刷新一次db里的客户端db记录状态 | ||
refreshInterval=180000 | ||
#(可选) 客户端db里的消息多久之前的认为可以重发 | ||
checkInterval=60000 | ||
#(可选) watchdog可以启动多个,与客户端db里的room对应 | ||
namespace=default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
qmq-metaserver/src/main/java/qunar/tc/qmq/meta/management/RegisterClientDbAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package qunar.tc.qmq.meta.management; | ||
|
||
import qunar.tc.qmq.meta.model.ClientDbInfo; | ||
import qunar.tc.qmq.meta.store.ClientDbConfigurationStore; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Optional; | ||
|
||
public class RegisterClientDbAction implements MetaManagementAction { | ||
|
||
private final ClientDbConfigurationStore store; | ||
|
||
public RegisterClientDbAction(ClientDbConfigurationStore store) { | ||
this.store = store; | ||
} | ||
|
||
@Override | ||
public Object handleAction(HttpServletRequest req) { | ||
String type = req.getParameter("type"); | ||
String host = req.getParameter("host"); | ||
int port = Integer.valueOf(req.getParameter("port")); | ||
String userName = req.getParameter("userName"); | ||
String password = req.getParameter("password"); | ||
|
||
String room = req.getParameter("room"); | ||
if (room == null || room.trim().length() == 0) { | ||
room = "default"; | ||
} | ||
|
||
String url = type + "://" + host + ":" + port; | ||
ClientDbInfo clientDbInfo = new ClientDbInfo(); | ||
clientDbInfo.setUrl(url); | ||
clientDbInfo.setUserName(userName); | ||
clientDbInfo.setPassword(password); | ||
clientDbInfo.setRoom(room); | ||
try { | ||
store.insertDb(clientDbInfo); | ||
return Optional.of("register success"); | ||
} catch (Exception e) { | ||
return Optional.of("register failed " + e.getMessage()); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
qmq-metaserver/src/main/java/qunar/tc/qmq/meta/model/ClientDbInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package qunar.tc.qmq.meta.model; | ||
|
||
public class ClientDbInfo { | ||
private String url; | ||
|
||
private String userName; | ||
|
||
private String password; | ||
|
||
private String room; | ||
|
||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public String getRoom() { | ||
return room; | ||
} | ||
|
||
public void setRoom(String room) { | ||
this.room = room; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
qmq-metaserver/src/main/java/qunar/tc/qmq/meta/store/ClientDbConfigurationStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package qunar.tc.qmq.meta.store; | ||
|
||
import qunar.tc.qmq.meta.model.ClientDbInfo; | ||
|
||
public interface ClientDbConfigurationStore { | ||
void insertDb(ClientDbInfo clientDbInfo); | ||
} |
Oops, something went wrong.