(release in the next hour or so)

2004-09-08  jrandom
    * Updated the "Active:" peer count to display the # of connections as well
      as the number of recently active router identities.
    * Implement some basic updating code - on startup, if there is a file named
      "i2pupdate.zip" in the I2P installation directory, extract it, delete it,
      then restart.
    * Added an ugly little script to allow launching the router on win9x
      machines without a dos box (using javaw to run a .bat file).
    * Logging updates.
    * Updated VERSION constants to 0.4.0.1
This commit is contained in:
jrandom
2004-09-09 02:26:42 +00:00
committed by zzz
parent af5665f67c
commit 39f3d6cc80
21 changed files with 211 additions and 53 deletions

View File

@ -25,6 +25,8 @@ public abstract class CommSystemFacade implements Service {
/** Create the set of RouterAddress structures based on the router's config */
public Set createAddresses() { return new HashSet(); }
public int countActivePeers() { return 0; }
}
class DummyCommSystemFacade extends CommSystemFacade {

View File

@ -251,39 +251,41 @@ public class JobQueue {
void shutdown() {
_alive = false;
StringBuffer buf = new StringBuffer(1024);
buf.append("current jobs: \n");
for (Iterator iter = _queueRunners.values().iterator(); iter.hasNext(); ) {
JobQueueRunner runner = (JobQueueRunner)iter.next();
Job j = runner.getCurrentJob();
buf.append("Runner ").append(runner.getRunnerId()).append(": ");
if (j == null) {
buf.append("no current job ");
} else {
buf.append(j.toString());
buf.append(" started ").append(_context.clock().now() - j.getTiming().getActualStart());
buf.append("ms ago");
}
j = runner.getLastJob();
if (j == null) {
buf.append("no last job");
} else {
buf.append(j.toString());
buf.append(" started ").append(_context.clock().now() - j.getTiming().getActualStart());
buf.append("ms ago and finished ");
buf.append(_context.clock().now() - j.getTiming().getActualEnd());
buf.append("ms ago");
if (_log.shouldLog(Log.WARN)) {
StringBuffer buf = new StringBuffer(1024);
buf.append("current jobs: \n");
for (Iterator iter = _queueRunners.values().iterator(); iter.hasNext(); ) {
JobQueueRunner runner = (JobQueueRunner)iter.next();
Job j = runner.getCurrentJob();
buf.append("Runner ").append(runner.getRunnerId()).append(": ");
if (j == null) {
buf.append("no current job ");
} else {
buf.append(j.toString());
buf.append(" started ").append(_context.clock().now() - j.getTiming().getActualStart());
buf.append("ms ago");
}
j = runner.getLastJob();
if (j == null) {
buf.append("no last job");
} else {
buf.append(j.toString());
buf.append(" started ").append(_context.clock().now() - j.getTiming().getActualStart());
buf.append("ms ago and finished ");
buf.append(_context.clock().now() - j.getTiming().getActualEnd());
buf.append("ms ago");
}
}
buf.append("\nready jobs: ").append(_readyJobs.size()).append("\n\t");
for (int i = 0; i < _readyJobs.size(); i++)
buf.append(_readyJobs.get(i).toString()).append("\n\t");
buf.append("\n\ntimed jobs: ").append(_timedJobs.size()).append("\n\t");
for (int i = 0; i < _timedJobs.size(); i++)
buf.append(_timedJobs.get(i).toString()).append("\n\t");
_log.log(Log.WARN, buf.toString());
}
buf.append("\nready jobs: ").append(_readyJobs.size()).append("\n\t");
for (int i = 0; i < _readyJobs.size(); i++)
buf.append(_readyJobs.get(i).toString()).append("\n\t");
buf.append("\n\ntimed jobs: ").append(_timedJobs.size()).append("\n\t");
for (int i = 0; i < _timedJobs.size(); i++)
buf.append(_timedJobs.get(i).toString()).append("\n\t");
_log.log(Log.CRIT, buf.toString());
}
boolean isAlive() { return _alive; }

View File

@ -131,8 +131,10 @@ public class MessageValidator {
}
void shutdown() {
StringBuffer buf = new StringBuffer(1024);
buf.append("Validated messages: ").append(_receivedIds.size());
_log.log(Log.CRIT, buf.toString());
if (_log.shouldLog(Log.WARN)) {
StringBuffer buf = new StringBuffer(1024);
buf.append("Validated messages: ").append(_receivedIds.size());
_log.log(Log.WARN, buf.toString());
}
}
}

View File

@ -716,10 +716,32 @@ public class Router {
}
public static void main(String args[]) {
installUpdates();
Router r = new Router();
r.runRouter();
}
private static final String UPDATE_FILE = "i2pupdate.zip";
private static void installUpdates() {
File updateFile = new File(UPDATE_FILE);
if (updateFile.exists()) {
System.out.println("INFO: Update file exists [" + UPDATE_FILE + "] - installing");
boolean ok = DataHelper.extractZip(updateFile, new File("."));
if (ok)
System.out.println("INFO: Update installed");
else
System.out.println("ERROR: Update failed!");
boolean deleted = updateFile.delete();
if (!deleted) {
System.out.println("ERROR: Unable to delete the update file!");
updateFile.deleteOnExit();
}
System.out.println("INFO: Restarting after update");
System.exit(EXIT_HARD_RESTART);
}
}
private static String getPingFile(Properties envProps) {
if (envProps != null)
return envProps.getProperty("router.pingFile", "router.ping");

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.27 $ $Date: 2004/09/07 17:13:11 $";
public final static String VERSION = "0.4";
public final static long BUILD = 10;
public final static String ID = "$Revision: 1.28 $ $Date: 2004/09/08 17:05:35 $";
public final static String VERSION = "0.4.0.1";
public final static long BUILD = 0;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -52,6 +52,8 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
_manager.restart();
}
public int countActivePeers() { return _manager.countActivePeers(); }
public List getBids(OutNetMessage msg) {
return _manager.getBids(msg);
}

View File

@ -40,12 +40,14 @@ public class OutboundMessageRegistry {
}
public void shutdown() {
StringBuffer buf = new StringBuffer(1024);
buf.append("Pending messages: ").append(_pendingMessages.size()).append("\n");
for (Iterator iter = _pendingMessages.values().iterator(); iter.hasNext(); ) {
buf.append(iter.next().toString()).append("\n\t");
if (_log.shouldLog(Log.WARN)) {
StringBuffer buf = new StringBuffer(1024);
buf.append("Pending messages: ").append(_pendingMessages.size()).append("\n");
for (Iterator iter = _pendingMessages.values().iterator(); iter.hasNext(); ) {
buf.append(iter.next().toString()).append("\n\t");
}
_log.log(Log.WARN, buf.toString());
}
_log.log(Log.CRIT, buf.toString());
}
/**

View File

@ -37,5 +37,7 @@ public interface Transport {
public void setListener(TransportEventListener listener);
public String getStyle();
public int countActivePeers();
public String renderStatusHTML();
}

View File

@ -52,6 +52,8 @@ public abstract class TransportImpl implements Transport {
_currentAddresses = new HashSet();
}
public int countActivePeers() { return 0; }
public OutNetMessage getNextMessage() {
OutNetMessage msg = null;
synchronized (_sendPool) {

View File

@ -124,6 +124,14 @@ public class TransportManager implements TransportEventListener {
return false;
}
public int countActivePeers() {
int peers = 0;
for (int i = 0; i < _transports.size(); i++) {
peers += ((Transport)_transports.get(i)).countActivePeers();
}
return peers;
}
public List getBids(OutNetMessage msg) {
if (msg == null)
throw new IllegalArgumentException("Null message? no bidding on a null outNetMessage!");

View File

@ -103,6 +103,13 @@ public class TCPTransport extends TransportImpl {
SigningPrivateKey getMySigningKey() { return _context.keyManager().getSigningPrivateKey(); }
int getListenPort() { return _listenPort; }
public int countActivePeers() {
synchronized (_connections) {
return _connections.size();
}
}
/** fetch all of our TCP listening addresses */
TCPAddress[] getMyAddresses() {
if (_address != null) {