Sentinel Shuttle - skpdi/sentinel-document GitHub Wiki

Sentinel Schema๋ฅผ ํ†ตํ•ด ์ •์˜๋œ ๊ทœ๊ฒฉ๋Œ€๋กœ ๋กœ๊ทธ๋ฅผ ๋‚จ๊ธธ ์ˆ˜ ์žˆ๋„๋ก Format ์„ ๋‹ด๋‹นํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.
๊ธฐ๋กํ•ด์•ผ ํ•˜๋Š” ์ปฌ๋Ÿผ์„ Setter ๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ํŽธ๋ฆฌํ•˜๊ฒŒ ๋‚จ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„ผํ‹ฐ๋„ฌ ํ™ˆํŽ˜์ด์ง€์—์„œ ๋‹ค์šด ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Shuttle ์€ ํฌ๋งท๋งŒ ๋‹ด๋‹นํ•˜๋ฉฐ, ์ „์†ก์„ ์œ„ํ•ด์„œ๋Š” ๊ฐ ํ™˜๊ฒฝ์— ๋งž๋Š” ์ž…์ˆ˜๋„๊ตฌ์™€ ๊ฐ™์ด ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ™˜๊ฒฝ๋ณ„ ์‚ฌ์šฉ ๊ฐ€์ด๋“œ๋Š” ์•„๋ž˜ ๋ชฉ๋ก์— ์ถ”๊ฐ€๋œ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด ์ฃผ์„ธ์š”.

  • Client์šฉ Shuttle
    • Android (Rake Android์™€ ์‚ฌ์šฉ)
    • iOS (Rake iOS์™€ ์‚ฌ์šฉ)
    • Javascript (Rake Javascript์™€ ์‚ฌ์šฉ)
  • Server์šฉ Shuttle
    • Java (RakeKafka, LogAgent, Direct-Kafka์™€ ์‚ฌ์šฉ)

ํšจ๊ณผ

  • ํ•„๋“œ ์ด๋ฆ„ ์˜คํƒ€๋ฅผ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (IDE ์ž๋™์™„์„ฑ)
  • ํ•„๋“œ ๊ฐ’ escaping ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. (\n, \r, ๊ธฐํƒ€ ์ด์ƒํ•œ ์•„์Šคํ‚ค ์ฝ”๋“œ๋“ฑ)
  • ํ•„๋“œ ํƒ€์ž… ๋ถˆ์ผ์น˜ ๋ฐฉ์ง€ (Integer ๊ฐ€ ํ•„์š”ํ•œ๋ฐ, String ์„ ๋„ฃ์œผ๋ฉด ์ปดํŒŒ์ผ์ด ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.)
  • ๋กœ๊ทธ ๋ฒ„์ „ ์ž๋™ ์ƒ์„ฑ
  • ๋กœ๊ทธ๋ฒ„์ „ ํ˜•์‹ : #define์‹œํŠธ๋‚ด์˜ #version : shuttle version : schema version (๊ณต๋ฐฑ์—†์ด ":"๋กœ concat)
  • ๋กœ๊ทธ ํ˜•์‹(JSON/TSV) ์ž๋™ ์ƒ์„ฑ

์ฃผ์˜์‚ฌํ•ญ 1. Client Shuttle ๊ณผ Server Shuttle ์ฐจ์ด

  • Shuttle ์€ ์Šค๋ ˆ๋“œ ์„ธ์ดํ”„ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ์ด์Šˆ๊ฐ€ ์žˆ๋Š” ์œ„์น˜์—์„œ๋Š” (e.g Controller) ๋งค๋ฒˆ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜, ๋ฌด๊ฑฐ์šธ ๊ฒฝ์šฐ ThreadLocal, Spring scope ๋“ฑ์„ ์ด์šฉํ•ด์ฃผ์„ธ์š”.
  • Client ์šฉ Shuttle ์€ Android, iOS, Javascript ๋ฒ„์ „์„ ์ง€์›ํ•˜๋ฉฐ, ์˜์กด์„ฑ์ด ์—†์Šต๋‹ˆ๋‹ค.
  • Server ์šฉ Shuttle ์€ Java ๋ฒ„์ „๋งŒ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์˜์กด์„ฑ๋„ ์žˆ์œผ๋ฉฐ, Shuttle.toString ์„ ์‚ฌ์šฉํ•ด์„œ ๋กœ๊น…ํ•ฉ๋‹ˆ๋‹ค. (toJSONObject ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค)

