本文整理汇总了Java中com.orbitz.consul.option.QueryOptions类的典型用法代码示例。如果您正苦于以下问题:Java QueryOptions类的具体用法?Java QueryOptions怎么用?Java QueryOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryOptions类属于com.orbitz.consul.option包,在下文中一共展示了QueryOptions类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValue
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@InvokeOnHeader(ConsulKeyValueActions.GET_VALUE)
protected void getValue(Message message) throws Exception {
Object result;
if (isValueAsString(message)) {
result = getClient().getValueAsString(
getMandatoryKey(message)
).orNull();
} else {
result = getClient().getValue(
getMandatoryKey(message),
getOption(message, QueryOptions.BLANK, QueryOptions.class)
).orNull();
}
setBodyAndResult(message, result);
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:ConsulKeyValueProducer.java
示例2: getValues
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@InvokeOnHeader(ConsulKeyValueActions.GET_VALUES)
protected void getValues(Message message) throws Exception {
Object result;
if (isValueAsString(message)) {
result = getClient().getValuesAsString(
getMandatoryKey(message)
);
} else {
result = getClient().getValues(
getMandatoryKey(message),
getOption(message, QueryOptions.BLANK, QueryOptions.class)
);
}
setBodyAndResult(message, result);
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:ConsulKeyValueProducer.java
示例3: watch
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@Override
public void watch(EventClient client) {
client.listEvents(
key,
QueryOptions.blockSeconds(configuration.getBlockSeconds(), index.get()).build(),
this
);
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:ConsulEventConsumer.java
示例4: list
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@InvokeOnHeader(ConsulEventActions.LIST)
protected void list(Message message) throws Exception {
setBodyAndResult(
message,
getClient().listEvents(
getKey(message),
getOption(message, QueryOptions.BLANK, QueryOptions.class)
)
);
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:ConsulEventProducer.java
示例5: run
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@Override
public void run() {
if (isRunAllowed()) {
// Refresh session
sessionClient.renewSession(sessionId);
keyValueClient.getValue(
servicePath,
QueryOptions.blockSeconds(ttl / 3, index.get()).build(),
this);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:ConsulRoutePolicy.java
示例6: getAclToken
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
/**
* Method to build an ACL token in a query option.
*
* @param token
* @return QueryOption
*/
public static QueryOptions getAclToken(String token){
if(token == null || token.trim().isEmpty()){
return ImmutableQueryOptions.BLANK;
}
//ACL token for registering as a service on consul, check health and get service catalog
ImmutableQueryOptions.Builder optionBuilder = ImmutableQueryOptions.builder().token(token);
return optionBuilder.build();
}
开发者ID:bitsofinfo,项目名称:hazelcast-consul-discovery-spi,代码行数:17,代码来源:ConsulUtility.java
示例7: queryOptions
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
protected QueryOptions queryOptions() {
return QueryOptions.blockSeconds(configuration.getBlockSeconds(), index.get()).build();
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ConsulKeyValueConsumer.java
示例8: blockingCallTest
import com.orbitz.consul.option.QueryOptions; //导入依赖的package包/类
@Test
public void blockingCallTest() throws InterruptedException {
injects();
keyValueClient.putValue(KEY, VALUE);
final StringBuilder builder = new StringBuilder();
final ConsulResponseCallback<Optional<Value>> callback = new ConsulResponseCallback<Optional<Value>>() {
final AtomicReference<BigInteger> index = new AtomicReference<BigInteger>(null);
@Override
public void onComplete(final ConsulResponse<Optional<Value>> consulResponse) {
if (consulResponse.getResponse().isPresent()) {
final Value v = consulResponse.getResponse().get();
builder.setLength(0);
builder.append(v.getValueAsString().get());
}
index.set(consulResponse.getIndex());
watch();
}
void watch() {
keyValueClient.getValue(KEY, QueryOptions.blockMinutes(5, index.get()).build(), this);
}
@Override
public void onFailure(final Throwable throwable) {
LOGGER.error("Error encountered", throwable);
watch();
}
};
keyValueClient.getValue(KEY, QueryOptions.blockMinutes(5, new BigInteger("0")).build(), callback);
Thread.sleep(1000);
keyValueClient.putValue(KEY, NEW_VALUE);
Thread.sleep(500);
Assert.assertEquals(builder.toString(), NEW_VALUE);
keyValueClient.deleteKey(KEY);
final String delValue = keyValueClient.getValueAsString(KEY).or(DELETED);
Assert.assertEquals(delValue, DELETED);
}
开发者ID:nano-projects,项目名称:nano-framework,代码行数:46,代码来源:ConsulTests.java
注:本文中的com.orbitz.consul.option.QueryOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论