Logging using PQS lower than 4.6

To logging PQS, you can log using NGINX as a proxy that records the HTTP Request Body and the timing.

On your Centos/RHEL machine, switch to root privileges
sudo -s

Add nginx.repo

Install nginx packages, and you can setup a proxy
yum install nginx.x86_64 -y

Create the nginx configuration so you have a log_format that outputs the body ($request_body) and time ($request_time)

Create the default server configuration, and set the proxy_pass to point to your PQS/phoenix query server

Reload nginx
nginx -s reload

Tail the log file to see the data called.
[root@data-com-4 pbastide]# tail -f /var/log/nginx/request-body.log


Logging using PQS 4.7 and Higher

1 – Drop this into /tmp and chmod 755 on the file
In practice, I’d probably put it in /opt/phoenix/config or /etc/hbase/phoenix

2 – Edit the queryserver.py (/opt/phoenix/bin/queryserver.py )
Around line 128 (hopefully not changed much from 4.7 to 4.8), add this
" -Dlog4j.configuration=file:///tmp/log4j.properties" + \

3 – Restart phoenix
/opt/phoenix/bin/queryserver.py stop
/opt/phoenix/bin/queryserver.py start

4 – scan the file
grep -i XYZ.dim /tmp/phoenix-query.log

2017-01-05 13:40:39,227 [qtp-1461017990-33 - /] TRACE org.apache.calcite.avatica.remote.ProtobufTranslationImpl - Serializing response 'results { connection_id: "0deb2c47-53e5-4846-b22b-ba3faa0bc37a" statement_id: 1 own_statement: true signature { columns { searchable: true display_size: 32 label: "ID" column_name: "ID" precision: 32 table_name: "XYZ.DIM" read_only: true column_class_name: "java.lang.String" type { id: 12 name: "VARCHAR" rep: STRING } } sql: "select ID from XYZ.DIM WHERE VLD_TO_TS IS NULL LIMIT 1" cursor_factory { style: LIST } } first_frame { done: true rows { value { scalar_value { type: STRING string_value: "00025a56f1084f0584a50f7cf9dc4bfc" } } } } update_count: 18446744073709551615 metadata { server_address: "demo.net:80" } } metadata { server_address: "demo.net:80" }'

You can then correlated on connection_id and analyze the log file for data.

Hamcrest Matchers Issue

I’ve been using Rest-Assured as a simple Integration Test tool for the last few months, and suddenly I started seeing this issue.

java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:895)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:665)
at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.test.restassured.TestCode.testaCreateTenant(TestCode.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

I wiped my .m2 repository of org.hamcrest.Matchers jar files, and rebuilt the maven repository (mvn clean package install -DskipTests).   The problem remained.

I ran across a simple for my code (on the rest-assured site thanks to johanhaleby)

I changed the code to

import static org.hamcrest.CoreMatchers.equalsTo;

Now the code passes the tests without a problem

CURL and LDAPS – How to Search and Debug

I hit an issue where I needed to Search LDAP from a machine I didn’t have access to install new RPMs on. I found this cool article on CURL and LDAP Search. I had to make some minor modifications to get it to work with a secure connection (–insecure ldaps:// and 636). I also added -v to diagnosis some connection problems.

curl "ldaps://,objectClass?sub?(objectClass=)" -u "cn=user1,ou=test_org3,o=dr,DC=IBM.COM" --insecure -v
Enter host password for user 'cn=user1,ou=test_org3,o=dr,DC=IBM.COM':
* Trying
* Connected to ( port 636 (#0)
* LDAP local: LDAP Vendor = OpenLDAP ; LDAP Version = 20428
* LDAP local: ldaps://,objectClass?sub?(objectClass=
* LDAP local: trying to establish encrypted connection
DN: dc=ibm.com
objectClass: domain
objectClass: top

DN: o=dr,dc=ibm.com
objectClass: organization
objectClass: top

DN: ou=test_org3,o=dr,dc=ibm.com
objectClass: organizationalunit
objectClass: top

You can then find the userids you need quickly. I left them off the output intentionally.

If you see connected, but no results, I suggest changing to the top level of the ldap, and using this string – ldaps://,objectClass?sub?(objectClass=*)