[ 
https://issues.apache.org/jira/browse/CASSANDRA-10837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15058991#comment-15058991
 ] 

Benjamin Lerer commented on CASSANDRA-10837:
--------------------------------------------

{quote} Cluster doesn't implement AutoClosable interface, so it has to be 
closed manually. Closing cluster will close all session objects associated with 
it. 
{quote}

{{Closeable}} extends {{AutoCloseable}} so you can use {{close-with-resources}} 
We have no guaranties on the {{Cluster.close()}} implementation. So let's do 
things properly: first closing the {{Sessions}} then closing the {{Cluster}}. 
It is the best way to avoid bad surprises.

{quote}NativeRingCache uses the cluster to get the metadata in the constructor 
when cluster object is still open. once the initialization of constructor is 
done, the cluster object is not used by NativeRingCache anymore.
{quote}

If the cluster is only used in the constructor there is not need to store it as 
an instance variable. Sooner or later somebody will try to use it and burn 
his/her fingers. 
The {{Cluster}}, or even better the {{Metadata}}, should be passed as an 
argument to the {{refreshEndpointMap}} method.
There is also no need to open a {{Session}} to get the {{Metadata}} 

> Cluster/session should be closed in Cassandra Hadoop Input/Output classes
> -------------------------------------------------------------------------
>
>                 Key: CASSANDRA-10837
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10837
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>            Reporter: Alex Liu
>            Assignee: Alex Liu
>             Fix For: 3.0.x
>
>         Attachments: 10837-3.0-branch.txt, 10837-v2-3.0-branch.txt
>
>
> See a lot of following warnings during Hadoop job running
> {code}
> ERROR 11:37:45 LEAK: You are creating too many HashedWheelTimer instances.  
> HashedWheelTimer is a shared resource that must be reused across the JVM,so 
> that only a few instances are created.
> {code}
> Each cluster/session needs be closed and a shared HashedWheelTimer may reduce 
> the resource leakage.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to