use of com.tencent.polaris.api.pojo.Instance in project polaris-java by polarismesh.
the class RuleBasedRouter method getInstancesOfEnv.
private List<Instance> getInstancesOfEnv(ServiceInstances serviceInstances, String env) {
List<Instance> instances = serviceInstances.getInstances();
List<Instance> retInstances = new ArrayList<>();
for (Instance ins : instances) {
if (env.equals(ins.getMetadata().get("env"))) {
retInstances.add(ins);
}
}
return retInstances;
}
use of com.tencent.polaris.api.pojo.Instance in project sofa-rpc by sofastack.
the class PolarisWatcher method currentProviders.
public List<ProviderInfo> currentProviders() {
List<ProviderInfo> providerInfos = new ArrayList<>();
Instance[] instances = currentData.getInstances();
for (Instance instance : instances) {
ProviderInfo providerInfo = ProviderHelper.toProviderInfo(convertInstanceToUrl(instance.getHost(), instance.getPort(), currentData.getMetadata()));
providerInfos.add(providerInfo);
}
return providerInfos;
}
use of com.tencent.polaris.api.pojo.Instance in project polaris-java-agent by polarismesh.
the class PolarisLoadBalance method doSelect.
@SuppressWarnings("unchecked")
@Override
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
if (null == invokers || invokers.size() == 0) {
return null;
}
String service = url.getServiceInterface();
LOGGER.info("[POLARIS] select instance for service {} by PolarisLoadBalance", service);
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
List<Instance> instances = (List<Instance>) ((List<?>) invokers);
Instance instance = PolarisSingleton.getPolarisOperator().loadBalance(service, key, instances);
return (InstanceInvoker<T>) instance;
}
Aggregations