当前位置: 首页>>代码示例>>Java>>正文


Java InstanceStatus类代码示例

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


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

示例1: testInstanceRegistrationUsingProvidedEurekaClient

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Test
public void testInstanceRegistrationUsingProvidedEurekaClient() {
    EurekaClient eurekaClient = mock(EurekaClient.class);
    ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
    EurekaInstanceConfig eurekaInstanceConfig = mock(EurekaInstanceConfig.class);

    when(eurekaClient.getApplicationInfoManager()).thenReturn(applicationInfoManager);
    when(eurekaClient.getApplication(anyString())).thenReturn(new Application(APP_NAME));

    when(applicationInfoManager.getEurekaInstanceConfig()).thenReturn(eurekaInstanceConfig);
    when(eurekaInstanceConfig.getAppname()).thenReturn(APP_NAME);

    // use provided EurekaClient
    EurekaOneDiscoveryStrategyFactory.setEurekaClient(eurekaClient);

    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    
    verify(eurekaClient, times(2)).getApplicationInfoManager();
    verify(eurekaClient, times(2)).getApplication(APP_NAME);
    verify(applicationInfoManager, never()).setInstanceStatus(InstanceStatus.UP);
    verify(applicationInfoManager, never()).setInstanceStatus(any(InstanceStatus.class));

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

示例2: beforeMethod

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Before
public void beforeMethod() {
    eurekaIsDisabledPropertySupplierMock = mock(Supplier.class);
    datacenterTypePropertySupplierMock = mock(Supplier.class);
    cloudInstanceConfigMock = mock(CloudInstanceConfig.class);

    doReturn(false).when(eurekaIsDisabledPropertySupplierMock).get();
    doReturn(MyOwn.name()).when(datacenterTypePropertySupplierMock).get();

    handlerSpy = spy(new EurekaHandler(eurekaIsDisabledPropertySupplierMock, datacenterTypePropertySupplierMock));

    doNothing().when(handlerSpy).initDiscoveryManager(any(EurekaInstanceConfig.class),
                                                      any(EurekaClientConfig.class));
    doNothing().when(handlerSpy).shutdownDiscoveryManager();
    doNothing().when(handlerSpy).setEurekaInstanceStatus(any(InstanceStatus.class));
    doReturn(cloudInstanceConfigMock).when(handlerSpy).createCloudInstanceConfig(anyString());
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:18,代码来源:EurekaHandlerTest.java

示例3: mock

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Test
public void register_uses_createEurekaInstanceConfig_then_calls_initDiscoveryManager_with_it_and_sets_instance_status_UP() {
    // given
    EurekaInstanceConfig instanceConfigMock = mock(EurekaInstanceConfig.class);
    doReturn(instanceConfigMock).when(handlerSpy).createEurekaInstanceConfig();
    assertThat(handlerSpy.registered.get()).isFalse();

    // when
    handlerSpy.register();

    // then
    assertThat(handlerSpy.registered.get()).isTrue();
    verify(handlerSpy).createEurekaInstanceConfig();

    ArgumentCaptor<EurekaClientConfig> clientConfigCaptor = ArgumentCaptor.forClass(EurekaClientConfig.class);
    verify(handlerSpy).initDiscoveryManager(eq(instanceConfigMock),
                                            clientConfigCaptor.capture());
    EurekaClientConfig clientConfigUsed = clientConfigCaptor.getValue();
    assertThat(clientConfigUsed).isInstanceOf(DefaultEurekaClientConfig.class);
    assertThat(Whitebox.getInternalState(clientConfigUsed, "namespace")).isEqualTo(handlerSpy.eurekaClientNamespace);

    verify(handlerSpy).setEurekaInstanceStatus(InstanceStatus.UP);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:24,代码来源:EurekaHandlerTest.java

示例4: markAsUp_sets_instance_status_to_up_only_if_eureka_is_enabled

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@DataProvider(value = {
    "true",
    "false"
})
@Test
public void markAsUp_sets_instance_status_to_up_only_if_eureka_is_enabled(
    boolean eurekaDisabled
) {
    // given
    doReturn(eurekaDisabled).when(eurekaIsDisabledPropertySupplierMock).get();

    // when
    handlerSpy.markAsUp();

    // then
    if (eurekaDisabled)
        verify(handlerSpy, never()).setEurekaInstanceStatus(any(InstanceStatus.class));
    else
        verify(handlerSpy).setEurekaInstanceStatus(InstanceStatus.UP);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:21,代码来源:EurekaHandlerTest.java

示例5: onApplicationEvent

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
    //we only want to tell Eureka that the application is up
    //when the root application context (thisApplicationContext) has
    //been fully started.  we want to ignore any ContextRefreshedEvent
    //from child application contexts.
    if (!event.getSource().equals(thisApplicationContext)) {
        return;
    }
    if (event instanceof ContextRefreshedEvent) {
        if (!disableEureka) {
            // tell Eureka the server UP which in turn starts the health checks and heartbeat
            ApplicationInfoManager.getInstance().setInstanceStatus(InstanceStatus.UP);
        }
    } else if (event instanceof ContextClosedEvent) {
        if (!disableEureka) {
            ApplicationInfoManager.getInstance().setInstanceStatus(InstanceStatus.DOWN);
        }
    }
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:21,代码来源:ChassisConfiguration.java

示例6: testServiceRegistration

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Test
 public void testServiceRegistration() throws InterruptedException {
 	// Registers "chasis-default-name" with a Eurkea server running on local host.
 	//   http://localhost:8184/v2/apps/chassis-default-name

 	// tell eureka the service is up which causes a registration
 	ApplicationInfoManager.getInstance().setInstanceStatus(InstanceInfo.InstanceStatus.UP);
 	
 	// get application registration from Eureka
 	DiscoveryClient client = DiscoveryManager.getInstance().getDiscoveryClient();
 	InstanceInfo instanceInfo = null;
 	for (int i = 0; (instanceInfo == null) && (i < 50); i++) {
 		Thread.sleep(5000);
 		try {
	instanceInfo =  client.getNextServerFromEureka("default-service", false);
} catch (RuntimeException e) {
	// eat not found runtime exception
}
 	}
 	Assert.assertNotNull(instanceInfo);
 	Assert.assertEquals(InstanceStatus.UP, instanceInfo.getStatus());
 	System.out.println("done");
 }
 
开发者ID:Kixeye,项目名称:chassis,代码行数:24,代码来源:ChassisEurekaRegistrationTest.java

示例7: sendHeartBeat

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Override
public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id,
		InstanceInfo info, InstanceStatus overriddenStatus) {
	String urlPath = serviceUrl + "apps/" + appName + '/' + id + "?status="
			+ info.getStatus().toString() + "&lastDirtyTimestamp="
			+ info.getLastDirtyTimestamp().toString() + (overriddenStatus != null
					? "&overriddenstatus=" + overriddenStatus.name() : "");

	ResponseEntity<InstanceInfo> response = restTemplate.exchange(urlPath,
			HttpMethod.PUT, null, InstanceInfo.class);

	EurekaHttpResponseBuilder<InstanceInfo> eurekaResponseBuilder = anEurekaHttpResponse(
			response.getStatusCodeValue(), InstanceInfo.class)
					.headers(headersOf(response));

	if (response.hasBody())
		eurekaResponseBuilder.entity(response.getBody());

	return eurekaResponseBuilder.build();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:21,代码来源:RestTemplateEurekaHttpClient.java

示例8: getStatus

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Override
public InstanceStatus getStatus(InstanceStatus currentStatus) {
    try {
        if (matcher != null) {
            return getInstanceStatusForHealth(healthCheckAggregator.check(matcher).get());
        } else {
            return getInstanceStatusForHealth(healthCheckAggregator.check().get());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Netflix,项目名称:runtime-health,代码行数:13,代码来源:HealthAggregatorEurekaHealthCheckHandler.java

示例9: getInstanceStatusForHealth

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
private InstanceStatus getInstanceStatusForHealth(HealthCheckStatus health) {
    if (health.isHealthy()) {
        return InstanceStatus.UP;
    } else {
        return InstanceStatus.DOWN;
    }
}
 
开发者ID:Netflix,项目名称:runtime-health,代码行数:8,代码来源:HealthAggregatorEurekaHealthCheckHandler.java

示例10: register_does_nothing_if_eureka_is_disabled

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Test
public void register_does_nothing_if_eureka_is_disabled() {
    // given
    doReturn(true).when(eurekaIsDisabledPropertySupplierMock).get();

    // when
    handlerSpy.register();

    // then
    verify(handlerSpy, never()).createEurekaInstanceConfig();
    verify(handlerSpy, never()).initDiscoveryManager(any(EurekaInstanceConfig.class),
                                                     any(EurekaClientConfig.class));
    verify(handlerSpy, never()).setEurekaInstanceStatus(any(InstanceStatus.class));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:15,代码来源:EurekaHandlerTest.java

示例11: register_does_nothing_if_already_registered

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Test
public void register_does_nothing_if_already_registered() {
    // given
    handlerSpy.registered.set(true);

    // when
    handlerSpy.register();

    // then
    verify(handlerSpy, never()).createEurekaInstanceConfig();
    verify(handlerSpy, never()).initDiscoveryManager(any(EurekaInstanceConfig.class),
                                                     any(EurekaClientConfig.class));
    verify(handlerSpy, never()).setEurekaInstanceStatus(any(InstanceStatus.class));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:15,代码来源:EurekaHandlerTest.java

示例12: register

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Override
public InstanceInfo register(Application application) {
	InstanceInfo instanceInfo = getInstanceInfo(application);
	InstanceStatus status = InstanceStatus.UP;
	if (application.getInstance_id().endsWith("down")) {
		status = InstanceStatus.DOWN;
	}
	return instanceInfo;
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:10,代码来源:EurekaLiteApplicationTests.java

示例13: checkDiscovery

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@Scheduled(fixedDelay = 3000L)
public void checkDiscovery() {
    InstanceStatus latestStatus = discoveryClient.getInstanceRemoteStatus();
    if(!latestStatus.equals(currentStatus)) {
        this.currentStatus = latestStatus;
        publisher.publishEvent(new EurekaStatusChangedEvent(latestStatus));
    }
}
 
开发者ID:netflix-spring-one,项目名称:spring-cloud-netflix-contrib,代码行数:9,代码来源:EurekaStatusApplicationEventPublisher.java

示例14: onEurekaStatusDown

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
@EventListener
public void onEurekaStatusDown(EurekaStatusChangedEvent event)
{
	if(event.getStatus() == InstanceStatus.DOWN || event.getStatus() == InstanceStatus.OUT_OF_SERVICE)
	{
		System.out.println("Stopping adapters...");
		controlChannel.send("@*ChannelAdapter.stop()");
	}
}
 
开发者ID:netflix-spring-one,项目名称:sample-membership,代码行数:10,代码来源:Membership.java

示例15: createInstance

import com.netflix.appinfo.InstanceInfo.InstanceStatus; //导入依赖的package包/类
InstanceInfo createInstance(int id) {
    return InstanceInfo.Builder.newBuilder()
            .setHostName("localhost:800" + id)
            .setAppName("foo")
            .setStatus(InstanceStatus.UP)
            .build();
}
 
开发者ID:Netflix,项目名称:ocelli,代码行数:8,代码来源:EurekaInterestManagerTest.java


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