SessionManager should invoke PREPARE on all nodes in parallel

Description

SessionManager.prepare essentially has this code.

private void SessionManager.prepare(String query, InetSocketAddress toExclude) throws InterruptedException {
for (Map.Entry<Host, HostConnectionPool> entry : pools.entrySet()) {
Connection c = entry.getValue().borrowConnection(200, TimeUnit.MILLISECONDS);
c.write(new Requests.Prepare(query)).get();
}
}

It sends PREPARE to one node and waits till it gets the response before it sends to the next. This is not necessary. It can write PREPARE to all nodes, collect the futures in a list and can do a futureList.get().

That will cut down the over all time to prepare when client is connected to large number of nodes.

Environment

None

Pull Requests

None

Activity

Show:
Olivier Michallat
May 29, 2015, 8:50 AM

The idea suggested in my previous comment was logged separately as JAVA-797.

Olivier Michallat
May 7, 2015, 2:07 PM

Another idea to explore: when there are many clients and they all prepare their statements at startup, re-preparing on other hosts will often be redundant, because these hosts could have already prepared the same statement for another client. So we could also have a switch to disable the reprepare on other hosts.

Fixed

Assignee

Alex Dutra

Reporter

Vishy Kasar

Labels

None

PM Priority

A

Affects versions

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Components

Priority

Major