streamsets 官方默認鏡像中文支持問題


以前在測試streamsets 的時候就發現中文亂碼,后邊也每太注意,以為支持問題,今天跑了下單元
測試代碼,以及使用本機運行,發現都沒有問題,然后運行以前的配置,使用jjs 發現模式的編碼為
ANSI_X3.4-1968

原有環境准備

 
version: "3"
services:
   sets:
     image: streamsets/datacollector 
     volumes:
     - "./ms/data:/data"
     - "./ms/logs:/logs"
     - "./ms/tmp:/tmp"
     ports:
     - "8000:8000"
     - "18630:18630"
   redis:
     image: redis
     ports:
     - "6379:6379"
   mongodb:
     image: mongo
     ports:
     - "27017:27017"

使用jjs 查看方式

  • 進入容器
docker-compose exec sets sh
  • 使用jjs 命令查看默認額編碼
var s = Java.type("java.lang.System")
print(s.getProperty("file.encoding"))
print(s.getProperty("sun.jnu.encoding"))

結果為上邊說的ANSI_X3.4-1968

結果方法

修改默認編碼為utf-8

  • dockerfile
FROM streamsets/datacollector:3.12.0-latest
ENV SDC_JAVA_OPTS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=utf-8"
ENV SDC_JAVA8_OPTS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=utf-8"
  • docker-compose 文件
version: "3"
services:
   sets:
     build: ./
     volumes:
     - "./ms/data:/data"
     - "./ms/logs:/logs"
     - "./ms/tmp:/tmp"
     ports:
     - "8000:8000"
     - "18630:18630"
   redis:
     image: redis
     ports:
     - "6379:6379"
   mongodb:
     image: mongo:3.0
     ports:
     - "27017:27017"
  • 安裝mongodb 包
  • 創建一個簡單的微服務pipeline

 

 

  • 配置

expression 處理

 

 


mongodb

 

 

測試效果

啟動pipeline很簡單, 點擊start 即可

  • 模擬http 數據
curl -i -X POST http://localhost:8000/rest/v1/user --header "X-SDC-APPLICATION-ID:microservice" -d '{"ID":1, "NAME": "Sample Name 榮", "AGE":34, "ADDRESS": "2333 San Francisco"}'
  • mongodb 數據存儲

 

 

說明

以上處理的方法比較簡單,主要是記錄下一個處理的問題的思路以及解決方法

參考資料

https://streamsets.com/documentation/datacollector/latest/help/datacollector/UserGuide/Configuration/DCEnvironmentConfig.html#concept_rng_qym_qr
https://github.com/streamsets/datacollector-docker


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM