sofastack / sofa-ark Goto Github PK
View Code? Open in Web Editor NEWSOFAArk is a light-weight,java based classloader isolation framework.
Home Page: https://www.sofastack.tech/projects/sofa-boot/sofa-ark-readme/
License: Apache License 2.0
SOFAArk is a light-weight,java based classloader isolation framework.
Home Page: https://www.sofastack.tech/projects/sofa-boot/sofa-ark-readme/
License: Apache License 2.0
Support telnet command to view ark plugin.
The logic of the current telnet processing command is to get the ArkCommandHandler
from Ark Plugin
, so in order to support the telnet command to view the Ark Plugin
, need to create an ark-plugin
project to complete (or can also add to the jarslink-plugin
).
In README, there should be a link to the contribution guide to let other known how to contribute.
We can put our further plan on the milestone, so those who are interested in this project cat see it. And we even can relate the issues to the milestone to organize the issues better.
Currently, Ark Biz is deployed by ark container in DeployBizStage
. we plan to provider a BizDeployer SPI, so ark plugin can implement it and custom the manner of biz deployment.
The useFastExceptions
in com.alipay.sofa.ark.loader.jar.JarURLConnection
is used to throw a generic static exception when a URL cannot be connected. This optimization is used during class loading to save creating lots of exceptions which are then swallowed. However,it's actually invalid because classloader isolation.
Ark should define standard rules based on which resources would be exported and imported gracefully.
Currently, we only support ark biz to load class and resource from ark plugin. However, sometime, it's necessary to load resource(NOT class
) of ark biz from ark plugin, such as SPI extension. So, we should support this feature.
如特定plugin依赖项目名称(配置到资源文件里)进行监控操作,而这个文件又不可能放到该插件里,或为每次使用该插件的项目开发一个单独的只用来提供这个资源的附属插件,有解决办法吗?看文档是biz单项依赖plugin的,但对于极端情况怎么解决
Thread.currentThread().getContextClassLoader() 该类加载器,与当前加载器不一致
解决方案:设置参数("log4j.ignoreTCL", "true"); 或者 主动设置改线程上下文类加载期为插件类加载器
When load class, we do not add any lock because of the parent URLClassloader has lock:
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
synchronized (getClassLoadingLock(name)) {
// First, check if the class has already been l
However when resolve local class, we use find class instead of load class
protected Class<?> resolveLocalClass(String name) {
try {
return super.findClass(name);
} catch (ClassNotFoundException e) {
// ignore
}
return null;
}
This may cause define class duplicated in multi-thread scenario
ark plugin导出类中的spring特性被屏蔽
对内提供了一个基础包,希望可以解决其他项目maven引入后,可能出现的依赖冲突问题。
使用sofa-ark的步骤:
1.将基础包打包成ark plugin,导出需要的类;
2.spring-boot项目引入ark plugin和sofa-ark-springboot-starter,打成ark包;
3.执行2生成的可执行包
结果:
1.不涉及到spring的类能正常通过PluginClassLoader加载;
2.使用spring相关特性的类,会出现以下几类错误和异常:
1)ArrayStoreException(Application监听器)
2)ClassCastException(Condition注解)
3)java.lang.LinkageError(get bean)
对于需要打包成ark plugin导出的类,如果用到了spring特性,spring-boot项目引入这样的插件,有没有什么比较好的解决方案
java -version
):1.8.0uname -a
):mac High Sierraupdate SOFAArk version to 0.3.0
For loading classes contained in JavaAgent Jar, PluginClassLoader
now attempts to delegate to SystemClassLoader
to resolve them. It leads some classes other than what in JavaAgent Jar to be
resolved by PluginClassLoader
. It should be safer to only resolve among classpath of JavaAgent.
Integrate with TestNG Framework,run test case in ark container
We change the generic collection declaration from the new diamond grammar in Java 7 back to older grammar before Java 7 due to the formatter problem which I think is not the right way to solve the problem.
We should fix the formatter so it can deal with the new diamond grammar in Java 7 in stead of change the grammar back before Java7.
Test under sofa-ark-springboot-starter module, for example: ArkBootRunnerTest
will fail under windows env because of RunnerHelper
for prepareForTest.sh
And we can try to figure out whether there is any way to do CI integration under windows env
Support to customize ark plugin classifier, default is empty.
我想在运行时通过类名来获取类对象,使用Class.forName()报错:
"com.alipay.sofa.ark.exception.ArkLoaderException [ArkBiz Loader] Startup In IDE:Mock version : can not load class: Hessian4Service"
请问应该怎么做呢?
请问,sofa-ark 可以用普通的spring io 框架跑么?我指不使用spring boot ,而是用xml配置的方式跑。
SOFA Ark would be integrated with junit test framework and spring-test, than test cases in SpringBoot project and normal maven project can run on ark container.
发现sofa-ark-plugin-maven-plugin中有标签shades
plugin之间出现包依赖
发现和excludes作用一样,可以把不必要的jar中fatjar剥离出
并且plugin还可以直接使用这个jar中的类
我的问题是
1,使用的是其他plugin中的jar还是biz中import的jar,如果是其他plugin的jar,优先级是什么呢
2,如果其他插件已经把一个类export了,但是当亲plugin没有import会发生什么事情?是使用已经export的类还是自己用当前classload重新load个?
使用2.x版本的springboot的项目,添加sofa ark的starter后,ide启动了服务2次
经查询监听的ApplicationStartedEvent事件在2.x版本的springboot事件含义发生变化,非启动前
需添加:SofaArkBootstrap.launch(args);
是否考虑支持?另sofa ark是否对springboot的版本有限制?
在0.4.1-SNAPSHOT版本中provided的包不会打到biz的lib中,但是这个包的依赖还会打到biz的lib中.这个正常吗?这些依赖包存在冲突是要手动排除吗?
java -version
):1.8uname -a
):windows10improve documentation, wipe out java document warning.
When running sample sofa-ark-sample-springboot-ark
from IDE,
Caused by: com.alipay.sofa.ark.exception.ArkException: No Ark Container Jar File Found.
at com.alipay.sofa.ark.bootstrap.ClasspathLauncher$ClassPathArchive.getContainerArchive(ClasspathLauncher.java:102)
at com.alipay.sofa.ark.bootstrap.AbstractLauncher.getContainerArchive(AbstractLauncher.java:131)
at com.alipay.sofa.ark.bootstrap.AbstractLauncher.launch(AbstractLauncher.java:62)
at com.alipay.sofa.ark.support.startup.SofaArkBootstrap.remain(SofaArkBootstrap.java:81)
... 6 more
after I add
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-ark-container</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
to the pom of sofa-ark-sample-springboot-ark
everything seem work fine.
java -version
): 1.8uname -a
): Win10 <dependencyManagement>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>runtime-sofa-boot-starter</artifactId>
<classifier>ark-plugin</classifier>
<version>1.0.1</version>
</dependency>
</dependencyManagement>
目前打包会打 ark 包,ark-biz 包,但其实很多时候不需要 ark-biz 包,需要有开关配置不打 ark-biz 包
Ark-Plugin 的使用是否会导致中间件的 starter 的 AutoConfiguration 等机制失效.
我想知道这是否是因为 ark plugin 包结构变化以后, 导致 spi 机制和 spring 的扫包机制失效了, 所以我们在用 sofa-boot 的时候不能再使用那些 sofa-boot 的配置方式, 只能通过原生的 rpc api 来启动.
此外我观察到 sofa-boot 项目的 ark 测试例子中也是没有使用 sofa-boot 的配置方式的, 是否是这个原因呢?
测试 boot-rpc 的 ark 版本
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-sofa-boot-starter</artifactId>
<classifier>ark-plugin</classifier>
</dependency>
发现使用 starter 的非 ark 版本能正常运行的 rpc demo , 如果改为使用 ark 版本会无法运行, 会报一些异常, 例如:
com.alipay.sofa.runtime.api.ServiceRuntimeException: Can't find BindingConverter of type binding.bolt
我的 rpc 配置如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sofa="http://sofastack.io/schema/sofaboot"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://sofastack.io/schema/sofaboot http://sofastack.io/schema/sofaboot.xsd"
default-autowire="byName">
<bean id="personServiceImpl" class="com.zim.test.sofa.sofaboottest.bean.PersonServiceImpl"/>
<sofa:service ref="personServiceImpl" interface="com.zim.test.sofa.sofaboottest.bean.PersonService">
<sofa:binding.bolt/>
<sofa:binding.rest/>
<sofa:binding.dubbo/>
</sofa:service>
<sofa:reference id="personReferenceBolt" interface="com.zim.test.sofa.sofaboottest.bean.PersonService">
<sofa:binding.bolt/>
</sofa:reference>
<sofa:reference id="personReferenceRest" interface="com.zim.test.sofa.sofaboottest.bean.PersonService">
<sofa:binding.rest/>
</sofa:reference>
<bean id="personFilter" class="com.zim.test.sofa.sofaboottest.bean.PersonServiceFilter"/>
</beans>
以及, 集成测试用例
@RunWith(ArkBootRunner.class)
//@RunWith(SpringRunner.class)
@SpringBootTest(classes = SofaBootTestApplication.class)
public class SofaBootTestApplicationTests {
@Autowired
private PersonService personReferenceBolt;
@Autowired
private PersonService personReferenceRest;
@Test
public void contextLoads() {
System.out.println(personReferenceBolt.sayName("abc"));
System.out.println(personReferenceRest.sayName("123"));
}
}
java -version
): 1.8.0_171uname -a
): windows 7写了个 SOFABoot 的工程,在没有使用 SOFAArk 之前,GC 次数为 6 次;在 使用之后(SOFAArk + rpc plugin),启动期间 YGC 上升到 12~13 次
Now, SOFAArk support the behavior of importing and exporting package; the following configuration
<export>
<packages>
<package>a.b</package>
</packages>
</export>
, means that all classes start with a.b
would be exported, e.g. a.b.C
, or a.b.d.E
. Sometimes, we find it's not very convenient.
With full consideration,in SOFAArk 0.3.0, we would change the rule of exporting and importing behavior. It's so pity that it would NOT be compatible with previous version. No matter import or export package, we define two pattern of configuration.
package-level configuration, e.g. a.b
, it just represents classes with accurate package name equals to a.b
;
package-level configuration, e.g. a.b.*
, it represents classes whose package name starts with a.b
These two rule would also be applied to denyImportPackages
看到目前只有spring-boot-starter和application-starter,如果我想在spring容器里面使用嘞
describe your question clearly
There are projects here:
deep100, the original deep version 1
deep200, the original deep version 2
pluginB100, project that depends on deep100
pluginC200, project that depends on deep200
projArk, project that use both pluginB100 and pluginC200
for deep100, deep200, pluginB100, pluginC200, use mvn clean package install them.
for projArk, use mvn clean package, but report error: can't find PluginB100Activator or PluginC200Activator
describe your use scenes (why need this feature)
What's wrong with the codes or pom.xml?
describe the advice or solution you'd like
java -version
):uname -a
):Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to stop embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.stop(TomcatEmbeddedServletContainer.java:284)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.stopAndReleaseEmbeddedServletContainer(EmbeddedWebApplicationContext.java:306)
... 3 more
Caused by: java.lang.NullPointerException
at com.alipay.sofa.ark.container.service.classloader.ClassloaderServiceImpl.isDeniedImportClass(ClassloaderServiceImpl.java:256)
at com.alipay.sofa.ark.container.service.classloader.BizClassLoader.shouldFindExportedClass(BizClassLoader.java:130)
at com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassloader.resolveExportClass(AbstractClasspathClassloader.java:147)
at com.alipay.sofa.ark.container.service.classloader.BizClassLoader.loadClassInternal(BizClassLoader.java:70)
at com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassloader.loadClass(AbstractClasspathClassloader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:240)
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:366)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.stopTomcat(TomcatEmbeddedServletContainer.java:224)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.stop(TomcatEmbeddedServletContainer.java:276)
... 4 more
Currently, a common java module can be repackaged into a ark-plugin. Project just imports this ark plugin as dependency instead of origin java module jar, then class isolation can be applied. However, as structure of jar has been changed, sometimes, project should add dependency of origin module just for compiling success. For simplify usage of ark plugin, we would adjust the structure of ark-plugin, then project just needs to import ark plugin individually.
Using annotation ArkJUnit4Runner
or ArkBootRunner
to run test case in ark container, we should switch classloader after every test class in these two runners.
Update README, add more information about the background, the difference with other competitors
Add a switch to disable or enable telnet server.
Currently if one plugin export and import the same class/resource, some unexpected results will occur. We should figure out rules check for such scenarios.
And on OSGI, it will check whether import class is exported by some other bundle, if not ,then will get error as "missing contrains..." . When figure out rules, we should also take this into consideration.
Rules can be checked on build stage or on runtime stage or both.
As described in the title and default port is 1234.
ark-biz包里含有maven scope为provided的jar
Currently, Ark Plugin and Ark Biz are loaded by independent classLoader,when an invocation steps into Ark Plugin from Ark Biz or inverse,we should take it clear whether it's necessary switch current thread classLoader(TCCL) . It may cause some problem, eg. #51
describe your question clearly
describe your use scenes (why need this feature)
describe the advice or solution you'd like
java -version
):uname -a
):Currently we only have unit test, this is not enough, when there are huge code changes, we have to do much manual test to guarantee code stability.
This can be done on next milestone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.