improve too many open files implementation

This commit is contained in:
CGF 2018-01-16 00:24:40 +08:00
parent be364148e7
commit 690758b2e3
4 changed files with 16 additions and 11 deletions

View File

@ -59,7 +59,7 @@ public class QueryForMerge {
private void unlockForCurrentQuery() {
try {
ReadLockManager.getInstance().unlockForOneRequest();
} catch (ProcessorException e) {
} catch (ProcessorException | IOException e) {
e.printStackTrace();
}
}

View File

@ -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.get().clear();
fileReaderMap.remove();
//fileReaderMap.remove();
}
}

View File

@ -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();
}
}

View File

@ -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));