New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IOTDB-538]add a simple connection pool for session api #880
Conversation
I need to add a new api to enable user closing a SessionPool. |
} | ||
} | ||
if (logger.isDebugEnabled()) { | ||
logger.error("Create a new Session {}, {}, {}, {}", ip, port, user, password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the password be printed?
* | ||
* @param rowBatch data batch | ||
*/ | ||
public TSExecuteBatchStatementResp insertSortedBatch(RowBatch rowBatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it needed to export the methods of Session in this Pool? the codes are double...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the codes are double...
Ah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the interfaces are double...
return resp; | ||
} catch (IoTDBSessionException e) { | ||
if (e.getCause() instanceof TException) { | ||
// TException means the connection is broken, remove it and get a new one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix.
The attachment is a patch for v0.9.1. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
The Session pool is already merged into rel/0.9 branch. If you want to use it in 0.9.x, rel/0.9 branch is the best choice |
Well, I think the pool is more easy to use than the description in IOTDB-538.
We provided a connection pool (`SessionPool) for Native API.
Using the interface, you need to define the pool size.
If you can not get a session connection in 60 secondes, there is a warning log but the program will hang.
If a session has finished an operation, it will be put back to the pool automatically.
If a session connection is broken, the session will be removed automatically and the pool will try
to create a new session and redo the operation.
For query operations:
SessionDataSetWrapper
;SessionDataSetWrapper
, if you have not scanned all the data in it and stop to use it,you have to call
SessionPool.closeResultSet(wrapper)
manually;hasNext()
andnext()
of aSessionDataSetWrapper
and there is an exception, thenyou have to call
SessionPool.closeResultSet(wrapper)
manually;Examples:
session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java