Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix close exception and server-info EXPIRED_INTERVAL #1804

Merged
merged 5 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public synchronized CompletableFuture<Void> stop() {
}

public void injectAuthGraph() {
HugeGraphAuthProxy.setContext(Context.admin());

GraphManager manager = this.getServerGremlinExecutor()
.getGraphManager();
for (String name : manager.getGraphNames()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,28 +337,33 @@ private void checkBackendVersionOrExit(HugeConfig config) {
for (String graph : this.graphs()) {
// TODO: close tx from main thread
HugeGraph hugegraph = this.graph(graph);
if (!hugegraph.backendStoreFeatures().supportsPersistence()) {
hugegraph.initBackend();
if (this.requireAuthentication()) {
String token = config.get(ServerOptions.AUTH_ADMIN_TOKEN);
try {
this.authenticator.initAdminUser(token);
} catch (Exception e) {
throw new BackendException(
"The backend store of '%s' can't " +
"initialize admin user", hugegraph.name());
try {
if (!hugegraph.backendStoreFeatures().supportsPersistence()) {
zyxxoo marked this conversation as resolved.
Show resolved Hide resolved
hugegraph.initBackend();
if (this.requireAuthentication()) {
String token = config.get(
ServerOptions.AUTH_ADMIN_TOKEN);
try {
this.authenticator.initAdminUser(token);
} catch (Exception e) {
throw new BackendException(
"The backend store of '%s' can't " +
"initialize admin user", hugegraph.name());
}
}
}
}
BackendStoreSystemInfo info = hugegraph.backendStoreSystemInfo();
if (!info.exists()) {
throw new BackendException(
BackendStoreSystemInfo info = hugegraph.backendStoreSystemInfo();
if (!info.exists()) {
throw new BackendException(
"The backend store of '%s' has not been initialized",
hugegraph.name());
}
if (!info.checkVersion()) {
throw new BackendException(
"The backend store version is inconsistent");
}
if (!info.checkVersion()) {
throw new BackendException(
"The backend store version is inconsistent");
}
} finally {
hugegraph.tx().close();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public static void shutdown(long timeout) {
shutdown.compareAndSet(true, false);
throw new HugeException("Failed to shutdown", e);
}

LOG.info("HugeFactory shutdown");
}

public static void removeShutdownHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.baidu.hugegraph.util.ConfigUtil;
import com.baidu.hugegraph.util.Log;

import java.util.concurrent.CompletableFuture;

public class HugeGraphServer {

private static final Logger LOG = Log.logger(HugeGraphServer.class);
Expand Down Expand Up @@ -117,16 +119,19 @@ public static void main(String[] args) throws Exception {
HugeGraphServer.register();

HugeGraphServer server = new HugeGraphServer(args[0], args[1]);
/*
* HugeFactory.shutdown hook may be invoked before server stop,
* causes event-hub can't execute notification events for another
* shutdown executor such as gremling-stop-shutdown
*/
HugeFactory.removeShutdownHook();
zyxxoo marked this conversation as resolved.
Show resolved Hide resolved
CompletableFuture<?> serverStopped = new CompletableFuture<>();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
LOG.info("HugeGraphServer stopping");
server.stop();
LOG.info("HugeGraphServer stopped");
serverStopped.complete(null);
}, "hugegraph-server-shutdown"));
/*
* HugeFactory shutdown hook be invoked before server stop, so that
* eventHub execute notify event on a shutdown executor, so here
* remove the HugeFactory shutdown hook.
*/
HugeFactory.removeShutdownHook();
serverStopped.get();
}
}