com.netflix.appinfo.DataCenterInfo Java Examples
The following examples show how to use
com.netflix.appinfo.DataCenterInfo.
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: EurekaController.java From didi-eureka-server with MIT License | 6 votes |
private void populateHeader(Map<String, Object> model) { model.put("currentTime", StatusResource.getCurrentTimeAsString()); model.put("upTime", StatusInfo.getUpTime()); model.put("environment", ConfigurationManager.getDeploymentContext() .getDeploymentEnvironment()); model.put("datacenter", ConfigurationManager.getDeploymentContext() .getDeploymentDatacenter()); PeerAwareInstanceRegistry registry = getRegistry(); model.put("registry", registry); model.put("isBelowRenewThresold", registry.isBelowRenewThresold() == 1); DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo(); if (info.getName() == DataCenterInfo.Name.Amazon) { AmazonInfo amazonInfo = (AmazonInfo) info; model.put("amazonInfo", amazonInfo); model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId)); model.put("availabilityZone", amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone)); model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId)); } }
Example #2
Source File: EurekaController.java From didi-eureka-server with MIT License | 6 votes |
private void populateInstanceInfo(Map<String, Object> model, StatusInfo statusInfo) { InstanceInfo instanceInfo = statusInfo.getInstanceInfo(); Map<String, String> instanceMap = new HashMap<>(); instanceMap.put("ipAddr", instanceInfo.getIPAddr()); instanceMap.put("status", instanceInfo.getStatus().toString()); if (instanceInfo.getDataCenterInfo().getName() == DataCenterInfo.Name.Amazon) { AmazonInfo info = (AmazonInfo) instanceInfo.getDataCenterInfo(); instanceMap.put("availability-zone", info.get(AmazonInfo.MetaDataKey.availabilityZone)); instanceMap.put("public-ipv4", info.get(AmazonInfo.MetaDataKey.publicIpv4)); instanceMap.put("instance-id", info.get(AmazonInfo.MetaDataKey.instanceId)); instanceMap.put("public-hostname", info.get(AmazonInfo.MetaDataKey.publicHostname)); instanceMap.put("ami-id", info.get(AmazonInfo.MetaDataKey.amiId)); instanceMap.put("instance-type", info.get(AmazonInfo.MetaDataKey.instanceType)); } model.put("instanceInfo", instanceMap); }
Example #3
Source File: EurekaController.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
private void populateInstanceInfo(Map<String, Object> model, StatusInfo statusInfo) { InstanceInfo instanceInfo = statusInfo.getInstanceInfo(); Map<String, String> instanceMap = new HashMap<>(); instanceMap.put("ipAddr", instanceInfo.getIPAddr()); instanceMap.put("status", instanceInfo.getStatus().toString()); if (instanceInfo.getDataCenterInfo().getName() == DataCenterInfo.Name.Amazon) { AmazonInfo info = (AmazonInfo) instanceInfo.getDataCenterInfo(); instanceMap.put("availability-zone", info.get(AmazonInfo.MetaDataKey.availabilityZone)); instanceMap.put("public-ipv4", info.get(AmazonInfo.MetaDataKey.publicIpv4)); instanceMap.put("instance-id", info.get(AmazonInfo.MetaDataKey.instanceId)); instanceMap.put("public-hostname", info.get(AmazonInfo.MetaDataKey.publicHostname)); instanceMap.put("ami-id", info.get(AmazonInfo.MetaDataKey.amiId)); instanceMap.put("instance-type", info.get(AmazonInfo.MetaDataKey.instanceType)); } model.put("instanceInfo", instanceMap); }
Example #4
Source File: EurekaController.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
private void populateHeader(Map<String, Object> model) { model.put("currentTime", StatusResource.getCurrentTimeAsString()); model.put("upTime", StatusInfo.getUpTime()); model.put("environment", "N/A"); // FIXME: model.put("datacenter", "N/A"); // FIXME: PeerAwareInstanceRegistry registry = getRegistry(); model.put("registry", registry); model.put("isBelowRenewThresold", registry.isBelowRenewThresold() == 1); DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo(); if (info.getName() == DataCenterInfo.Name.Amazon) { AmazonInfo amazonInfo = (AmazonInfo) info; model.put("amazonInfo", amazonInfo); model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId)); model.put("availabilityZone", amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone)); model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId)); } }
Example #5
Source File: MockedDiscoveryServerListTest.java From ribbon with Apache License 2.0 | 5 votes |
static List<InstanceInfo> getDummyInstanceInfo(String appName, List<Server> serverList){ List<InstanceInfo> list = new ArrayList<InstanceInfo>(); for (Server server: serverList) { InstanceInfo info = InstanceInfo.Builder.newBuilder().setAppName(appName) .setHostName(server.getHost()) .setPort(server.getPort()) .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); list.add(info); } return list; }
Example #6
Source File: NacosSyncToEurekaServiceImpl.java From nacos-sync with Apache License 2.0 | 5 votes |
private InstanceInfo buildSyncInstance(Instance instance, TaskDO taskDO) { DataCenterInfo dataCenterInfo = new MyDataCenterInfo(DataCenterInfo.Name.MyOwn); HashMap<String, String> metadata = new HashMap<>(16); metadata.put(SkyWalkerConstants.DEST_CLUSTERID_KEY, taskDO.getDestClusterId()); metadata.put(SkyWalkerConstants.SYNC_SOURCE_KEY, skyWalkerCacheServices.getClusterType(taskDO.getSourceClusterId()).getCode()); metadata.put(SkyWalkerConstants.SOURCE_CLUSTERID_KEY, taskDO.getSourceClusterId()); String homePageUrl = "http://" + instance.getIp() + ":" + instance.getPort(); String serviceName = taskDO.getServiceName(); return new InstanceInfo( instance.getIp() + ":" + serviceName + ":" + instance.getPort(), serviceName, null, instance.getIp(), null, new InstanceInfo.PortWrapper(true, instance.getPort()), null, homePageUrl, homePageUrl + "/info", homePageUrl + "/health", null, serviceName, serviceName, 1, dataCenterInfo, instance.getIp(), InstanceInfo.InstanceStatus.UP, InstanceInfo.InstanceStatus.UNKNOWN, null, new LeaseInfo(30, 90, 0L, 0L, 0L, 0L, 0L), false, metadata, System.currentTimeMillis(), System.currentTimeMillis(), null, null ); }
Example #7
Source File: LoadBalancerTestUtils.java From ribbon with Apache License 2.0 | 5 votes |
static List<InstanceInfo> getDummyInstanceInfo(String appName, String host, String ipAddr, int port){ List<InstanceInfo> list = new ArrayList<InstanceInfo>(); InstanceInfo info = InstanceInfo.Builder.newBuilder().setAppName(appName) .setHostName(host) .setIPAddr(ipAddr) .setPort(port) .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); list.add(info); return list; }
Example #8
Source File: EurekaControllerTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class); when(peerEurekaNodes.getPeerNodesView()) .thenReturn(Collections.<PeerEurekaNode>emptyList()); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); this.infoManager = mock(ApplicationInfoManager.class); this.original = ApplicationInfoManager.getInstance(); setInstance(this.infoManager); when(this.infoManager.getInfo()).thenReturn(instanceInfo); Application myapp = new Application("myapp"); myapp.addInstance(InstanceInfo.Builder.newBuilder().setAppName("myapp") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .setInstanceId("myapp:1").build()); ArrayList<Application> applications = new ArrayList<>(); applications.add(myapp); PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class); when(registry.getSortedApplications()).thenReturn(applications); EurekaServerContext serverContext = mock(EurekaServerContext.class); EurekaServerContextHolder.initialize(serverContext); when(serverContext.getRegistry()).thenReturn(registry); when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes); when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager); }
Example #9
Source File: ArmeriaEurekaClientTest.java From armeria with Apache License 2.0 | 5 votes |
private static com.linecorp.armeria.internal.common.eureka.DataCenterInfo convertDataCenterInfo( DataCenterInfo dataCenterInfo) { final Map<String, String> metadata; if (dataCenterInfo.getName() == Name.Amazon) { metadata = ((AmazonInfo) dataCenterInfo).getMetadata(); } else { metadata = ImmutableMap.of(); } return new com.linecorp.armeria.internal.common.eureka.DataCenterInfo( dataCenterInfo.getName().name(), metadata); }
Example #10
Source File: EurekaControllerTest.java From didi-eureka-server with MIT License | 5 votes |
@Before public void setup() throws Exception { PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class); when(peerEurekaNodes.getPeerNodesView()).thenReturn(Collections.<PeerEurekaNode>emptyList()); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setAppName("test") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); this.infoManager = mock(ApplicationInfoManager.class); this.original = ApplicationInfoManager.getInstance(); setInstance(this.infoManager); when(this.infoManager.getInfo()).thenReturn(instanceInfo); Application myapp = new Application("myapp"); myapp.addInstance(InstanceInfo.Builder.newBuilder() .setAppName("myapp") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .setInstanceId("myapp:1") .build()); ArrayList<Application> applications = new ArrayList<>(); applications.add(myapp); PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class); when(registry.getSortedApplications()).thenReturn(applications); EurekaServerContext serverContext = mock(EurekaServerContext.class); EurekaServerContextHolder.initialize(serverContext); when(serverContext.getRegistry()).thenReturn(registry); when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes); when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager); }
Example #11
Source File: KixeyeMyDataCenterInstanceConfig.java From chassis with Apache License 2.0 | 4 votes |
public KixeyeMyDataCenterInstanceConfig(MetadataCollector collector, String namespace,DataCenterInfo dataCenterInfo) { super(namespace, dataCenterInfo); this.collector = collector; }
Example #12
Source File: EurekaInstanceConfigBean.java From hippo with Apache License 2.0 | 4 votes |
@Override public DataCenterInfo getDataCenterInfo() { return this.dataCenterInfo; }
Example #13
Source File: EurekaInstanceConfigBean.java From hippo with Apache License 2.0 | 4 votes |
public void setDataCenterInfo(DataCenterInfo dataCenterInfo) { this.dataCenterInfo = dataCenterInfo; }
Example #14
Source File: EurekaServerBootstrap.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
protected boolean isAws(InstanceInfo selfInstanceInfo) { boolean result = DataCenterInfo.Name.Amazon == selfInstanceInfo .getDataCenterInfo().getName(); log.info("isAws returned " + result); return result; }
Example #15
Source File: CloudJacksonJson.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") CloudJacksonCodec() { super(); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); SimpleModule module = new SimpleModule("eureka1.x", VERSION); module.addSerializer(DataCenterInfo.class, new DataCenterInfoSerializer()); module.addSerializer(InstanceInfo.class, new CloudInstanceInfoSerializer()); module.addSerializer(Application.class, new ApplicationSerializer()); module.addSerializer(Applications.class, new ApplicationsSerializer( this.getVersionDeltaKey(), this.getAppHashCodeKey())); // TODO: Watch if this causes problems // module.addDeserializer(DataCenterInfo.class, // new DataCenterInfoDeserializer()); module.addDeserializer(LeaseInfo.class, new LeaseInfoDeserializer()); module.addDeserializer(InstanceInfo.class, new CloudInstanceInfoDeserializer(mapper)); module.addDeserializer(Application.class, new ApplicationDeserializer(mapper)); module.addDeserializer(Applications.class, new ApplicationsDeserializer( mapper, this.getVersionDeltaKey(), this.getAppHashCodeKey())); mapper.registerModule(module); HashMap<Class<?>, Supplier<ObjectReader>> readers = new HashMap<>(); readers.put(InstanceInfo.class, () -> mapper.reader() .withType(InstanceInfo.class).withRootName("instance")); readers.put(Application.class, () -> mapper.reader() .withType(Application.class).withRootName("application")); readers.put(Applications.class, () -> mapper.reader() .withType(Applications.class).withRootName("applications")); setField("objectReaderByClass", readers); HashMap<Class<?>, ObjectWriter> writers = new HashMap<>(); writers.put(InstanceInfo.class, mapper.writer().withType(InstanceInfo.class) .withRootName("instance")); writers.put(Application.class, mapper.writer().withType(Application.class) .withRootName("application")); writers.put(Applications.class, mapper.writer().withType(Applications.class) .withRootName("applications")); setField("objectWriterByClass", writers); setField("mapper", mapper); }
Example #16
Source File: EurekaInstanceConfigBean.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
public DataCenterInfo getDataCenterInfo() { return dataCenterInfo; }
Example #17
Source File: EurekaInstanceConfigBean.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
public void setDataCenterInfo(DataCenterInfo dataCenterInfo) { this.dataCenterInfo = dataCenterInfo; }
Example #18
Source File: CloudJacksonJson.java From didi-eureka-server with MIT License | 4 votes |
@SuppressWarnings("deprecation") public CloudJacksonCodec() { super(); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); SimpleModule module = new SimpleModule("eureka1.x", VERSION); module.addSerializer(DataCenterInfo.class, new DataCenterInfoSerializer()); module.addSerializer(InstanceInfo.class, new CloudInstanceInfoSerializer()); module.addSerializer(Application.class, new ApplicationSerializer()); module.addSerializer(Applications.class, new ApplicationsSerializer( this.getVersionDeltaKey(), this.getAppHashCodeKey())); module.addDeserializer(DataCenterInfo.class, new DataCenterInfoDeserializer()); module.addDeserializer(LeaseInfo.class, new LeaseInfoDeserializer()); module.addDeserializer(InstanceInfo.class, new CloudInstanceInfoDeserializer(mapper)); module.addDeserializer(Application.class, new ApplicationDeserializer(mapper)); module.addDeserializer(Applications.class, new ApplicationsDeserializer( mapper, this.getVersionDeltaKey(), this.getAppHashCodeKey())); mapper.registerModule(module); HashMap<Class<?>, ObjectReader> readers = new HashMap<>(); readers.put(InstanceInfo.class, mapper.reader().withType(InstanceInfo.class) .withRootName("instance")); readers.put(Application.class, mapper.reader().withType(Application.class) .withRootName("application")); readers.put(Applications.class, mapper.reader().withType(Applications.class) .withRootName("applications")); setField("objectReaderByClass", readers); HashMap<Class<?>, ObjectWriter> writers = new HashMap<>(); writers.put(InstanceInfo.class, mapper.writer().withType(InstanceInfo.class) .withRootName("instance")); writers.put(Application.class, mapper.writer().withType(Application.class) .withRootName("application")); writers.put(Applications.class, mapper.writer().withType(Applications.class) .withRootName("applications")); setField("objectWriterByClass", writers); setField("mapper", mapper); }
Example #19
Source File: EurekaServerBootstrap.java From didi-eureka-server with MIT License | 4 votes |
protected boolean isAws(InstanceInfo selfInstanceInfo) { boolean result = DataCenterInfo.Name.Amazon == selfInstanceInfo .getDataCenterInfo().getName(); log.info("isAws returned " + result); return result; }