Skip to content

Commit

Permalink
Merge remote-tracking branch 'bertm/remove-nlm-load-sending' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Nov 30, 2024
2 parents 0c51872 + f7fa0c4 commit 25916aa
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 741 deletions.
71 changes: 9 additions & 62 deletions src/freenet/io/comm/DMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import freenet.keys.Key;
import freenet.keys.NodeCHK;
import freenet.keys.NodeSSK;
import freenet.node.NodeStats.PeerLoadStats;
import freenet.node.probe.Error;
import freenet.node.probe.Type;
import freenet.support.BitArray;
Expand Down Expand Up @@ -474,17 +473,19 @@ public static Message createFNPRejectedLoop(long id) {
addField(UID, Long.class);
addField(IS_LOCAL, Boolean.class);
}};


/**
* @deprecated last two NLM related arguments are ignored and can be omitted
*/
@Deprecated
public static Message createFNPRejectedOverload(long id, boolean isLocal, boolean needsLoad, boolean realTimeFlag) {
return createFNPRejectedOverload(id, isLocal);
}

public static Message createFNPRejectedOverload(long id, boolean isLocal) {
Message msg = new Message(FNPRejectedOverload);
msg.set(UID, id);
msg.set(IS_LOCAL, isLocal);
if(needsLoad) {
if(realTimeFlag)
msg.setNeedsLoadRT();
else
msg.setNeedsLoadBulk();
}
return msg;
}

Expand Down Expand Up @@ -1723,60 +1724,6 @@ public static Message createFNPRejectIsSoft() {
addField(REAL_TIME_FLAG, Boolean.class);
}};

