日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

flume spooldir bug修复

發布時間:2025/3/18 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 flume spooldir bug修复 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

BUG:在往目錄中copy大文件時,沒有復制完,flume就開始讀-->導致報錯

在代碼中體現為:
org.apache.flume.client.avro.ReliableSpoolingFileEventReader.retireCurrentFile()方法內

解決方案:
等文件完全拷貝完成,再開始讀這個文件

1.5版本:

private Optional<FileInfo> getNextFile() {7 /* Filter to exclude finished or hidden files */8 FileFilter filter = new FileFilter() {9 public boolean accept(File candidate) { 10 String fileName = candidate.getName(); 11 if ((candidate.isDirectory()) || 12 (fileName.endsWith(completedSuffix)) || 13 (fileName.startsWith(".")) || 14 ignorePattern.matcher(fileName).matches()) { 15 return false; 16 } 17 return true; 18 } 19 }; 20 List<File> candidateFiles = Arrays.asList(spoolDirectory.listFiles(filter)); //獲取spoolDirectory下滿足條件的文件 21 if (candidateFiles.isEmpty()) { 22 return Optional.absent(); 23 } else { 24 Collections.sort(candidateFiles, new Comparator<File>() { //按最后修改時間排序文件 25 public int compare(File a, File b) { 26 int timeComparison = new Long(a.lastModified()).compareTo( 27 new Long(b.lastModified())); 28 if (timeComparison != 0) { 29 return timeComparison; 30 } 31 else { 32 return a.getName().compareTo(b.getName()); 33 } 34 } 35 }); 36 File nextFile = candidateFiles.get(0); //因為每次獲取到的文件處理完都會被標記為已完成,所以直接取拍完序的第一個 37 //修復傳輸大文件報錯文件被修改的BUG 38 this.checkFileCpIsOver(nextFile);//此處被阻塞,直到文件拷貝文件或者超過20秒 39 40 try { 41 // roll the meta file, if needed 42 String nextPath = nextFile.getPath()

1.7版本 :

private Optional<FileInfo> getNextFile() {List<File> candidateFiles = Collections.emptyList();if (consumeOrder != ConsumeOrder.RANDOM ||candidateFileIter == null ||!candidateFileIter.hasNext()) {candidateFiles = getCandidateFiles(spoolDirectory.toPath());listFilesCount++;candidateFileIter = candidateFiles.iterator();}if (!candidateFileIter.hasNext()) { // No matching file in spooling directory.return Optional.absent();}File selectedFile = candidateFileIter.next();if (consumeOrder == ConsumeOrder.RANDOM) { // Selected file is random.return openFile(selectedFile);} else if (consumeOrder == ConsumeOrder.YOUNGEST) {for (File candidateFile : candidateFiles) {long compare = selectedFile.lastModified() -candidateFile.lastModified();if (compare == 0) { // ts is same pick smallest lexicographically.selectedFile = smallerLexicographical(selectedFile, candidateFile);} else if (compare < 0) { // candidate is younger (cand-ts > selec-ts)selectedFile = candidateFile;}}} else { // default order is OLDESTfor (File candidateFile : candidateFiles) {long compare = selectedFile.lastModified() -candidateFile.lastModified();if (compare == 0) { // ts is same pick smallest lexicographically.selectedFile = smallerLexicographical(selectedFile, candidateFile);} else if (compare > 0) { // candidate is older (cand-ts < selec-ts).selectedFile = candidateFile;}}}firstTimeRead = true;//修復傳輸大文件報錯文件被修改的BUG this.checkFileCpIsOver(selectedFile);//此處被阻塞,直到文件拷貝文件或者超過20秒return openFile(selectedFile);}

?

解決代碼:

/**** @Title: checkFileCpIsOver* @Description: TODO(用來檢查文件拷貝是否完成)* @param @param currentFile 設定文件* @return void 返回類型* @throws*/ private void checkFileCpIsOver(File file) {long modified = file.lastModified();//目前文件的修改時間long length = file.length();//目前文件的大小try {Thread.sleep(1000);//等待1秒鐘} catch (InterruptedException e) {// TODO Auto-generated catch block e.printStackTrace();}File currentFile = new File(file.getAbsolutePath());int count = 0;//記錄循環次數,超過20次,也就是10秒后拋出異常while(currentFile.lastModified() != modified || currentFile.length() != length) {if(count > 20) {String message = "File Copy time too long. please check copy whether exception!" + "\n"+ "File at :" + file.getAbsolutePath() + "\n"+ "File current length is:" + currentFile.lastModified();new IllegalStateException(message);}count++;modified = currentFile.lastModified();length = currentFile.length();try {Thread.sleep(500);//等待500毫秒} catch (InterruptedException e) {// TODO Auto-generated catch block e.printStackTrace();}currentFile = new File(file.getAbsolutePath());}//一直到文件傳輸完成就可以退出 }

?

總結

以上是生活随笔為你收集整理的flume spooldir bug修复的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 狠狠干b| 黄色网址大全免费 | 爱情岛论坛永久入址测速 | 亚洲欧美偷拍视频 | 男人桶女人桶爽30分钟 | 亚洲国产中文字幕在线观看 | 精品国产一区二区三区四区阿崩 | 亚洲狠狠丁香婷婷综合久久久 | 国产亚洲精品久 | 日韩av在线网站 | 国产一区二区三区在线 | 女儿的朋友5中汉字晋通话 欧美成人免费高清视频 | 亚洲美女屁股眼交3 | 综合久久99| 国产三级一区二区三区 | 久久av免费观看 | 亚洲天堂网一区 | 午夜久久福利 | 白浆av| 久久亚洲av无码精品色午夜麻豆 | 熟女少妇a性色生活片毛片 亚洲伊人成人网 | 911香蕉 | 美女露隐私网站 | 欧美日韩高清一区二区 | 欧美综合影院 | 国产又粗又猛又黄又爽无遮挡 | aⅴ在线免费观看 | 色吧久久| а天堂中文在线官网 | 国产老女人精品毛片久久 | 亚洲精品在线观看av | 黄视频免费在线观看 | 精品久久免费观看 | 欧美日韩123区 | 中文字幕色站 | 日本激情电影 | 日韩av一级片 | 青青草国产成人av片免费 | 毛片a | 狠狠干2018 | 宅男深夜视频 | 一级毛片基地 | 日韩不卡一二三 | 久久婷婷国产麻豆91天堂 | 日本成人片网站 | 国产永久免费 | 日本一区二区视频在线观看 | 亚洲男人天堂av | 国产又粗又猛又爽69xx | 成人影| 美女交配 | 国产9区| 男女做爰猛烈吃奶啪啪喷水网站 | 天天干视频在线 | 午夜污片| 免费黄片毛片 | 天堂成人国产精品一区 | 免费成人美女女 | 9人人澡人人爽人人精品 | 综合久久久久久久久久久 | 台湾佬美性中文娱乐网 | 中文视频一区 | 国产亚洲精久久久久久无码苍井空 | 日本女人hd| 人人澡超碰碰97碰碰碰 | 激情六月综合 | 国产一级片精品 | 永久免费看mv网站入口亚洲 | 91小视频| 欧美精品一级 | 九九色综合 | 亚洲欧美一区二区激情 | 中国丰满熟妇xxxx性 | 欧美人妻精品一区二区免费看 | 2025中文字幕 | 91色站 | 久久人人爽爽 | 亚洲好骚综合 | 99re热这里只有精品视频 | 看一级黄色 | 亚洲综合精品一区 | 中文字幕在线成人 | 国产精彩视频在线观看 | 97人人模人人爽人人少妇 | 影音先锋亚洲天堂 | 麻豆精品91| www欧美在线 | 日韩av黄色片 | 黄色成年人网站 | 91久久久久久久久 | 尤物网站在线播放 | 一区二区高清在线观看 | 国产一级片a | 毛茸茸多毛bbb毛多视频 | 欧美aa在线观看 | 亚洲精品成人网 | 日本中文在线视频 | 国产污污视频 | 亚洲最大毛片 |