Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
luanjia committed Dec 27, 2018
1 parent 9f74182 commit 38f8c34
Show file tree
Hide file tree
Showing 483 changed files with 1,613 additions and 1,483 deletions.
30 changes: 0 additions & 30 deletions .github/ISSUE_TEMPLATE/----.md

This file was deleted.

6 changes: 0 additions & 6 deletions .gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions bin/sandbox.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ user_module=~/.sandbox-module;
# switch the sandbox can enhance system class
unsafe.enable=true

# define the sandbox event pool arguments(min/max/total)
event.pool.enable=true
event.pool.max.total=6000
event.pool.min.idle.per.event=50
event.pool.max.idle.per.event=100
event.pool.max.total.per.event=2000
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>sandbox ${sandbox.version}</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sandbox.version>1.1.2-SNAPSHOT</sandbox.version>
<sandbox.version>1.2.0-SNAPSHOT</sandbox.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion sandbox-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>sandbox-agent</artifactId>
<name>sandbox-agent ${sandbox.version}</name>
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion sandbox-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>sandbox-api</artifactId>
<name>sandbox-api ${sandbox.version}</name>
Expand All @@ -21,10 +21,13 @@
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>sandbox-common-api</artifactId>
</dependency>

<!-- 废弃对Servlet的依赖 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.alibaba.jvm.sandbox.api.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* 模块命令注解,拥有此注解的模块方法将能接收到从{@code sandbox.sh -d} 发出的命令
* <p>
* 有这个注解的方法只能接收四类型的参数:
* <ul>
* <li>命令参数: {@code Map<String,String>}</li>
* <li>命令参数: {@code Map<String,String[]>}</li>
* <li>命令参数: {@code String}</li>
* <li>文本输出: {@code PrintWriter}</li>
* </ul>
*
* @author luanjia@taobao.com
* @since {@code sandbox-api:1.2.0}
*/
@Target(METHOD)
@Retention(RUNTIME)
public @interface Command {

/**
* 命令名称
*
* @return 命令名称
*/
String value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* HTTP服务请求
*
* @author luanjia@taobao.com
* @deprecated 请使用 {@link com.alibaba.jvm.sandbox.api.annotation.Command}
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface Http {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* @author luanjia@taobao.com
*/
@Deprecated
public interface TextMessageListener extends WebSocketConnectionListener {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author luanjia@taobao.com
*/
@Deprecated
public interface WebSocketAcceptor {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author luanjia@taobao.com
*/
@Deprecated
public interface WebSocketConnection {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* @author luanjia@taobao.com
*/
@Deprecated
public interface WebSocketConnectionListener {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ protected OpStack initialValue() {

@Override
final public void onEvent(final Event event) throws Throwable {
final OpStack opStack = opStackRef.get();
try {
switchEvent(opStack, event);
} finally {
// 如果执行到TOP的最后一个事件,则需要主动清理占用的资源
if (opStack.isEmpty()) {
opStackRef.remove();
}
}

}


// 执行事件
private void switchEvent(final OpStack opStack,
final Event event) throws Throwable {

switch (event.type) {
case BEFORE: {
final BeforeEvent bEvent = (BeforeEvent) event;
Expand All @@ -50,7 +67,6 @@ final public void onEvent(final Event event) throws Throwable {
bEvent.target
);

final OpStack opStack = opStackRef.get();
final Advice top;
final Advice parent;

Expand Down Expand Up @@ -78,11 +94,12 @@ final public void onEvent(final Event event) throws Throwable {
case IMMEDIATELY_THROWS:
case IMMEDIATELY_RETURN: {
final InvokeEvent invokeEvent = (InvokeEvent) event;
opStackRef.get().popByExpectInvokeId(invokeEvent.invokeId);
opStack.popByExpectInvokeId(invokeEvent.invokeId);
// 修复#123
break;
}

case RETURN: {
final OpStack opStack = opStackRef.get();
final ReturnEvent rEvent = (ReturnEvent) event;
final WrapAdvice wrapAdvice = opStack.popByExpectInvokeId(rEvent.invokeId);
if (null != wrapAdvice) {
Expand All @@ -91,7 +108,6 @@ final public void onEvent(final Event event) throws Throwable {
break;
}
case THROWS: {
final OpStack opStack = opStackRef.get();
final ThrowsEvent tEvent = (ThrowsEvent) event;
final WrapAdvice wrapAdvice = opStack.popByExpectInvokeId(tEvent.invokeId);
if (null != wrapAdvice) {
Expand All @@ -101,7 +117,6 @@ final public void onEvent(final Event event) throws Throwable {
}

case CALL_BEFORE: {
final OpStack opStack = opStackRef.get();
final CallBeforeEvent cbEvent = (CallBeforeEvent) event;
final WrapAdvice wrapAdvice = opStack.peekByExpectInvokeId(cbEvent.invokeId);
if (null == wrapAdvice) {
Expand All @@ -125,7 +140,6 @@ final public void onEvent(final Event event) throws Throwable {
}

case CALL_RETURN: {
final OpStack opStack = opStackRef.get();
final CallReturnEvent crEvent = (CallReturnEvent) event;
final WrapAdvice wrapAdvice = opStack.peekByExpectInvokeId(crEvent.invokeId);
if (null == wrapAdvice) {
Expand All @@ -147,7 +161,6 @@ final public void onEvent(final Event event) throws Throwable {
}

case CALL_THROWS: {
final OpStack opStack = opStackRef.get();
final CallThrowsEvent ctEvent = (CallThrowsEvent) event;
final WrapAdvice wrapAdvice = opStack.peekByExpectInvokeId(ctEvent.invokeId);
if (null == wrapAdvice) {
Expand All @@ -170,7 +183,6 @@ final public void onEvent(final Event event) throws Throwable {
}

case LINE: {
final OpStack opStack = opStackRef.get();
final LineEvent lEvent = (LineEvent) event;
final WrapAdvice wrapAdvice = opStack.peekByExpectInvokeId(lEvent.invokeId);
if (null == wrapAdvice) {
Expand Down Expand Up @@ -208,6 +220,12 @@ void pushForBegin(final Advice advice) {
adviceStack.push(new WrapAdvice(advice));
}

WrapAdvice pop() {
return !adviceStack.isEmpty()
? adviceStack.pop()
: null;
}

/**
* 在通知堆栈中,BEFORE:[RETURN/THROWS]的invokeId是配对的,
* 如果发生错位则说明BEFORE的事件没有被成功压入堆栈,没有被正确的处理,外界没有正确感知BEFORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
*
* @author luanjia@taobao.com
* @since {@code sandbox-api:1.0.9}
* @deprecated 后续不再支持事件池
*/
@Deprecated
public interface EventMonitor {

/**
* 事件池信息
*
* @author luanjia@taobao.com
* @since {@code sandbox-api:1.0.9}
* @deprecated 后续不再支持事件池
*/
interface EventPoolInfo {

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 0 additions & 14 deletions sandbox-api/target/test-classes/logback.xml

This file was deleted.

2 changes: 1 addition & 1 deletion sandbox-common-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>com.alibaba.jvm.sandbox</groupId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>sandbox-common-api</artifactId>
<name>sandbox-common-api ${sandbox.version}</name>
Expand Down
Loading

0 comments on commit 38f8c34

Please sign in to comment.