📄 transactioncanvas.java
字号:
//$Id: TransactionCanvas.java,v 1.3 2002/08/27 08:32:26 per_nyfelt Exp $
package org.ozoneDB.core.monitor;
import org.ozoneDB.DxLib.*;
import org.ozoneDB.core.*;
import java.awt.*;
import java.awt.event.*;
public class TransactionCanvas extends Canvas {
static Color createColor = new Color( 255, 150, 80 );
static Color readColor = new Color( 176, 196, 222 );
static Color writeColor = new Color( 123, 104, 238 );
private Graphics dbg;
private Image dbImage;
/** */
public TransactionCanvas() {
setBackground( StorageCanvas.bg1Color );
}
/** */
public void update( Graphics g ) {
if (dbImage == null) {
/* BUG 0: deprecated function: size() */
dbImage = createImage( size().width, size().height );
dbg = dbImage.getGraphics();
}
paint( dbg );
g.drawImage( dbImage, 0, 0, this );
}
/** */
public void paint( Graphics g ) {
super.paint( g );
Rectangle rect = getBounds();
g.setColor( StorageCanvas.bg1Color );
g.fillRect( 1, 1, rect.width - 2, rect.height - 2 );
g.draw3DRect( 1, 1, rect.width - 2, rect.height - 2, true );
g.setColor( StorageCanvas.headColor );
g.fillRect( 3, 3, rect.width - 5, 13 );
g.setColor( Color.white );
g.drawString( "Transaction View", 6, 13 );
int viewHeight = (rect.height - 60) / 3;
Rectangle osRect = new Rectangle( 10, rect.height - viewHeight * 3 - 40, rect.width - 20, viewHeight );
updateCV( g, osRect );
Rectangle csRect = new Rectangle( 10, rect.height - viewHeight * 2 - 25, rect.width - 20, viewHeight );
updateBV( g, csRect );
Rectangle psRect = new Rectangle( 10, rect.height - viewHeight - 10, rect.width - 20, viewHeight );
updateTV( g, psRect );
}
/** */
public void updateTV( Graphics g, Rectangle r ) {
TransactionManager tam = Env.currentEnv().transactionManager;
g.setColor( StorageCanvas.bgColor );
g.fillRect( r.x, r.y + 14, r.width, r.height - 14 );
g.draw3DRect( r.x, r.y + 14, r.width, r.height - 14, false );
/*
int read = 0;
int write = 0;
int create = 0;
int viewW = r.width / 4;
DxIterator it = tam.taTable.iterator();
for (int i = 0; i < 4; i++) {
if (i > 0) {
g.setColor( StorageCanvas.bgColor );
g.draw3DRect( r.x + viewW * i - 1, r.y + 14, 1, r.height - 14, true );
}
Transaction ta = (Transaction)it.next();
if (ta != null && ta.createTable != null) {
Rectangle taRect = new Rectangle( r.x + viewW * i + 1, r.y + 14 + 1, viewW, r.height - 14 - 1 );
updateTA( g, taRect, ta );
create += ta.createTable.count();
read += ta.readTable.count();
write += ta.writeTable.count();
}
}
g.setColor( StorageCanvas.fontColor );
String label =
"Object access - " + new Integer( tam.taTable.count() ).toString() + " transactions [ " + new Integer(
create ).toString() + " / " + new Integer( read ).toString() + " / " + new Integer( write ).toString()
+ " ]";
g.drawString( label, r.x, r.y + 12 );
*/
}
/** */
public void updateTA( Graphics g, Rectangle r, Transaction ta ) {
/*
int max = ta.createTable.count();
max = Math.max( max, ta.readTable.count() );
max = Math.max( max, ta.writeTable.count() );
int scale = 1;
while (max / scale > r.height) {
scale++;
}
int bw = r.width / 3;
int bh = ta.createTable.count() / scale;
g.setColor( createColor );
g.fillRect( r.x, r.y + r.height - bh, bw, bh );
bh = ta.readTable.count() / scale;
g.setColor( readColor );
g.fillRect( r.x + bw, r.y + r.height - bh, bw, bh );
bh = ta.writeTable.count() / scale;
g.setColor( writeColor );
g.fillRect( r.x + bw * 2, r.y + r.height - bh, bw, bh );
*/
}
/** */
public void updateBV( Graphics g, Rectangle r ) {
TransactionManager tam = Env.currentEnv().transactionManager;
g.setColor( StorageCanvas.bgColor );
g.fillRect( r.x, r.y + 14, r.width, r.height - 14 );
g.draw3DRect( r.x, r.y + 14, r.width, r.height - 14, false );
g.setColor( StorageCanvas.fontColor );
String label = "Blocking";
g.drawString( label, r.x, r.y + 12 );
int y = r.y + 14 + 14;
int x = r.x + 5;
g.setColor( StorageCanvas.fontColor );
/*
if (tam.taTable.isEmpty()) {
g.drawString( "No transactions.", x, y );
} else {
boolean somethingBlocked = false;
DxIterator it = tam.taTable.iterator();
Transaction ta;
while ((ta = (Transaction)it.next()) != null) {
if (ta.blocker != null) {
somethingBlocked = true;
Transaction blocker = Env.currentEnv().objectSpace.objectForID( ta.blocker ).writeLocker;
g.drawString( new Short( (short)ta.taID.hashCode() ).toString() + " blocked by " + new Short(
(short)blocker.taID.hashCode() ).toString(), x, y );
y += 14;
}
}
if (!somethingBlocked) {
g.drawString( "No transaction blocked.", x, y );
}
}
*/
}
/** */
public void updateCV( Graphics g, Rectangle r ) {
TransactionManager tam = Env.currentEnv().transactionManager;
g.setColor( StorageCanvas.bgColor );
g.fillRect( r.x, r.y + 14, r.width, r.height - 14 );
g.draw3DRect( r.x, r.y + 14, r.width, r.height - 14, false );
g.setColor( StorageCanvas.fontColor );
String label = "Clients - ";
g.drawString( label, r.x, r.y + 12 );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -