From: <Dam...@us...> - 2008-01-13 21:30:35
|
Revision: 1572 http://azsmrc.svn.sourceforge.net/azsmrc/?rev=1572&view=rev Author: Damokles Date: 2008-01-13 13:30:41 -0800 (Sun, 13 Jan 2008) Log Message: ----------- changed some layout replaced NodeLookup in refresh bucket with PingRefresh Modified Paths: -------------- azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/DHTView.java azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/RoutingTableCanvas.java azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHT.java azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHTBase.java azsmrcplugins/trunk/lbms/plugins/mldht/kad/Node.java azsmrcplugins/trunk/lbms/plugins/mldht/kad/PingRefreshTask.java Modified: azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/DHTView.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/DHTView.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/DHTView.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -15,6 +15,7 @@ import lbms.plugins.mldht.kad.messages.MessageBase.Type; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -119,6 +120,9 @@ sentBytes.setText(formatters.formatByteCountToKiBEtcPerSec(rpc.getSentBytesPerSec())); long uptimeSec = (System.currentTimeMillis() - stats.getStartedTimestamp()) / 1000; + if (uptimeSec == 0) { + uptimeSec = 1; + } uptime.setText(formatters.formatTimeFromSeconds(uptimeSec)); avgReceivedBytes.setText(formatters.formatByteCountToKiBEtcPerSec(rpc.getReceivedBytes() / uptimeSec)); @@ -171,10 +175,7 @@ createRPCGroup(comp); createMessageStatsGroup(comp); - GridData gd = new GridData(); - gd.horizontalSpan = 2; - rtc = new RoutingTableCanvas(comp, gd); - + createRoutingTableView(comp); createTaskTable(comp); } @@ -190,7 +191,7 @@ GridLayout gl = new GridLayout(2, false); grp.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); grp.setLayoutData(gd); Label ourIDLabel = new Label(grp, SWT.None); @@ -268,7 +269,7 @@ GridLayout gl = new GridLayout(2, true); grp.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); grp.setLayoutData(gd); Label peerLabel = new Label(grp, SWT.None); @@ -322,7 +323,7 @@ GridLayout gl = new GridLayout(2, true); grp.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); grp.setLayoutData(gd); Label rBytesLabel = new Label(grp, SWT.None); @@ -371,7 +372,7 @@ GridLayout gl = new GridLayout(6, false); grp.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); grp.setLayoutData(gd); //empty label @@ -432,11 +433,24 @@ } } + private void createRoutingTableView (Composite comp) { + ScrolledComposite sc = new ScrolledComposite(comp, SWT.H_SCROLL + | SWT.V_SCROLL | SWT.BORDER); + + GridData gd = new GridData(); + gd.horizontalSpan = 2; + + sc.setLayoutData(gd); + + rtc = new RoutingTableCanvas(sc); + } + private void createTaskTable (Composite comp) { taskTable = new Table(comp, SWT.VIRTUAL | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; + gd.minimumWidth = 150; taskTable.setLayoutData(gd); Modified: azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/RoutingTableCanvas.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/RoutingTableCanvas.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/azureus/gui/RoutingTableCanvas.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -6,6 +6,7 @@ import lbms.plugins.mldht.kad.KBucketEntry; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; @@ -59,7 +60,18 @@ public RoutingTableCanvas (Composite parent, Object layoutData) { display = parent.getDisplay(); img = new Image(display, DEFAULT_WIDTH, DEFAULT_HEIGHT); - canvas = new Canvas(parent, SWT.BORDER); + + if (parent instanceof ScrolledComposite) { + final ScrolledComposite sc = (ScrolledComposite) parent; + canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED); + sc.setContent(canvas); + sc.setExpandHorizontal(true); + sc.setExpandVertical(true); + sc.setMinHeight(DEFAULT_HEIGHT); + sc.setMinWidth(DEFAULT_WIDTH); + } else { + canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED | SWT.BORDER); + } canvas.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); calculateMeasures(DEFAULT_WIDTH, DEFAULT_HEIGHT); canvas.addPaintListener(new PaintListener() { Modified: azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHT.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHT.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHT.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -471,7 +471,7 @@ * If the either Task is finished than it will try to fill the Buckets. */ public synchronized void bootstrap () { - if (bootstrapping) { + if (!running || bootstrapping) { return; } bootstrapping = true; @@ -540,7 +540,10 @@ return null; } - public NodeLookup refreshBucket (Key id, KBucket bucket) { + /* (non-Javadoc) + * @see lbms.plugins.mldht.kad.DHTBase#fillBucket(lbms.plugins.mldht.kad.KBucket) + */ + public NodeLookup fillBucket (Key id, KBucket bucket) { if (!running) { return null; } @@ -563,6 +566,20 @@ return null; } + public PingRefreshTask refreshBucket (KBucket bucket) { + if (!running) { + return null; + } + + PingRefreshTask prt = new PingRefreshTask(srv, node, bucket, false); + if (canStartTask()) { + prt.start(); + } + tman.addTask(prt); + + return prt; + } + public boolean canStartTask () { // we can start a task if we have less then 7 runnning and // there are at least 16 RPC slots available Modified: azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHTBase.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHTBase.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/kad/DHTBase.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -103,7 +103,9 @@ NodeLookup findNode (Key id); - NodeLookup refreshBucket (Key id, KBucket bucket); + PingRefreshTask refreshBucket (KBucket bucket); + NodeLookup fillBucket (Key id, KBucket bucket); + Key getOurID (); } Modified: azsmrcplugins/trunk/lbms/plugins/mldht/kad/Node.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/kad/Node.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/kad/Node.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -133,8 +133,7 @@ if (b != null && b.needsToBeRefreshed()) { DHT.logDebug("Refreshing Bucket: " + i); // the key needs to be the refreshed - NodeLookup nl = dh_table.refreshBucket( - our_id.createKeyWithDistance(i), b); + PingRefreshTask nl = dh_table.refreshBucket(b); if (nl != null) { b.setRefreshTask(nl); nl.setInfo("Refreshing Bucket #" + i); @@ -162,7 +161,7 @@ foundFirst = true; DHT.logDebug("Filling Bucket: " + i); // the key needs to be the refreshed - NodeLookup nl = dh_table.refreshBucket( + NodeLookup nl = dh_table.fillBucket( our_id.createKeyWithDistance(i), b); if (nl != null) { b.setRefreshTask(nl); Modified: azsmrcplugins/trunk/lbms/plugins/mldht/kad/PingRefreshTask.java =================================================================== --- azsmrcplugins/trunk/lbms/plugins/mldht/kad/PingRefreshTask.java 2008-01-13 16:48:32 UTC (rev 1571) +++ azsmrcplugins/trunk/lbms/plugins/mldht/kad/PingRefreshTask.java 2008-01-13 21:30:41 UTC (rev 1572) @@ -40,6 +40,30 @@ } } + /** + * @param rpc + * @param node + * @param bucket the bucket to refresh + * @param cleanOnTimeout if true Nodes that fail to respond are removed. should be false for normal use. + */ + public PingRefreshTask (RPCServerBase rpc, Node node, KBucket bucket, + boolean cleanOnTimeout) { + super(rpc, node); + this.targetKey = node.getOurID(); + this.cleanOnTimeout = cleanOnTimeout; + if (cleanOnTimeout) { + lookupMap = new HashMap<MessageBase, KBucketEntry>(); + } + + if (bucket != null) { + for (KBucketEntry e : bucket.getEntries()) { + if (e.isQuestionable()) { + todo.add(e); + } + } + } + } + /* (non-Javadoc) * @see lbms.plugins.mldht.kad.Task#callFinished(lbms.plugins.mldht.kad.RPCCallBase, lbms.plugins.mldht.kad.messages.MessageBase) */ @@ -76,7 +100,7 @@ void update () { // go over the todo list and send ping // until we have nothing left - while (todo.size() > 0 && canDoRequest()) { + while (!todo.isEmpty() && canDoRequest()) { KBucketEntry e = todo.first(); todo.remove(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |