本文整理汇总了Java中com.netflix.appinfo.DataCenterInfo类的典型用法代码示例。如果您正苦于以下问题:Java DataCenterInfo类的具体用法?Java DataCenterInfo怎么用?Java DataCenterInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataCenterInfo类属于com.netflix.appinfo包,在下文中一共展示了DataCenterInfo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: populateHeader
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
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));
}
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:21,代码来源:EurekaController.java
示例2: populateInstanceInfo
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
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);
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:20,代码来源:EurekaController.java
示例3: setup
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
@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);
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:36,代码来源:EurekaControllerTest.java
示例4: marshall
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
/**
* Private helper that marshals the information from each instance into something that
* Turbine can understand. Override this method for your own implementation for
* parsing Eureka info.
* @param instanceInfo
* @return Instance
*/
Instance marshall(InstanceInfo instanceInfo) {
String hostname = instanceInfo.getHostName();
final String managementPort = instanceInfo.getMetadata().get("management.port");
String port = managementPort == null ? String.valueOf(instanceInfo.getPort()) : managementPort;
String cluster = getClusterName(instanceInfo);
Boolean status = parseInstanceStatus(instanceInfo.getStatus());
if (hostname != null && cluster != null && status != null) {
Instance instance = getInstance(hostname, port, cluster, status);
Map<String, String> metadata = instanceInfo.getMetadata();
boolean securePortEnabled = instanceInfo.isPortEnabled(InstanceInfo.PortType.SECURE);
String securePort = String.valueOf(instanceInfo.getSecurePort());
addMetadata(instance, hostname, port, securePortEnabled, securePort, metadata);
// add amazon metadata
String asgName = instanceInfo.getASGName();
if (asgName != null) {
instance.getAttributes().put(ASG_KEY, asgName);
}
DataCenterInfo dcInfo = instanceInfo.getDataCenterInfo();
if (dcInfo != null && dcInfo.getName().equals(DataCenterInfo.Name.Amazon)) {
AmazonInfo amznInfo = (AmazonInfo) dcInfo;
instance.getAttributes().putAll(amznInfo.getMetadata());
}
return instance;
}
else {
return null;
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:41,代码来源:EurekaInstanceDiscovery.java
示例5: isAws
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
protected boolean isAws(InstanceInfo selfInstanceInfo) {
boolean result = DataCenterInfo.Name.Amazon == selfInstanceInfo
.getDataCenterInfo().getName();
log.info("isAws returned " + result);
return result;
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:7,代码来源:EurekaServerBootstrap.java
示例6: CloudJacksonCodec
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
@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);
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:47,代码来源:CloudJacksonJson.java
示例7: getDataCenterInfo
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
public DataCenterInfo getDataCenterInfo() {
return instanceConfig.getDataCenterInfo();
}
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:4,代码来源:EurekaOneDiscoveryStrategy.java
示例8: KixeyeMyDataCenterInstanceConfig
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
public KixeyeMyDataCenterInstanceConfig(MetadataCollector collector, String namespace,DataCenterInfo dataCenterInfo) {
super(namespace, dataCenterInfo);
this.collector = collector;
}
开发者ID:Kixeye,项目名称:chassis,代码行数:5,代码来源:KixeyeMyDataCenterInstanceConfig.java
示例9: CloudJacksonCodec
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
@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()));
// 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);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:48,代码来源:CloudJacksonJson.java
示例10: getDataCenterInfo
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
public DataCenterInfo getDataCenterInfo() {
return dataCenterInfo;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:4,代码来源:EurekaInstanceConfigBean.java
示例11: setDataCenterInfo
import com.netflix.appinfo.DataCenterInfo; //导入依赖的package包/类
public void setDataCenterInfo(DataCenterInfo dataCenterInfo) {
this.dataCenterInfo = dataCenterInfo;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:4,代码来源:EurekaInstanceConfigBean.java
注:本文中的com.netflix.appinfo.DataCenterInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论