forked from easonjim/5_java_example
-
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
Showing
10 changed files
with
184 additions
and
196 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
zookeeper/test1/test1/src/main/java/com/jsoft/testzookeeper/test1/App.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,42 @@ | ||
package com.jsoft.testzookeeper.test1; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) throws JsonProcessingException, InterruptedException { | ||
ConfigManager cfgManager = new ConfigManager(); | ||
ClientApp clientApp = new ClientApp(); | ||
|
||
// 模拟【配置管理中心】初始化时,从db加载配置初始参数 | ||
cfgManager.loadConfigFromDB(); | ||
|
||
// 然后将配置同步到ZK | ||
cfgManager.syncFtpConfigToZk(); | ||
|
||
// 模拟客户端程序运行 | ||
clientApp.run(); | ||
|
||
// 模拟配置修改 | ||
cfgManager.updateFtpConfigToDB(23, "10.6.12.34", "newUser", "newPwd"); | ||
|
||
// 然后将配置同步到ZK | ||
cfgManager.syncFtpConfigToZk(); | ||
|
||
//线程阻塞,让程序保持在后台运行 | ||
new Thread() { | ||
@Override | ||
public void run() { | ||
try { | ||
while (true) { | ||
Thread.sleep(1); | ||
} | ||
} catch (InterruptedException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
}.start(); | ||
} | ||
|
||
} |
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 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,12 @@ | ||
# Configure logging for testing: optionally with log file | ||
log4j.rootLogger=WARN, stdout | ||
# log4j.rootLogger=WARN, stdout, logfile | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n | ||
|
||
log4j.appender.logfile=org.apache.log4j.FileAppender | ||
log4j.appender.logfile.File=target/out.log | ||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n |
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
Oops, something went wrong.