* The comment of the trust relation
*/
public void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment) {
- updateJobs.add(new SetTrustJob(truster, trustee, score, comment));
+ SetTrustJob setTrustJob = new SetTrustJob(truster, trustee, score, comment);
+ if (updateJobs.contains(setTrustJob)) {
+ updateJobs.remove(setTrustJob);
+ }
+ logger.log(Level.FINER, "Adding Trust Update Job: " + setTrustJob);
+ try {
+ updateJobs.put(setTrustJob);
+ } catch (InterruptedException e) {
+ /* the queue is unbounded so it should never block. */
+ }
}
//
if (shouldStop() || (updateJob == stopJob)) {
break;
}
+ logger.log(Level.FINE, "Running Trust Update Job: " + updateJob);
+ long startTime = System.currentTimeMillis();
updateJob.run();
+ long endTime = System.currentTimeMillis();
+ logger.log(Level.FINE, "Trust Update Job finished, took " + (endTime - startTime) + " ms.");
} catch (InterruptedException ie1) {
/* happens, ignore, loop. */
}
*/
@Override
public int hashCode() {
- return ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode());
+ return getClass().hashCode() ^ ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode());
}
/**