com.orbitz.consul.option.ImmutableQueryOptions Java Examples

The following examples show how to use com.orbitz.consul.option.ImmutableQueryOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogWatcher.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private void setupWatcher(String serviceName) {
    if (watchers.containsKey(serviceName)) {
        return;
    }
    QueryOptions options = ImmutableQueryOptions.builder()
            .build();

    ServiceHealthCache healthCache = ServiceHealthCache.newCache(
            this.healthClientInjector.getValue(),
            serviceName,
            true,
            options,
            5
    );

    try {
        healthCache.addListener(new ServiceCacheListener(serviceName, this.topologyManagerInjector.getValue()));
        healthCache.start();
        healthCache.awaitInitialized(1, TimeUnit.SECONDS);
        this.watchers.put(serviceName, healthCache);
    } catch (Exception e) {
        ConsulTopologyMessages.MESSAGES.errorSettingUpCatalogWatcher(serviceName, e);
    }
}
 
Example #2
Source File: ConsulUtility.java    From hazelcast-consul-discovery-spi with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}