-1

I have 2 clusters in websphere 8.5 and a frecvent used method in an Ejb 3.1 stateless bean. I want to use a timer that logs every hour the fail and success count and average execution time.It is not important to be very accurate. What is the best/fastest way to keep statistics for every cluster node: EJB singleton, dynacache, class with static or synchronized methods,AtomicLong?

dapi
  • 11
  • 4

2 Answers2

0

My solution was to use an EJB Singleton with a timer (@Schedule) started in Postconstruct.

@Singleton
public class NodeStatistics {
private long totalTime = 0;
private int fail = 0;
private int success = 0;

@PostConstruct
@Schedule(hour = "*/1", minute = "0", second = "0", persistent = false)
public void run() {
    int count = this.fail + this.success;
    long avgTime = 0;
    if (count > 0) {
        avgTime = this.totalTime / count;
    }
    logStatistics();
    reset();
}

public void addFail(long time) {
    this.fail++;
    totalTime += time;
}

public void addSuccess(long time) {
    this.success++;
    totalTime += time;
}

public void reset() {
    this.fail = 0;
    this.success = 0;
}
}
dapi
  • 11
  • 4
-1

If you can access each cluster using direct URL. How about create a batch file to execute each cluster every hour.