3434import com .google .gson .JsonParser ;
3535import com .google .gson .JsonSyntaxException ;
3636import 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 ;
3839import org .joda .time .Duration ;
3940
4041public 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 );
4243 private final String _uuid ;
4344 private final String _sourceHost ;
4445 private final int _sourcePort ;
@@ -226,12 +227,12 @@ public String getHearthBeatPath() {
226227 @ Override
227228 public String createHeartBeatCommand (HAStoragePool pool , String hostPrivateIp ,
228229 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 ));
230231 boolean isStorageNodeUp = checkingHeartBeat (pool , null );
231232 if (!isStorageNodeUp && !hostValidation ) {
232233 //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 );
235236 cmd .add ("-c" );
236237 cmd .execute ();
237238 return "Down" ;
@@ -247,7 +248,7 @@ public String getStorageNodeId() {
247248
248249 static String getHostname () {
249250 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 );
251252 String res = sc .execute (parser );
252253 if (res != null ) {
253254 throw new CloudRuntimeException (String .format ("Unable to run 'hostname' command: %s" , res ));
@@ -264,7 +265,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
264265 } else {
265266 hostName = host .getParent ();
266267 if (hostName == null ) {
267- s_logger .error ("No hostname set in host.getParent()" );
268+ LOGGER .error ("No hostname set in host.getParent()" );
268269 return false ;
269270 }
270271 }
@@ -273,7 +274,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
273274 }
274275
275276 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 );
277278 sc .add ("status" );
278279 sc .add ("--json" );
279280 return sc .execute (parser );
@@ -293,12 +294,12 @@ private boolean checkDrbdSetupStatusOutput(String output, String otherNodeName)
293294 }
294295 }
295296 }
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 ));
297298 return false ;
298299 }
299300
300301 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 );
302303 sc .add ("events2" );
303304 sc .add ("--now" );
304305 return sc .execute (parser );
@@ -307,13 +308,13 @@ private String executeDrbdEventsNow(OutputInterpreter.AllLinesParser parser) {
307308 private boolean checkDrbdEventsNowOutput (String output ) {
308309 boolean healthy = output .lines ().noneMatch (line -> line .matches (".*role:Primary .* promotion_score:0.*" ));
309310 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" );
311312 }
312313 return healthy ;
313314 }
314315
315316 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 ));
317318 OutputInterpreter .AllLinesParser parser = new OutputInterpreter .AllLinesParser ();
318319
319320 if (localNodeName .equalsIgnoreCase (hostName )) {
@@ -331,15 +332,15 @@ private boolean checkHostUpToDateAndConnected(String hostName) {
331332 try {
332333 return checkDrbdSetupStatusOutput (parser .getLines (), hostName );
333334 } catch (JsonIOException | JsonSyntaxException e ) {
334- s_logger .error ("Error parsing drbdsetup status --json" , e );
335+ LOGGER .error ("Error parsing drbdsetup status --json" , e );
335336 }
336337 }
337338 return false ;
338339 }
339340
340341 @ Override
341342 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 ()));
343344 return checkingHeartBeat (pool , host );
344345 }
345346}
0 commit comments