本文整理汇总了Java中com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo类的典型用法代码示例。如果您正苦于以下问题:Java BasicDataCenterInfo类的具体用法?Java BasicDataCenterInfo怎么用?Java BasicDataCenterInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicDataCenterInfo类属于com.netflix.eureka2.registry.datacenter包,在下文中一共展示了BasicDataCenterInfo类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
List<NetworkAddress> na = Collections.singletonList(new NetworkAddress("private",
NetworkAddress.ProtocolType.IPv4, "localhost", "myHost"));
ServicePort sp = new ServicePort("port", 8088, false, null);
DataCenterInfo myDataCenter = new BasicDataCenterInfo("TestDataCenter", na);
InstanceInfo ii = new InstanceInfo.Builder()
.withId("testDataCenterInfo")
.withPorts(sp)
.withDataCenterInfo(myDataCenter)
.build();
this.ii = ii;
testServer.start();
}
示例2: createInstanceInfo
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
protected InstanceInfo createInstanceInfo(int port) {
final HashSet<ServicePort> ports = new HashSet<>(Arrays.asList(new ServicePort(port, false)));
String hostAddress = "unknown";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
hostAddress = "unknown-" + UUID.randomUUID();
}
return new InstanceInfo.Builder()
.withId(hostAddress + "-" + port)
.withApp("reactive-lab")
.withStatus(InstanceInfo.Status.UP)
.withVipAddress(eurekaVipAddress)
.withPorts(ports)
.withDataCenterInfo(BasicDataCenterInfo.fromSystemData())
.build();
}
示例3: testInterestSubscriber
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
@Test
public void testInterestSubscriber() throws Exception {
List<NetworkAddress> na = Collections.singletonList(new NetworkAddress("public",
NetworkAddress.ProtocolType.IPv4, "192.168.0.1", "myHost"));
DataCenterInfo myDataCenter = new BasicDataCenterInfo("TestDataCenter", na);
InstanceInfo ii = new InstanceInfo.Builder()
.withId("testDataCenterInfo")
.withDataCenterInfo(myDataCenter)
.build();
ChangeNotification<InstanceInfo> cn = new ChangeNotification<>(ChangeNotification.Kind.Add, ii);
InstanceInfoModel.interestSubscriber(cn);
assert(InstanceInfoModel.getInstanceInfo().values().contains(cn.getData()));
}
示例4: setUp
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
List<NetworkAddress> na = Collections.singletonList(new NetworkAddress("public",
NetworkAddress.ProtocolType.IPv4, "192.168.0.1", "myHost"));
ServicePort sp = new ServicePort("port", 8080, false, null);
DataCenterInfo myDataCenter = new BasicDataCenterInfo("pluto-dc", na);
InstanceInfo ii = new InstanceInfo.Builder()
.withId("testDataCenterInfo")
.withPorts(sp)
.withDataCenterInfo(myDataCenter)
.build();
this.ii = ii;
ChangeNotification<InstanceInfo> cn = new ChangeNotification<>(ChangeNotification.Kind.Add, ii);
InstanceInfoModel.interestSubscriber(cn);
}
示例5: initializeInstanceInfos
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
private void initializeInstanceInfos(int count) {
for (int n = 0; n < count; n++) {
List<NetworkAddress> na = Collections.singletonList(new NetworkAddress("public",
NetworkAddress.ProtocolType.IPv4, "192.168.0." + Integer.toString(n + 1),
"myHost-" + Integer.toString(n)));
DataCenterInfo dc = new BasicDataCenterInfo("datacenter-" + Integer.toString(n), na);
InstanceInfo ii = new InstanceInfo.Builder()
.withId("instance-info-id-" + Integer.toString(n))
.withDataCenterInfo(dc)
.build();
ChangeNotification<InstanceInfo> cn = new ChangeNotification<>(ChangeNotification.Kind.Add, ii);
InstanceInfoModel.interestSubscriber(cn);
}
}
示例6: registerWithEureka
import com.netflix.eureka2.registry.datacenter.BasicDataCenterInfo; //导入依赖的package包/类
public static void registerWithEureka(int serverPort, EurekaClient client, String vipAddress) {
final HashSet<ServicePort> ports = new HashSet<>(Arrays.asList(new ServicePort(serverPort, false)));
InstanceInfo instance = new InstanceInfo.Builder()
.withId(String.valueOf(serverPort))
.withApp("mock_server")
.withStatus(InstanceInfo.Status.UP)
.withVipAddress(vipAddress)
.withPorts(ports)
.withDataCenterInfo(BasicDataCenterInfo.fromSystemData())
.build();
client.register(instance).toBlocking().lastOrDefault(null); // Wait till the registration is successful.
}