Menu

#1 variation in results

open
nobody
None
5
2012-12-05
2004-05-11
No

When I run several times a Graph generation, I don't
have save result (max, total value) every time.

Discussion

  • David Bernard

    David Bernard - 2004-05-11

    first generation

     
  • David Bernard

    David Bernard - 2004-05-11
     
  • David Bernard

    David Bernard - 2004-05-11

    Logged In: YES
    user_id=103936

    Code use to generate the graph :
    ---
    public static RrdGraphDef generateGraph(Date start, Date
    end) throws Exception {
    RrdGraphDef def = new RrdGraphDef();
    def.setTimePeriod(start, end);
    def.setVerticalLabel("Messages throughput");
    def.setImageBorder(Color.GRAY, 1);
    def.setShowSignature(false);
    def.datasource("enqueue", RrdPath_, "enqueue",
    "AVERAGE");
    def.datasource("dequeue", RrdPath_, "dequeue",
    "AVERAGE");
    def.line("enqueue", Color.BLUE, "Throughput of
    incoming messages@L@r");
    def.gprint("enqueue", "AVERAGE", "average: @2.1
    msg/s@L");
    def.gprint("enqueue", "MAX", "maximum: @2.1 msg/s@C");
    def.gprint("enqueue", "TOTAL", "total: @4.1 msg@R@r");
    def.area("dequeue", Color.GREEN, "Throughput of
    outgoing messages@L@r");
    def.gprint("dequeue", "AVERAGE", "average: @2.1
    msg/s@L");
    def.gprint("dequeue", "MAX", "maximum: @2.1 msg/s@C");
    def.gprint("dequeue", "TOTAL", "total: @4.1 msg@R");
    def.setAntiAliasing(true);
    return def;
    }

    public static byte[] generateDailyGraph() throws Exception {
    Date end = new Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(end);
    cal.add(Calendar.DATE, -1);
    Date start = cal.getTime();
    RrdGraphDef graphDef = generateGraph(start, end);
    graphDef.setTitle("Daily Usage Traffic");
    return new RrdGraph(graphDef).getPNGBytes(600, 200);
    }
    ---

    Code use to create an fill the RDD :

    public void initialize() throws Exception {
    Stage stage = (Stage) manager.lookup(Stage.ROLE +
    '/' + queueName);
    queue = stage.getQueue();

    // create new RRD definition
    if (!new File(RRD_DATABASE_FILE).exists()) {
    try {
    RrdDef def = new RrdDef(RRD_DATABASE_FILE,
    PERIOD);
    def.addDatasource("enqueue", "COUNTER",
    PERIOD * 2, 0, Integer.MAX_VALUE);
    def.addDatasource("dequeue", "COUNTER",
    PERIOD * 2, 0, Integer.MAX_VALUE);

    // keep the info of every PERIOD over the
    last 24 hours
    def.addArchive("AVERAGE", 0.5, 1, (24 * 60 *
    60) / PERIOD);
    def.addArchive("MAX", 0.5, 1, (24 * 60 * 60)
    / PERIOD);

    // keep the info of every PERIOD in minutes
    over the last 7 days
    def.addArchive("AVERAGE", 0.5, 60, (7 * 24 *
    60) / PERIOD);
    def.addArchive("MAX", 0.5, 60, (7 * 24 * 60)
    / PERIOD);

    // keep the info of every PERIOD in hours
    over the last 31 days
    def.addArchive("AVERAGE", 0.5, 60 * 60, (31
    * 24) / PERIOD);
    def.addArchive("MAX", 0.5, 60 * 60, (31 *
    24) / PERIOD);
    RrdDb rrd = new RrdDb(def);
    rrd.close();
    } catch (Exception e) {
    log.info("Can't initialize the queue
    statistics", e);
    }
    }
    }

    public void run() {
    RrdDb rrd = null;
    RrdDbPool pool = null;
    try {
    pool = RrdDbPool.getInstance();
    rrd = pool.requestRrdDb(RRD_DATABASE_FILE);
    if (sample == null) {
    sample = rrd.createSample();
    } else {
    sample.setTime((System.currentTimeMillis() +
    500L) / 1000L);
    }
    sample.setValue("enqueue",
    queue.getMessageCountEnqueued());
    sample.setValue("dequeue",
    queue.getMessageCountDequeued());
    sample.update();
    pool.release(rrd);
    } catch (Exception e) {
    log.info("Can't update the memory statistics", e);
    } finally {
    if ((rrd != null) && (pool != null)){
    try {
    pool.release(rrd);
    } catch(Exception exc) {
    log.warn("Can't update the memory
    statistics", exc);
    }
    }
    }
    }