forked from weibocom/motan
-
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
5 changed files
with
191 additions
and
125 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...n-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkNodeType.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 com.weibo.api.motan.registry.zookeeper; | ||
|
||
enum ZkNodeType { | ||
AVAILABLE_SERVER, | ||
UNAVAILABLE_SERVER, | ||
CLIENT | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...try-zookeeper/src/test/java/com/weibo/api/motan/registry/zookeeper/EmbeddedZookeeper.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,51 @@ | ||
package com.weibo.api.motan.registry.zookeeper; | ||
|
||
import org.I0Itec.zkclient.ZkClient; | ||
import org.apache.zookeeper.server.ServerConfig; | ||
import org.apache.zookeeper.server.ZooKeeperServerMain; | ||
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
public class EmbeddedZookeeper { | ||
private static Properties properties = new Properties(); | ||
|
||
static { | ||
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg"); | ||
try { | ||
properties.load(in); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private ZooKeeperServerMain zookeeperServer; | ||
private Thread t1; | ||
|
||
public void start() throws IOException, QuorumPeerConfig.ConfigException { | ||
Properties properties = new Properties(); | ||
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg"); | ||
properties.load(in); | ||
|
||
QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig(); | ||
quorumConfiguration.parseProperties(properties); | ||
in.close(); | ||
|
||
zookeeperServer = new ZooKeeperServerMain(); | ||
final ServerConfig configuration = new ServerConfig(); | ||
configuration.readFrom(quorumConfiguration); | ||
|
||
t1 = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
zookeeperServer.runFromConfig(configuration); | ||
} catch (IOException e) { | ||
} | ||
} | ||
}); | ||
t1.start(); | ||
} | ||
} |
Oops, something went wrong.