Java Code Examples for com.netflix.appinfo.InstanceInfo#isPortEnabled()
The following examples show how to use
com.netflix.appinfo.InstanceInfo#isPortEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmeriaEurekaClientTest.java From armeria with Apache License 2.0 | 6 votes |
private static com.linecorp.armeria.internal.common.eureka.InstanceInfo convertInstanceInfo( InstanceInfo info) { final PortWrapper port = new PortWrapper(info.isPortEnabled(PortType.UNSECURE), info.getPort()); final PortWrapper securePort = new PortWrapper(info.isPortEnabled(PortType.SECURE), info.getSecurePort()); return new com.linecorp.armeria.internal.common.eureka.InstanceInfo( info.getInstanceId(), info.getAppName(), info.getAppGroupName(), info.getHostName(), info.getIPAddr(), info.getVIPAddress(), info.getSecureVipAddress(), port, securePort, com.linecorp.armeria.internal.common.eureka.InstanceInfo.InstanceStatus .toEnum(info.getStatus().name()), info.getHomePageUrl(), info.getStatusPageUrl(), info.getHealthCheckUrl(), info.getSecureHealthCheckUrl(), convertDataCenterInfo(info.getDataCenterInfo()), convertLeaseInfo(info.getLeaseInfo()), info.getMetadata()); }
Example 2
Source File: APIDocRetrievalService.java From api-layer with Eclipse Public License 2.0 | 5 votes |
/** * Creates a URL from the routing metadata 'apiml.routes.api-doc.serviceUrl' when 'apiml.apiInfo.swaggerUrl' is * not present * * @param instanceInfo the information about service instance * @return the URL of API doc endpoint * @deprecated Added to support services which were on-boarded before 'apiml.apiInfo.swaggerUrl' parameter was * introduced. It will be removed when all services will be using the new configuration style. */ @Deprecated private String createApiDocUrlFromRouting(InstanceInfo instanceInfo, RoutedServices routes) { String scheme; int port; if (instanceInfo.isPortEnabled(InstanceInfo.PortType.SECURE)) { scheme = "https"; port = instanceInfo.getSecurePort(); } else { scheme = "http"; port = instanceInfo.getPort(); } String path = null; RoutedService route = routes.findServiceByGatewayUrl("api/v1/api-doc"); if (route != null) { path = route.getServiceUrl(); } if (path == null) { throw new ApiDocNotFoundException("No API Documentation defined for service " + instanceInfo.getAppName().toLowerCase() + " ."); } UriComponents uri = UriComponentsBuilder .newInstance() .scheme(scheme) .host(instanceInfo.getHostName()) .port(port) .path(path) .build(); return uri.toUriString(); }
Example 3
Source File: CachedProductFamilyService.java From api-layer with Eclipse Public License 2.0 | 5 votes |
/** * Create a APIService object using the instances metadata * * @param instanceInfo the service instance * @return a APIService object */ private APIService createAPIServiceFromInstance(InstanceInfo instanceInfo) { boolean secureEnabled = instanceInfo.isPortEnabled(InstanceInfo.PortType.SECURE); String instanceHomePage = getInstanceHomePageUrl(instanceInfo); return new APIService( instanceInfo.getAppName().toLowerCase(), instanceInfo.getMetadata().get(SERVICE_TITLE), instanceInfo.getMetadata().get(SERVICE_DESCRIPTION), secureEnabled, instanceHomePage); }
Example 4
Source File: InstanceInfoMapper.java From eureka-consul-adapter with MIT License | 5 votes |
private int getPort(InstanceInfo instanceInfo) { if (instanceInfo.isPortEnabled(SECURE)) { return instanceInfo.getSecurePort(); } else { return instanceInfo.getPort(); } }
Example 5
Source File: DiscoveryEnabledServer.java From ribbon with Apache License 2.0 | 5 votes |
public DiscoveryEnabledServer(final InstanceInfo instanceInfo, boolean useSecurePort, boolean useIpAddr) { super(useIpAddr ? instanceInfo.getIPAddr() : instanceInfo.getHostName(), instanceInfo.getPort()); if(useSecurePort && instanceInfo.isPortEnabled(PortType.SECURE)) super.setPort(instanceInfo.getSecurePort()); this.instanceInfo = instanceInfo; this.serviceInfo = new MetaInfo() { @Override public String getAppName() { return instanceInfo.getAppName(); } @Override public String getServerGroup() { return instanceInfo.getASGName(); } @Override public String getServiceIdForDiscovery() { return instanceInfo.getVIPAddress(); } @Override public String getInstanceId() { return instanceInfo.getId(); } }; }