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 other module checkstyle issue #1858

Merged
merged 5 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,32 @@

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,
"ConfDumper need a config file.");

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<String> keywords = exceptions.getCollection(clz);
Collection<String> keywords = EXCEPTIONS.getCollection(clz);
for (String keyword : keywords) {
if (message.contains(keyword)) {
LOG.info("Init failed with exception '{} : {}', " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@
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;
import com.baidu.hugegraph.backend.query.Query;
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);
}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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());
}
}
}