• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Applications类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.netflix.discovery.shared.Applications的典型用法代码示例。如果您正苦于以下问题:Java Applications类的具体用法?Java Applications怎么用?Java Applications使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Applications类属于com.netflix.discovery.shared包,在下文中一共展示了Applications类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testSimpleDiscovery

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void testSimpleDiscovery(){
    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();

    verify(requestHandler, timeout(5000).times(2)).register(captor.capture());
    response = generateMockResponse(captor.getAllValues());
    when(requestHandler.getApplications()).thenReturn(response);

    assertClusterSizeEventually(2, hz1);
    assertClusterSizeEventually(2, hz2);

    HazelcastInstance client = factory.newHazelcastClient();
    reset(requestHandler);
    when(requestHandler.getApplications()).thenReturn(response);
    verify(requestHandler, timeout(1000).times(0)).register(Matchers.<InstanceInfo>any());
    assertClusterSizeEventually(2, client);
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:24,代码来源:HazelcastClientTestCase.java


示例2: testExternalRegistration

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void testExternalRegistration(){
    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("self-registration", "false");

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(2, hz1);
    assertClusterSizeEventually(2, hz2);

    verify(requestHandler, after(5000).never()).register(any(InstanceInfo.class));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:20,代码来源:HazelcastClientTestCase.java


示例3: testNamespaceRegistration

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void testNamespaceRegistration(){
    final String appName = "other";
    final String namespace = "hz";
    configure(namespace, appName);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList(), appName);
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("namespace", namespace);

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(1, hz1);

    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);
    verify(requestHandler, timeout(5000).atLeastOnce()).register(captor.capture());

    String actual = captor.getValue().getAppName().toLowerCase();
    assertThat(actual, is(appName));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:26,代码来源:HazelcastClientTestCase.java


示例4: mappingJacksonHttpMessageConverter

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
/**
 * Provides the serialization configurations required by the Eureka Server. JSON
 * content exchanged with eureka requires a root node matching the entity being
 * serialized or deserialized. Achived with
 * {@link SerializationFeature.WRAP_ROOT_VALUE} and
 * {@link DeserializationFeature.UNWRAP_ROOT_VALUE}.
 * {@link PropertyNamingStrategy.SnakeCaseStrategy} is applied to the underlying
 * {@link ObjectMapper}.
 * 
 * 
 * @return
 */
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
	MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
	converter.setObjectMapper(new ObjectMapper()
			.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE));

	SimpleModule jsonModule = new SimpleModule();
	jsonModule.setSerializerModifier(createJsonSerializerModifier());//keyFormatter, compact));
	converter.getObjectMapper().registerModule(jsonModule);

	converter.getObjectMapper().configure(SerializationFeature.WRAP_ROOT_VALUE, true);
	converter.getObjectMapper().configure(DeserializationFeature.UNWRAP_ROOT_VALUE,
			true);
	converter.getObjectMapper().addMixIn(Applications.class, ApplicationsJsonMixIn.class);
	converter.getObjectMapper().addMixIn(InstanceInfo.class, InstanceInfoJsonMixIn.class);

	// converter.getObjectMapper().addMixIn(DataCenterInfo.class, DataCenterInfoXmlMixIn.class);
	// converter.getObjectMapper().addMixIn(InstanceInfo.PortWrapper.class, PortWrapperXmlMixIn.class);
	// converter.getObjectMapper().addMixIn(Application.class, ApplicationXmlMixIn.class);
	// converter.getObjectMapper().addMixIn(Applications.class, ApplicationsXmlMixIn.class);


	return converter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:36,代码来源:RestTemplateTransportClientFactory.java


