11/*
2- * Copyright (c) 2015, EMC Corporation.
2+ * Copyright (c) 2015-2016 , EMC Corporation.
33 * Redistribution and use in source and binary forms, with or without modification,
44 * are permitted provided that the following conditions are met:
55 *
2626 */
2727package com .emc .rest .smart ;
2828
29- import org .apache . log4j . LogMF ;
30- import org .apache . log4j . Logger ;
29+ import org .slf4j . Logger ;
30+ import org .slf4j . LoggerFactory ;
3131
3232/**
3333 * Polling thread that will terminate automatically when the application exits
3434 */
3535public class PollingDaemon extends Thread {
3636 public static final String PROPERTY_KEY = "com.emc.rest.smart.pollingDaemon" ;
3737
38- private static final Logger l4j = Logger .getLogger (PollingDaemon .class );
38+ private static final Logger log = LoggerFactory .getLogger (PollingDaemon .class );
3939
4040 private SmartConfig smartConfig ;
4141 private boolean running = true ;
@@ -49,36 +49,36 @@ public PollingDaemon(SmartConfig smartConfig) {
4949 public void run () {
5050 while (running ) {
5151 long start = System .currentTimeMillis ();
52- l4j .debug ("polling daemon running" );
52+ log .debug ("polling daemon running" );
5353
5454 LoadBalancer loadBalancer = smartConfig .getLoadBalancer ();
5555 HostListProvider hostListProvider = smartConfig .getHostListProvider ();
5656
5757 if (!smartConfig .isHostUpdateEnabled ()) {
58- l4j .info ("host update is disabled; not updating hosts" );
58+ log .info ("host update is disabled; not updating hosts" );
5959 } else if (hostListProvider == null ) {
60- l4j .info ("no host list provider; not updating hosts" );
60+ log .info ("no host list provider; not updating hosts" );
6161 } else {
6262 try {
6363 loadBalancer .updateHosts (hostListProvider .getHostList ());
6464 } catch (Throwable t ) {
65- l4j .warn ("unable to enumerate servers" , t );
65+ log .warn ("unable to enumerate servers" , t );
6666 }
6767 }
6868
6969 if (!smartConfig .isHealthCheckEnabled ()) {
70- l4j .info ("health check is disabled; not checking hosts" );
70+ log .info ("health check is disabled; not checking hosts" );
7171 } else if (hostListProvider == null ) {
72- l4j .info ("no host list provider; not checking hosts" );
72+ log .info ("no host list provider; not checking hosts" );
7373 } else {
7474 for (Host host : loadBalancer .getAllHosts ()) {
7575 try {
7676 hostListProvider .runHealthCheck (host );
7777 host .setHealthy (true );
78- LogMF .debug (l4j , "health check successful for {0 }; host is marked healthy" , host .getName ());
78+ log .debug ("health check successful for {}; host is marked healthy" , host .getName ());
7979 } catch (Throwable t ) {
8080 host .setHealthy (false );
81- l4j .warn ("health check failed for " + host .getName () + "; host is marked unhealthy" , t );
81+ log .warn ("health check failed for " + host .getName () + "; host is marked unhealthy" , t );
8282 }
8383 }
8484 }
@@ -87,15 +87,14 @@ public void run() {
8787 try {
8888 long sleepTime = smartConfig .getPollInterval () * 1000 - callTime ;
8989 if (sleepTime < 0 ) sleepTime = 0 ;
90- LogMF .debug (l4j , "polling daemon finished; will poll again in {0 }ms.." , sleepTime );
90+ log .debug ("polling daemon finished; will poll again in {}ms.." , Long . toString ( sleepTime ) );
9191 if (sleepTime > 0 ) Thread .sleep (sleepTime );
9292 } catch (InterruptedException e ) {
93- l4j .warn ("interrupted while sleeping" , e );
93+ log .warn ("interrupted while sleeping" , e );
9494 }
9595 }
9696 }
9797
98- @ SuppressWarnings ("unused" )
9998 public void terminate () {
10099 running = false ;
101100 }
0 commit comments