1 package org.apache.helix;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.concurrent.ExecutorService;
23 import java.util.concurrent.Executors;
24
25 import org.apache.helix.BaseDataAccessor;
26 import org.apache.helix.GroupCommit;
27 import org.apache.helix.ZNRecord;
28
29
30 public class TestGroupCommit
31 {
32
33 public void testGroupCommit() throws InterruptedException
34 {
35 final BaseDataAccessor<ZNRecord> accessor = new Mocks.MockBaseDataAccessor();
36 final GroupCommit commit = new GroupCommit();
37 ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(400);
38 for (int i = 0; i < 2400; i++)
39 {
40 Runnable runnable = new MyClass(accessor, commit, i);
41 newFixedThreadPool.submit(runnable);
42 }
43 Thread.sleep(10000);
44 System.out.println(accessor.get("test", null, 0));
45 System.out.println(accessor.get("test", null, 0).getSimpleFields().size());
46 }
47
48 }
49
50 class MyClass implements Runnable
51 {
52 private final BaseDataAccessor<ZNRecord> store;
53 private final GroupCommit commit;
54 private final int i;
55
56 public MyClass(BaseDataAccessor<ZNRecord> store, GroupCommit commit, int i)
57 {
58 this.store = store;
59 this.commit = commit;
60 this.i = i;
61 }
62
63 @Override
64 public void run()
65 {
66
67
68 ZNRecord znRecord = new ZNRecord("test");
69 znRecord.setSimpleField("test_id" + i, "" + i);
70 commit.commit(store, 0, "test", znRecord);
71 store.get("test", null, 0).getSimpleField("");
72
73
74 }
75
76 }