@@ -24,6 +24,7 @@ import (
24
24
"text/template"
25
25
"sort"
26
26
"strconv"
27
+ "./orderedmap"
27
28
)
28
29
29
30
var DEBUG bool = false
@@ -82,12 +83,13 @@ func FileExists(name string) bool {
82
83
// Parse json data from string to map
83
84
// Return map[string]interface{}
84
85
func ParseJson (jsonData string ) map [string ]interface {} {
85
- var data map [ string ] interface {}
86
- if err := json .Unmarshal ([]byte (jsonData ), & data ); err != nil {
86
+ orderedData := orderedmap . New ()
87
+ if err := json .Unmarshal ([]byte (jsonData ), & orderedData ); err != nil {
87
88
dbg ("Can't parse json data:" , err )
88
89
return nil
89
90
} else {
90
- return data
91
+ dt := orderedData .ToInterfaceArray ()
92
+ return dt
91
93
}
92
94
}
93
95
@@ -239,8 +241,10 @@ func determineMasterReplica(data map[string]interface{}) {
239
241
if hostData ["role" ] == "master" {
240
242
hostRoles ["master" ] = host
241
243
} else {
242
- index , _ := strconv .Atoi (pyraconv .ToString (hostData ["index" ]))
243
- replicas [index ] = host
244
+ if host != "_keys" {
245
+ index , _ := strconv .Atoi (pyraconv .ToString (hostData ["index" ]))
246
+ replicas [index ] = host
247
+ }
244
248
}
245
249
}
246
250
var keys []int
@@ -292,7 +296,7 @@ func main() {
292
296
} else {
293
297
log .Fatal ("ERROR: Content given by --checkdata is wrong json content." )
294
298
}
295
-
299
+
296
300
checkId = strings .ToUpper (checkId )
297
301
loadDependencies (resultData )
298
302
determineMasterReplica (resultData )
0 commit comments