oshdb icon indicating copy to clipboard operation
oshdb copied to clipboard

⚠️ close tagtranslators in mapreducers

Open tyrasd opened this issue 5 years ago • 2 comments

⚠️ – 292c011 has breaking changes, needs to be discussed thoroughly ~🚧 – merge after #246~

tyrasd avatar May 29 '20 15:05 tyrasd

Moving the ownership for the TagTranslator from MapReducer to OSHDBDatabase could solve the problem. Up to now I don't see a case where we need to have the same OSHDBDatabase connection with different TagTranslator instances.

// set explicit  keytables connection for Cluster OSHDBDatabases
try(Connection keytables = DriverManager.getConnection(url);
    OSHDBDatabase oshdb = new OSHDBIgnite("ignite.xml", keytables);){
  // ...
}

try(Connection conn = DriverManager.getConnection(url);
    OSHDBDatabase oshdb = new OSHDBJdbc(conn)){
  //  ...
}

The MapReducer instance gets the TagTranslator reference through the OSHDBDatabase and the OSHDBDatabase is responsible for closing the TagTranslator probably.

This also has the positive side effect that the TagTranslator could be better utilize its cache tags by executing multiple MapReducer with the some OSHDBDatabase.

rtroilo avatar Jun 02 '20 08:06 rtroilo

related: #225 :pray:

tyrasd avatar Jun 02 '20 08:06 tyrasd