์ฃผ์˜์‚ฌํ•ญ 2. Shuttle์„ ๋‘ ๊ฐœ ์ด์ƒ ์‚ฌ์šฉ์‹œ
(์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉํ•˜๋Š” Sentinel ๋กœ๊ทธ์ •์˜์„œ๊ฐ€ 2๊ฐœ ์ด์ƒ์ธ ๊ฒฝ์šฐ)

  • ํ•ด๋‹น ๊ฒฝ์šฐ Rake ์ธ์Šคํ„ด์Šค์™€ Shuttle์˜ ๋งตํ•‘ ๊ด€๊ณ„๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธํ•ด ์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
๋กœ๊ทธ์ •์˜์„œA์˜ ๋กœ๊ทธ ์ˆ˜์ง‘์šฉ Rake ์ธ์Šคํ„ด์Šค - ๋กœ๊ทธ์ •์˜์„œA์—์„œ ์ƒ์„ฑํ•œ Shuttle ์‚ฌ์šฉ 
๋กœ๊ทธ์ •์˜์„œB์˜ ๋กœ๊ทธ ์ˆ˜์ง‘์šฉ Rake ์ธ์Šคํ„ด์Šค - ๋กœ๊ทธ์ •์˜์„œB์—์„œ ์ƒ์„ฑํ•œ Shuttle ์‚ฌ์šฉ
  • ์›๋ž˜ ์ˆ˜์ง‘ํ•˜๊ณ ์ž ํ•˜๋Š” ์ฑ„๋„(Sentinel ๋กœ๊ทธ์ •์˜์„œ)์—์„œ ์ƒ์„ฑ๋œ Shuttle์ด ์•„๋‹Œ ๋‹ค๋ฅธ ์ฑ„๋„์—์„œ ์ƒ์„ฑ๋œ Shuttle์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ, ๋กœ๊ทธ ์ž…์ˆ˜๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Schema Type - Shuttle Type

Header / Body Schema Type (= Hive Table Type) Java Type (๊ด„ํ˜ธ ์•ˆ์€ ๊ธฐ๋ณธ๊ฐ’) Javascript Objective-C Swift Note
Header / Body string String (null) var NSString* (nil) String? (nil)
Header / Body long Long (null) var NSNumber* (nil) Int? (nil)
Header / Body double Double (null) var NSNumber* (nil) Double? (nil)
Header Only fixed string(n) String (null) var NSString* (nil) String? (nil)
Body Only list<long> List<Long> (new ArrayList<Long>) var NSMutableArray* (nil) [Int]? (nil)
Body Only list<double> List<Double> (new ArrayList<Double>) var NSMutableArray* (nil) [Double]? (nil)
Body Only list<string> List<String> (new ArrayList<String>) var NSMutableArray* (nil) [String]? (nil)
Body Only map<string,long> Map<String, Long> (new LinkedHashMap<String, Long>) var NSMutableDictionary* (nil) [String:Int]? (nil)
Body Only map<string,double> Map<String, Double> (new LinkedHashMap<String, Double>) var NSMutableDictionary* (nil) [String:Double]? (nil)
Body Only map<string,string> Map<String, String> (new LinkedHashMap<String, String>) var NSMutableDictionary* (nil) [String:String]? (nil)
Body Only json JSONObject (null) var NSMutableDictionary* (nil) [String:Any]? (nil) ์•”ํ˜ธํ™” ๋ฐ ๊ฒ€์ฆ ์ง€์› ๋ถˆ๊ฐ€

Body ์ปฌ๋Ÿผ์˜ ํƒ€์ž…์œผ๋กœ JSON ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Body๊ฐ€ 1 depth ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์ด ๊ฒฝ์šฐ 2 depth ์ด์ƒ์ด ๋ฉ๋‹ˆ๋‹ค. json ์˜ depth๊ฐ€ 2 ์ด์ƒ์ธ ๊ฐ’์— ๋Œ€ํ•ด ๊ฒ€์ฆ ๋ฐ ์•”ํ˜ธํ™”๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์œ„ ์‚ฌํ•ญ์— ๋Œ€ํ•ด์„œ ๊ณ ๋ คํ•˜์‹œ๊ณ  ์‚ฌ์šฉํ•˜์…”์•ผ ํ•˜๋ฉฐ, ๋กœ๊ทธ ์•”ํ˜ธํ™”๋‚˜ ๊ฒ€์ฆ ๋ฌธ์ œ๋Š” DAS/DA ์™€ ์ƒ์˜ํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ ์—ฌ๋Ÿฌ depth์˜ json ๊ฐ’๋„ Hive์˜ get_json_object() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด ์ถ”์ถœ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.


default value (๊ธฐ๋ณธ๊ฐ’), null, ๋นˆ ๋ฌธ์ž์—ด(Empty String) ๊ด€๋ จ

Field: Header / Body Shuttle: Client / Server INPUT: none / null / "" STORAGE: Kafka, HDFS OUTPUT note migration
Header Client none (default value, ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ) Kafka (์ค‘๊ฐ„๋‹จ๊ณ„) "" ๋นˆ๊ฐ’์„ "" ๋กœ ํ‘œํ˜„ ์ถ”ํ›„ JSONObject.NULL ๋กœ ๋ณ€๊ฒฝ์˜ˆ์ •. JSONObject.NULL ๋กœ ๋นˆ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ฒŒ ๋˜๋ฉด, Client ์…”ํ‹€๋กœ ์ „์†ก๋œ ๋กœ๊ทธ๋Š” "" ๋ฅผ HDFS ์—์„œ TSV ๋กœ ์ €์žฅํ•  ๋•Œ '' ๋นˆ ๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ๋จ
Header Client null Kafka (์ค‘๊ฐ„๋‹จ๊ณ„) "" ๋นˆ๊ฐ’์„ "" ๋กœ ํ‘œํ˜„ ์ถ”ํ›„ JSONObject.NULL ๋กœ ๋ณ€๊ฒฝ์˜ˆ์ •. JSONObject.NULL ๋กœ ๋นˆ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ฒŒ ๋˜๋ฉด, Client ์…”ํ‹€๋กœ ์ „์†ก๋œ ๋กœ๊ทธ๋Š” "" ๋ฅผ HDFS ์—์„œ TSV ๋กœ ์ €์žฅํ•  ๋•Œ '' ๋นˆ ๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ๋จ
Header Server null Kafka (์ค‘๊ฐ„๋‹จ๊ณ„) "" ๋นˆ๊ฐ’์„ "" ๋กœ ํ‘œํ˜„ ์„œ๋ฒ„ ๋กœ๊ทธ๋Š” ์ค‘๊ฐ„ ๋‹จ๊ณ„๋ถ€ํ„ฐ TSV ํฌ๋งท
Header Server none (default value, ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ) Kafka (์ค‘๊ฐ„๋‹จ๊ณ„) "" ๋นˆ๊ฐ’์„ "" ๋กœ ํ‘œํ˜„ ์„œ๋ฒ„ ๋กœ๊ทธ๋Š” ์ค‘๊ฐ„ ๋‹จ๊ณ„๋ถ€ํ„ฐ TSV ํฌ๋งท
Header Header "" (empty string) Kafka (์ค‘๊ฐ„๋‹จ๊ณ„) ""
Header Header ALL HDFS (์ตœ์ข…๋‹จ๊ณ„) '' TSV ํฌ๋งท์œผ๋กœ ๋กœ๊ทธ๋ฅผ ์ €์žฅํ•˜๋ฏ€๋กœ ์ค‘๊ฐ„๋‹จ๊ณ„์˜ "" ๊ฐ€ '' (๋นˆ ๋ฌธ์ž, ๊ฐ’์ด ์—†์Œ)
Body Client none ALL ํ‚ค ์‚ญ์ œ ๋ฐ”๋””์—์„œ๋Š” ๋นˆ ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ํ‚ค๋ฅผ ์‚ญ์ œ ์ถ”ํ›„ JSONObject.NULL ๋กœ ๋ณ€๊ฒฝ์˜ˆ์ •
Body Client null ALL ํ‚ค ์‚ญ์ œ ๋ฐ”๋””์—์„œ๋Š” ๋นˆ ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ํ‚ค๋ฅผ ์‚ญ์ œ ์ถ”ํ›„ JSONObject.NULL ๋กœ ๋ณ€๊ฒฝ์˜ˆ์ •
Body Server none ALL ํ‚ค ์‚ญ์ œ ๋ฐ”๋””์—์„œ๋Š” ๋นˆ ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ํ‚ค๋ฅผ ์‚ญ์ œ
Body Server null ALL ํ‚ค ์‚ญ์ œ ๋ฐ”๋””์—์„œ๋Š” ๋นˆ ๊ฐ’์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ํ‚ค๋ฅผ ์‚ญ์ œ
Body ALL "" ALL ""

์ •๋ฆฌํ•˜๋ฉด, ์…”ํ‹€์— ๋นˆ ๊ฐ’ ์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด null ๊ฐ’์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ์œผ๋‚˜, Header (TSV) ์™€ Body (JSON) ์—์„œ ๋นˆ ๊ฐ’์ด ๋‹ค๋ฅด๊ฒŒ ํ‘œํ˜„๋˜๊ณ , ์ €์žฅ๋œ ์œ„์น˜ (Kafka ๋˜๋Š” HDFS) ์— ๋”ฐ๋ผ ๋‹ค๋ฅด๋‹ˆ ์•Œ๊ณ  ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.


๊ธฐํƒ€ ๊ด€๋ จํŽ˜์ด์ง€

โš ๏ธ **GitHub.com Fallback** โš ๏ธ