MCPcopy Create free account
hub / github.com/akeranen/the-one / transferDone

Method transferDone

routing/SprayAndWaitRouter.java:137–157  ·  view source on GitHub ↗

Called just before a transfer is finalized (by ActiveRouter#update()). Reduces the number of copies we have left for a message. In binary Spray and Wait, sending host is left with floor(n/2) copies, but in standard mode, nrof copies left is reduced by one.

(Connection con)

Source from the content-addressed store, hash-verified

135 * but in standard mode, nrof copies left is reduced by one.
136 */
137 @Override
138 protected void transferDone(Connection con) {
139 Integer nrofCopies;
140 String msgId = con.getMessage().getId();
141 /* get this router's copy of the message */
142 Message msg = getMessage(msgId);
143
144 if (msg == null) { // message has been dropped from the buffer after..
145 return; // ..start of transfer -> no need to reduce amount of copies
146 }
147
148 /* reduce the amount of copies left */
149 nrofCopies = (Integer)msg.getProperty(MSG_COUNT_PROPERTY);
150 if (isBinary) {
151 nrofCopies /= 2;
152 }
153 else {
154 nrofCopies--;
155 }
156 msg.updateProperty(MSG_COUNT_PROPERTY, nrofCopies);
157 }
158
159 @Override
160 public SprayAndWaitRouter replicate() {

Callers

nothing calls this directly

Calls 4

getPropertyMethod · 0.95
updatePropertyMethod · 0.95
getIdMethod · 0.80
getMessageMethod · 0.45

Tested by

no test coverage detected