configure Bigtable and gRPC logging - java

I would like to configure logging from Google Cloud Bigtable (gRPC) like the other modules of my application
Logs with SLF4J/log4j with properties configured to dismiss INFO logs from spark
2017-01-11 10:44:08 INFO algoServingLauncherTest$:12 - Starting algo Serving...
2017-01-11 10:44:09 INFO MongoDBAlgorithm$:12 - Retrieving all algorithms from mongodb://mongo:27017/mycompany/algorithms...
2017-01-11 10:44:09 INFO MongoDBAlgorithmHandler$:12 - Algorithms retrieval succeeded (1 algorithms)
2017-01-11 10:44:09 INFO MongoDBPredictor$:12 - Retrieving all predictors from mongodb://mongo:27017/mycompany/predictors...
2017-01-11 10:44:09 INFO MongoDBPredictorHandler$:12 - Predictors retrieval succeeded (13 predictors)
logs from Bigtable gRPC
Jan 11, 2017 10:44:23 AM com.google.bigtable.repackaged.io.grpc.internal.ManagedChannelImpl <init>
INFO: [ManagedChannelImpl#1cf6d1be] Created with target directaddress:///bigtable.googleapis.com/[omitted]:443
Jan 11, 2017 10:44:23 AM com.google.bigtable.repackaged.io.grpc.internal.ManagedChannelImpl <init>
INFO: [ManagedChannelImpl#4b29d1d2] Created with target directaddress:///bigtable.googleapis.com/[omitted]:443
Jan 11, 2017 10:44:23 AM com.google.bigtable.repackaged.io.grpc.internal.ManagedChannelImpl <init>
INFO: [ManagedChannelImpl#7f485fda] Created with target directaddress:///bigtable.googleapis.com/[omitted]:443
I would like to force logging to use SLF4J/Log4j.
What should I do ?
Thanks for your help

Unfortunately there isn't an existing direct SLF4J integration in grpc; grpc currently uses java.util.logging which has some complications.
You may want to read the open GitHub issue which discusses this in a lot more detail, and in particular this comment suggests that you may have some success with SLF4JBridgeHandler.

Related

Initial EJB RMI works but with exception

I'm working through an EJB tutorial where my client program invokes a method via remote stateless EJB to add a book. Upon exit the client retrieves and prints all the books from the EJB (I know it's not a good idea to store data in a list within a stateless EJB). All of this works fine, except the initial RMI also returns the following exception (I've included the full output from the client test as well).
Client output:
Nov 29, 2016 11:34:29 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.1.4.Final
**********************
Welcome to Book Store
**********************
Options
1. Add Book
2. Exit
Enter Choice: 1
Enter book name: Some book
Nov 29, 2016 11:34:44 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.4.0.Final
Nov 29, 2016 11:34:44 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.4.0.Final
Nov 29, 2016 11:34:44 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.21.Final
Nov 29, 2016 11:34:45 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Nov 29, 2016 11:34:45 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#4f7d0008, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection#271053e1,channel=jboss.ejb,nodename=slave01:server01]} on channel Channel ID 87a6ebda (outbound) of Remoting connection 64bfbc86 to /127.0.0.1:8133 of endpoint "client-endpoint" <64bf3bbf>
Nov 29, 2016 11:34:45 PM org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager getEJBReceiver
INFO: Could not create a connection for cluster node ClusterNode{clusterName='ejb', nodeName='slave01:server01', clientMappings=[ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='0.0.0.0', destinationPort=8080}], resolvedDestination=[Destination address=0.0.0.0, destination port=8080]} in cluster ejb
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.xnio.nio.WorkerThread$ConnectHandle.handleReady(WorkerThread.java:321)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:294)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:430)
at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:153)
at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:133)
at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:78)
at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
at org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager.getEJBReceiver(RemotingConnectionClusterNodeManager.java:79)
at org.jboss.ejb.client.ClusterContext$EJBReceiverAssociationTask.call(ClusterContext.java:469)
at org.jboss.ejb.client.ClusterContext$EJBReceiverAssociationTask.call(ClusterContext.java:443)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
**********************
Welcome to Book Store
**********************
Options
1. Add Book
2. Exit
Enter Choice: 2
Book(s) entered so far: 2
1. test1
2. Some book
***Using second lookup to get library stateless object***
Book(s) entered so far: 2
1. test1
2. Some book
So everything with the client, other than the exception, appears to work correctly. I suspect this issue has something to do with the zero'd out node addresses, but I'm not certain. The client properties file is below (in case that configuration is incorrect).
jboss-ejb-clients.properties:
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
invocation.timeout=3000
reconnect.tasks.timeout=2000
# User Credentials
username=user
password=pass
# Remote Connections
remote.connections=h1,h2
remote.connection.h1.host=127.0.0.1
remote.connection.h1.port=8133
remote.connection.h1.username=user
remote.connection.h1.password=pass
remote.connection.h2.host=127.0.0.1
remote.connection.h2.port=8134
remote.connection.h2.username=user
remote.connection.h2.password=pass
# Cluster
remote.clusters=ejb
remote.cluster.ejb.connect.timeout=2500
remote.cluster.ejb.max-allowed-connected-nodes=2
remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
remote.cluster.ejb.username=user
remote.cluster.ejb.password=pass
After extensive research (and a good amount of trial and error with test code), I found a book on Safari (Java EE 7 Development with WildFly) that lead me in the right direction. I had to drop the jboss-ejb-clients.properties file and add the ejb-client configuration found in the answer here to my main client class.

Pivotal server log messages not show in Spring tools suite

I am working on Spring web MVC. I am using Spring tools suite and pivotal server. I did not found any server log messages in STS. Console only show the server startup message. I want to view all the server message, error and exceptions. Currently I am unable to view any server error messages and errors.
The console is showing the message like this-
Nov 19, 2016 1:08:21 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1312 ms
Nov 19, 2016 1:08:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5332 ms
i see the question is old but I came across the same issue just now and didn't want to let this one go unanswered ;)
I found an solution from pivotal themselves. But it has a little typo in it: The first line in the logging.properties is
handlers= java.util.logging.ConsoleHandler.level= INFO
but should rather be just
handlers= java.util.logging.ConsoleHandler
This should do the trick.
And if you would still want to keep the default catalina, localhost, etc. files of the tcServer additional to the console output you can modify or copy the logging.properties file found inside of your tcServer - base instance ({pivotal-tc-server-folder}/base-instance/conf/).
Here are many configurations but the one concerning the console output, which is otherwise only in the catalina-{date}.log is in the line
.handlers = 1catalina.org.apache.juli.AsyncFileHandler
just change it to
.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
and you'll have both: logs and console output.
Best regards,
Uwe

Connecting Java client to Hazelcast-Kubernetes fails

I'm running a kubernetes cluster in which I am deploying a "cloud native hazelcast" following the instructions on the kubernetes-hazelcast github page. Once I have a number of hazelcast instances running, I try to connect a java client to one of the instances but for some reason the connection fails.
Some background
Using a kubernetes external endpoint I can connect to hazelcast from outside the kubernetes cluster. When I do a REST call with curl kubernetes-master:32469/hazelcast/rest/cluster, I get a correct response from hazelcast with it's cluster information. So I know my endpoint works.
The hazelcast-kubernetes deployment uses the hazelcast-kubernetes-bootstrapper which allows some configuration by setting environment variables with the replication controller, but I'm using all defaults. So my group and password are "someGroup" and "someSecret".
The java client
My Java client code is really straightforward:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(0);
clientConfig.getNetworkConfig().setConnectionTimeout(10000);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(2000);
clientConfig.getNetworkConfig().addAddress("kubernetes-master:32469");
clientConfig.getGroupConfig().setName("someGroup");
clientConfig.getGroupConfig().setPassword("someSecret")
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
When start my client this is the log output of the hazelcast container
2016-07-05 12:54:38.143 INFO 5 --- [thread-Acceptor] com.hazelcast.nio.tcp.SocketAcceptor : [172.16.15.4]:5701 [someGroup] [3.5.2] Accepting socket connection from /172.16.29.0:54333
2016-07-05 12:54:38.143 INFO 5 --- [ cached4] c.h.nio.tcp.TcpIpConnectionManager : [172.16.15.4]:5701 [someGroup] [3.5.2] Established socket connection between /172.16.15.4:5701
2016-07-05 12:54:38.157 INFO 5 --- [.IO.thread-in-1] c.h.nio.tcp.SocketClientMessageReader : [172.16.15.4]:5701 [someGroup] [3.5.2] Unknown client type: <
And the console output of the client
jul 05, 2016 2:54:37 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTING
jul 05, 2016 2:54:38 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTED
jul 05, 2016 2:54:48 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 1 of 2147483647.
jul 05, 2016 2:54:58 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 2 of 2147483647.
jul 05, 2016 2:55:08 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
etc...
The client just keeps trying to connect but no connection is ever established.
What am I missing?
So why won't my client connect to the hazelcast instance? Is it some configuration part I'm missing?
Not sure about the official kubernetes support, however Hazelcast has a kubernetes discovery plugin (based on the new discovery spi) that works on both, client and nodes: https://github.com/noctarius/hazelcast-kubernetes-discovery
Looking at the console logs, you have different Hazelcast versions between Node and Client? Can you either update both to be 3.6.4 i.e., the latest or just change the cluster to be 3.6.2 to match with client. 3.6.x has many configuration changes and many bug fixes as well.

Not able to deploy Cloud end point backend module

I am working on an android project which uses data from Google data store. For this I have JSP & Servlet based admin module which will be used to upload data. To read data from Android client application I have cloud entry points.
Thus, I have created a module comprising of JSP, servlets, and cloud entry points. This is working fine with local dev server. Able to access data through android app.
Now, trying to deploy the module to Google App Engine. But getting following error:
SEVERE: Endpoints configuration not updated. The app returned an
error when the Google Cloud Endpoints server attempted to communicate
with it.
What could be missing here?
Let me know if anymore information needed regarding this issue.
Please help me in this regard.
Full trace:
/usr/lib/jvm/java-8-oracle/bin/java -Dfile.encoding=UTF-8 -classpath /root/.gradle/appengine-sdk/appengine-java-sdk-1.9.18/lib/appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --application=rotary-bidar-01 --version=1 --oauth2 --oauth2_client_secret=***** --oauth2_client_id=***** --oauth2_refresh_token=***** update /mnt/4CF2AADEF2AACC10/Projects/Rotary_Bidar/AndroidApplication/RotaryBidar/server/build/exploded-app
Reading application configuration data...
Jan 16, 2016 11:28:59 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /mnt/4CF2AADEF2AACC10/Projects/Rotary_Bidar/AndroidApplication/RotaryBidar/server/build/exploded-app/WEB-INF/appengine-web.xml
Jan 16, 2016 11:28:59 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /mnt/4CF2AADEF2AACC10/Projects/Rotary_Bidar/AndroidApplication/RotaryBidar/server/build/exploded-app/WEB-INF/web.xml
Beginning interaction for module default...
0% Created staging directory at: '/tmp/appcfg5838290850638628913.tmp'
5% Scanning for jsp files.
8% Compiling jsp files.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /tmp/1452967141068-0/org/apache/jsp/admin_jsp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Jan 16, 2016 11:29:10 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /tmp/appcfg5838290850638628913.tmp/WEB-INF/web.xml
20% Scanning files on local disk.
25% Initiating update.
28% Cloning 13 static files.
31% Cloning 50 application files.
40% Uploading 2 files.
52% Uploaded 1 files.
61% Uploaded 2 files.
68% Initializing precompilation...
73% Sending batch containing 2 file(s) totaling 1KB.
90% Deploying new version.
95% Will check again in 1 seconds.
98% Will check again in 2 seconds.
99% Will check again in 4 seconds.
99% Will check again in 8 seconds.
99% Will check again in 16 seconds.
99% Will check again in 32 seconds.
99% Endpoints configuration not updated. The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.
Jan 16, 2016 11:30:32 PM com.google.appengine.tools.admin.AppVersionUpload checkEndpointsServingStatusResult
99% See the deployment troubleshooting documentation for more information: https://developers.google.com/appengine/docs/java/endpoints/test_deploy#troubleshooting_a_deployment_failure
SEVERE: Endpoints configuration not updated. The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.
99% Ignoring Endpoints failure and proceeding with update.
99% Closing update: new version is ready to start serving.
99% Uploading index definitions.
Update for module default completed successfully.
Success.
Cleaning up temporary files for module default...

how to enable NIO / atmosphere on tomcat 6

I'm trying out atmosphere on tomcat 6 but only long polling works not websockets. The message i receive in the console output is
Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
Any info on this would be appreciated, thanks
Update: After modifying web.xml and server.xml the error message goes but the chat application always fallsback to long polling - I've tried several different .war deployments of websocket demos and they all behave the same.
I tried Tomcat 7 also, but it still uses long polling.
Some log info for startup
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Installed Default AtmosphereInterceptor [Android Interceptor Support, SSE Interceptor Support, JSONP Interceptor Support]. Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
10:42:30.423 [main] WARN o.atmosphere.cpr.AtmosphereFramework - No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the HeaderBroadcasterCache.
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - HttpSession supported: false
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using Broadcaster: org.atmosphere.jersey.JerseyBroadcaster
10:42:30.428 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Atmosphere Framework 1.0.0.beta5 started.
27/08/2012 10:42:30 AM org.apache.coyote.http11.Http11NioProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
27/08/2012 10:42:30 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11568 ms
When the chat client connects
27/08/2012 10:47:57 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
When a message is sent
10:48:09.256 [http-8080-exec-2] DEBUG o.a.cpr.AsynchronousProcessor - Cancelling the connection for request AtmosphereRequest{ contextPath=/atmosphere-rest-chat servletPath=/chat pathInfo=null requestURI=/atmosphere-rest-chat/chat requestURL=http://mogwai:8080/atmosphere-rest-chat/chat destroyable=true}
In context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Loader delegate="true"/>
</Context>
In server.xml:
<Connector connectionTimeout="20000" port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
redirectPort="8443"/>
Make sure you only have one implementation of CometProcessor defined in your classpath. You may want to remove catalina.jar from your webpass if it's bundled in. See this thread for more info:
http://mail-archives.apache.org/mod_mbox/tomcat-users/200707.mbox/%3C11785700.post#talk.nabble.com%3E

Categories

Resources