Search in sources :

Example 6 with StandardSofaRuntimeManager

use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by alipay.

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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 7 with StandardSofaRuntimeManager

use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by alipay.

the class RuntimeConfiguration method sofaRuntimeManager.

@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(Environment environment, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
    String appName = environment.getProperty(SofaBootConstants.APP_NAME_KEY);
    ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
    SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(appName, 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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) ReferenceClientImpl(com.alipay.sofa.runtime.service.client.ReferenceClientImpl) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ServiceClientImpl(com.alipay.sofa.runtime.service.client.ServiceClientImpl) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with StandardSofaRuntimeManager

use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by alipay.

the class RuntimeTestConfiguration method sofaRuntimeManager.

@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(@Value("${spring.application.name}") String appName, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
    ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
    SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(appName, 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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) ReferenceClientImpl(com.alipay.sofa.runtime.service.client.ReferenceClientImpl) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ServiceClientImpl(com.alipay.sofa.runtime.service.client.ServiceClientImpl) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 9 with StandardSofaRuntimeManager

use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by alipay.

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;
    }
}
Also used : ComponentHealthChecker(com.alipay.sofa.healthcheck.impl.ComponentHealthChecker) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) SofaRuntimeContext(com.alipay.sofa.runtime.spi.component.SofaRuntimeContext) Test(org.junit.Test)

Example 10 with StandardSofaRuntimeManager

use of com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager in project sofa-boot by alipay.

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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) ReferenceClientImpl(com.alipay.sofa.runtime.service.client.ReferenceClientImpl) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ServiceClientImpl(com.alipay.sofa.runtime.service.client.ServiceClientImpl) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

StandardSofaRuntimeManager (com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager)17 SofaRuntimeManager (com.alipay.sofa.runtime.spi.component.SofaRuntimeManager)15 ClientFactoryImpl (com.alipay.sofa.runtime.client.impl.ClientFactoryImpl)11 ClientFactoryInternal (com.alipay.sofa.runtime.spi.client.ClientFactoryInternal)11 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)10 Bean (org.springframework.context.annotation.Bean)10 ReferenceClientImpl (com.alipay.sofa.runtime.service.client.ReferenceClientImpl)9 ServiceClientImpl (com.alipay.sofa.runtime.service.client.ServiceClientImpl)9 Test (org.junit.Test)6 ComponentHealthChecker (com.alipay.sofa.healthcheck.impl.ComponentHealthChecker)4 SofaRuntimeContext (com.alipay.sofa.runtime.spi.component.SofaRuntimeContext)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 MultiApplicationHealthIndicator (com.alipay.sofa.boot.actuator.health.MultiApplicationHealthIndicator)2 SofaFrameworkImpl (com.alipay.sofa.runtime.SofaFrameworkImpl)1 AppConfiguration (com.alipay.sofa.runtime.api.component.AppConfiguration)1 ComponentManager (com.alipay.sofa.runtime.spi.component.ComponentManager)1