fix serfSnapShot create path
| | |
| | | return nil |
| | | } |
| | | return strNodes |
| | | } |
| | | func GetClusters(key string) []byte { |
| | | clusters := sdb.CreateSearchNodeWhitClose(key, 2*time.Second); |
| | | clustersJson, err := json.Marshal(clusters) |
| | | if err != nil { |
| | | logger.Error("json.Marshal:", err) |
| | | return nil |
| | | } |
| | | return clustersJson; |
| | | } |
| | |
| | | //package main |
| | | package androidSync |
| | | |
| | | import ( |
| | | sdb "basic.com/Android/syncdb.git" |
| | | "fmt" |
| | | "time" |
| | | ) |
| | | |
| | | |
| | | |
| | | |
| | | func main() { |
| | | Leave() |
| | | InitCluster() |
| | | clusters := GetClusters("bjbasic123"+"123455") |
| | | fmt.Println(string(clusters)) |
| | | clusters1, _ := sdb.CreateSearchNode("bjbasic123"+"123455") |
| | | fmt.Println(clusters1) |
| | | if 1==1 { |
| | | return; |
| | | } |
| | | Leave() |
| | | InitCluster() |
| | | InitAgent("node2") |
| | | SyncInit("c4d03d5d-64c3-4941-bb53-152277a3271f","123456","node2","") |
| | | SyncInit("c4d03d5d-64c3-4941-bb53-152277a3271a","123455","node2","", "") |
| | | //JoinByNodeAddrs("192.168.222.103:30190") |
| | | JoinByNodeAddrs("192.168.5.22:30190") |
| | | fmt.Println("hello") |
| | | //JoinByNodeAddrs("192.168.5.22:30190") |
| | | fmt.Println("hello1") |
| | | var count = 0 |
| | | for { |
| | | //SyncSql("select * from table1 count="+strconv.Itoa(count)) |
| | |
| | | return true |
| | | } |
| | | |
| | | func SyncInit(clusterID string, password string, nodeID string, strAddrs string) bool { |
| | | func SyncInit(clusterID string, password string, nodeID string, strAddrs string, snapshotPath string) bool { |
| | | var ips []string |
| | | if strAddrs == "" { |
| | | ips = nil |
| | |
| | | |
| | | pwdFull := syncClusterKeyPrefix + password |
| | | |
| | | agent, _ = sdb.Init(clusterID, pwdFull, nodeID, ips) |
| | | agent, _ = sdb.Init(clusterID, pwdFull, nodeID, ips, snapshotPath) |
| | | if agent == nil { |
| | | logger.Error("sdb.Init") |
| | | return false |
| | |
| | | return true |
| | | } |
| | | |
| | | func JoinCluster(clusterID, password, strAddrs, devID, devIP, devName string) bool { |
| | | func JoinCluster(clusterID, password, strAddrs, devID, devIP, devName string, snapshotPath string) bool { |
| | | |
| | | isOk := SyncInit(clusterID, password, devID, strAddrs) |
| | | isOk := SyncInit(clusterID, password, devID, strAddrs,snapshotPath) |
| | | |
| | | if isOk { |
| | | logger.Debug("dbSync.Init success") |