mirror of https://github.com/apache/iotdb
improve too many open files implementation
This commit is contained in:
parent
be364148e7
commit
690758b2e3
|
@ -59,7 +59,7 @@ public class QueryForMerge {
|
|||
private void unlockForCurrentQuery() {
|
||||
try {
|
||||
ReadLockManager.getInstance().unlockForOneRequest();
|
||||
} catch (ProcessorException e) {
|
||||
} catch (ProcessorException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,14 @@ public class FileReaderMap {
|
|||
/** map to store opened file stream **/
|
||||
private static ThreadLocal<Map<String, TsRandomAccessLocalFileReader>> fileReaderMap = new ThreadLocal<>();
|
||||
|
||||
private static class ReaderHolder {
|
||||
private static final FileReaderMap INSTANCE = new FileReaderMap();
|
||||
}
|
||||
|
||||
public static FileReaderMap getInstance() {
|
||||
return ReaderHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public static TsRandomAccessLocalFileReader get(String path) throws IOException {
|
||||
if (fileReaderMap.get() == null) {
|
||||
fileReaderMap.set(new HashMap<>());
|
||||
|
@ -32,9 +40,11 @@ public class FileReaderMap {
|
|||
TsRandomAccessLocalFileReader reader = entry.getValue();
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
fileReaderMap.get().clear();
|
||||
fileReaderMap.remove();
|
||||
}
|
||||
|
||||
|
||||
//fileReaderMap.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,12 +95,7 @@ public class ReaderManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
for (Map.Entry<String, List<RowGroupReader>> entry : rowGroupReaderMap.entrySet()) {
|
||||
List<RowGroupReader> rowGroupReaderList = entry.getValue();
|
||||
for (RowGroupReader reader : rowGroupReaderList) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
public void close() {
|
||||
rowGroupReaderMap.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
|
|||
try {
|
||||
ReadLockManager.getInstance().unlockForOneRequest();
|
||||
clearAllStatusForCurrentRequest();
|
||||
} catch (ProcessorException e) {
|
||||
} catch (ProcessorException | IOException e) {
|
||||
LOGGER.error("Error in closeOperation : {}", e.getMessage());
|
||||
}
|
||||
return new TSCloseOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
|
||||
|
|
Loading…
Reference in New Issue