more splitting classes
This commit is contained in:
@ -92,29 +92,3 @@ public abstract class ClientManagerFacade implements Service {
|
||||
public abstract SessionConfig getClientSessionConfig(Destination dest);
|
||||
public void renderStatusHTML(Writer out) throws IOException { }
|
||||
}
|
||||
|
||||
class DummyClientManagerFacade extends ClientManagerFacade {
|
||||
private RouterContext _context;
|
||||
public DummyClientManagerFacade(RouterContext ctx) {
|
||||
_context = ctx;
|
||||
}
|
||||
public boolean isLocal(Hash destHash) { return true; }
|
||||
public boolean isLocal(Destination dest) { return true; }
|
||||
public void reportAbuse(Destination dest, String reason, int severity) { }
|
||||
public void messageReceived(ClientMessage msg) {}
|
||||
public void requestLeaseSet(Destination dest, LeaseSet set, long timeout,
|
||||
Job onCreateJob, Job onFailedJob) {
|
||||
_context.jobQueue().addJob(onFailedJob);
|
||||
}
|
||||
public void startup() {}
|
||||
public void stopAcceptingClients() { }
|
||||
public void shutdown() {}
|
||||
public void restart() {}
|
||||
|
||||
public void messageDeliveryStatusUpdate(Destination fromDest, MessageId id, boolean delivered) {}
|
||||
|
||||
public SessionConfig getClientSessionConfig(Destination _dest) { return null; }
|
||||
|
||||
public void requestLeaseSet(Hash dest, LeaseSet set) {}
|
||||
|
||||
}
|
||||
|
@ -91,9 +91,11 @@ public abstract class CommSystemFacade implements Service {
|
||||
|
||||
}
|
||||
|
||||
/** unused
|
||||
class DummyCommSystemFacade extends CommSystemFacade {
|
||||
public void shutdown() {}
|
||||
public void startup() {}
|
||||
public void restart() {}
|
||||
public void processMessage(OutNetMessage msg) { }
|
||||
}
|
||||
**/
|
||||
|
47
router/java/src/net/i2p/router/DummyClientManagerFacade.java
Normal file
47
router/java/src/net/i2p/router/DummyClientManagerFacade.java
Normal file
@ -0,0 +1,47 @@
|
||||
package net.i2p.router;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by jrandom in 2003 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.LeaseSet;
|
||||
import net.i2p.data.i2cp.MessageId;
|
||||
import net.i2p.data.i2cp.SessionConfig;
|
||||
|
||||
/**
|
||||
* Manage all interactions with clients
|
||||
*
|
||||
* @author jrandom
|
||||
*/
|
||||
public class DummyClientManagerFacade extends ClientManagerFacade {
|
||||
private RouterContext _context;
|
||||
public DummyClientManagerFacade(RouterContext ctx) {
|
||||
_context = ctx;
|
||||
}
|
||||
public boolean isLocal(Hash destHash) { return true; }
|
||||
public boolean isLocal(Destination dest) { return true; }
|
||||
public void reportAbuse(Destination dest, String reason, int severity) { }
|
||||
public void messageReceived(ClientMessage msg) {}
|
||||
public void requestLeaseSet(Destination dest, LeaseSet set, long timeout,
|
||||
Job onCreateJob, Job onFailedJob) {
|
||||
_context.jobQueue().addJob(onFailedJob);
|
||||
}
|
||||
public void startup() {}
|
||||
public void stopAcceptingClients() { }
|
||||
public void shutdown() {}
|
||||
public void restart() {}
|
||||
|
||||
public void messageDeliveryStatusUpdate(Destination fromDest, MessageId id, boolean delivered) {}
|
||||
|
||||
public SessionConfig getClientSessionConfig(Destination _dest) { return null; }
|
||||
|
||||
public void requestLeaseSet(Hash dest, LeaseSet set) {}
|
||||
|
||||
}
|
||||
|
32
router/java/src/net/i2p/router/DummyPeerManagerFacade.java
Normal file
32
router/java/src/net/i2p/router/DummyPeerManagerFacade.java
Normal file
@ -0,0 +1,32 @@
|
||||
package net.i2p.router;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by jrandom in 2003 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
|
||||
/**
|
||||
* Manage peer references and keep them up to date so that when asked for peers,
|
||||
* it can provide appropriate peers according to the criteria provided. This
|
||||
* includes periodically queueing up outbound messages to the peers to test them.
|
||||
*
|
||||
*/
|
||||
class DummyPeerManagerFacade implements PeerManagerFacade {
|
||||
public void shutdown() {}
|
||||
public void startup() {}
|
||||
public void restart() {}
|
||||
public void renderStatusHTML(Writer out) { }
|
||||
public List selectPeers(PeerSelectionCriteria criteria) { return null; }
|
||||
public List getPeersByCapability(char capability) { return null; }
|
||||
public void setCapabilities(Hash peer, String caps) {}
|
||||
public void removeCapabilities(Hash peer) {}
|
||||
public Hash selectRandomByCapability(char capability) { return null; }
|
||||
}
|
52
router/java/src/net/i2p/router/DummyTunnelManagerFacade.java
Normal file
52
router/java/src/net/i2p/router/DummyTunnelManagerFacade.java
Normal file
@ -0,0 +1,52 @@
|
||||
package net.i2p.router;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by jrandom in 2003 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.TunnelId;
|
||||
|
||||
/**
|
||||
* Build and maintain tunnels throughout the network.
|
||||
*
|
||||
*/
|
||||
class DummyTunnelManagerFacade implements TunnelManagerFacade {
|
||||
|
||||
public TunnelInfo getTunnelInfo(TunnelId id) { return null; }
|
||||
public TunnelInfo selectInboundTunnel() { return null; }
|
||||
public TunnelInfo selectInboundTunnel(Hash destination) { return null; }
|
||||
public TunnelInfo selectOutboundTunnel() { return null; }
|
||||
public TunnelInfo selectOutboundTunnel(Hash destination) { return null; }
|
||||
public boolean isInUse(Hash peer) { return false; }
|
||||
public boolean isValidTunnel(Hash client, TunnelInfo tunnel) { return false; }
|
||||
public int getParticipatingCount() { return 0; }
|
||||
public int getFreeTunnelCount() { return 0; }
|
||||
public int getOutboundTunnelCount() { return 0; }
|
||||
public int getInboundClientTunnelCount() { return 0; }
|
||||
public int getOutboundClientTunnelCount() { return 0; }
|
||||
public long getLastParticipatingExpiration() { return -1; }
|
||||
public void buildTunnels(Destination client, ClientTunnelSettings settings) {}
|
||||
public TunnelPoolSettings getInboundSettings() { return null; }
|
||||
public TunnelPoolSettings getOutboundSettings() { return null; }
|
||||
public TunnelPoolSettings getInboundSettings(Hash client) { return null; }
|
||||
public TunnelPoolSettings getOutboundSettings(Hash client) { return null; }
|
||||
public void setInboundSettings(TunnelPoolSettings settings) {}
|
||||
public void setOutboundSettings(TunnelPoolSettings settings) {}
|
||||
public void setInboundSettings(Hash client, TunnelPoolSettings settings) {}
|
||||
public void setOutboundSettings(Hash client, TunnelPoolSettings settings) {}
|
||||
public int getInboundBuildQueueSize() { return 0; }
|
||||
|
||||
public void renderStatusHTML(Writer out) throws IOException {}
|
||||
public void restart() {}
|
||||
public void shutdown() {}
|
||||
public void startup() {}
|
||||
}
|
@ -32,15 +32,3 @@ public interface PeerManagerFacade extends Service {
|
||||
public void removeCapabilities(Hash peer);
|
||||
public Hash selectRandomByCapability(char capability);
|
||||
}
|
||||
|
||||
class DummyPeerManagerFacade implements PeerManagerFacade {
|
||||
public void shutdown() {}
|
||||
public void startup() {}
|
||||
public void restart() {}
|
||||
public void renderStatusHTML(Writer out) { }
|
||||
public List selectPeers(PeerSelectionCriteria criteria) { return null; }
|
||||
public List getPeersByCapability(char capability) { return null; }
|
||||
public void setCapabilities(Hash peer, String caps) {}
|
||||
public void removeCapabilities(Hash peer) {}
|
||||
public Hash selectRandomByCapability(char capability) { return null; }
|
||||
}
|
||||
|
@ -79,35 +79,3 @@ public interface TunnelManagerFacade extends Service {
|
||||
public void setInboundSettings(Hash client, TunnelPoolSettings settings);
|
||||
public void setOutboundSettings(Hash client, TunnelPoolSettings settings);
|
||||
}
|
||||
|
||||
class DummyTunnelManagerFacade implements TunnelManagerFacade {
|
||||
|
||||
public TunnelInfo getTunnelInfo(TunnelId id) { return null; }
|
||||
public TunnelInfo selectInboundTunnel() { return null; }
|
||||
public TunnelInfo selectInboundTunnel(Hash destination) { return null; }
|
||||
public TunnelInfo selectOutboundTunnel() { return null; }
|
||||
public TunnelInfo selectOutboundTunnel(Hash destination) { return null; }
|
||||
public boolean isInUse(Hash peer) { return false; }
|
||||
public boolean isValidTunnel(Hash client, TunnelInfo tunnel) { return false; }
|
||||
public int getParticipatingCount() { return 0; }
|
||||
public int getFreeTunnelCount() { return 0; }
|
||||
public int getOutboundTunnelCount() { return 0; }
|
||||
public int getInboundClientTunnelCount() { return 0; }
|
||||
public int getOutboundClientTunnelCount() { return 0; }
|
||||
public long getLastParticipatingExpiration() { return -1; }
|
||||
public void buildTunnels(Destination client, ClientTunnelSettings settings) {}
|
||||
public TunnelPoolSettings getInboundSettings() { return null; }
|
||||
public TunnelPoolSettings getOutboundSettings() { return null; }
|
||||
public TunnelPoolSettings getInboundSettings(Hash client) { return null; }
|
||||
public TunnelPoolSettings getOutboundSettings(Hash client) { return null; }
|
||||
public void setInboundSettings(TunnelPoolSettings settings) {}
|
||||
public void setOutboundSettings(TunnelPoolSettings settings) {}
|
||||
public void setInboundSettings(Hash client, TunnelPoolSettings settings) {}
|
||||
public void setOutboundSettings(Hash client, TunnelPoolSettings settings) {}
|
||||
public int getInboundBuildQueueSize() { return 0; }
|
||||
|
||||
public void renderStatusHTML(Writer out) throws IOException {}
|
||||
public void restart() {}
|
||||
public void shutdown() {}
|
||||
public void startup() {}
|
||||
}
|
||||
|
@ -81,23 +81,23 @@ public class RepublishLeaseSetJob extends JobImpl {
|
||||
_log.warn("FAILED publishing of the leaseSet for " + _dest.toBase64());
|
||||
requeue(getContext().random().nextInt(60*1000));
|
||||
}
|
||||
}
|
||||
|
||||
class OnRepublishSuccess extends JobImpl {
|
||||
public OnRepublishSuccess(RouterContext ctx) { super(ctx); }
|
||||
public String getName() { return "Publish leaseSet successful"; }
|
||||
public void runJob() {
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("successful publishing of the leaseSet for " + _dest.toBase64());
|
||||
class OnRepublishSuccess extends JobImpl {
|
||||
public OnRepublishSuccess(RouterContext ctx) { super(ctx); }
|
||||
public String getName() { return "Publish leaseSet successful"; }
|
||||
public void runJob() {
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("successful publishing of the leaseSet for " + _dest.toBase64());
|
||||
}
|
||||
}
|
||||
|
||||
class OnRepublishFailure extends JobImpl {
|
||||
private RepublishLeaseSetJob _job;
|
||||
public OnRepublishFailure(RouterContext ctx, RepublishLeaseSetJob job) {
|
||||
super(ctx);
|
||||
_job = job;
|
||||
}
|
||||
public String getName() { return "Publish leaseSet failed"; }
|
||||
public void runJob() { _job.requeueRepublish(); }
|
||||
}
|
||||
}
|
||||
|
||||
class OnRepublishFailure extends JobImpl {
|
||||
private RepublishLeaseSetJob _job;
|
||||
public OnRepublishFailure(RouterContext ctx, RepublishLeaseSetJob job) {
|
||||
super(ctx);
|
||||
_job = job;
|
||||
}
|
||||
public String getName() { return "Publish leaseSet failed"; }
|
||||
public void runJob() { _job.requeueRepublish(); }
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.i2p.router.peermanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.router.JobImpl;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
class PersistProfileJob extends JobImpl {
|
||||
private PersistProfilesJob _job;
|
||||
private Iterator _peers;
|
||||
public PersistProfileJob(RouterContext enclosingContext, PersistProfilesJob job, Set peers) {
|
||||
super(enclosingContext);
|
||||
_peers = peers.iterator();
|
||||
_job = job;
|
||||
}
|
||||
public void runJob() {
|
||||
if (_peers.hasNext())
|
||||
_job.persist((Hash)_peers.next());
|
||||
if (_peers.hasNext()) {
|
||||
requeue(1000);
|
||||
} else {
|
||||
// no more left, requeue up the main persist-em-all job
|
||||
_job.requeue();
|
||||
}
|
||||
}
|
||||
public String getName() { return "Persist profile"; }
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package net.i2p.router.peermanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
@ -25,24 +24,3 @@ class PersistProfilesJob extends JobImpl {
|
||||
void persist(Hash peer) { _mgr.storeProfile(peer); }
|
||||
void requeue() { requeue(PERSIST_DELAY); }
|
||||
}
|
||||
|
||||
class PersistProfileJob extends JobImpl {
|
||||
private PersistProfilesJob _job;
|
||||
private Iterator _peers;
|
||||
public PersistProfileJob(RouterContext enclosingContext, PersistProfilesJob job, Set peers) {
|
||||
super(enclosingContext);
|
||||
_peers = peers.iterator();
|
||||
_job = job;
|
||||
}
|
||||
public void runJob() {
|
||||
if (_peers.hasNext())
|
||||
_job.persist((Hash)_peers.next());
|
||||
if (_peers.hasNext()) {
|
||||
requeue(1000);
|
||||
} else {
|
||||
// no more left, requeue up the main persist-em-all job
|
||||
_job.requeue();
|
||||
}
|
||||
}
|
||||
public String getName() { return "Persist profile"; }
|
||||
}
|
Reference in New Issue
Block a user