diff --git a/src/main/java/server/ChunkedCompressedChecksumFileReader.java b/src/main/java/server/ChunkedCompressedChecksumFileReader.java index 5f2b378..8593a7c 100644 --- a/src/main/java/server/ChunkedCompressedChecksumFileReader.java +++ b/src/main/java/server/ChunkedCompressedChecksumFileReader.java @@ -28,23 +28,23 @@ public class ChunkedCompressedChecksumFileReader { } public FileHeader readChunk(Tracer trace, Span sp) throws IOException { - //Span gf = trace.spanBuilder("Chunk Read").setParent(Context.current().with(sp)).startSpan(); + Span gf = trace.spanBuilder("Chunk Read").setParent(Context.current().with(sp)).startSpan(); FileHeader header = readHeader(); - //try (Scope scope = gf.makeCurrent()) { + try (Scope scope = gf.makeCurrent()) { if (header.getUncompressed() == 0) return header; - sp.addEvent("Read Data"); + gf.addEvent("Read Data"); byte[] data = readSome(header); - sp.addEvent("Decompress Data"); + gf.addEvent("Decompress Data"); byte[] decompressed = decompress(header, data); - sp.addEvent("Hash"); + gf.addEvent("Hash"); hash(header, decompressed); - sp.addEvent("Write"); + gf.addEvent("Write"); fileOutputWriter.write(decompressed, 0, decompressed.length); - sp.addEvent("End"); -// } finally { -// gf.end(); -// } + gf.addEvent("End"); + } finally { + gf.end(); + } return header; } diff --git a/src/main/java/server/Connection.java b/src/main/java/server/Connection.java index ca484fd..69f0b8e 100644 --- a/src/main/java/server/Connection.java +++ b/src/main/java/server/Connection.java @@ -44,7 +44,6 @@ public class Connection implements Runnable { try (Scope scope = fileSend.makeCurrent()) { int filesReceived = 0; while (server.isRunning()) { - System.out.println("Hello " + clientSocket.isConnected()); if (!clientSocket.isConnected()) { System.out.println("Client Disconnected"); break; @@ -78,6 +77,8 @@ public class Connection implements Runnable { in.close(); clientSocket.close(); } catch (Exception ignored) {} + Server.running = false; + Server.close(); } } diff --git a/src/main/java/server/Server.java b/src/main/java/server/Server.java index b5efc3f..99ed41e 100644 --- a/src/main/java/server/Server.java +++ b/src/main/java/server/Server.java @@ -21,7 +21,7 @@ public class Server { public static final int SERVER_PORT = 42069; - private volatile boolean running = true; + public static volatile boolean running = true; private static final OpenTelemetry ot = OTelUtils.create(); @@ -67,8 +67,14 @@ public class Server { return running; } + private static Server srv; + public static void main(String[] args) { - new Server(); + srv = new Server(); + } + + public static void close(){ + srv.notifyAll(); } } \ No newline at end of file diff --git a/target/classes/server/ChunkedCompressedChecksumFileReader.class b/target/classes/server/ChunkedCompressedChecksumFileReader.class index 6c61c2c..594e896 100644 Binary files a/target/classes/server/ChunkedCompressedChecksumFileReader.class and b/target/classes/server/ChunkedCompressedChecksumFileReader.class differ diff --git a/target/classes/server/Connection.class b/target/classes/server/Connection.class index 520ea35..5d68511 100644 Binary files a/target/classes/server/Connection.class and b/target/classes/server/Connection.class differ diff --git a/target/classes/server/Server$1.class b/target/classes/server/Server$1.class index 93d94ca..944a7d6 100644 Binary files a/target/classes/server/Server$1.class and b/target/classes/server/Server$1.class differ diff --git a/target/classes/server/Server.class b/target/classes/server/Server.class index ed8321e..996c1a4 100644 Binary files a/target/classes/server/Server.class and b/target/classes/server/Server.class differ