1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jgroup.test.performance;
20
21 import java.rmi.RemoteException;
22
23 import jgroup.core.GroupManager;
24 import jgroup.core.JgroupException;
25 import jgroup.core.MembershipListener;
26 import jgroup.core.View;
27 import jgroup.core.protocols.Anycast;
28 import jgroup.core.protocols.Multicast;
29 import jgroup.util.log.Eventlogger;
30
31
32
33
34
35
36
37
38 public class PerformanceServer
39 implements SpeedTest, RemoteShutdown, MembershipListener
40 {
41
42
43
44
45
46
47 private int cnt = 0;
48
49
50
51
52
53
54 public PerformanceServer()
55 throws JgroupException
56 {
57 GroupManager gm = GroupManager.getGroupManager(this);
58 System.out.println("PerformanceServer initialized");
59 }
60
61
62
63
64
65
66 public void mtest()
67 throws RemoteException
68 {
69 System.out.print("+");
70 cnt++;
71 if ((cnt%20)==0) {
72 System.out.println(": " + cnt);
73 }
74 }
75
76 public byte[] mtest(byte[] x)
77 throws RemoteException
78 {
79 System.out.print("+");
80 cnt++;
81 if ((cnt%20)==0) {
82 System.out.println(": " + cnt);
83 }
84 return x;
85 }
86
87 public void vmtest(byte[] x)
88 throws RemoteException
89 {
90 return;
91 }
92
93 public String mtest(String x)
94 throws RemoteException
95 {
96 return x;
97 }
98
99 public void test()
100 throws RemoteException
101 {
102 }
103
104 public byte[] test(byte[] x)
105 throws RemoteException
106 {
107 return x;
108 }
109
110 public String test(String x)
111 throws RemoteException
112 {
113 return x;
114 }
115
116
117
118
119
120
121 @Multicast public void preShutdown()
122 throws RemoteException
123 {
124 if (Eventlogger.ENABLED) {
125 Eventlogger.logEventFlush("PreShutdown");
126 }
127 }
128
129 @Anycast public void shutdown(final int delay)
130 throws RemoteException
131 {
132 new Thread() {
133 public void run() {
134 System.out.println("I'm shuting down in " + delay + " milliseconds.");
135 if (delay > 0) {
136 try { sleep(delay); } catch (InterruptedException e) { }
137 }
138 System.exit(0);
139 }
140 }.start();
141 }
142
143
144
145
146
147
148 public void viewChange(View view)
149 {
150 System.out.println(view);
151 }
152
153
154 public void hasLeft() { }
155
156
157 public void prepareChange() { }
158
159
160
161
162
163
164 public static void main(String[] argv)
165 throws Exception
166 {
167 new PerformanceServer();
168 }
169
170 }