当前位置: 首页>>代码示例>>Java>>正文


Java CatalogClient类代码示例

本文整理汇总了Java中com.orbitz.consul.CatalogClient的典型用法代码示例。如果您正苦于以下问题:Java CatalogClient类的具体用法?Java CatalogClient怎么用?Java CatalogClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CatalogClient类属于com.orbitz.consul包,在下文中一共展示了CatalogClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: discover

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
public Collection<ServiceInfo> discover(CatalogClient catalogClient, 
                                        String serviceName,
                                        Collection<Integer> ports, 
                                        Collection<String> mustMatchTags) throws Exception {

    Collection<ServiceInfo> services = new ArrayList<ServiceInfo>();
    
    // for each port, we need to append the port to the serviceName base
    for (Integer port : ports) {
        services.addAll(
                super._discover(catalogClient, (serviceName+"-"+port.toString()), ports, mustMatchTags)
                );
        
    }
    
    return services;
    
}
 
开发者ID:bitsofinfo,项目名称:docker-discovery-registrator-consul,代码行数:19,代码来源:MultiServiceNameSinglePortStrategy.java

示例2: configure

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public void configure(final Binder binder) {
    loading();

    cfgs.forEach((id, cfg) -> {
        final Consul consul = build(cfg);
        binder.bind(Consul.class).annotatedWith(Names.named(CONSUL_PREFIX + id)).toInstance(consul);
        binder.bind(AgentClient.class).annotatedWith(Names.named(CONSUL_AGENT_CLIENT_PREFIX + id)).toInstance(consul.agentClient());
        binder.bind(HealthClient.class).annotatedWith(Names.named(CONSUL_HEALTH_CLIENT_PREFIX + id)).toInstance(consul.healthClient());
        binder.bind(KeyValueClient.class).annotatedWith(Names.named(CONSUL_KEY_VALUE_CLIENT_PREFIX + id)).toInstance(consul.keyValueClient());
        binder.bind(CatalogClient.class).annotatedWith(Names.named(CONSUL_CATALOG_CLIENT_PREFIX + id)).toInstance(consul.catalogClient());
        binder.bind(StatusClient.class).annotatedWith(Names.named(CONSUL_STATUS_CLIENT_PREFIX + id)).toInstance(consul.statusClient());
        binder.bind(SessionClient.class).annotatedWith(Names.named(CONSUL_SESSION_CLIENT_PREFIX + id)).toInstance(consul.sessionClient());
        binder.bind(EventClient.class).annotatedWith(Names.named(CONSUL_EVENT_CLIENT_PREFIX + id)).toInstance(consul.eventClient());
        binder.bind(PreparedQueryClient.class).annotatedWith(Names.named(CONSUL_PREPARED_QUERY_CLIENT_PREFIX + id))
                .toInstance(consul.preparedQueryClient());
        binder.bind(CoordinateClient.class).annotatedWith(Names.named(CONSUL_COORDINATE_CLIENT_PREFIX + id))
                .toInstance(consul.coordinateClient());
        binder.bind(OperatorClient.class).annotatedWith(Names.named(CONSUL_OPERATOR_CLIENT + id)).toInstance(consul.operatorClient());
    });

}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:23,代码来源:ConsulModule.java

示例3: getServiceNodes

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
private static List<CatalogService> getServiceNodes(String serviceName) {
    try {
        CatalogClient catalogClient = consul.catalogClient();
        ConsulResponse<List<CatalogService>> serviceResponse = catalogClient.getService(serviceName);
        return serviceResponse.getResponse();
    } catch (NullPointerException e) {
        LOGGER.error("Could not retrieve Consul Catalog Client");
        return null;
    }
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:11,代码来源:ConsulPlugin.java

示例4: start

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
    ServiceTarget target = startContext.getChildTarget();

    CatalogWatcher watcher = new CatalogWatcher();
    target.addService(CatalogWatcher.SERVICE_NAME, watcher)
            .addDependency(CatalogClientService.SERVICE_NAME, CatalogClient.class, watcher.getCatalogClientInjector())
            .addDependency(HealthClientService.SERIVCE_NAME, HealthClient.class, watcher.getHealthClientInjector())
            .addDependency(TopologyManager.SERVICE_NAME, TopologyManager.class, watcher.getTopologyManagerInjector())
            .install();


}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology-consul,代码行数:14,代码来源:ConsulTopologyConnector.java

示例5: start

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
    ServiceTarget target = startContext.getChildTarget();

    CatalogWatcher watcher = new CatalogWatcher();
    target.addService(CatalogWatcher.SERVICE_NAME, watcher)
            .addDependency(CatalogClientService.SERVICE_NAME, CatalogClient.class, watcher.getCatalogClientInjector())
            .addDependency(HealthClientService.SERIVCE_NAME, HealthClient.class, watcher.getHealthClientInjector())
            .addDependency(TopologyManagerActivator.SERVICE_NAME, TopologyManager.class, watcher.getTopologyManagerInjector())
            .install();


}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:14,代码来源:ConsulTopologyConnector.java

示例6: discover

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
public Collection<ServiceInfo> discover(CatalogClient catalogClient, 
                                        String serviceName, 
                                        Collection<Integer> ports,
                                        Collection<String> mustMatchTags) throws Exception {
    
    return super._discover(catalogClient, serviceName, ports, mustMatchTags);
    
}
 
开发者ID:bitsofinfo,项目名称:docker-discovery-registrator-consul,代码行数:9,代码来源:OneServiceNameMultiPortStrategy.java

示例7: getClient

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
/**
 * Construct the client to connect to Consul.
 * 
 * @return CatalogClient
 * @throws MalformedURLException 
 */
private synchronized CatalogClient getClient() throws MalformedURLException {
    if (this.catalogClient == null) {
        this.catalogClient = Consul.builder().
                withUrl(new URL("http", consulHost, consulPort, "")).
                build().
                catalogClient();
    }
    return this.catalogClient;
}
 
开发者ID:Neofonie,项目名称:hazelcast-consul-discovery,代码行数:16,代码来源:ConsulDiscovery.java

示例8: start

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
    ServiceTarget target = startContext.getChildTarget();

    ConsulService consul = new ConsulService(this.url);
    target.addService(ConsulService.SERVICE_NAME, consul)
            .install();

    HealthClientService healthClient = new HealthClientService();
    target.addService(HealthClientService.SERIVCE_NAME, healthClient)
            .addDependency(ConsulService.SERVICE_NAME, Consul.class, healthClient.getConsulInjector())
            .install();

    AgentClientService agentClient = new AgentClientService();
    target.addService(AgentClientService.SERVICE_NAME, agentClient)
            .addDependency(ConsulService.SERVICE_NAME, Consul.class, agentClient.getConsulInjector())
            .install();

    CatalogClientService catalogClient = new CatalogClientService();
    target.addService(CatalogClientService.SERVICE_NAME, catalogClient)
            .addDependency(ConsulService.SERVICE_NAME, Consul.class, catalogClient.getConsulInjector())
            .install();


    this.advertiser = new Advertiser();
    target.addService(Advertiser.SERVICE_NAME, advertiser)
            .addDependency(AgentClientService.SERVICE_NAME, AgentClient.class, advertiser.getAgentClientInjector())
            .install();

    CatalogWatcher watcher = new CatalogWatcher();
    target.addService(CatalogWatcher.SERVICE_NAME, watcher)
            .addDependency(CatalogClientService.SERVICE_NAME, CatalogClient.class, watcher.getCatalogClientInjector())
            .addDependency(HealthClientService.SERIVCE_NAME, HealthClient.class, watcher.getHealthClientInjector())
            .addDependency(TopologyManager.SERVICE_NAME, TopologyManager.class, watcher.getTopologyManagerInjector())
            .install();
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:37,代码来源:ConsulTopologyConnector.java

