作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.xjeffrose.xio.storage.ZooKeeperWriteProvider
类的一些代码示例,展示了ZooKeeperWriteProvider
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperWriteProvider
类的具体详情如下:
包路径:com.xjeffrose.xio.storage.ZooKeeperWriteProvider
类名称:ZooKeeperWriteProvider
暂无
代码示例来源:origin: xjdr/xio
public static Configurator build(Config config) {
Config configurationUpdateServer = config.getConfig("configurationUpdateServer");
if (configurationUpdateServer.getBoolean("enabled") == false) {
return new NullConfigurator();
}
CuratorFramework client = new ZooKeeperClientFactory(config.getConfig("zookeeper")).newClient();
client.start();
ZooKeeperWriteProvider zkWriter = new ZooKeeperWriteProvider(new ThriftMarshaller(), client);
ZooKeeperReadProvider zkReader = new ZooKeeperReadProvider(new ThriftUnmarshaller(), client);
Config configurationManager = config.getConfig("configurationManager");
Ruleset rules = new Ruleset(configurationManager);
rules.read(zkReader);
ZooKeeperUpdateHandler zkUpdater = new ZooKeeperUpdateHandler(zkWriter, rules);
ZooKeeperValidator zkValidator = new ZooKeeperValidator(zkReader, rules, configurationManager);
Duration writeInterval = configurationUpdateServer.getDuration("writeInterval");
InetSocketAddress serverAddress =
new InetSocketAddress(
configurationUpdateServer.getString("bindIp"),
configurationUpdateServer.getInt("bindPort"));
Configurator server =
new Configurator(zkUpdater, writeInterval, serverAddress, rules, zkValidator);
return server;
}
}
代码示例来源:origin: xjdr/xio
String path = "/some/path/to/nodes/ipRules";
ZooKeeperWriteProvider provider = new ZooKeeperWriteProvider(marshaller, client);
provider.write(path, config);
代码示例来源:origin: xjdr/xio
@Test
public void testWriteHostnameDeterministicRuleEngineConfig() throws Exception {
try (TestingServer server = new TestingServer()) {
server.start();
HostnameDeterministicRuleEngineConfig config = new HostnameDeterministicRuleEngineConfig();
config.blacklistHost("localhost");
config.blacklistHost("localhost.localdomain");
config.whitelistHost("google.com");
ThriftMarshaller marshaller = new ThriftMarshaller();
RetryPolicy retryPolicy = new RetryOneTime(1);
try (CuratorFramework client =
CuratorFrameworkFactory.newClient(server.getConnectString(), retryPolicy)) {
client.start();
String path = "/some/path/to/nodes/hostRules";
ZooKeeperWriteProvider provider = new ZooKeeperWriteProvider(marshaller, client);
provider.write(path, config);
byte[] data = client.getData().forPath(path);
ThriftUnmarshaller unmarshaller = new ThriftUnmarshaller();
HostnameDeterministicRuleEngineConfig read = new HostnameDeterministicRuleEngineConfig();
unmarshaller.unmarshall(read, data);
assertEquals(config, read);
}
}
}
代码示例来源:origin: xjdr/xio
@Test
public void testWriteHttp1DeterministicRuleEngineConfig() throws Exception {
try (TestingServer server = new TestingServer()) {
server.start();
Http1DeterministicRuleEngineConfig config = new Http1DeterministicRuleEngineConfig();
HashMultimap<String, String> headers = HashMultimap.create();
headers.put("User-Agent", "Bad-actor: 1.0");
Http1DeterministicRuleEngineConfig.Rule bad =
new Http1DeterministicRuleEngineConfig.Rule(
HttpMethod.GET, "/path/to/failure", HttpVersion.HTTP_1_0, headers);
Http1DeterministicRuleEngineConfig.Rule good =
new Http1DeterministicRuleEngineConfig.Rule(null, null, null, null);
config.blacklistRule(bad);
config.whitelistRule(good);
ThriftMarshaller marshaller = new ThriftMarshaller();
RetryPolicy retryPolicy = new RetryOneTime(1);
try (CuratorFramework client =
CuratorFrameworkFactory.newClient(server.getConnectString(), retryPolicy)) {
client.start();
String path = "/some/path/to/nodes/http1Rules";
ZooKeeperWriteProvider provider = new ZooKeeperWriteProvider(marshaller, client);
provider.write(path, config);
byte[] data = client.getData().forPath(path);
ThriftUnmarshaller unmarshaller = new ThriftUnmarshaller();
Http1DeterministicRuleEngineConfig read = new Http1DeterministicRuleEngineConfig();
unmarshaller.unmarshall(read, data);
assertEquals(config, read);
}
}
}
本文整理了Java中com.xjeffrose.xio.storage.ZooKeeperWriteProvider.()方法的一些代码示例,展示了ZooKeeperWriteProvider.()的
我是一名优秀的程序员,十分优秀!