public static Message createFNPPeerLoadStatus(PeerLoadStats stats) {
Message msg;
if(stats.expectedTransfersInCHK < 256 && stats.expectedTransfersInSSK < 256 &&
stats.expectedTransfersOutCHK < 256 && stats.expectedTransfersOutSSK < 256 &&
stats.averageTransfersOutPerInsert < 256 && stats.maxTransfersOut < 256 &&
stats.maxTransfersOutLowerLimit < 256 && stats.maxTransfersOutPeerLimit < 256 &&
stats.maxTransfersOutUpperLimit < 256) {
msg = new Message(FNPPeerLoadStatusByte);
msg.set(OTHER_TRANSFERS_OUT_CHK, (byte)stats.expectedTransfersOutCHK);
msg.set(OTHER_TRANSFERS_IN_CHK, (byte)stats.expectedTransfersInCHK);
msg.set(OTHER_TRANSFERS_OUT_SSK, (byte)stats.expectedTransfersOutSSK);
msg.set(OTHER_TRANSFERS_IN_SSK, (byte)stats.expectedTransfersInSSK);
msg.set(AVERAGE_TRANSFERS_OUT_PER_INSERT, (byte)stats.averageTransfersOutPerInsert);
msg.set(MAX_TRANSFERS_OUT, (byte)stats.maxTransfersOut);
msg.set(MAX_TRANSFERS_OUT_PEER_LIMIT, (byte)stats.maxTransfersOutPeerLimit);
msg.set(MAX_TRANSFERS_OUT_LOWER_LIMIT, (byte)stats.maxTransfersOutLowerLimit);
msg.set(MAX_TRANSFERS_OUT_UPPER_LIMIT, (byte)stats.maxTransfersOutUpperLimit);
} else if(stats.expectedTransfersInCHK < 65536 && stats.expectedTransfersInSSK < 65536 &&
stats.expectedTransfersOutCHK < 65536 && stats.expectedTransfersOutSSK < 65536 &&
stats.averageTransfersOutPerInsert < 65536 && stats.maxTransfersOut < 65536 &&
stats.maxTransfersOutLowerLimit < 65536 && stats.maxTransfersOutPeerLimit < 65536 &&
stats.maxTransfersOutUpperLimit < 65536) {
msg = new Message(FNPPeerLoadStatusShort);
msg.set(OTHER_TRANSFERS_OUT_CHK, (short)stats.expectedTransfersOutCHK);
msg.set(OTHER_TRANSFERS_IN_CHK, (short)stats.expectedTransfersInCHK);
msg.set(OTHER_TRANSFERS_OUT_SSK, (short)stats.expectedTransfersOutSSK);
msg.set(OTHER_TRANSFERS_IN_SSK, (short)stats.expectedTransfersInSSK);
msg.set(AVERAGE_TRANSFERS_OUT_PER_INSERT, (short)stats.averageTransfersOutPerInsert);
msg.set(MAX_TRANSFERS_OUT, (short)stats.maxTransfersOut);
msg.set(MAX_TRANSFERS_OUT_PEER_LIMIT, (short)stats.maxTransfersOutPeerLimit);
msg.set(MAX_TRANSFERS_OUT_LOWER_LIMIT, (short)stats.maxTransfersOutLowerLimit);
msg.set(MAX_TRANSFERS_OUT_UPPER_LIMIT, (short)stats.maxTransfersOutUpperLimit);
} else {
msg = new Message(FNPPeerLoadStatusInt);
msg.set(OTHER_TRANSFERS_OUT_CHK, stats.expectedTransfersOutCHK);
msg.set(OTHER_TRANSFERS_IN_CHK, stats.expectedTransfersInCHK);
msg.set(OTHER_TRANSFERS_OUT_SSK, stats.expectedTransfersOutSSK);
msg.set(OTHER_TRANSFERS_IN_SSK, stats.expectedTransfersInSSK);
msg.set(AVERAGE_TRANSFERS_OUT_PER_INSERT, stats.averageTransfersOutPerInsert);
msg.set(MAX_TRANSFERS_OUT, stats.maxTransfersOut);
msg.set(MAX_TRANSFERS_OUT_PEER_LIMIT, stats.maxTransfersOutPeerLimit);
msg.set(MAX_TRANSFERS_OUT_LOWER_LIMIT, stats.maxTransfersOutLowerLimit);
msg.set(MAX_TRANSFERS_OUT_UPPER_LIMIT, stats.maxTransfersOutUpperLimit);
}
msg.set(OUTPUT_BANDWIDTH_LOWER_LIMIT, (int)stats.outputBandwidthLowerLimit);
msg.set(OUTPUT_BANDWIDTH_UPPER_LIMIT, (int)stats.outputBandwidthUpperLimit);
msg.set(OUTPUT_BANDWIDTH_PEER_LIMIT, (int)stats.outputBandwidthPeerLimit);
msg.set(INPUT_BANDWIDTH_LOWER_LIMIT, (int)stats.inputBandwidthLowerLimit);
msg.set(INPUT_BANDWIDTH_UPPER_LIMIT, (int)stats.inputBandwidthUpperLimit);
msg.set(INPUT_BANDWIDTH_PEER_LIMIT, (int)stats.inputBandwidthPeerLimit);
msg.set(REAL_TIME_FLAG, stats.realTime);
return msg;
}

public static final String AVERAGE_TRANSFERS_OUT_PER_INSERT = "averageTransfersOutPerInsert";

public static final String OTHER_TRANSFERS_OUT_CHK = "otherTransfersOutCHK";
Expand Down
24 changes: 2 additions & 22 deletions src/freenet/io/comm/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import freenet.support.Fields;
import freenet.support.LogThresholdCallback;
import freenet.support.Logger;
import freenet.support.Logger.LogLevel;
import freenet.support.Serializer;
import freenet.support.ShortBuffer;
import freenet.support.Logger.LogLevel;

