1 package org.apache.helix.manager.zk;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.helix.HelixDataAccessor;
23 import org.apache.helix.TestHelper;
24 import org.apache.helix.TestHelper.StartCMResult;
25 import org.apache.helix.controller.HelixControllerMain;
26 import org.apache.helix.controller.restlet.ZKPropertyTransferServer;
27 import org.apache.helix.integration.ZkStandAloneCMTestBaseWithPropertyServerCheck;
28 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
29 import org.apache.log4j.Logger;
30 import org.testng.Assert;
31 import org.testng.annotations.Test;
32
33
34 public class TestZKPropertyTransferServer extends ZkStandAloneCMTestBaseWithPropertyServerCheck
35 {
36 private static Logger LOG =
37 Logger.getLogger(TestZKPropertyTransferServer.class);
38
39 @Test
40 public void TestControllerChange() throws Exception
41 {
42 String controllerName = CONTROLLER_PREFIX + "_0";
43 _startCMResultMap.get(controllerName)._manager.disconnect();
44
45 Thread.sleep(1000);
46
47
48 for (int i = 0; i < NODE_NR; i++)
49 {
50 String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
51 HelixDataAccessor accessor = _startCMResultMap.get(instanceName)._manager.getHelixDataAccessor();
52 ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor;
53 Assert.assertTrue(zkAccessor._zkPropertyTransferSvcUrl == null || zkAccessor._zkPropertyTransferSvcUrl.equals(""));
54 }
55 _startCMResultMap.get(controllerName)._thread.interrupt();
56 _startCMResultMap.remove(controllerName);
57
58 StartCMResult startResult =
59 TestHelper.startController(CLUSTER_NAME,
60 controllerName,
61 ZK_ADDR,
62 HelixControllerMain.STANDALONE);
63 _startCMResultMap.put(controllerName, startResult);
64
65 Thread.sleep(1000);
66
67
68 for (int i = 0; i < NODE_NR; i++)
69 {
70 String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
71 HelixDataAccessor accessor = _startCMResultMap.get(instanceName)._manager.getHelixDataAccessor();
72 ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor;
73 Assert.assertTrue(zkAccessor._zkPropertyTransferSvcUrl.equals(ZKPropertyTransferServer.getInstance().getWebserviceUrl()));
74 }
75 }
76
77
78 }