diff --git a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/ConfDumper.java b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/ConfDumper.java index 6e2a114a6f..0f5229b1ad 100644 --- a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/ConfDumper.java +++ b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/ConfDumper.java @@ -25,17 +25,22 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; import com.baidu.hugegraph.config.HugeConfig; import com.baidu.hugegraph.config.OptionSpace; import com.baidu.hugegraph.config.TypedOption; import com.baidu.hugegraph.dist.RegisterUtil; +import com.baidu.hugegraph.server.RestServer; import com.baidu.hugegraph.util.E; +import com.baidu.hugegraph.util.Log; public class ConfDumper { public static final String EOL = System.getProperty("line.separator"); + private static final Logger LOG = Log.logger(ConfDumper.class); + public static void main(String[] args) throws ConfigurationException, IOException { E.checkArgument(args.length == 1, @@ -43,8 +48,9 @@ public static void main(String[] args) String input = args[0]; File output = new File(input + ".default"); - System.out.println("Input config: " + input); - System.out.println("Output config: " + output.getPath()); + + LOG.info("Input config: {}", input); + LOG.info("Output config: {}", output.getPath()); RegisterUtil.registerBackends(); RegisterUtil.registerServer(); diff --git a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/InitStore.java b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/InitStore.java index 352d7fdaa0..99b4e060ae 100644 --- a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/InitStore.java +++ b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/InitStore.java @@ -47,15 +47,15 @@ public class InitStore { // Less than 5000 may cause mismatch exception with Cassandra backend private static final long RETRY_INTERVAL = 5000; - private static final MultiValueMap exceptions = new MultiValueMap(); + private static final MultiValueMap EXCEPTIONS = new MultiValueMap(); static { - exceptions.put("OperationTimedOutException", + EXCEPTIONS.put("OperationTimedOutException", "Timed out waiting for server response"); - exceptions.put("NoHostAvailableException", + EXCEPTIONS.put("NoHostAvailableException", "All host(s) tried for query failed"); - exceptions.put("InvalidQueryException", "does not exist"); - exceptions.put("InvalidQueryException", "unconfigured table"); + EXCEPTIONS.put("InvalidQueryException", "does not exist"); + EXCEPTIONS.put("InvalidQueryException", "unconfigured table"); } public static void main(String[] args) throws Exception { @@ -114,9 +114,9 @@ private static void initBackend(final HugeGraph graph) } catch (Exception e) { String clz = e.getClass().getSimpleName(); String message = e.getMessage(); - if (exceptions.containsKey(clz) && retries > 0) { + if (EXCEPTIONS.containsKey(clz) && retries > 0) { @SuppressWarnings("unchecked") - Collection keywords = exceptions.getCollection(clz); + Collection keywords = EXCEPTIONS.getCollection(clz); for (String keyword : keywords) { if (message.contains(keyword)) { LOG.info("Init failed with exception '{} : {}', " + diff --git a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/StoreDumper.java b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/StoreDumper.java index c1ed2cfdc0..8737e05970 100644 --- a/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/StoreDumper.java +++ b/hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/StoreDumper.java @@ -22,6 +22,7 @@ import java.util.Iterator; import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; +import org.slf4j.Logger; import com.baidu.hugegraph.HugeFactory; import com.baidu.hugegraph.HugeGraph; @@ -29,14 +30,18 @@ import com.baidu.hugegraph.backend.store.BackendEntry; import com.baidu.hugegraph.backend.store.BackendStore; import com.baidu.hugegraph.dist.RegisterUtil; +import com.baidu.hugegraph.server.RestServer; import com.baidu.hugegraph.testutil.Whitebox; import com.baidu.hugegraph.type.HugeType; import com.baidu.hugegraph.util.E; +import com.baidu.hugegraph.util.Log; public class StoreDumper { private final HugeGraph graph; + private static final Logger LOG = Log.logger(StoreDumper.class); + public StoreDumper(String conf) { this.graph = HugeFactory.open(conf); } @@ -49,12 +54,12 @@ public void dump(HugeType table, long offset, long limit) { for (long i = 0; i < offset && rs.hasNext(); i++) { rs.next(); } - String title = String.format("Dump table %s (offset %d limit %d):", - table, offset, limit); - System.out.println(title); + + LOG.info("Dump table {} (offset {} limit {}):", table, offset, limit); + for (long i = 0; i < limit && rs.hasNext(); i++) { BackendEntry entry = rs.next(); - System.out.println(entry); + LOG.info("{}", entry); } CloseableIterator.closeIterator(rs); diff --git a/hugegraph-dist/src/main/java/com/baidu/hugegraph/dist/RegisterUtil.java b/hugegraph-dist/src/main/java/com/baidu/hugegraph/dist/RegisterUtil.java index f137946bda..8fa9711814 100644 --- a/hugegraph-dist/src/main/java/com/baidu/hugegraph/dist/RegisterUtil.java +++ b/hugegraph-dist/src/main/java/com/baidu/hugegraph/dist/RegisterUtil.java @@ -19,16 +19,13 @@ package com.baidu.hugegraph.dist; -import java.io.InputStream; import java.net.URL; import java.util.List; import java.util.ServiceLoader; -import org.apache.commons.configuration2.Configuration; import org.apache.commons.configuration2.PropertiesConfiguration; import org.apache.commons.configuration2.builder.fluent.Configurations; import org.apache.commons.configuration2.ex.ConfigurationException; -import org.apache.kerby.config.Conf; import org.slf4j.Logger; import com.baidu.hugegraph.HugeException; diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTables.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTables.java index a7598cfe47..25e9e66df3 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTables.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTables.java @@ -43,7 +43,6 @@ import com.baidu.hugegraph.util.E; import com.google.common.collect.ImmutableMap; - public class MysqlTables { public static final String BOOLEAN = "BOOLEAN"; @@ -108,7 +107,7 @@ public long getCounter(Session session, HugeType type) { String select = String.format("SELECT ID FROM %s WHERE %s = '%s';", this.table(), schemaCol, type.name()); - try (ResultSetWrapper results = session.select(select)){ + try (ResultSetWrapper results = session.select(select)) { ResultSet rs = results.resultSet(); if (rs.next()) { return rs.getLong(idCol); diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/ResultSetWrapper.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/ResultSetWrapper.java index 85dd45167c..413ecb01f2 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/ResultSetWrapper.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/ResultSetWrapper.java @@ -6,7 +6,7 @@ import java.sql.SQLException; import java.sql.Statement; -public class ResultSetWrapper implements AutoCloseable{ +public class ResultSetWrapper implements AutoCloseable { private final ResultSet resultSet; private final Statement statement; diff --git a/hugegraph-palo/src/main/java/com/baidu/hugegraph/backend/store/palo/PaloSessions.java b/hugegraph-palo/src/main/java/com/baidu/hugegraph/backend/store/palo/PaloSessions.java index d7f9078a59..905b1bb6d8 100644 --- a/hugegraph-palo/src/main/java/com/baidu/hugegraph/backend/store/palo/PaloSessions.java +++ b/hugegraph-palo/src/main/java/com/baidu/hugegraph/backend/store/palo/PaloSessions.java @@ -197,7 +197,7 @@ private PaloFile getOrCreate(String table) { @SuppressWarnings("unused") private PaloLoadInfo getLoadInfoByLabel(String label) { String sql = String.format("SHOW LOAD WHERE LABEL = '%s'", label); - try (ResultSetWrapper results = this.select(sql)){ + try (ResultSetWrapper results = this.select(sql)) { ResultSet rs = results.resultSet(); if (rs.next()) { return new PaloLoadInfo(rs); @@ -213,7 +213,7 @@ private PaloLoadInfo getLoadInfoByLabel(String label) { public final class PaloLoadTask extends TimerTask { private static final String DF = "yyyy-MM-dd-HH-mm-ss"; - private final SafeDateFormat DATE_FORMAT = new SafeDateFormat(DF); + private final SafeDateFormat dateFormat = new SafeDateFormat(DF); /** * There exist two running palo load task corresponds to two stores, @@ -313,7 +313,7 @@ private void loadThenDelete(PaloFile file) { } private String formatLabel(String table) { - return table + "-" + this.DATE_FORMAT.format(new Date()); + return table + "-" + this.dateFormat.format(new Date()); } } }