Skip to content

Commit

Permalink
adding support for partial transfers and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
codybum committed Feb 18, 2024
1 parent c95a056 commit 33ea401
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/main/java/crescoclient/dataplane/DataPlaneInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ public void send(ByteBuffer byteBuffer) {
}
}

public void sendPartial(ByteBuffer byteBuffer, boolean complete) {

try {
if(wsInterface.connected()) {
System.out.println("sendPartial(ByteBuffer byteBuffer, boolean complete) support not implemented on wsapi");
wsInterface.getSession().getRemote().sendPartialBytes(byteBuffer, complete);
} else {
System.out.println("WS not connected!");
}
} catch (Exception e) {
e.printStackTrace();
}
}

public void update_config(String dst_region, String dst_agent) {
send(dst_region + ',' + dst_agent + ",Trace,default");
}
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/example/BinaryPerformanceTesting.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onMessage(byte[] b, int offset, int length) {
bytesTransferred = bytesTransferred + length;
//String s = new String(b, StandardCharsets.UTF_8);
//System.out.println("binary: " + s);
//System.out.println("length: " + b.length + " offset: " + offset + " length: " + length);
System.out.println("length: " + b.length + " offset: " + offset + " length: " + length);
}
}

Expand All @@ -96,12 +96,25 @@ public void onMessage(byte[] b, int offset, int length) {
Random random = new Random();
int byteSize = 32768 * 10;

for(int i=0; i<10; i++) {
byte[] byteArray = new byte[byteSize];
random.nextBytes(byteArray);
ByteBuffer buffer = ByteBuffer.wrap(byteArray);
dataPlaneSend.sendPartial(buffer, false);
}
byte[] byteArray = new byte[byteSize];
random.nextBytes(byteArray);
ByteBuffer buffer = ByteBuffer.wrap(byteArray);
dataPlaneSend.sendPartial(buffer, true);

/*
for(int i=0; i<100000; i++) {
byte[] byteArray = new byte[byteSize];
random.nextBytes(byteArray);
ByteBuffer buffer = ByteBuffer.wrap(byteArray);
dataPlaneSend.send(buffer);
}
*/

} catch (Exception ex) {
ex.printStackTrace();
Expand Down

0 comments on commit 33ea401

Please sign in to comment.