当我执行我的代码时,我收到了很多有关该过程的信息
...
17:00:32.847 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #4
17:00:32.847 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: next 1
17:00:32.847 [main] DEBUG o.a.h.h.c.HConnectionManager$HConnectionImplementation - Cached location for users,,1457026980361.19aa4c864d45ba861fb1e90777e7a8fb. is localhost:60020
17:00:32.847 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #5
17:00:32.848 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #5
17:00:32.848 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: next 1
17:00:32.848 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #6
17:00:32.849 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #6
17:00:32.849 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: close 1
17:00:32.851 [main] DEBUG o.a.h.hbase.client.ClientScanner - Creating scanner over users starting at key ''
17:00:32.851 [main] DEBUG o.a.h.hbase.client.ClientScanner - Advancing internal scanner to startKey at ''
17:00:32.851 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #7
17:00:32.852 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #7
17:00:32.852 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: openScanner 1
17:00:32.853 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #8
17:00:32.854 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #8
17:00:32.854 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: next 1
Username: alican Password: alican123 - ID: 1
17:00:32.854 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #9
17:00:32.855 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #9
17:00:32.855 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: next 1
Username: dino Password: dino123 - ID: 2
17:00:32.856 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #10
17:00:32.856 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #10
17:00:32.856 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: next 1
17:00:32.857 [main] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican sending #11
17:00:32.857 [IPC Client (47) connection to localhost/127.0.0.1:60020 from alican] DEBUG org.apache.hadoop.ipc.HBaseClient - IPC Client (47) connection to localhost/127.0.0.1:60020 from alican got value #11
17:00:32.857 [main] DEBUG org.apache.hadoop.ipc.RPCEngine - Call: close 1
17:00:32.857 [main] DEBUG o.a.h.hbase.client.ClientScanner - Finished with scanning at {NAME => 'users,,1457026980361.19aa4c864d45ba861fb1e90777e7a8fb.', STARTKEY => '', ENDKEY => '', ENCODED => 19aa4c864d45ba861fb1e90777e7a8fb,}
我找到的东西只能显示我想看到的输出。
if (otherArgs.length != 1) {
System.out.println("usage: [regular expression]");
System.exit(-1);
}
RegexStringComparator regex = new RegexStringComparator(otherArgs[0]);
SingleColumnValueFilter filter = new SingleColumnValueFilter(
usernameFamily,
userQualifier,
CompareOp.EQUAL,
regex
}
scan.setFilter(filter);
当我添加这些代码时,程序仅显示System.out.println("usage: [regular expression]");
。我调试程序时无法理解这些代码是什么。
还有什么其他方法可以隐藏这一过程的每一步吗?
以下是完整代码:
Configuration config = HBaseConfiguration.create();
String[] otherArgs = new GenericOptionsParser(config, args).getRemainingArgs();
/* if (otherArgs.length != 1) {
System.out.println("usage: [regular expression]");
System.exit(-1);
}*/
HTable table = new HTable(config, "users");
byte[] usernameFamily = Bytes.toBytes("username");
byte[] userQualifier = Bytes.toBytes("user");
byte[] passwordFamily = Bytes.toBytes("password");
byte[] passQualifier = Bytes.toBytes("pass");
/* RegexStringComparator regex = new RegexStringComparator(otherArgs[0]);
SingleColumnValueFilter filter = new SingleColumnValueFilter(
usernameFamily,
userQualifier,
CompareOp.EQUAL,
regex
); only shows username. */
Scan scan = new Scan();
// scan.setFilter(filter);
ResultScanner results = table.getScanner(scan);
for (Result result : results ) {
String id = new String(result.getRow());
byte[] byteUsername = result.getValue(usernameFamily, userQualifier);
String strUsername = new String(byteUsername);
byte[] bytePassword = result.getValue(passwordFamily, passQualifier);
String strPassword = new String(bytePassword);
System.out.println("Username: " +strUsername + " Password: " + strPassword + " - ID: " + id);
}
results.close();
table.close(); }
答案 0 :(得分:0)
这看起来就像你的日志属性或 xml 文件一样(取决于你如何配置它,假设你可能有一种类型)对于 log4j 或 logback )的那些文件,org.apache.hadoop.ipc
设置为DEBUG
级别。将此更改为INFO
应该缩小输出方式,或ERROR
进一步缩放输出。
请参阅此code link,例如,搜索已完成扫描 - 将其包含在调试检查中并使用debug
进行调用记录方法。 (注意,链接是旧版本的HBase,但它说明了这个问题。)
顺便说一句,请注意,在上面的代码中,您使用的是System.out.println
。我建议使用上述属性或xml文件从根记录器设置中获取 logger ,并记录下来。这样,可以在同一配置文件中管理所有包的日志级别和其他设置。