@@ -988,41 +988,43 @@ public boolean stopProxy(long proxyVmId) {
988988
989989 @ Override
990990 @ DB
991- public void setManagementState (final ConsoleProxyManagementState state ) {
991+ public void setManagementState (final ConsoleProxyManagementState newState ) {
992992 try {
993- final ConsoleProxyManagementState lastState = getManagementState ();
994- if (lastState == null ) {
993+ final ConsoleProxyManagementState currentState = getManagementState ();
994+ if (currentState == null ) {
995995 return ;
996996 }
997997
998- if (lastState != state ) {
998+ if (currentState != newState ) {
999+ logger .debug ("Updating console proxy management state config to new state: {}, it's current state is {} and last management state config to {}." , newState , currentState , currentState );
9991000 Transaction .execute (new TransactionCallbackNoReturn () {
10001001 @ Override
10011002 public void doInTransactionWithoutResult (TransactionStatus status ) {
1002- configurationDao .update (ConsoleProxyManagementLastState .key (), ConsoleProxyManagementLastState .category (), lastState .toString ());
1003- configurationDao .update (ConsoleProxyServiceManagementState .key (), ConsoleProxyServiceManagementState .category (), state .toString ());
1003+ configurationDao .update (ConsoleProxyServiceManagementLastState .key (), ConsoleProxyServiceManagementLastState .category (), currentState .toString ());
1004+ configurationDao .update (ConsoleProxyServiceManagementState .key (), ConsoleProxyServiceManagementState .category (), newState .toString ());
10041005 }
10051006 });
1007+ } else {
1008+ logger .debug ("Console proxy management state is already set to {}, no need to update." , newState );
10061009 }
10071010 } catch (Exception e ) {
1008- logger .error (String . format ( "Unable to set console proxy management state to [%s ] due to [%s ]." , state , e .getMessage () ), e );
1011+ logger .error ("Unable to update console proxy management state to [{} ] due to [{} ]." , newState , e .getMessage (), e );
10091012 }
10101013 }
10111014
10121015 @ Override
10131016 public ConsoleProxyManagementState getManagementState () {
1014- String configKey = ConsoleProxyServiceManagementState .key ();
1015- String value = ConsoleProxyServiceManagementState .value ();
1016-
1017- if (value != null ) {
1018- ConsoleProxyManagementState state = ConsoleProxyManagementState .valueOf (value );
1017+ String stateConfigKey = ConsoleProxyServiceManagementState .key ();
1018+ String stateConfigValue = ConsoleProxyServiceManagementState .value ();
10191019
1020+ if (stateConfigValue != null ) {
1021+ ConsoleProxyManagementState state = ConsoleProxyManagementState .valueOf (stateConfigValue );
10201022 if (state != null ) {
10211023 return state ;
10221024 }
10231025 }
10241026
1025- logger .error (String . format ( "Value [%s] set in global configuration [%s] is not a valid console proxy management state ." , value , configKey ) );
1027+ logger .error ("Console proxy management state value is null in the global configuration [{}] ." , stateConfigKey );
10261028 return null ;
10271029 }
10281030
@@ -1037,26 +1039,26 @@ public void resumeLastManagementState() {
10371039 }
10381040
10391041 if (lastState != state ) {
1042+ logger .debug ("Resuming console proxy management state to last state {}, current state is {}." , lastState , state );
10401043 configurationDao .update (ConsoleProxyServiceManagementState .key (), ConsoleProxyServiceManagementState .category (), lastState .toString ());
10411044 }
10421045 } catch (Exception e ) {
1043- logger .error (String . format ( "Unable to resume last management state due to [%s ]." , e .getMessage () ), e );
1046+ logger .error ("Unable to resume last management state due to [{} ]." , e .getMessage (), e );
10441047 }
10451048 }
10461049
10471050 private ConsoleProxyManagementState getLastManagementState () {
1048- String configKey = ConsoleProxyManagementLastState .key ();
1049- String value = ConsoleProxyManagementLastState .value ();
1051+ String lastStateConfigKey = ConsoleProxyServiceManagementLastState .key ();
1052+ String lastStateConfigValue = ConsoleProxyServiceManagementLastState .value ();
10501053
1051- if (value != null ) {
1052- ConsoleProxyManagementState state = ConsoleProxyManagementState .valueOf (value );
1053-
1054- if (state != null ) {
1055- return state ;
1054+ if (lastStateConfigValue != null ) {
1055+ ConsoleProxyManagementState lastState = ConsoleProxyManagementState .valueOf (lastStateConfigValue );
1056+ if (lastState != null ) {
1057+ return lastState ;
10561058 }
10571059 }
10581060
1059- logger .error (String . format ( "Value [%s] set in global configuration [%s] is not a valid console proxy management state ." , value , configKey ) );
1061+ logger .error ("Console proxy last management state value is null in the global configuration [{}] ." , lastStateConfigKey );
10601062 return null ;
10611063 }
10621064
@@ -1074,7 +1076,7 @@ public boolean rebootProxy(long proxyVmId) {
10741076
10751077 if (answer != null && answer .getResult ()) {
10761078 if (logger .isDebugEnabled ()) {
1077- logger .debug ("Successfully reboot console proxy " + proxy .getHostName ());
1079+ logger .debug ("Successfully reboot console proxy {}" , proxy .getHostName ());
10781080 }
10791081
10801082 SubscriptionMgr .getInstance ().notifySubscribers (ConsoleProxyManager .ALERT_SUBJECT , this ,
@@ -1083,7 +1085,7 @@ public boolean rebootProxy(long proxyVmId) {
10831085 return true ;
10841086 } else {
10851087 if (logger .isDebugEnabled ()) {
1086- logger .debug ("failed to reboot console proxy : " + proxy .getHostName ());
1088+ logger .debug ("Failed to reboot console proxy : {}" , proxy .getHostName ());
10871089 }
10881090
10891091 return false ;
@@ -1113,7 +1115,7 @@ public boolean destroyProxy(long vmId) {
11131115
11141116 return true ;
11151117 } catch (ResourceUnavailableException e ) {
1116- logger .warn (String . format ( "Unable to destroy console proxy [%s ] due to [%s ]." , proxy , e .getMessage () ), e );
1118+ logger .warn ("Unable to destroy console proxy [{} ] due to [{} ]." , proxy , e .getMessage (), e );
11171119 return false ;
11181120 }
11191121 }
@@ -1590,7 +1592,7 @@ public String getConfigComponentName() {
15901592 public ConfigKey <?>[] getConfigKeys () {
15911593 return new ConfigKey <?>[] {ConsoleProxySslEnabled , NoVncConsoleDefault , NoVncConsoleSourceIpCheckEnabled , ConsoleProxyServiceOffering ,
15921594 ConsoleProxyCapacityStandby , ConsoleProxyCapacityScanInterval , ConsoleProxyRestart , ConsoleProxyUrlDomain , ConsoleProxySessionMax , ConsoleProxySessionTimeout , ConsoleProxyDisableRpFilter , ConsoleProxyLaunchMax ,
1593- ConsoleProxyManagementLastState , ConsoleProxyServiceManagementState , NoVncConsoleShowDot ,
1595+ ConsoleProxyServiceManagementLastState , ConsoleProxyServiceManagementState , NoVncConsoleShowDot ,
15941596 ConsoleProxyVmUserData };
15951597 }
15961598
0 commit comments