Skip to content

Commit 8308ae0

Browse files
zhucegepxcaspar
authored andcommitted
- 把full gc spec加入jvm列表。
Signed-off-by: shizhi.zhu <shizhi.zhu@qunar.com>
1 parent ca28204 commit 8308ae0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

chaosblade-exec-plugin/chaosblade-exec-plugin-jvm/src/main/java/com/alibaba/chaosblade/exec/plugin/jvm/JvmModelSpec.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.alibaba.chaosblade.exec.common.plugin.MethodModelSpec;
2828
import com.alibaba.chaosblade.exec.plugin.jvm.codecache.CodeCacheFillingActionSpec;
2929
import com.alibaba.chaosblade.exec.plugin.jvm.cpu.JvmCpuFullLoadActionSpec;
30+
import com.alibaba.chaosblade.exec.plugin.jvm.gc.FullGCActionSpec;
3031
import com.alibaba.chaosblade.exec.plugin.jvm.oom.JvmOomActionSpec;
3132
import com.alibaba.chaosblade.exec.plugin.jvm.script.model.JvmDynamicActionSpec;
3233
import com.alibaba.chaosblade.exec.plugin.jvm.thread.model.JvmThreadFullActionSpec;
@@ -48,7 +49,7 @@
4849
* @date 2019-04-19
4950
*/
5051
public class JvmModelSpec extends MethodModelSpec implements PreCreateInjectionModelHandler,
51-
PreDestroyInjectionModelHandler {
52+
PreDestroyInjectionModelHandler {
5253

5354
public JvmModelSpec() {
5455
super();
@@ -57,14 +58,15 @@ public JvmModelSpec() {
5758
addActionSpec(new JvmDynamicActionSpec());
5859
addActionSpec(new CodeCacheFillingActionSpec());
5960
addActionSpec(new JvmThreadFullActionSpec());
61+
addActionSpec(new FullGCActionSpec());
6062
}
6163

6264
@Override
6365
public void preDestroy(String uid, Model model) throws ExperimentException {
6466
ActionSpec actionSpec = getActionSpec(model.getActionName());
6567
if (actionSpec instanceof DirectlyInjectionAction) {
6668
try {
67-
((DirectlyInjectionAction)actionSpec).destroyInjection(uid, model);
69+
((DirectlyInjectionAction) actionSpec).destroyInjection(uid, model);
6870
} catch (Exception e) {
6971
throw new ExperimentException("destroy injection failed:" + e.getMessage());
7072
}
@@ -74,7 +76,7 @@ public void preDestroy(String uid, Model model) throws ExperimentException {
7476
if (actionExecutor instanceof StoppableActionExecutor) {
7577
EnhancerModel enhancerModel = new EnhancerModel(null, model.getMatcher());
7678
try {
77-
((StoppableActionExecutor)actionExecutor).stop(enhancerModel);
79+
((StoppableActionExecutor) actionExecutor).stop(enhancerModel);
7880
} catch (Exception e) {
7981
throw new ExperimentException("stop experiment exception", e);
8082
}
@@ -88,7 +90,7 @@ public void preCreate(String uid, Model model) throws ExperimentException {
8890
ActionSpec actionSpec = getActionSpec(model.getActionName());
8991
if (actionSpec instanceof DirectlyInjectionAction) {
9092
try {
91-
((DirectlyInjectionAction)actionSpec).createInjection(uid, model);
93+
((DirectlyInjectionAction) actionSpec).createInjection(uid, model);
9294
} catch (Exception e) {
9395
throw new ExperimentException("create injection failed:" + e.getMessage());
9496
}

chaosblade-exec-plugin/chaosblade-exec-plugin-jvm/src/main/java/com/alibaba/chaosblade/exec/plugin/jvm/gc/FullGCActionSpec.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ public PredicateResult predicate(ActionModel actionModel) {
5656
return PredicateResult.success();
5757
}
5858

59+
@Override
60+
public String getExample() {
61+
return "# Specifies full gc\n" +
62+
"blade c jvm fgc --effect-count 100 --interval 1000\n\n";
63+
}
64+
5965
@Override
6066
public String[] getCategories() {
61-
return new String[]{CategoryConstants.JAVA_RESOURCE_MEMORY, CategoryConstants.JAVA_RESOURCE_CPU};
67+
return new String[]{CategoryConstants.JAVA_RESOURCE_MEMORY};
6268
}
6369

6470
@Override

0 commit comments

Comments
 (0)