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 checkstyle of core-task issue #1854

Merged
merged 6 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
20 changes: 10 additions & 10 deletions hugegraph-core/src/main/java/com/baidu/hugegraph/HugeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class HugeFactory {

private static final Logger LOG = Log.logger(HugeGraph.class);

private static final Thread shutdownHook = new Thread(() -> {
private static final Thread SHUT_DOWN_HOOK = new Thread(() -> {
LOG.info("HugeGraph is shutting down");
HugeFactory.shutdown(30L);
}, "hugegraph-shutdown");
Expand All @@ -54,14 +54,14 @@ public class HugeFactory {
SerialEnum.registerInternalEnums();
HugeGraph.registerTraversalStrategies(StandardHugeGraph.class);

Runtime.getRuntime().addShutdownHook(shutdownHook);
Runtime.getRuntime().addShutdownHook(SHUT_DOWN_HOOK);
}

private static final String NAME_REGEX = "^[A-Za-z][A-Za-z0-9_]{0,47}$";

private static final Map<String, HugeGraph> graphs = new HashMap<>();
private static final Map<String, HugeGraph> GRAPHS = new HashMap<>();

private static final AtomicBoolean shutdown = new AtomicBoolean(false);
private static final AtomicBoolean SHUT_DOWN = new AtomicBoolean(false);

public static synchronized HugeGraph open(Configuration config) {
HugeConfig conf = config instanceof HugeConfig ?
Expand All @@ -86,10 +86,10 @@ public static synchronized HugeGraph open(HugeConfig config) {
String name = config.get(CoreOptions.STORE);
checkGraphName(name, "graph config(like hugegraph.properties)");
name = name.toLowerCase();
HugeGraph graph = graphs.get(name);
HugeGraph graph = GRAPHS.get(name);
if (graph == null || graph.closed()) {
graph = new StandardHugeGraph(config);
graphs.put(name, graph);
GRAPHS.put(name, graph);
} else {
String backend = config.get(CoreOptions.BACKEND);
E.checkState(backend.equalsIgnoreCase(graph.backend()),
Expand All @@ -109,7 +109,7 @@ public static HugeGraph open(URL url) {

public static void remove(HugeGraph graph) {
String name = graph.option(CoreOptions.STORE);
graphs.remove(name);
GRAPHS.remove(name);
}

public static void checkGraphName(String name, String configFile) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public static PropertiesConfiguration getRemoteConfig(URL url) {
* @param timeout seconds
*/
public static void shutdown(long timeout) {
if (!shutdown.compareAndSet(false, true)) {
if (!SHUT_DOWN.compareAndSet(false, true)) {
return;
}
try {
Expand All @@ -158,14 +158,14 @@ public static void shutdown(long timeout) {
OltpTraverser.destroy();
} catch (Throwable e) {
LOG.error("Error while shutdown", e);
shutdown.compareAndSet(true, false);
SHUT_DOWN.compareAndSet(true, false);
throw new HugeException("Failed to shutdown", e);
}

LOG.info("HugeFactory shutdown");
}

public static void removeShutdownHook() {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
Runtime.getRuntime().removeShutdownHook(SHUT_DOWN_HOOK);
}
}
Loading