@@ -103,16 +103,28 @@ protected String startQuorum(
103
103
}
104
104
105
105
protected int [] startQuorum (final int serverCount , StringBuilder connectStr , Map <String , String > authConfigs ,
106
- int authServerCount , boolean multiAddress ) throws IOException {
106
+ int authServerCount , boolean multiAddress ) throws IOException {
107
+ int [] defalutMyidList = new int [serverCount ];
108
+ String [] defalutRoleList = new String [serverCount ];
109
+ for (int i = 0 ; i < serverCount ; i ++) {
110
+ defalutMyidList [i ] = i ;
111
+ defalutRoleList [i ] = "participant" ;
112
+ }
113
+ return startQuorum (serverCount , connectStr , authConfigs , authServerCount , multiAddress , defalutMyidList , defalutRoleList );
114
+ }
115
+
116
+ protected int [] startQuorum (final int serverCount , StringBuilder connectStr , Map <String , String > authConfigs ,
117
+ int authServerCount , boolean multiAddress , int [] myidList , String [] roleList ) throws IOException {
107
118
final int [] clientPorts = new int [serverCount ];
108
119
StringBuilder sb = new StringBuilder ();
109
120
for (int i = 0 ; i < serverCount ; i ++) {
110
121
clientPorts [i ] = PortAssignment .unique ();
111
- String server = String .format ("server.%d=localhost:%d:%d" , i , PortAssignment .unique (), PortAssignment .unique ());
122
+ String server = String .format ("server.%d=localhost:%d:%d" , myidList [ i ] , PortAssignment .unique (), PortAssignment .unique ());
112
123
if (multiAddress ) {
113
124
server = server + String .format ("|localhost:%d:%d" , PortAssignment .unique (), PortAssignment .unique ());
114
125
}
115
- sb .append (server + ":participant\n " );
126
+
127
+ sb .append (server + ":" + roleList [i ] + "\n " );
116
128
connectStr .append ("127.0.0.1:" + clientPorts [i ]);
117
129
if (i < serverCount - 1 ) {
118
130
connectStr .append ("," );
@@ -122,11 +134,11 @@ protected int[] startQuorum(final int serverCount, StringBuilder connectStr, Map
122
134
// servers with authentication interfaces configured
123
135
int i = 0 ;
124
136
for (; i < authServerCount ; i ++) {
125
- startServer (authConfigs , clientPorts , quorumCfg , i );
137
+ startServer (authConfigs , clientPorts , quorumCfg , i , myidList );
126
138
}
127
139
// servers without any authentication configured
128
140
for (int j = 0 ; j < serverCount - authServerCount ; j ++, i ++) {
129
- MainThread mthread = new MainThread (i , clientPorts [i ], quorumCfg );
141
+ MainThread mthread = new MainThread (myidList [ i ] , clientPorts [i ], quorumCfg );
130
142
mt .add (mthread );
131
143
mthread .start ();
132
144
}
@@ -137,8 +149,9 @@ private void startServer(
137
149
Map <String , String > authConfigs ,
138
150
final int [] clientPorts ,
139
151
String quorumCfg ,
140
- int i ) throws IOException {
141
- MainThread mthread = new MainThread (i , clientPorts [i ], quorumCfg , authConfigs );
152
+ int i ,
153
+ int [] myidList ) throws IOException {
154
+ MainThread mthread = new MainThread (myidList [i ], clientPorts [i ], quorumCfg , authConfigs );
142
155
mt .add (mthread );
143
156
mthread .start ();
144
157
}
@@ -149,6 +162,16 @@ protected void startServer(MainThread restartPeer, Map<String, String> authConfi
149
162
mthread .start ();
150
163
}
151
164
165
+ protected void startServer (
166
+ Map <String , String > authConfigs ,
167
+ final int clientPort ,
168
+ String quorumCfg ,
169
+ int myid ) throws IOException {
170
+ MainThread mthread = new MainThread (myid , clientPort , quorumCfg , authConfigs );
171
+ mt .add (mthread );
172
+ mthread .start ();
173
+ }
174
+
152
175
void shutdownAll () {
153
176
for (int i = 0 ; i < mt .size (); i ++) {
154
177
shutdown (i );
0 commit comments