use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by alipay.
the class SofaBizUninstallEventHandler method doUninstallBiz.
private void doUninstallBiz(Biz biz) {
// Remove dynamic JVM service cache
DynamicJvmServiceProxyFinder.getDynamicJvmServiceProxyFinder().afterBizUninstall(biz);
SofaRuntimeProperties.unRegisterProperties(biz.getBizClassLoader());
SofaRuntimeManager sofaRuntimeManager = getSofaRuntimeManager(biz);
SofaFramework.unRegisterSofaRuntimeManager(sofaRuntimeManager);
sofaRuntimeManager.shutDownExternally();
}
use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by sofastack.
the class MultiApplicationHealthIndicator method health.
@Override
public Health health() {
boolean allPassed = true;
Health.Builder builder = new Health.Builder();
for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) {
Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager);
if (biz == null) {
continue;
}
if (!sofaRuntimeManager.isLivenessHealth()) {
allPassed = false;
builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()), "failed");
} else {
builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()), "passed");
}
}
if (allPassed) {
return builder.up().build();
} else {
return builder.down().build();
}
}
use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by sofastack.
the class ModelCreatingStage method doProcess.
@Override
protected void doProcess() throws Exception {
ApplicationRuntimeModel application = new ApplicationRuntimeModel();
application.setAppName(appName);
SofaRuntimeManager sofaRuntimeManager = applicationContext.getBean(SofaRuntimeManager.class);
application.setSofaRuntimeContext(sofaRuntimeManager.getSofaRuntimeContext());
application.setModuleDeploymentValidator(new DefaultModuleDeploymentValidator());
getAllDeployments(application);
applicationContext.getBeanFactory().registerSingleton(SofaBootConstants.APPLICATION, application);
}
use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by sofastack.
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;
}
use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by sofastack.
the class DynamicJvmServiceProxyFinder method afterBizStartup.
public void afterBizStartup(Biz biz) {
if (!SofaRuntimeProperties.isDynamicJvmServiceCacheEnable()) {
return;
}
// The overhead is acceptable as this only happens after biz's successful installation
for (SofaRuntimeManager runtimeManager : SofaFramework.getRuntimeSet()) {
if (runtimeManager.getAppClassLoader().equals(biz.getBizClassLoader())) {
for (ComponentInfo componentInfo : runtimeManager.getComponentManager().getComponents()) {
if (componentInfo instanceof ServiceComponent) {
ServiceComponent serviceComponent = (ServiceComponent) componentInfo;
String uniqueName = getUniqueName(serviceComponent.getService());
jvmServiceTargetHabitats.computeIfAbsent(uniqueName, e -> new JvmServiceTargetHabitat(biz.getBizName()));
JvmServiceTargetHabitat jvmServiceTargetHabitat = jvmServiceTargetHabitats.get(uniqueName);
jvmServiceTargetHabitat.addServiceComponent(biz.getBizVersion(), serviceComponent);
}
}
}
}
}
Aggregations