Search in sources :

Example 1 with Instance

use of org.apache.servicecomb.localregistry.RegistryBean.Instance in project java-chassis by ServiceComb.

the class RegistryBeansConfiguration method demoLocalRegistryServerBean.

@Bean
public RegistryBean demoLocalRegistryServerBean() {
    List<String> endpoints = new ArrayList<>();
    endpoints.add("rest://localhost:8080");
    List<Instance> instances = new ArrayList<>();
    instances.add(new Instance().setEndpoints(endpoints));
    return new RegistryBean().setServiceName("demo-local-registry-server-bean").setId("002").setVersion("0.0.3").setAppId("demo-local-registry").addSchemaId("ServerEndpoint").addSchemaId("CodeFirstEndpoint").setInstances(new Instances().setInstances(instances));
}
Also used : Instances(org.apache.servicecomb.localregistry.RegistryBean.Instances) Instance(org.apache.servicecomb.localregistry.RegistryBean.Instance) RegistryBean(org.apache.servicecomb.localregistry.RegistryBean) ArrayList(java.util.ArrayList) RegistryBean(org.apache.servicecomb.localregistry.RegistryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with Instance

use of org.apache.servicecomb.localregistry.RegistryBean.Instance in project java-chassis by ServiceComb.

the class LocalRegistryStore method addInstances.

private void addInstances(RegistryBean bean, Microservice microservice) {
    Map<String, MicroserviceInstance> instanceMap = new ConcurrentHashMap<>();
    microserviceInstanceMap.put(microservice.getServiceId(), instanceMap);
    for (Instance item : bean.getInstances().getInstances()) {
        MicroserviceInstance instance = new MicroserviceInstance();
        instance.setInstanceId(UUID.randomUUID().toString());
        instance.setEndpoints(item.getEndpoints());
        instance.setServiceId(microservice.getServiceId());
        instanceMap.put(instance.getInstanceId(), instance);
    }
}
Also used : MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) Instance(org.apache.servicecomb.localregistry.RegistryBean.Instance) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Instance (org.apache.servicecomb.localregistry.RegistryBean.Instance)2 ArrayList (java.util.ArrayList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 RegistryBean (org.apache.servicecomb.localregistry.RegistryBean)1 Instances (org.apache.servicecomb.localregistry.RegistryBean.Instances)1 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)1 Bean (org.springframework.context.annotation.Bean)1