34
34
import com .google .gson .JsonParser ;
35
35
import com .google .gson .JsonSyntaxException ;
36
36
import org .apache .cloudstack .utils .qemu .QemuImg ;
37
- import org .apache .log4j .Logger ;
37
+ import org .apache .logging .log4j .LogManager ;
38
+ import org .apache .logging .log4j .Logger ;
38
39
import org .joda .time .Duration ;
39
40
40
41
public class LinstorStoragePool implements KVMStoragePool {
41
- private static final Logger s_logger = Logger .getLogger (LinstorStoragePool .class );
42
+ private static final Logger LOGGER = LogManager .getLogger (LinstorStoragePool .class );
42
43
private final String _uuid ;
43
44
private final String _sourceHost ;
44
45
private final int _sourcePort ;
@@ -226,12 +227,12 @@ public String getHearthBeatPath() {
226
227
@ Override
227
228
public String createHeartBeatCommand (HAStoragePool pool , String hostPrivateIp ,
228
229
boolean hostValidation ) {
229
- s_logger .trace (String .format ("Linstor.createHeartBeatCommand: %s, %s, %b" , pool .getPoolIp (), hostPrivateIp , hostValidation ));
230
+ LOGGER .trace (String .format ("Linstor.createHeartBeatCommand: %s, %s, %b" , pool .getPoolIp (), hostPrivateIp , hostValidation ));
230
231
boolean isStorageNodeUp = checkingHeartBeat (pool , null );
231
232
if (!isStorageNodeUp && !hostValidation ) {
232
233
//restart the host
233
- s_logger .debug (String .format ("The host [%s] will be restarted because the health check failed for the storage pool [%s]" , hostPrivateIp , pool .getPool ().getType ()));
234
- Script cmd = new Script (pool .getPool ().getHearthBeatPath (), Duration .millis (HeartBeatUpdateTimeout ), s_logger );
234
+ LOGGER .debug (String .format ("The host [%s] will be restarted because the health check failed for the storage pool [%s]" , hostPrivateIp , pool .getPool ().getType ()));
235
+ Script cmd = new Script (pool .getPool ().getHearthBeatPath (), Duration .millis (HeartBeatUpdateTimeout ), LOGGER );
235
236
cmd .add ("-c" );
236
237
cmd .execute ();
237
238
return "Down" ;
@@ -247,7 +248,7 @@ public String getStorageNodeId() {
247
248
248
249
static String getHostname () {
249
250
OutputInterpreter .AllLinesParser parser = new OutputInterpreter .AllLinesParser ();
250
- Script sc = new Script ("hostname" , Duration .millis (10000L ), s_logger );
251
+ Script sc = new Script ("hostname" , Duration .millis (10000L ), LOGGER );
251
252
String res = sc .execute (parser );
252
253
if (res != null ) {
253
254
throw new CloudRuntimeException (String .format ("Unable to run 'hostname' command: %s" , res ));
@@ -264,7 +265,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
264
265
} else {
265
266
hostName = host .getParent ();
266
267
if (hostName == null ) {
267
- s_logger .error ("No hostname set in host.getParent()" );
268
+ LOGGER .error ("No hostname set in host.getParent()" );
268
269
return false ;
269
270
}
270
271
}
@@ -273,7 +274,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
273
274
}
274
275
275
276
private String executeDrbdSetupStatus (OutputInterpreter .AllLinesParser parser ) {
276
- Script sc = new Script ("drbdsetup" , Duration .millis (HeartBeatUpdateTimeout ), s_logger );
277
+ Script sc = new Script ("drbdsetup" , Duration .millis (HeartBeatUpdateTimeout ), LOGGER );
277
278
sc .add ("status" );
278
279
sc .add ("--json" );
279
280
return sc .execute (parser );
@@ -293,12 +294,12 @@ private boolean checkDrbdSetupStatusOutput(String output, String otherNodeName)
293
294
}
294
295
}
295
296
}
296
- s_logger .warn (String .format ("checkDrbdSetupStatusOutput: no resource connected to %s." , otherNodeName ));
297
+ LOGGER .warn (String .format ("checkDrbdSetupStatusOutput: no resource connected to %s." , otherNodeName ));
297
298
return false ;
298
299
}
299
300
300
301
private String executeDrbdEventsNow (OutputInterpreter .AllLinesParser parser ) {
301
- Script sc = new Script ("drbdsetup" , Duration .millis (HeartBeatUpdateTimeout ), s_logger );
302
+ Script sc = new Script ("drbdsetup" , Duration .millis (HeartBeatUpdateTimeout ), LOGGER );
302
303
sc .add ("events2" );
303
304
sc .add ("--now" );
304
305
return sc .execute (parser );
@@ -307,13 +308,13 @@ private String executeDrbdEventsNow(OutputInterpreter.AllLinesParser parser) {
307
308
private boolean checkDrbdEventsNowOutput (String output ) {
308
309
boolean healthy = output .lines ().noneMatch (line -> line .matches (".*role:Primary .* promotion_score:0.*" ));
309
310
if (!healthy ) {
310
- s_logger .warn ("checkDrbdEventsNowOutput: primary resource with promotion score==0; HA false" );
311
+ LOGGER .warn ("checkDrbdEventsNowOutput: primary resource with promotion score==0; HA false" );
311
312
}
312
313
return healthy ;
313
314
}
314
315
315
316
private boolean checkHostUpToDateAndConnected (String hostName ) {
316
- s_logger .trace (String .format ("checkHostUpToDateAndConnected: %s/%s" , localNodeName , hostName ));
317
+ LOGGER .trace (String .format ("checkHostUpToDateAndConnected: %s/%s" , localNodeName , hostName ));
317
318
OutputInterpreter .AllLinesParser parser = new OutputInterpreter .AllLinesParser ();
318
319
319
320
if (localNodeName .equalsIgnoreCase (hostName )) {
@@ -331,15 +332,15 @@ private boolean checkHostUpToDateAndConnected(String hostName) {
331
332
try {
332
333
return checkDrbdSetupStatusOutput (parser .getLines (), hostName );
333
334
} catch (JsonIOException | JsonSyntaxException e ) {
334
- s_logger .error ("Error parsing drbdsetup status --json" , e );
335
+ LOGGER .error ("Error parsing drbdsetup status --json" , e );
335
336
}
336
337
}
337
338
return false ;
338
339
}
339
340
340
341
@ Override
341
342
public Boolean vmActivityCheck (HAStoragePool pool , HostTO host , Duration activityScriptTimeout , String volumeUUIDListString , String vmActivityCheckPath , long duration ) {
342
- s_logger .trace (String .format ("Linstor.vmActivityCheck: %s, %s" , pool .getPoolIp (), host .getPrivateNetwork ().getIp ()));
343
+ LOGGER .trace (String .format ("Linstor.vmActivityCheck: %s, %s" , pool .getPoolIp (), host .getPrivateNetwork ().getIp ()));
343
344
return checkingHeartBeat (pool , host );
344
345
}
345
346
}
0 commit comments