a
554325746@qq.com
2019-10-24 c61e776980f038bb0e195f7753a3d7e127d6028f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.basic.security.manager;
 
import android.text.TextUtils;
 
import com.basic.security.model.Cluster;
import com.basic.security.model.ModelAdapter;
import com.basic.security.utils.Constants;
 
public class ClusterManager extends BaseManager {
 
    public static ModelAdapter cluster = new ModelAdapter();
 
    public static ModelAdapter getCluster() {
        if (cluster == null) {
            initCluster();
        }
        return cluster;
    }
 
    public static void initCluster() {
        cluster = findById(Cluster.tableName, Cluster.tableName);
        if (cluster == null) {
            cluster = new ModelAdapter();
            cluster.setString(Cluster.id, Cluster.tableName);
            cluster.setString(Cluster.cluster_id, "cluster1");
            cluster.setString(Cluster.node_id, "node3");
            cluster.setString(Cluster.cluster_name, "cluster1");
            cluster.setString(Cluster.exit, Constants.TRUE);
            cluster.setString(Cluster.nodes_json, "");
            cluster.setString(Cluster.other_node_ip, "192.168.1.187");
            cluster.setString(Cluster.password, "YmpiYXNpYzEyMzEyMzQ1Ng==");
            cluster.setString(Constants.TABLE, Cluster.tableName);
            save(cluster);
        }
    }
 
    public static void saveCluster(ModelAdapter cluster) {
        ClusterManager.cluster = cluster;
        save(cluster);
    }
 
    public static String getOtherNodeIp() {
        String otherNodeIp = cluster.getString(Cluster.other_node_ip);
        if (!TextUtils.isEmpty(otherNodeIp)) {
            return otherNodeIp;
        }
        return "";
    }
 
    public static String getLocalNodeId() {
        String localNodeId = cluster.getString(Cluster.node_id);
        if (!TextUtils.isEmpty(localNodeId)) {
            return localNodeId;
        }
        return "";
    }
 
    public static String getClusterName() {
        String clusterName = cluster.getString(Cluster.cluster_name);
        if (!TextUtils.isEmpty(clusterName)) {
            return clusterName;
        }
        return "";
    }
 
    public static String getPassword() {
        String password = cluster.getString(Cluster.password);
        if (!TextUtils.isEmpty(password)) {
            return password;
        }
        return "";
    }
 
    public static void start() {
        ClusterSerfSyncManager.start();
    }
 
 
}