本文整理汇总了Java中com.netflix.discovery.shared.Applications.getRegisteredApplications方法的典型用法代码示例。如果您正苦于以下问题:Java Applications.getRegisteredApplications方法的具体用法?Java Applications.getRegisteredApplications怎么用?Java Applications.getRegisteredApplications使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.discovery.shared.Applications
的用法示例。
在下文中一共展示了Applications.getRegisteredApplications方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServices
import com.netflix.discovery.shared.Applications; //导入方法依赖的package包/类
@Override
public List<String> getServices() {
Applications applications = this.eurekaClient.getApplications();
if (applications == null) {
return Collections.emptyList();
}
List<Application> registered = applications.getRegisteredApplications();
List<String> names = new ArrayList<>();
for (Application app : registered) {
if (app.getInstances().isEmpty()) {
continue;
}
names.add(app.getName().toLowerCase());
}
return names;
}
示例2: getEurekaDetails
import com.netflix.discovery.shared.Applications; //导入方法依赖的package包/类
@GET
public Response getEurekaDetails() {
List<EurekaInstanceInfo> instanceInfoList = new ArrayList<EurekaInstanceInfo>();
DiscoveryClient discoveryClient = DiscoveryManager.getInstance().getDiscoveryClient();
if (null != discoveryClient) {
Applications apps = discoveryClient.getApplications();
for (Application app : apps.getRegisteredApplications()) {
for (InstanceInfo inst : app.getInstances()) {
instanceInfoList.add(new EurekaInstanceInfo(inst.getAppName(), inst.getId(), inst.getStatus().name(), inst.getIPAddr(), inst.getHostName()));
}
}
}
GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls();
Gson gson = gsonBuilder.create();
String response = gson.toJson(new KaryonAdminResponse(instanceInfoList));
return Response.ok(response).build();
}
示例3: getApplications
import com.netflix.discovery.shared.Applications; //导入方法依赖的package包/类
private Map<String, Object> getApplications() {
Applications applications = this.eurekaClient.getApplications();
if (applications == null) {
return Collections.emptyMap();
}
Map<String, Object> result = new HashMap<>();
for (Application application : applications.getRegisteredApplications()) {
result.put(application.getName(), application.getInstances().size());
}
return result;
}
示例4: getClusterNames
import com.netflix.discovery.shared.Applications; //导入方法依赖的package包/类
@Override
public List<String> getClusterNames() {
Applications applications = eurekaClient.getApplications();
List<Application> registeredApplications = applications.getRegisteredApplications();
List<String> appNames = new ArrayList<>(registeredApplications.size());
for (Application application : registeredApplications) {
appNames.add(application.getName());
}
log.trace("Using clusters names: " + appNames);
return appNames;
}