use of info.xiancloud.core.distribution.service_discovery.ApplicationInstance in project xian by happyyangyuan.
the class ApplicationRouter method loadBalancedInstance.
public ApplicationInstance loadBalancedInstance(String application) throws ApplicationOfflineException, ApplicationUndefinedException {
ApplicationInstance instance = localInstance(application);
if (instance != null)
return instance;
newestDefinition(application);
if (ApplicationDiscovery.singleton != null)
instance = ApplicationDiscovery.singleton.lb(application);
if (instance != null)
return instance;
throw new ApplicationOfflineException(application);
}
use of info.xiancloud.core.distribution.service_discovery.ApplicationInstance in project xian by happyyangyuan.
the class ApplicationRouter method firstInstance.
@Override
public ApplicationInstance firstInstance(String application) throws ApplicationOfflineException, ApplicationUndefinedException {
ApplicationInstance instance = localInstance(application);
if (instance != null)
return instance;
newestDefinition(application);
if (ApplicationDiscovery.singleton != null)
instance = ApplicationDiscovery.singleton.firstInstance(application);
if (instance != null)
return instance;
throw new ApplicationOfflineException(application);
}
use of info.xiancloud.core.distribution.service_discovery.ApplicationInstance in project xian by happyyangyuan.
the class ApplicationRouter method allInstances.
/**
* @return 根据目标获取相应的客户端列表, 目前本方法主要提供一致性哈希节点id列表入参;
*/
public List<ApplicationInstance> allInstances(String application) throws ApplicationOfflineException, ApplicationUndefinedException {
newestDefinition(application);
List<ApplicationInstance> instances;
if (ApplicationDiscovery.singleton != null)
instances = ApplicationDiscovery.singleton.all(application);
else {
instances = new ArrayList<>();
instances.add(localInstance(application));
}
if (instances.isEmpty())
throw new ApplicationOfflineException(application);
/*instances.sort(Comparator.comparing(ApplicationInstance::getNodeId));
we do not sort this any more, if you want to use the consistent hash, sort by yourself.*/
return instances;
}
Aggregations