mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] autoDump и завершение работы
This commit is contained in:
parent
9084361a38
commit
3cd9ddee0d
4 changed files with 33 additions and 12 deletions
|
@ -319,7 +319,8 @@ public void buildLauncherBinaries() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
|
LogHelper.info("Close server socket");
|
||||||
|
nettyServerSocketHandler.close();
|
||||||
// Close handlers & providers
|
// Close handlers & providers
|
||||||
config.close(ReloadType.FULL);
|
config.close(ReloadType.FULL);
|
||||||
modulesManager.invokeEvent(new ClosePhase());
|
modulesManager.invokeEvent(new ClosePhase());
|
||||||
|
@ -368,8 +369,14 @@ public void run() {
|
||||||
}
|
}
|
||||||
if (config.netty != null)
|
if (config.netty != null)
|
||||||
rebindNettyServerSocket();
|
rebindNettyServerSocket();
|
||||||
modulesManager.fullInitializedLaunchServer(this);
|
try {
|
||||||
modulesManager.invokeEvent(new LaunchServerFullInitEvent(this));
|
modulesManager.fullInitializedLaunchServer(this);
|
||||||
|
modulesManager.invokeEvent(new LaunchServerFullInitEvent(this));
|
||||||
|
LogHelper.info("LaunchServer started");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
JVMHelper.RUNTIME.exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncLauncherBinaries() throws IOException {
|
public void syncLauncherBinaries() throws IOException {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection {
|
public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection, AutoCloseable {
|
||||||
|
|
||||||
private transient final Map<UUID, Entry> clientSet = new ConcurrentHashMap<>(128);
|
private transient final Map<UUID, Entry> clientSet = new ConcurrentHashMap<>(128);
|
||||||
private transient final Map<UUID, Set<Entry>> uuidIndex = new ConcurrentHashMap<>(32);
|
private transient final Map<UUID, Set<Entry>> uuidIndex = new ConcurrentHashMap<>(32);
|
||||||
|
@ -90,10 +90,6 @@ public boolean deleteSessionsByUserUUID(UUID userUUID) {
|
||||||
public void clear() {
|
public void clear() {
|
||||||
clientSet.clear();
|
clientSet.clear();
|
||||||
uuidIndex.clear();
|
uuidIndex.clear();
|
||||||
if(autoDump) {
|
|
||||||
garbageCollection();
|
|
||||||
dumpSessionsData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dumpSessionsData() {
|
public void dumpSessionsData() {
|
||||||
|
@ -161,6 +157,14 @@ public void garbageCollection() {
|
||||||
to_delete.clear();
|
to_delete.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws Exception {
|
||||||
|
if(autoDump) {
|
||||||
|
garbageCollection();
|
||||||
|
dumpSessionsData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class Entry {
|
private static class Entry {
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
public UUID sessionUuid;
|
public UUID sessionUuid;
|
||||||
|
@ -174,8 +178,8 @@ public Entry(byte[] data, UUID sessionUuid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DumpedData {
|
private static class DumpedData {
|
||||||
private transient final Map<UUID, Entry> clientSet;
|
private final Map<UUID, Entry> clientSet;
|
||||||
private transient final Map<UUID, Set<Entry>> uuidIndex;
|
private final Map<UUID, Set<Entry>> uuidIndex;
|
||||||
|
|
||||||
private DumpedData(Map<UUID, Entry> clientSet, Map<UUID, Set<Entry>> uuidIndex) {
|
private DumpedData(Map<UUID, Entry> clientSet, Map<UUID, Set<Entry>> uuidIndex) {
|
||||||
this.clientSet = clientSet;
|
this.clientSet = clientSet;
|
||||||
|
|
|
@ -235,6 +235,13 @@ public void close(LaunchServer.ReloadType type) {
|
||||||
}
|
}
|
||||||
if(sessions != null) {
|
if(sessions != null) {
|
||||||
server.unregisterObject("sessions", sessions);
|
server.unregisterObject("sessions", sessions);
|
||||||
|
if (sessions instanceof AutoCloseable) {
|
||||||
|
try {
|
||||||
|
((AutoCloseable) sessions).close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dao != null) {
|
if (dao != null) {
|
||||||
server.unregisterObject("dao", dao);
|
server.unregisterObject("dao", dao);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class LauncherNettyServer implements AutoCloseable {
|
public class LauncherNettyServer implements AutoCloseable {
|
||||||
private static final String WEBSOCKET_PATH = "/api";
|
private static final String WEBSOCKET_PATH = "/api";
|
||||||
|
@ -77,7 +78,9 @@ public ChannelFuture bind(InetSocketAddress address) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
workerGroup.shutdownGracefully();
|
workerGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
||||||
bossGroup.shutdownGracefully();
|
bossGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
||||||
|
//workerGroup.shutdownGracefully();
|
||||||
|
//bossGroup.shutdownGracefully();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue