本文整理汇总了Java中com.netflix.eureka.EurekaServerContextHolder类的典型用法代码示例。如果您正苦于以下问题:Java EurekaServerContextHolder类的具体用法?Java EurekaServerContextHolder怎么用?Java EurekaServerContextHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EurekaServerContextHolder类属于com.netflix.eureka包,在下文中一共展示了EurekaServerContextHolder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getState
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的package包/类
@Override
public TxState getState() {
TxState state = new TxState();
String ipAddress = EurekaServerContextHolder.getInstance().getServerContext().getApplicationInfoManager().getEurekaInstanceConfig().getIpAddress();
if(!isIp(ipAddress)){
ipAddress = "127.0.0.1";
}
state.setIp(ipAddress);
state.setPort(Constants.socketPort);
state.setMaxConnection(SocketManager.getInstance().getMaxConnection());
state.setNowConnection(SocketManager.getInstance().getNowConnection());
state.setRedisSaveMaxTime(redis_save_max_time);
state.setTransactionNettyDelayTime(transaction_netty_delay_time);
state.setTransactionNettyHeartTime(transaction_netty_heart_time);
state.setSlbList(getServices());
return state;
}
开发者ID:1991wangliang,项目名称:tx-lcn,代码行数:18,代码来源:TxServiceImpl.java
示例2: initEurekaServerContext
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的package包/类
protected void initEurekaServerContext() throws Exception {
// For backward compatibility
JsonXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(),
XStream.PRIORITY_VERY_HIGH);
XmlXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(),
XStream.PRIORITY_VERY_HIGH);
if (isAws(this.applicationInfoManager.getInfo())) {
this.awsBinder = new AwsBinderDelegate(this.eurekaServerConfig,
this.eurekaClientConfig, this.registry, this.applicationInfoManager);
this.awsBinder.start();
}
EurekaServerContextHolder.initialize(this.serverContext);
log.info("Initialized server context");
// Copy registry from neighboring eureka node
int registryCount = this.registry.syncUp();
this.registry.openForTraffic(this.applicationInfoManager, registryCount);
// Register all monitoring statistics.
EurekaMonitors.registerAllStats();
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:25,代码来源:EurekaServerBootstrap.java
示例3: findTxManagerInfo
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的package包/类
/**
* 服务端信息
*
* @return TxManagerInfo
*/
@Override
public TxManagerInfo findTxManagerInfo() {
TxManagerInfo txManagerInfo = new TxManagerInfo();
//设置ip为eureka 上注册的TxManager ip
String ip = EurekaServerContextHolder.getInstance().getServerContext().getApplicationInfoManager().getEurekaInstanceConfig().getIpAddress();
txManagerInfo.setIp(ip);
txManagerInfo.setPort(nettyConfig.getPort());
txManagerInfo.setMaxConnection(SocketManager.getInstance().getMaxConnection());
txManagerInfo.setNowConnection(SocketManager.getInstance().getNowConnection());
txManagerInfo.setTransactionWaitMaxTime(transactionWaitMaxTime);
txManagerInfo.setRedisSaveMaxTime(redisSaveMaxTime);
txManagerInfo.setClusterInfoList(findEurekaService());
return txManagerInfo;
}
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:20,代码来源:TxManagerInfoServiceImpl.java
示例4: setup
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的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
示例5: getServerContext
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的package包/类
private EurekaServerContext getServerContext() {
return EurekaServerContextHolder.getInstance().getServerContext();
}
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:4,代码来源:EurekaResource.java
示例6: getServerContext
import com.netflix.eureka.EurekaServerContextHolder; //导入依赖的package包/类
private EurekaServerContext getServerContext() {
return EurekaServerContextHolder.getInstance().getServerContext();
}
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:4,代码来源:EurekaController.java
注:本文中的com.netflix.eureka.EurekaServerContextHolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论