Migration from HTTPAsyncClient to HTTPClient5 - Replacement for PoolingNHttpClientConnectionManager? and how to set Socket timeout on RequestConfig? - apache-httpclient-4.x

I am migrating from HTTPAsyncCLient to HTTPCLient5 to make use of the HTTP/2 support that comes with it.
We used to use PoolingNHttpClientConnectionManager as our connection manager but it is no longer available. I was wondering what the best replacement for it is and why? is PoolingAsyncClientConnectionManager the right candidate for it?
Also, the API to set the socket connection timeout is no longer available. What is the alternative for it now?
Previously:
RequestConfig.Builder builder =RequestConfig.custom()
.setSocketTimeout(something)
I am new to this and most likely have some knowledge gaps. It would be great if someone can help me out or point me to a resource to understand it.

Related

How to resolve com.couchbase.client.core.RequestCancelledException: Could not dispatch request, cancelling instead of retrying?

I am using Cocuhbase client 2.5.0 jar as mentioned below.
1)couchbase-core-io-1.5.0
2)couchbase-java-client-2.5.0
3)rxjava-1.3.0
I follow the few blogs and suggestion of retry mechanism to change as like this:
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().queryEndpoints(2)
.retryStrategy(BestEffortRetryStrategy.INSTANCE).build();
This is not working.
So any other suggestion welcome.
If you're using Java 2.5.x, rather than using queryEndpoints, you should use the pooling configuration. This will let the SDK dynamically create and shut down more connections as needed in case some of your queries take longer. By saying .queryEndpoints(2), you're saying only allow two connections, which may not be enough.
For something like this, try to diagnose it with:
CouchbaseEnvironment env = (CouchbaseEnvironment) DefaultCouchbaseEnvironment
.builder()
.queryServiceConfig(QueryServiceConfig.create(2,50))
.build();
That will give you a minimum of 2 and a maximum of 50 queryEndpoints. You may have to adjust the max to your production workload, but if this makes the issue go away we know that you had exhausted the endpoints.

JNDI pooled data source: Driver-based vs DataSource-based

I'm looking to set up Tomcat to use a JNDI pooled data source for a MySQL database. HikariCP seems to be the recommended choice recently (at least on StackOverflow).
The documentation helpfully lists the configuration (presumably for server.xml or context.xml) but divides into "Driver-based" and "DataSource-based". Couldn't find much more info about this - could anyone advise on how to make the choice?
All things being equal, I'd go with DataSource-based. With Driver-based the driver is basically wrapped as a DataSource internally -- so it adds an extra layer (thin though it may be).
However, all things are not always equal. Sometimes there are drivers that expose some settings as URL parameters but not as DataSource properties. Most drivers are good about equivalency. So, if you happen to need to tweak a setting that is only available as a URL parameter, you'll have no choice but to use the Driver-based approach.

sqljocky - MySql - communication with MySql

I'm looking at sqljocky for use with MySql, and checking to see how it "works". There doesn't appear to be any "C" code and it appears to use sockets.
Is that correct, and could someone who knows, elaborate a little bit for me?
I wrote SQLjocky, and you are correct - there is no C code in SQLjocky, it is completely written in Dart, and uses sockets to communicate with the MySQL server. The protocol is documented to varying levels of usefulness at http://dev.mysql.com/doc/internals/en/client-server-protocol.html

Preferred way to DB connection in iOS

I'm a beginner iOS developer, and I'm trying to build a CRM system to learn the different aspects of developing.
I have a question regarding the preferred way to connect to an external SQL-server. I'm using Karl Krafts' Obj-C MySQL Connector by the way.
Right now I init the Database-controller (which in turn creates, then idles the connection to the server) object in my app delegate (didFinishLaunchingWithOptions), and that gives me some unwanted side-effects.. The screen is black a long time at startup if connection to the DB is slow, and sometimes the app is "too fast" and the query is trying to execute before the connection has been fully established - resulting in an exception being thrown.
The behavior I want (and guess is the preferred) is that the GUI loads up first, and then the initialization of the DB-controller and connection is established in a background thread - updating the GUI when the data has been acquired.
How would I achieve this? I have tried a number of different ways i've come across in my research, dispatch_queues and initing it straight from the viewDidLoad etc, but none give me the desired "GUI then data"-effect.
Also, would it be preferred to have an idling connection during the session of the program - or should each query 'connect - do its thing - disconnect'?
Regards, Christopher
Commandment One: don't do networking on the main thread - it's reserved for the UI. Else your app will have a laggy and frozen UI.
Commandment Two: instead of a lot of sequential synchronous calls, use asynchronous calls (GCD, background threads, etc.), events and callbacks. Cocoa (Touch) is designed with this in mind, so it's easy to do.
Commandment Three: if you launch something automatically, let it be launched when the app is fully ready. Let the call to the web service be the last one in application:didFinishLaunchingWithOptions:. Even better, let the user have the possibility to initiate the login via a user action, i. e. by pressing a "Login" button.
Commandment Four: read the first three Commandment again and keep them in mind. Practice them until you know them well.

Memcache (northscale) socket pool question for Enyim

I'm using Northscale 1.0.0 and need a little help getting it to limp along for long enough to upgrade to the new version. I'm using C# and ASP.NET to work with it using the Enyim libraries. I currently suspect that the application does not have enough connections per the socketPool setting in my app.config. I also noted that the previous developer's code simply treats ANY exception from an attempted Get call to MemCache as if the item isn't in the cache, which (I believe) may be resulting in periodic spikes in calls to the database when the pool gets starved. We've been having oddball load spikes that don't seem to have any relation to server load. I suspect that he is not correctly managing the lifecycle on the connections to Northscale and that we are periodically experiencing starvation in the socket pool as a result, but I'm unable to prove it.
Is there a specific exception I should be looking for when I call the Get method to retrieve items from cache? I'm not really seeing much in the docs that gives me sufficient information on this. Anybody have any sample code on this? I'd even accept java or php code, as I think the .NET libraries were probably based on one of those anyway.
Any ideas?
Thanks,
Will
If you have made the connection correctly to the membase server(formerly Northscale) typically you only get an exception on 'get' when it's not a hit.