Skip to content

Commit a549200

Browse files
committed
Merge pull request #43 from scouter-project/dev
Dev
2 parents c09caef + d7bb0ce commit a549200

File tree

12 files changed

+928
-336
lines changed

12 files changed

+928
-336
lines changed

scouter.agent.java/src/scouter/agent/Configure.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public final static synchronized Configure getInstance() {
171171
public boolean hook_method_access_protected = false;
172172
public boolean hook_method_access_none = false;
173173

174+
public boolean trace_method_enabled=true;
175+
176+
174177
public String hook_service = "";
175178
public String hook_apicall = "";
176179
public String hook_apicall_info = "";
@@ -313,7 +316,7 @@ public File getPropertyFile() {
313316
}
314317

315318
long last_check = 0;
316-
319+
317320

318321
public synchronized boolean reload(boolean force) {
319322
long now = System.currentTimeMillis();
@@ -441,6 +444,8 @@ private void apply() {
441444
this._hook_method_ignore_classes = new StringSet(StringUtil.tokenizer(
442445
this.hook_method_ignore_classes.replace('.', '/'), ","));
443446

447+
this.trace_method_enabled=getBoolean("trace_method_enabled", true);
448+
444449
this.hook_service = getValue("hook_service", "");
445450
this.hook_apicall = getValue("hook_apicall", "");
446451
this.hook_apicall_info = getValue("hook_apicall_info", "");

scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import scouter.agent.counter.CounterBasket;
3434
import scouter.agent.counter.anotation.Counter;
3535
import scouter.agent.counter.meter.MeterResource;
36+
import scouter.agent.counter.task.TomcatJMXPerf.CtxObj;
37+
import scouter.agent.counter.task.TomcatJMXPerf.MeterKey;
3638
import scouter.lang.TimeTypeEnum;
3739
import scouter.lang.conf.ConfObserver;
3840
import scouter.lang.counters.CounterConstants;
@@ -78,22 +80,22 @@ private MeterResource getMeter(MeterKey key) {
7880

7981
static class MeterKey {
8082

81-
String objName;
83+
int mbeanHash;
8284
String counter;
8385

84-
public MeterKey(String objName, String counter) {
85-
this.objName = objName;
86+
public MeterKey(int mbeanHash, String counter) {
87+
this.mbeanHash = mbeanHash;
8688
this.counter = counter;
8789
}
8890

8991
public int hashCode() {
90-
return objName.hashCode() ^ counter.hashCode();
92+
return mbeanHash ^ counter.hashCode();
9193
}
9294

9395
public boolean equals(Object obj) {
9496
if (obj instanceof MeterKey) {
9597
MeterKey key = (MeterKey) obj;
96-
return (this.objName.equals(key.objName)) && (this.counter.equals(key.counter));
98+
return (this.mbeanHash == key.mbeanHash) && (this.counter.equals(key.counter));
9799
}
98100
return false;
99101
}
@@ -110,8 +112,6 @@ public void process(CounterBasket pw) {
110112
if (CounterConstants.JBOSS.equals(ObjTypeDetector.objType) == false) {
111113
return;
112114
}
113-
// if(CounterConstants.JBOSS.equals(conf.objType) ==false)
114-
// return;
115115

116116
getMBeanServer();
117117

@@ -124,12 +124,12 @@ public void process(CounterBasket pw) {
124124
}
125125
collectCnt++;
126126

127+
collectCnt++;
127128
MBeanServer server = servers.get(0);
128-
129129
for (CtxObj ctx : ctxList) {
130130
if (ctx.valueType == ValueEnum.DECIMAL) {
131131
try {
132-
MeterKey key = new MeterKey(ctx.objName, ctx.counter);
132+
MeterKey key = new MeterKey(ctx.mbeanHash, ctx.counter);
133133
long v = CastUtil.clong(server.getAttribute(ctx.mbean, ctx.attrName));
134134
if (deltas.contains(ctx.counter)) {
135135
v = getDelta(key, v);
@@ -138,17 +138,17 @@ public void process(CounterBasket pw) {
138138
v = (long) meter.getSum(60);
139139
long sum = (long) meter.getSum(300) / 5;
140140

141-
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).put(ctx.counter, new DecimalValue(v));
142-
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).put(ctx.counter, new DecimalValue(sum));
141+
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, new DecimalValue(v));
142+
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, new DecimalValue(sum));
143143
} else {
144144
MeterResource meter = getMeter(key);
145145
meter.add(v);
146146
double d = meter.getAvg(30);
147147
double avg = meter.getAvg(300);
148148
FloatValue value = new FloatValue((float) d);
149149
FloatValue avgValue = new FloatValue((float) avg);
150-
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).put(ctx.counter, value);
151-
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).put(ctx.counter, avgValue);
150+
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, value);
151+
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, avgValue);
152152
}
153153
} catch (Exception e) {
154154
errors.add(ctx.attrName);
@@ -268,23 +268,30 @@ private static String checkObjName(String name) {
268268
}
269269

270270
class CtxObj {
271-
private String objName;
272-
private ObjectName mbean;
273-
private String objType;
274-
private byte valueType;
275-
private String attrName;
276-
private String counter;
271+
public int mbeanHash;
272+
public String objName;
273+
public ObjectName mbean;
274+
public String objType;
275+
public byte valueType;
276+
public String attrName;
277+
public String counter;
277278

278279
public CtxObj(String objName, ObjectName mbean, String objType, byte valueType, String attrName, String counter) {
279280

280281
this.objName = objName;
281282
this.mbean = mbean;
283+
this.mbeanHash = HashUtil.hash(mbean.toString());
282284
this.objType = objType;
283285
this.valueType = valueType;
284286
this.attrName = attrName;
285287
this.counter = counter;
286288
}
287289

288-
}
290+
@Override
291+
public String toString() {
292+
return "CtxObj [objName=" + objName + ", mbean=" + mbean + ", objType=" + objType + ", valueType="
293+
+ valueType + ", attrName=" + attrName + ", counter=" + counter + "]";
294+
}
289295

296+
}
290297
}

0 commit comments

Comments
 (0)