示例5: getApplicationsInternal

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
private EurekaHttpResponse<Applications> getApplicationsInternal(String urlPath,
		String[] regions) {
	String url = serviceUrl + urlPath;

	if (regions != null && regions.length > 0)
		urlPath = (urlPath.contains("?") ? "&" : "?") + "regions="
				+ StringUtil.join(regions);

	ResponseEntity<EurekaApplications> response = restTemplate.exchange(url,
			HttpMethod.GET, null, EurekaApplications.class);

	return anEurekaHttpResponse(response.getStatusCodeValue(),
			response.getStatusCode().value() == HttpStatus.OK.value()
					&& response.hasBody() ? (Applications) response.getBody() : null)
							.headers(headersOf(response)).build();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:17,代码来源:RestTemplateEurekaHttpClient.java


示例6: getServices

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public List<String> getServices() {
	Applications applications = this.eurekaClient.getApplications();
	if (applications == null) {
		return Collections.emptyList();
	}
	List<Application> registered = applications.getRegisteredApplications();
	List<String> names = new ArrayList<>();
	for (Application app : registered) {
		if (app.getInstances().isEmpty()) {
			continue;
		}
		names.add(app.getName().toLowerCase());

	}
	return names;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:EurekaDiscoveryClient.java


示例7: getEurekaDetails

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@GET
public Response getEurekaDetails() {
    List<EurekaInstanceInfo> instanceInfoList = new ArrayList<EurekaInstanceInfo>();

    DiscoveryClient discoveryClient = DiscoveryManager.getInstance().getDiscoveryClient();
    if (null != discoveryClient) {
        Applications apps = discoveryClient.getApplications();
        for (Application app : apps.getRegisteredApplications()) {
            for (InstanceInfo inst : app.getInstances()) {
                instanceInfoList.add(new EurekaInstanceInfo(inst.getAppName(), inst.getId(), inst.getStatus().name(), inst.getIPAddr(), inst.getHostName()));
            }
        }
    }

    GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls();
    Gson gson = gsonBuilder.create();
    String response = gson.toJson(new KaryonAdminResponse(instanceInfoList));
    return Response.ok(response).build();
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:20,代码来源:EurekaResource.java


示例8: testInstanceDown

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void testInstanceDown(){
    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();

    verify(requestHandler, timeout(5000).times(2)).register(captor.capture());
    response = generateMockResponse(captor.getAllValues());
    when(requestHandler.getApplications()).thenReturn(response);

    hz1.shutdown();

    ArgumentCaptor<String> id = ArgumentCaptor.forClass(String.class);
    verify(requestHandler, timeout(5000).times(1)).cancel(anyString(), id.capture());

    reset(requestHandler);
    for(InstanceInfo info : captor.getAllValues()){
        if(info.getId().equals(id.getValue())){
            captor.getAllValues().remove(info);
            break;
        }
    }

    response = generateMockResponse(captor.getAllValues());
    when(requestHandler.getApplications()).thenReturn(response);

    assertClusterSizeEventually(1, hz2);
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:33,代码来源:HazelcastClientTestCase.java


示例9: generateMockResponse

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
private EurekaHttpResponse<Applications> generateMockResponse(List<InstanceInfo> infoList, String appName){

        Application application = new Application();
        application.setName(appName);
        for(InstanceInfo info : infoList){
            application.addInstance(info);
        }

        Applications applications = new Applications();
        applications.addApplication(application);

        return anEurekaHttpResponse(200, applications)
                .type(MediaType.APPLICATION_JSON_TYPE)
                .build();
    }
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:16,代码来源:HazelcastClientTestCase.java


示例10: getApplications

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
public Map<String, List<Registration>> getApplications() {
	//TODO: support regions
	EurekaHttpResponse<Applications> response = this.transport.getEurekaHttpClient().getApplications();
	List<com.netflix.discovery.shared.Application> applications = response.getEntity().getRegisteredApplications();
	LinkedHashMap<String, List<Registration>> map = new LinkedHashMap<>();

	for (com.netflix.discovery.shared.Application application : applications) {
		List<Registration> registrations = getRegistrations(application);
		map.put(application.getName(), registrations);
	}

	return map;
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:14,代码来源:Eureka.java


示例11: getApplications

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
private Map<String, Object> getApplications() {
	Applications applications = this.eurekaClient.getApplications();
	if (applications == null) {
		return Collections.emptyMap();
	}
	Map<String, Object> result = new HashMap<>();
	for (Application application : applications.getRegisteredApplications()) {
		result.put(application.getName(), application.getInstances().size());
	}
	return result;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:12,代码来源:EurekaHealthIndicator.java


示例12: getClusterNames

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public List<String> getClusterNames() {
	Applications applications = eurekaClient.getApplications();
	List<Application> registeredApplications = applications.getRegisteredApplications();
	List<String> appNames = new ArrayList<>(registeredApplications.size());
	for (Application application : registeredApplications) {
		appNames.add(application.getName());
	}
	log.trace("Using clusters names: " + appNames);
	return appNames;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:12,代码来源:EurekaBasedTurbineClustersProvider.java


示例13: shouldProvideAllClustersNames

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void shouldProvideAllClustersNames() throws Exception {
	Applications applications = registeredApplications(asList(application("service1"),
			application("service2"), application("service3")));
	when(eurekaClient.getApplications()).thenReturn(applications);

	List<String> clusterNames = provider.getClusterNames();

	assertThat(clusterNames).containsOnly("service1", "service2", "service3");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:EurekaBasedTurbineClustersProviderTest.java


示例14: CloudJacksonCodec

import com.netflix.discovery.shared.Applications; //导入依赖的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


示例15: testInstanceRegistration

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Test
public void testInstanceRegistration(){

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    factory.newHazelcastInstance();

    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);
    verify(requestHandler, timeout(5000).times(1)).register(captor.capture());

    assertNotNull(captor.getAllValues());
    assertEquals(captor.getAllValues().size(), 1);

    InstanceInfo actual = captor.getValue();
    assertEquals(actual.getAppName().toLowerCase(), APP_NAME);

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:19,代码来源:HazelcastClientTestCase.java


示例16: CloudJacksonCodec

import com.netflix.discovery.shared.Applications; //导入依赖的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


示例17: getApplications

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public EurekaHttpResponse<Applications> getApplications(String... regions) {
	return getApplicationsInternal("apps/", regions);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:5,代码来源:RestTemplateEurekaHttpClient.java


示例18: getDelta

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public EurekaHttpResponse<Applications> getDelta(String... regions) {
	return getApplicationsInternal("apps/delta", regions);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:5,代码来源:RestTemplateEurekaHttpClient.java


示例19: getVip

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public EurekaHttpResponse<Applications> getVip(String vipAddress, String... regions) {
	return getApplicationsInternal("vips/" + vipAddress, regions);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:5,代码来源:RestTemplateEurekaHttpClient.java


示例20: getSecureVip

import com.netflix.discovery.shared.Applications; //导入依赖的package包/类
@Override
public EurekaHttpResponse<Applications> getSecureVip(String secureVipAddress,
		String... regions) {
	return getApplicationsInternal("svips/" + secureVipAddress, regions);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:6,代码来源:RestTemplateEurekaHttpClient.java



注:本文中的com.netflix.discovery.shared.Applications类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GLboolean类代码示例发布时间:2022-05-22
下一篇:
Java DocumentSecurityAttribute类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap