JAVA 의 노드 흐름 과 처리 흐름 및 흐름 의 닫 기 순서
5067 단어 자바
코드:
1 FSDataInputStream fsin = fs.open(new Path(filein));
2 FSDataOutputStream fsout = fs.append(new Path(fileout));
3 BufferedReader br = new BufferedReader(new InputStreamReader(fsin));
4 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fsout));
5 ...
6 br.close();
7 fsin.close();
8 bw.close();
9 fsout.close(); 이상:
1 [root@bigdata004 bigdata]# ./bigdataTimer.sh
2 INFO [main] com.sinosoft.bigdata.BigDataTimer.main(227) | -----Timer begin-----
3 INFO [main] com.sinosoft.bigdata.BigDataInit.<clinit>(70) | bigdata init ...
4 WARN [main] org.apache.hadoop.util.NativeCodeLoader.<clinit>(62) | Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
5 INFO [main] com.sinosoft.bigdata.BigDataTimer.mergeFile(66) | Finished appending file.
6 INFO [main] com.sinosoft.bigdata.BigDataTimer.mergeFile(68) | deleted the input data path.
7 INFO [main] com.sinosoft.bigdata.BigDataTimer.mergeFile(70) | create the input data path.
8 ERROR [main] org.apache.hadoop.hdfs.DFSClient.closeAllFilesBeingWritten(776) | Failed to close file /user/root/dayfileInput/dayfileIn
9 org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException): No lease on /user/root/dayfileInput/dayfileIn: File does not exist. Holder DFSClient_NONMAPREDUCE_-221972347_1 does not have any open files. 원인:처리 흐름 br.close()를 닫 습 니 다.이후 이와 관련 된 fsin.close()를 닫 았 다.의 노드 흐름.사실 br.close();fsin.close()를 호출 합 니 다. 그래서 fsin.close()를 두 번 반복 해서 닫 았 습 니 다.결국 이상 을 던 졌 다.
흐 르 는 지식 을 되 돌아 보 았 다.
흐름 이 특정한 곳(예 를 들 어 디스크,메모리,장치 등)과 직접 연결 되 는 지 여부 에 따라 노드 흐름 과 처리 흐름 두 가지 로 나 뉜 다.
JAVA 에서 자주 사용 하 는 노드 흐름:
상용 처리 흐름(처리 흐름 닫 기 사용 안 노드 흐름 닫 기)
주의: