mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Studio bridge: smaller tiles, quiet hang-ups, files removed on stop
- 128-pixel tiles by default and scales up to 4096 blocks per pixel, so the studio fills the screen in smaller steps and can zoom out further - A client that drops a tile it no longer needs closes the exchange instead of logging a broken-pipe stack trace - The bridge keeps its port after closing, and Paper's server-stop quiesce closes the bridges, so their connection files are removed even when the deferred service teardown never runs
This commit is contained in:
1 parent
a375d3b2f0
commit
4de21dace7
3 files changed
+18
-3
No files matched your search
@@ -74,6 +74,7 @@ import art.arcane.iris.core.service.ObjectSVC;
|
||||
import art.arcane.iris.core.service.ObjectStudioSaveService;
|
||||
import art.arcane.iris.core.service.PreservationSVC;
|
||||
import art.arcane.iris.core.service.StudioSVC;
|
||||
import art.arcane.iris.core.studio.bridge.StudioBridges;
|
||||
import art.arcane.iris.core.service.TreeFellerSVC;
|
||||
import art.arcane.iris.core.service.TreeSVC;
|
||||
import art.arcane.iris.core.service.WandSVC;
|
||||
@@ -968,6 +969,7 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
if (studioService != null) {
|
||||
studioService.quiesceDownloadsForShutdown();
|
||||
}
|
||||
StudioBridges.closeAll();
|
||||
|
||||
try {
|
||||
PregeneratorJob.shutdownAndWait(SERVER_STOP_PREGEN_TIMEOUT_MILLIS);
|
||||
|
||||
@@ -65,10 +65,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public final class StudioBridge implements AutoCloseable {
|
||||
private static final String API = "/v1/";
|
||||
private static final int TOKEN_BYTES = 24;
|
||||
private static final int DEFAULT_TILE_SIZE = 256;
|
||||
private static final int DEFAULT_TILE_SIZE = 128;
|
||||
private static final int LARGEST_TILE_SIZE = 512;
|
||||
private static final double SMALLEST_BLOCKS_PER_PIXEL = 1D / 16D;
|
||||
private static final double LARGEST_BLOCKS_PER_PIXEL = 1024D;
|
||||
private static final double LARGEST_BLOCKS_PER_PIXEL = 4_096D;
|
||||
private static final long ENTITY_WAIT_MILLIS = 3_000L;
|
||||
private static final int STATUS_OK = 200;
|
||||
private static final int STATUS_NO_CONTENT = 204;
|
||||
@@ -83,6 +83,7 @@ public final class StudioBridge implements AutoCloseable {
|
||||
private final String token;
|
||||
private final Gson gson = new Gson();
|
||||
private final HttpServer server;
|
||||
private final int port;
|
||||
private final ExecutorService workers;
|
||||
private final ScheduledExecutorService ticker;
|
||||
private final StudioEvents events;
|
||||
@@ -94,6 +95,7 @@ public final class StudioBridge implements AutoCloseable {
|
||||
this.token = newToken();
|
||||
this.events = new StudioEvents(world, gson);
|
||||
this.server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
|
||||
this.port = server.getAddress().getPort();
|
||||
this.workers = Executors.newFixedThreadPool(workerCount(), daemonThreads("Iris Studio Bridge"));
|
||||
this.ticker = Executors.newSingleThreadScheduledExecutor(daemonThreads("Iris Studio Events"));
|
||||
this.hotloadHook = events::hotloaded;
|
||||
@@ -114,7 +116,7 @@ public final class StudioBridge implements AutoCloseable {
|
||||
}
|
||||
|
||||
public int port() {
|
||||
return server.getAddress().getPort();
|
||||
return port;
|
||||
}
|
||||
|
||||
public String token() {
|
||||
@@ -163,6 +165,8 @@ public final class StudioBridge implements AutoCloseable {
|
||||
sendJson(exchange, error.status, new ErrorBody(error.getMessage()));
|
||||
} catch (CancellationException stopped) {
|
||||
sendJson(exchange, STATUS_UNAVAILABLE, new ErrorBody("The world stopped"));
|
||||
} catch (IOException clientHungUp) {
|
||||
exchange.close();
|
||||
} catch (Throwable error) {
|
||||
IrisLogging.reportError("Studio bridge request " + exchange.getRequestURI().getPath(), error);
|
||||
sendJson(exchange, STATUS_SERVER_ERROR, new ErrorBody(String.valueOf(error.getMessage())));
|
||||
|
||||
@@ -90,6 +90,15 @@ public class StudioBridgeTest {
|
||||
bridge.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aClosedBridgeStillKnowsItsPortSoItsConnectionFileCanBeRemoved() {
|
||||
int openPort = bridge.port();
|
||||
|
||||
bridge.close();
|
||||
|
||||
assertEquals(openPort, bridge.port());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRequestWithoutTheTokenIsRefused() throws Exception {
|
||||
HttpResponse<String> response = http.send(HttpRequest.newBuilder(uri("world")).timeout(WAIT).build(),
|
||||
|
||||
Reference in new issue
Block a user