wsky / top-push

Message-push abstraction component, provide useful messaging components.
8 stars 4 forks source link

add btrace script for some methods #52

Closed wsky closed 10 years ago

wsky commented 10 years ago

PullRequestScheduler

wsky commented 10 years ago
package com.taobao.top.messaging.testsuite.btrace;

import com.sun.btrace.*;
import com.sun.btrace.BTraceUtils.Reflective;
import com.sun.btrace.annotations.*;

@BTrace
public class PullingTrigger {
    @OnMethod(
            clazz = "com.taobao.top.push.pulling.PullRequestScheduler",
            method = "acquirePulling",
            location = @Location(value = Kind.RETURN))
    public static void acquirePulling(
            AnyType[] args,
            @Return Object state) {
        Object id = Reflective.get(BTraceUtils.field(
                "com.taobao.top.messaging.channel.handle.pull.PullRequest",
                "toString"),
                args[1]);

        BTraceUtils.print(id);
        BTraceUtils.print(",");
        BTraceUtils.print(args[2]);
        BTraceUtils.print(",");
        BTraceUtils.print(args[3]);
        BTraceUtils.print(",");
        Reflective.printFields(state);
    }

    @OnMethod(
                        // care about abstract method
            clazz = "com.taobao.top.push.pulling.PullRequestScheduler",
            method = "continuingTrigger",
            location = @Location(value = Kind.RETURN))
    public static void continuingTrigger(AnyType[] args) {
        BTraceUtils.print("continue:");
        Reflective.printFields(args[0]);
    }
}