User: juhalindfors
Date: 01/04/16 14:55:20
Modified: src/org/jboss/admin/monitor/graph DefaultGraphModel.java
DefaultGraphRenderer.java GraphModel.java
InvocationTimeGraphModel.java
Log:
initial cache monitoring + a bunch of other stuff
Revision Changes Path
1.3 +79 -2 admin/src/org/jboss/admin/monitor/graph/DefaultGraphModel.java
Index: DefaultGraphModel.java
===================================================================
RCS file:
/cvsroot/jboss/admin/src/org/jboss/admin/monitor/graph/DefaultGraphModel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultGraphModel.java 2001/02/18 20:31:01 1.2
+++ DefaultGraphModel.java 2001/04/16 21:55:20 1.3
@@ -27,10 +27,59 @@
protected EventListenerList listenerList = new EventListenerList();
+ protected double max = 1.0;
+ protected double min = 0.0;
+
/* lazy create */
// hmm? protected GraphModelEvent graphModelEvent = null;
+/*
+ *************************************************************************
+ *
+ * PUBLIC INSTANCE METHODS
+ *
+ *************************************************************************
+ */
+
+ /*
+ * note that cannot max < min
+ */
+ public void setVerticalMax(double max) {
+ this.max = max;
+
+ fireLimitChanged(max, GraphModelListener.MAX_VERTICAL_LIMIT);
+
+ if (max < min)
+ setVerticalMin(max);
+ }
+
+ public double getVerticalMax() {
+ return max;
+ }
+
+ /*
+ * note that cannot min > max
+ */
+ public void setVerticalMin(double min) {
+ this.min = min;
+
+ fireLimitChanged(min, GraphModelListener.MIN_VERTICAL_LIMIT);
+
+ if (min > max)
+ setVerticalMax(min);
+ }
+
+ public double getVerticalMin() {
+ return min;
+ }
+
+ public double getHorizontalMin() {
+ throw new Error("NYI");
+ }
+ public double getHorizontalMax() {
+ throw new Error("NYI");
+ }
/*
*************************************************************************
*
@@ -41,11 +90,16 @@
/*
* append is synchronized
+ * will automatically set max
*/
public void append(Number number) {
xAxis.add(number);
+ double value = number.doubleValue();
- fireValueAppended(number.doubleValue());
+ if (value > getVerticalMax())
+ setVerticalMax(value);
+
+ fireValueAppended(value);
}
public Collection getPlotPoints() {
@@ -97,6 +151,29 @@
}
}
}
-
+
+ /*
+ * Notify all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created using the parameters passed into
+ * the fire method.
+ */
+ protected void fireLimitChanged(double value, int target) {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length-2; i >= 0; i -= 2) {
+
+ if (listeners[i] == GraphModelListener.class) {
+
+ GraphModelEvent evt = new GraphModelEvent(this, value, target);
+
+ ((GraphModelListener)listeners[i+1]).limitChanged(evt);
+ }
+ }
+ }
+
}
1.4 +68 -40
admin/src/org/jboss/admin/monitor/graph/DefaultGraphRenderer.java
Index: DefaultGraphRenderer.java
===================================================================
RCS file:
/cvsroot/jboss/admin/src/org/jboss/admin/monitor/graph/DefaultGraphRenderer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultGraphRenderer.java 2001/02/18 20:31:01 1.3
+++ DefaultGraphRenderer.java 2001/04/16 21:55:20 1.4
@@ -54,9 +54,11 @@
private ArrayList points = new ArrayList();
-
- GraphController controller = new GraphController(GraphController.VERTICAL);
-
+ private boolean autoScale = true;
+
+ private GraphController controller = new
GraphController(GraphController.VERTICAL);
+
+ private GraphView parent = null;
/*
*************************************************************************
*
@@ -71,10 +73,28 @@
setOpaque(true);
// set bevel border around the graph (not the controls though)
- setBorder(new BevelBorder(BevelBorder.LOWERED));
+ setBorder(new BevelBorder(BevelBorder.LOWERED));
+
+ // enable auto-scaling
+ //setAutoScaleEnabled(true);
}
-
+/*
+ *************************************************************************
+ *
+ * PUBLIC INSTANCE METHODS
+ *
+ *************************************************************************
+ */
+
+// public void setAutoScaleEnabled(boolean autoScale) {
+// this.autoScale = autoScale;
+// }
+//
+// public boolean isAutoScaled() {
+// return autoScale;
+// }
+
/*
*************************************************************************
*
@@ -85,23 +105,25 @@
public Component getGraphRendererObject(GraphView graph) {
- try {
- points = new ArrayList(graph.getModel().getPlotPoints());
+ try {
+ //Point maxPoint = (Point)Collections.max(points, new
PointComparator());
- Point maxPoint = (Point)Collections.max(points, new PointComparator());
-
- if (!isWithinScale(maxPoint.getY()))
- rescale(maxPoint.getY());
-
+ //if (isAutoScaled())
+ // if (!isWithinScale(maxPoint.getY()))
+ // rescale(maxPoint.getY());
+ this.parent = graph;
+ this.max = graph.getModel().getVerticalMax();
+
+ points = new ArrayList(graph.getModel().getPlotPoints());
Collections.reverse(points);
}
catch (NoSuchElementException ignored) {
// collection was empty, just ignore
- }
- catch (ClassCastException e) {
- System.err.println(e);
- e.printStackTrace();
}
+// catch (ClassCastException e) {
+// System.err.println(e);
+// e.printStackTrace();
+// }
return this;
}
@@ -115,7 +137,7 @@
controller.setVerticalGridGap(gridGapWidth);
controller.setVerticalMinValue(0);
- controller.setVerticalMaxValue(max);
+ controller.setVerticalMaxValue(graph.getVerticalMax());
return controller;
}
@@ -125,12 +147,21 @@
double value = evt.getValue();
points.add(0, new Point(points.size(), (int)value));
- if (!isWithinScale(value))
- rescale(value);
+ //if (isAutoScaled())
+ // if (!isWithinScale(value))
+ // rescale(value);
repaint();
}
+ public void limitChanged(GraphModelEvent evt) {
+
+ // just checking this one limit for now
+ if (evt.getTarget() == MAX_VERTICAL_LIMIT)
+ max = evt.getValue();
+ // [TODO] these should tweak the controller objects
+
+ }
/*
*************************************************************************
*
@@ -241,9 +272,6 @@
// set drawing color
g.setColor(plotColor);
- //int x = ((points.size() * horzPlotStep) < width)
- // ? width - points.size() * horzPlotStep
- // : 0;
int x = width - 1;
int y = height - 1;
@@ -251,29 +279,29 @@
while ((it.hasNext()) && (x >= 0)) {
Point p = (Point)it.next();
- g.drawLine(x, y, (x -= horzPlotStep), (y = height - (int)(p.y * height
/ max)));
+ g.drawLine(x, y, (x -= horzPlotStep), (y = height - (int)(p.y * height
/ parent.getVerticalMax())));
--x;
}
}
-
- private boolean isWithinScale(Double value) {
- return isWithinScale(value.doubleValue());
- }
-
- private boolean isWithinScale(double value) {
-
- if (value < 0.9 * max)
- return true;
-
- return false;
- }
- private void rescale(double value) {
-
- max = 1.4 * value;
-
- }
+// private boolean isWithinScale(Double value) {
+// return isWithinScale(value.doubleValue());
+// }
+//
+// private boolean isWithinScale(double value) {
+//
+// if (value < 0.9 * parent.getVerticalMax())
+// return true;
+//
+// return false;
+// }
+//
+// private void rescale(double value) {
+//
+// max = 1.4 * value;
+//
+// }
/*
*************************************************************************
1.2 +8 -7 admin/src/org/jboss/admin/monitor/graph/GraphModel.java
Index: GraphModel.java
===================================================================
RCS file: /cvsroot/jboss/admin/src/org/jboss/admin/monitor/graph/GraphModel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GraphModel.java 2000/12/17 20:11:23 1.1
+++ GraphModel.java 2001/04/16 21:55:20 1.2
@@ -14,13 +14,14 @@
*/
public interface GraphModel {
- void append(Number number);
-
- Collection getPlotPoints();
-
- void addGraphModelListener(GraphModelListener listener);
-
- void removeGraphModelListener(GraphModelListener listener);
+ public Collection getPlotPoints();
+ public void append(Number number);
+ public double getVerticalMax();
+ public double getVerticalMin();
+ public double getHorizontalMax();
+ public double getHorizontalMin();
+ public void addGraphModelListener(GraphModelListener listener);
+ public void removeGraphModelListener(GraphModelListener listener);
}
1.3 +49 -33
admin/src/org/jboss/admin/monitor/graph/InvocationTimeGraphModel.java
Index: InvocationTimeGraphModel.java
===================================================================
RCS file:
/cvsroot/jboss/admin/src/org/jboss/admin/monitor/graph/InvocationTimeGraphModel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InvocationTimeGraphModel.java 2001/02/18 20:31:01 1.2
+++ InvocationTimeGraphModel.java 2001/04/16 21:55:20 1.3
@@ -37,6 +37,9 @@
private int mode = CONTINUOUS_UPDATE;
+ private Thread updateThread = null;
+ private boolean running = true;
+
/*
*************************************************************************
*
@@ -46,37 +49,37 @@
*/
public InvocationTimeGraphModel() {
- this(CONTINUOUS_UPDATE);
+ // this(CONTINUOUS_UPDATE);
}
- public InvocationTimeGraphModel(int mode) {
-
- this.mode = mode;
-
- // Just a little tweak. Add a few zeroes to the model so the
- // first actual entries don't look so lonely.
- for (int i = 0; i < 10; ++i)
- append(new Integer(0));
-
- switch (mode) {
-
- case CONTINUOUS_UPDATE:
-
- Thread t = new Thread(this);
- t.start();
-
- break;
-
- case PER_INVOCATION_UPDATE:
-
-
- break;
-
- default:
- throw new IllegalArgumentException("Invalid mode: " +
getModeAsString(mode));
- }
-
- }
+// public InvocationTimeGraphModel(int mode) {
+//
+// this.mode = mode;
+//
+// // Just a little tweak. Add a few zeroes to the model so the
+// // first actual entries don't look so lonely.
+// for (int i = 0; i < 10; ++i)
+// append(new Integer(0));
+//
+// switch (mode) {
+//
+// case CONTINUOUS_UPDATE:
+//
+// Thread t = new Thread(this);
+// t.start();
+//
+// break;
+//
+// case PER_INVOCATION_UPDATE:
+//
+//
+// break;
+//
+// default:
+// throw new IllegalArgumentException("Invalid mode: " +
getModeAsString(mode));
+// }
+//
+// }
/*
*************************************************************************
@@ -115,7 +118,7 @@
}
}
- public void setContinuousUpdateInterval(long ms) {
+ public void setUpdateInterval(long ms) {
if (ms <= 0) {
System.err.println("negative or zero delay: " + ms);
return;
@@ -124,11 +127,25 @@
this.delay = ms;
}
- public long getContinuousUpdateInterval() {
+ public long getUpdateInterval() {
return delay;
}
-
+ public void startContinuousUpdate() {
+
+ running = true;
+
+ updateThread = new Thread(this);
+ updateThread.setName("Invocation Time Update Thread");
+ updateThread.setDaemon(true);
+
+ updateThread.start();
+ }
+
+ public void stopContinuousUpdate() {
+ running = false;
+ updateThread.interrupt();
+ }
/*
*************************************************************************
@@ -154,7 +171,6 @@
}
}
}
- private boolean running = true;
/*
* This is just for the timer thread to call
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development