rel="">
public static IDataset getPushServerListCache() throws Exception {
if (null == getBizDataCache().get(PUSH_SERVER_LIST)) {
synchronized (BizDataCacheManager.class) {
if (null != getBizDataCache().get(PUSH_SERVER_LIST)) {// 避免时间差
return (IDataset) getBizDataCache().get(PUSH_SERVER_LIST);
}
initPushServerListCache();
}
}
return (IDataset) getBizDataCache().get(PUSH_SERVER_LIST);
}
public static boolean containsPushServer(String serverId) throws Exception {
if (null == serverId) {
throw new IpuBaseException("serverId is null.");
}
IDataset list = getPushServerListCache();
if (list.isEmpty()) {
return false;
}
IData pushServer;
for (int i = 0; i < list.size(); i++) {
pushServer = list.getData(i);
if (serverId.equals(pushServer.getString("serverId"))) {
return true;
}
}
return false;
}
/**
* 读取数据库,初始化数据
*/
// private static void initPushServerListCache() throws Exception {
// ServerDao dao = new ServerDao(Constant.connName);
// IData param = new DataMap();
// param.put("STATE", Constant.Server.STATE_AVAILABLE);
// IDataset list = dao.getServerList(param);
// if (list == null || list.isEmpty()) {
// IpuLogger.error(log, "tab_server表未找到数据.");
// IpuUtility.error("tab_server表未找到数据.");
// }
// getBizDataCache().put(PUSH_SERVER_LIST, list);
//
// IpuLogger.debug(log, "初始化" + PUSH_SERVER_LIST + "成功.");
// }
/**
* 初始化P的列表,应该是主动扫描P的列表
*/
private static void initPushServerListCache() throws Exception {
// 待处理。。。
log.debug("待处理,初始化扫描可用的P的列表");
IDataset list = new DatasetList();
getBizDataCache().put(PUSH_SERVER_LIST, list);
}
/**
* 主动更改缓存,用于数据库tab_server表变动
*/
public static void putPushServerListCache(IDataset list) throws Exception {
getBizDataCache().put(PUSH_SERVER_LIST, list);
log.debug("更改" + PUSH_SERVER_LIST + "成功.");
}
/**
* 获取指定push_server端的accounts的Set集合
*/
@SuppressWarnings("unchecked")
public static Set<String> getPushServerAccountsCache(String serverId) throws Exception {
if (null == getBizDataCache().get(PUSH_SERVER_ACCOUNTS_PREFIX + serverId)) {
return new HashSet<String>();
}
return (Set<String>) getBizDataCache().get(PUSH_SERVER_ACCOUNTS_PREFIX + serverId);
}
/**
* 存放accountSet值
*/
public static void putPushServerAccountsCache(Set<String> accountSet, String serverId) throws Exception {
getBizDataCache().put(PUSH_SERVER_ACCOUNTS_PREFIX + serverId, accountSet);
}
/**
* 初始化或者更改accountSet值
*/
public static void addAccountToPushServerAccountsId(String account, String serverId) throws Exception {
Set<String> accountSet = getPushServerAccountsCache(serverId);
log.debug("M add route, put before:key=" + (PUSH_SERVER_ACCOUNTS_PREFIX + serverId) + ",value=" + accountSet.toString());
accountSet.add(account);
putPushServerAccountsCache(accountSet, serverId);
log.debug("M add route, put after:key=" + (PUSH_SERVER_ACCOUNTS_PREFIX + serverId) + ",value=" + accountSet.toString());
}
/**
* 删除指定serverId的一个account值
*/
public static void removeAccountToPushServerAccountsId(String account, String serverId) throws Exception {
Set<String> accountSet = getPushServerAccountsCache(serverId);
if (null == accountSet || !accountSet.contains(account)) {
log.debug("has not this account [" + account + "] on this " + serverId + "server");
return;
}
accountSet.remove(account);
putPushServerAccountsCache(accountSet, serverId);
}
public static void addAvailableAccount(String account) throws Exception {
if (getAvailableAccountSet().contains(account)) {
// account已经存在了
log.debug("account[" + account + "] already exists.");
}
Set<String> accountSet = getAvailableAccountSet();
accountSet.add(account);
putAvailableAccountSet(accountSet);
}
@SuppressWarnings("unchecked")
public static Set<String> getAvailableAccountSet() throws Exception {
if (null == getBizDataCache().get(AVAILABLE_ACCOUNTS)) {
return new HashSet<String>();
}
return (Set<String>) getBizDataCache().get(AVAILABLE_ACCOUNTS);
}
public static void putAvailableAccountSet(Set<String> accountSet) throws Exception {
getBizDataCache().put(AVAILABLE_ACCOUNTS, accountSet);
}
public static boolean containsAvailableAccount(String account) throws Exception {
return getAvailableAccountSet().contains(account);
}
public static void increasePushServerAccountsSize(String serverId) throws Exception {
int size = getPushServerAccountsSize(serverId);
putPushServerAccountsSize(serverId, size + 1);
log.debug("Number of server connections plus one");
}
public static void decreasePushServerAccountsSize(String serverId) throws Exception {
int size = getPushServerAccountsSize(serverId);
if (size < 1) {
throw new IpuBaseException("The number of current connected account is less than one.");
}
putPushServerAccountsSize(serverId, size - 1);
log.debug("Number of server connections minus one");
}
private static void putPushServerAccountsSize(String serverId, int accountsSize) throws Exception {
getBizDataCache().put(PUSH_SERVER_ACCOUNTS_SIZE_PREFIX + serverId, accountsSize);
}
private static int getPushServerAccountsSize(String serverId) throws Exception {
if (null == getBizDataCache().get(PUSH_SERVER_ACCOUNTS_SIZE_PREFIX + serverId)) {
return 0;
}
return (Integer) getBizDataCache().get(PUSH_SERVER_ACCOUNTS_SIZE_PREFIX + serverId);
}
}
|
||
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 |
|
|
||
1 | 1 |
|
2 | 2 |
|
3 | 3 |
|
4 |
|
|
5 | 4 |
|
6 | 5 |
|
7 | 6 |
|
8 | 7 |
|
9 | 8 |
|
10 |
|
|
11 |
|
|
9 |
|
|
12 | 10 |
|
13 | 11 |
|
14 | 12 |
|
|
||
17 | 15 |
|
18 | 16 |
|
19 | 17 |
|
18 |
|
|
19 |
|
|
20 | 20 |
|
21 |
|
|
21 | 22 |
|
22 | 23 |
|
23 | 24 |
|
24 | 25 |
|
25 |
|
|
26 |
|
|
27 | 26 |
|
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 |
|
|
27 |
|
|
28 |
|
|
57 | 29 |
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
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 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
62 | 97 |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 | 98 |
|
97 | 99 |
|
98 | 100 |
|
|
||
111 | 113 |
|
112 | 114 |
|
113 | 115 |
|
116 |
|
|
117 |
|
|
118 |
|
|
114 | 119 |
|
115 |
|
|
116 |
|
|
120 |
|
|
117 | 121 |
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
149 | 157 |
|
150 | 158 |
|
151 | 159 |
|
|
||
1 | 1 |
|
2 | 2 |
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
3 |
|
|
4 |
|
|
10 | 5 |
|
11 | 6 |
|
12 | 7 |
|
|
||
14 | 9 |
|
15 | 10 |
|
16 | 11 |
|
12 |
|
|
17 | 13 |
|
14 |
|
|
18 | 15 |
|
19 |
|
|
20 |
|
|
21 | 16 |
|
22 | 17 |
|
23 |
|
|
18 |
|
|
19 |
|
|
24 | 20 |
|
25 | 21 |
|
26 | 22 |
|
|
||
58 | 54 |
|
59 | 55 |
|
60 | 56 |
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
57 |
|
|
58 |
|
|
76 | 59 |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
91 | 93 |
|
92 | 94 |
|
93 | 95 |
|
|
||
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 |
|
|
||
2 | 2 |
|
3 | 3 |
|
4 | 4 |
|
5 |
|
|
5 |
|
|
6 | 6 |
|
7 | 7 |
|
8 | 8 |
|
|
||
210 | 210 |
|
211 | 211 |
|
212 | 212 |
|
213 |
|
|
213 |
|
|
214 | 214 |
|
215 | 215 |
|
216 | 216 |
|
|
||
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 |
|
|
||
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 |
|
|
||
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
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