示例9: getValue

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public CatalogClient getValue() throws IllegalStateException, IllegalArgumentException {
    return this.client;
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:5,代码来源:CatalogClientService.java

示例10: resolveByName

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
@Override
public Set<CatalogService> resolveByName(String name) {
    CatalogClient catalogClient = getConsul().catalogClient();

    List<CatalogService> catalogServices = catalogClient.getService(name).getResponse();
    Set<CatalogService> result = new TreeSet<>((o1, o2) -> o1.getServiceName().compareToIgnoreCase(o2.getServiceName()));
    result.addAll(catalogServices);

    return result;
}
 
开发者ID:amirkibbar,项目名称:plum,代码行数:11,代码来源:Consul4Spring.java

示例11: getCatalogClientInjector

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
public Injector<CatalogClient> getCatalogClientInjector() {
    return this.catalogClientInjector;
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology-consul,代码行数:4,代码来源:CatalogWatcher.java

示例12: _discover

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
protected Collection<ServiceInfo> _discover(CatalogClient catalogClient, 
                                            String serviceName, 
                                            Collection<Integer> ports,
                                            Collection<String> mustMatchTags) throws Exception {
    
    List<ServiceInfo> discoveredServices = new ArrayList<ServiceInfo>();
    
    ConsulResponse<List<CatalogService>> resp = catalogClient.getService(serviceName);
    List<CatalogService> serviceList = resp.getResponse();
    
    logger.trace("_discover() catalogClient.getService("+serviceName+") returned " + serviceList.size() + " results..");
    
    for (CatalogService srv : serviceList) {
    	
    	logger.trace("_discover() evaluating consul service: name:" + srv.getServiceName() + 
    				" serviceId:" + srv.getServiceId() + 
    				" servicePort:" + srv.getServicePort() +
    				" tags: " + Arrays.toString(srv.getServiceTags().toArray()));
        
        if (matchesTags(srv.getServiceTags(),mustMatchTags)) {
            
            try {
                // we parse mapped port from serviceId format "xx:yy:port"
                // registrator sets the serviceId = to this format above for each
                // unique port
                int mappedPort = Integer.valueOf(srv.getServiceId().split(":")[2]);

                // if we care about this mapped port... capture the service 
                if (ports.contains(mappedPort)) {
                    
                	InetAddress exposedAddress = null;
                	if (srv.getServiceAddress() != null) {
                		exposedAddress = InetAddress.getByName(srv.getServiceAddress());
                	} else {
                		// https://www.consul.io/docs/agent/http/catalog.html#ServiceAddress
                		logger.trace("_discover() CatalogService.serviceAddress is null... "
                				+ "falling back to address["+srv.getAddress()+"]");
                		exposedAddress = InetAddress.getByName(srv.getAddress());
                	}
                	
                    ServiceInfo info = new ServiceInfo(srv.getServiceName(),
                                                        srv.getServiceId(),
                                                        exposedAddress,
                                                        srv.getServicePort(),
                                                        mappedPort,
                                                        srv.getServiceTags());
                    discoveredServices.add(info);
                    
                    logger.debug("_discover() Discovered ServiceInfo: " + info);
                    
                } else {
                	logger.trace("_discover() serviceNameToFind=" + serviceName + 
                			", skipping consul service: " + srv.getServiceName() + 
                			" as its mappedPort[" + mappedPort + "] is not in list of "
                					+ "ports we care about: " + Arrays.toString(ports.toArray()) );;
                }
                
            } catch(Exception e) {
                throw new Exception("discover() Unexpected error processing "
                		+ "service: " + srv.getServiceName() + " " + e.getMessage(),e);
            }
            
        } else {
        	logger.trace("_discover() serviceNameToFind=" + serviceName + 
        			" skipping consul service: " + srv.getServiceName() + 
        			" with tags: " + (srv.getServiceTags() != null ? Arrays.toString(srv.getServiceTags().toArray()) : "[no tags]") + 
        			" as they don't contain mustMatchTags: " + Arrays.toString(mustMatchTags.toArray()));
        }
        
    }
    
    return discoveredServices;
}
 
开发者ID:bitsofinfo,项目名称:docker-discovery-registrator-consul,代码行数:74,代码来源:ServiceNameStrategyBase.java

示例13: discover

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
public Collection<ServiceInfo> discover(CatalogClient catalogClient,
String serviceName,
Collection<Integer> ports,
Collection<String> mustMatchTags) throws Exception;
 
开发者ID:bitsofinfo,项目名称:docker-discovery-registrator-consul,代码行数:5,代码来源:ServiceNameStrategy.java

示例14: getCatalogClient

import com.orbitz.consul.CatalogClient; //导入依赖的package包/类
protected CatalogClient getCatalogClient() {
    return client.catalogClient();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ConsulServiceCallServerListStrategy.java


注:本文中的com.orbitz.consul.CatalogClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。