/**
* A Message which can be read from and written to a DatagramPacket.
Expand Down Expand Up @@ -75,9 +75,7 @@ public void shouldUpdate(){
public final long localInstantiationTime;
final int _receivedByteCount;
short priority;
private boolean needsLoadRT;
private boolean needsLoadBulk;


public static Message decodeMessageFromPacket(byte[] buf, int offset, int length, PeerContext peer, int overhead) {
ByteBufferInputStream bb = new ByteBufferInputStream(buf, offset, length);
return decodeMessage(bb, peer, length + overhead, true, false, false);
Expand Down Expand Up @@ -179,8 +177,6 @@ private Message(Message m) {
localInstantiationTime = System.currentTimeMillis();
_receivedByteCount = 0;
priority = m.priority;
needsLoadRT = m.needsLoadRT;
needsLoadBulk = m.needsLoadBulk;
}

public boolean getBoolean(String key) {
Expand Down Expand Up @@ -406,22 +402,6 @@ public void boostPriority() {
priority--;
}

public boolean needsLoadRT() {
return needsLoadRT;
}

public boolean needsLoadBulk() {
return needsLoadBulk;
}

public void setNeedsLoadRT() {
needsLoadRT = true;
}

public void setNeedsLoadBulk() {
needsLoadBulk = true;
}

/** Clone the message, clear sub-messages and set originator to self. */
public Message cloneAndDropSubMessages() {
return new Message(this);
Expand Down
14 changes: 0 additions & 14 deletions src/freenet/node/BasePeerNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,6 @@ public interface BasePeerNode extends PeerContext {

void handleMessage(Message msg);

/** Make a load stats message.
* @param realtime True for the realtime load stats, false for the bulk load stats.
* @param highPriority If true, boost the priority so it gets sent fast.
* @param noRemember If true, generating it for a lossy message in a packet; don't
* remember that we sent it, since it might be lost, and generate it even if the last
* one was the same, since the last one might be delayed. */
MessageItem makeLoadStats(boolean realtime, boolean highPriority, boolean noRemember);

boolean grabSendLoadStatsASAP(boolean realtime);

/** Set the load stats to be sent asap. E.g. if we grabbed it and can't actually
* execute the send for some reason. */
void setSendLoadStatsASAP(boolean realtime);

/** Average ping time incorporating variance, calculated like TCP SRTT, as with RFC 2988. */
double averagePingTimeCorrected();

Expand Down
8 changes: 1 addition & 7 deletions src/freenet/node/MessageItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class MessageItem {
private final short priority;
private long cachedID;
private boolean hasCachedID;
final boolean sendLoadRT;
final boolean sendLoadBulk;
private long deadline;

public MessageItem(Message msg2, AsyncMessageCallback[] cb2, ByteCounter ctr, short overridePriority) {
Expand All @@ -40,8 +38,6 @@ public MessageItem(Message msg2, AsyncMessageCallback[] cb2, ByteCounter ctr, sh
priority = overridePriority;
else
priority = msg2.getPriority();
this.sendLoadRT = msg2.needsLoadRT();
this.sendLoadBulk = msg2.needsLoadBulk();
buf = msg.encodeToPacket();
if(buf.length > NewPacketFormat.MAX_MESSAGE_SIZE) {
// This is bad because fairness between UID's happens at the level of message queueing,
Expand All @@ -56,7 +52,7 @@ public MessageItem(Message msg2, AsyncMessageCallback[] cb2, ByteCounter ctr) {
this(msg2, cb2, ctr, (short)-1);
}

public MessageItem(byte[] data, AsyncMessageCallback[] cb2, boolean formatted, ByteCounter ctr, short priority, boolean sendLoadRT, boolean sendLoadBulk) {
public MessageItem(byte[] data, AsyncMessageCallback[] cb2, boolean formatted, ByteCounter ctr, short priority) {
this.cb = cb2;
this.msg = null;
this.buf = data;
Expand All @@ -66,8 +62,6 @@ public MessageItem(byte[] data, AsyncMessageCallback[] cb2, boolean formatted, B
this.ctrCallback = ctr;
this.submitted = System.currentTimeMillis();
this.priority = priority;
this.sendLoadRT = sendLoadRT;
this.sendLoadBulk = sendLoadBulk;
}

/**
Expand Down
Loading

0 comments on commit 25916aa

Please sign in to comment.