I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit 59ab4077 authored by zzz's avatar zzz
Browse files

NetDB: RepublishLeaseSetJob

Don't requeue on failure if there is a newer LS, KNDF will have already done that.
Log tweaks and cleanups
parent 85b9862b
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,6 @@ class RepublishLeaseSetJob extends JobImpl {
_log = ctx.logManager().getLog(RepublishLeaseSetJob.class);
_facade = facade;
_dest = destHash;
//getTiming().setStartAfter(ctx.clock().now()+REPUBLISH_LEASESET_DELAY);
}
public String getName() { return "Republish a local leaseSet"; }
......@@ -51,21 +50,16 @@ class RepublishLeaseSetJob extends JobImpl {
if (_log.shouldLog(Log.WARN))
_log.warn("Not publishing a LOCAL lease that isn't current - " + _dest.toBase32(), new Exception("Publish expired LOCAL lease?"));
} else {
if (_log.shouldLog(Log.INFO))
_log.info("Publishing " + ls);
if (_log.shouldInfo())
_log.info(getJobId() + ": Publishing LS for " + _dest.toBase32());
getContext().statManager().addRateData("netDb.republishLeaseSetCount", 1);
_facade.sendStore(_dest, ls, null, new OnRepublishFailure(getContext(), this), REPUBLISH_LEASESET_TIMEOUT, null);
_facade.sendStore(_dest, ls, null, new OnRepublishFailure(ls), REPUBLISH_LEASESET_TIMEOUT, null);
_lastPublished = getContext().clock().now();
//getContext().jobQueue().addJob(new StoreJob(getContext(), _facade, _dest, ls, new OnSuccess(getContext()), new OnFailure(getContext()), REPUBLISH_LEASESET_TIMEOUT));
}
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Client " + _dest.toBase32() + " is local, but we can't find a valid LeaseSet? perhaps its being rebuilt?");
}
//if (false) { // floodfill doesnt require republishing
// long republishDelay = getContext().random().nextLong(2*REPUBLISH_LEASESET_DELAY);
// requeue(republishDelay);
//}
return;
} else {
if (_log.shouldLog(Log.INFO))
......@@ -81,8 +75,8 @@ class RepublishLeaseSetJob extends JobImpl {
}
void requeueRepublish() {
if (_log.shouldLog(Log.WARN))
_log.warn("FAILED publishing of the leaseSet for " + _dest.toBase32());
if (_log.shouldWarn())
_log.warn("Failed publishing of the leaseSet for " + _dest.toBase32());
getContext().jobQueue().removeJob(this);
requeue(RETRY_DELAY + getContext().random().nextInt(RETRY_DELAY));
}
......@@ -95,13 +89,25 @@ class RepublishLeaseSetJob extends JobImpl {
}
/** requeue */
private static class OnRepublishFailure extends JobImpl {
private final RepublishLeaseSetJob _job;
public OnRepublishFailure(RouterContext ctx, RepublishLeaseSetJob job) {
super(ctx);
_job = job;
private class OnRepublishFailure extends JobImpl {
private final LeaseSet _ls;
public OnRepublishFailure(LeaseSet ls) {
super(RepublishLeaseSetJob.this.getContext());
_ls = ls;
}
public String getName() { return "Publish leaseSet failed"; }
public void runJob() { _job.requeueRepublish(); }
public void runJob() {
// Don't requeue if there's a newer LS, KNDF will have already done that
LeaseSet ls = _facade.lookupLeaseSetLocally(_ls.getHash());
if (ls != null && ls.getEarliestLeaseDate() == _ls.getEarliestLeaseDate()) {
requeueRepublish();
} else {
if (_log.shouldWarn())
_log.warn(getJobId() + ": Failed publishing LS for " + _ls.getDestination().toBase32() + " but not requeueing, there is a newer LS");
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment