use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by sofastack.
the class MultiApplicationHealthIndicatorTest method testUp.
@Test
public void testUp() {
SofaFramework.registerSofaRuntimeManager(new StandardSofaRuntimeManager("test1", this.getClass().getClassLoader(), null));
Assert.assertEquals(Status.UP, new MultiApplicationHealthIndicator().health().getStatus());
}
use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by sofastack.
the class SofaRuntimeAutoConfiguration method sofaRuntimeManager.
@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(Environment environment, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(environment.getProperty("spring.application.name"), Thread.currentThread().getContextClassLoader(), clientFactoryInternal);
sofaRuntimeManager.getComponentManager().registerComponentClient(ReferenceClient.class, new ReferenceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory));
sofaRuntimeManager.getComponentManager().registerComponentClient(ServiceClient.class, new ServiceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory));
SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager);
return sofaRuntimeManager;
}
use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by sofastack.
the class HealthCheckerProcessorParallelTest method testComponentHealthCheckerFailedFirst.
@Test
public void testComponentHealthCheckerFailedFirst() {
SofaRuntimeManager manager = new StandardSofaRuntimeManager("testComponentHealthCheckerFailedFirst", Thread.currentThread().getContextClassLoader(), null);
manager.getComponentManager().register(new TestComponent("component1", true));
manager.getComponentManager().register(new TestComponent("component2", true));
manager.getComponentManager().register(new TestComponent("component3", false));
manager.getComponentManager().register(new TestComponent("component4", true));
manager.getComponentManager().register(new TestComponent("component5", false));
ComponentHealthChecker componentHealthChecker = new ComponentHealthChecker(new SofaRuntimeContext(manager, manager.getComponentManager(), null));
int i = 0;
for (Map.Entry<String, Object> entry : componentHealthChecker.isHealthy().getDetails().entrySet()) {
if (i < 2) {
Assert.assertEquals(entry.getValue().toString(), "failed");
} else {
Assert.assertEquals(entry.getValue().toString(), "passed");
}
++i;
}
}
use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by sofastack.
the class HealthCheckerProcessorTest method testComponentHealthCheckerFailedFirst.
@Test
public void testComponentHealthCheckerFailedFirst() {
SofaRuntimeManager manager = new StandardSofaRuntimeManager("testComponentHealthCheckerFailedFirst", Thread.currentThread().getContextClassLoader(), null);
manager.getComponentManager().register(new TestComponent("component1", true));
manager.getComponentManager().register(new TestComponent("component2", true));
manager.getComponentManager().register(new TestComponent("component3", false));
manager.getComponentManager().register(new TestComponent("component4", true));
manager.getComponentManager().register(new TestComponent("component5", false));
ComponentHealthChecker componentHealthChecker = new ComponentHealthChecker(new SofaRuntimeContext(manager, manager.getComponentManager(), null));
int i = 0;
for (Map.Entry<String, Object> entry : componentHealthChecker.isHealthy().getDetails().entrySet()) {
if (i < 2) {
Assert.assertEquals(entry.getValue().toString(), "failed");
} else {
Assert.assertEquals(entry.getValue().toString(), "passed");
}
++i;
}
}
use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by sofastack.
the class SofaStartupIsleAutoConfiguration method sofaRuntimeManager.
@Bean(destroyMethod = "")
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager() {
ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager("IsleStageCostTest", Thread.currentThread().getContextClassLoader(), clientFactoryInternal);
SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager);
return sofaRuntimeManager;
}
Aggregations