i came in ur dad

main
Brett 2023-11-16 20:49:18 -05:00
parent bc1aa49115
commit 8cf701d408
7 changed files with 20 additions and 13 deletions

View File

@ -28,23 +28,23 @@ public class ChunkedCompressedChecksumFileReader {
} }
public FileHeader readChunk(Tracer trace, Span sp) throws IOException { 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(); FileHeader header = readHeader();
//try (Scope scope = gf.makeCurrent()) { try (Scope scope = gf.makeCurrent()) {
if (header.getUncompressed() == 0) if (header.getUncompressed() == 0)
return header; return header;
sp.addEvent("Read Data"); gf.addEvent("Read Data");
byte[] data = readSome(header); byte[] data = readSome(header);
sp.addEvent("Decompress Data"); gf.addEvent("Decompress Data");
byte[] decompressed = decompress(header, data); byte[] decompressed = decompress(header, data);
sp.addEvent("Hash"); gf.addEvent("Hash");
hash(header, decompressed); hash(header, decompressed);
sp.addEvent("Write"); gf.addEvent("Write");
fileOutputWriter.write(decompressed, 0, decompressed.length); fileOutputWriter.write(decompressed, 0, decompressed.length);
sp.addEvent("End"); gf.addEvent("End");
// } finally { } finally {
// gf.end(); gf.end();
// } }
return header; return header;
} }

View File

@ -44,7 +44,6 @@ public class Connection implements Runnable {
try (Scope scope = fileSend.makeCurrent()) { try (Scope scope = fileSend.makeCurrent()) {
int filesReceived = 0; int filesReceived = 0;
while (server.isRunning()) { while (server.isRunning()) {
System.out.println("Hello " + clientSocket.isConnected());
if (!clientSocket.isConnected()) { if (!clientSocket.isConnected()) {
System.out.println("Client Disconnected"); System.out.println("Client Disconnected");
break; break;
@ -78,6 +77,8 @@ public class Connection implements Runnable {
in.close(); in.close();
clientSocket.close(); clientSocket.close();
} catch (Exception ignored) {} } catch (Exception ignored) {}
Server.running = false;
Server.close();
} }
} }

View File

@ -21,7 +21,7 @@ public class Server {
public static final int SERVER_PORT = 42069; 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(); private static final OpenTelemetry ot = OTelUtils.create();
@ -67,8 +67,14 @@ public class Server {
return running; return running;
} }
private static Server srv;
public static void main(String[] args) { public static void main(String[] args) {
new Server(); srv = new Server();
}
public static void close(){
srv.notifyAll();
} }
} }

Binary file not shown.

Binary file not shown.