Skip to content

Commit

Permalink
logging: validate table name and print log for problem diagnosis (apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
qinzuoyan committed Nov 13, 2018
1 parent cf7893e commit c8d0bb2
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.xiaomi.infra.pegasus.replication.query_cfg_response;
import com.xiaomi.infra.pegasus.rpc.Table;
import io.netty.util.concurrent.*;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;

import java.util.ArrayList;
Expand Down Expand Up @@ -47,7 +48,21 @@ final static class TableConfiguration {
long lastQueryTime_;

public TableHandler(ClusterManager mgr, String name, KeyHasher h) throws ReplicationException {
logger.debug("initialize table handler, table_name({})", name);
int i = 0;
for (; i < name.length(); i++) {
char c = name.charAt(i);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
|| c == '_' || c == '.' || c == ':')
continue;
else
break;
}
if (name.length() > 0 && i == name.length()) {
logger.info("initialize table handler, table name is \"{}\"", StringEscapeUtils.escapeJava(name));
} else {
logger.warn("initialize table handler, maybe invalid table name \"{}\"", StringEscapeUtils.escapeJava(name));
}

query_cfg_request req = new query_cfg_request(name, new ArrayList<Integer>());
query_cfg_operator op = new query_cfg_operator(new gpid(-1, -1), req);

Expand Down

0 comments on commit c8d0bb2

Please sign in to comment.