@@ -718,9 +718,6 @@ public void removeAgent(AgentAttache attache, Status nextState) {
718718 public void updateStatus (HostVO host , Status .Event event ) {
719719 _hostDao .updateStatus (host , event , _nodeId );
720720 }
721- public void disconnect (AgentAttache attache , final Status .Event event , final boolean investigate ) {
722- _executor .submit (new DisconnectTask (attache , event , investigate ));
723- }
724721
725722 protected AgentAttache notifyMonitorsOfConnection (AgentAttache attache , final StartupCommand [] cmd , boolean forRebalance ) throws ConnectionException {
726723 long hostId = attache .getId ();
@@ -737,19 +734,19 @@ protected AgentAttache notifyMonitorsOfConnection(AgentAttache attache, final St
737734 ConnectionException ce = (ConnectionException )e ;
738735 if (ce .isSetupError ()) {
739736 s_logger .warn ("Monitor " + monitor .second ().getClass ().getSimpleName () + " says there is an error in the connect process for " + hostId + " due to " + e .getMessage ());
740- handleDisconnect (attache , Event .AgentDisconnected );
737+ handleDisconnectWithoutInvestigation (attache , Event .AgentDisconnected );
741738 throw ce ;
742739 } else {
743740 s_logger .info ("Monitor " + monitor .second ().getClass ().getSimpleName () + " says not to continue the connect process for " + hostId + " due to " + e .getMessage ());
744- handleDisconnect (attache , Event .ShutdownRequested );
741+ handleDisconnectWithoutInvestigation (attache , Event .ShutdownRequested );
745742 return attache ;
746743 }
747744 } else if (e instanceof HypervisorVersionChangedException ) {
748- handleDisconnect (attache , Event .HypervisorVersionChanged );
745+ handleDisconnectWithoutInvestigation (attache , Event .HypervisorVersionChanged );
749746 throw new CloudRuntimeException ("Unable to connect " + attache .getId (), e );
750747 } else {
751748 s_logger .error ("Monitor " + monitor .second ().getClass ().getSimpleName () + " says there is an error in the connect process for " + hostId + " due to " + e .getMessage (), e );
752- handleDisconnect (attache , Event .AgentDisconnected );
749+ handleDisconnectWithoutInvestigation (attache , Event .AgentDisconnected );
753750 throw new CloudRuntimeException ("Unable to connect " + attache .getId (), e );
754751 }
755752 }
@@ -763,7 +760,7 @@ protected AgentAttache notifyMonitorsOfConnection(AgentAttache attache, final St
763760 // this is tricky part for secondary storage
764761 // make it as disconnected, wait for secondary storage VM to be up
765762 // return the attache instead of null, even it is disconnectede
766- handleDisconnect (attache , Event .AgentDisconnected );
763+ handleDisconnectWithoutInvestigation (attache , Event .AgentDisconnected );
767764 }
768765
769766 _hostDao .updateStatus (host , Event .Ready , _nodeId );
@@ -1010,7 +1007,7 @@ public String getName() {
10101007 return _name ;
10111008 }
10121009
1013- protected boolean handleDisconnect (AgentAttache attache , Status .Event event ) {
1010+ protected boolean handleDisconnectWithoutInvestigation (AgentAttache attache , Status .Event event ) {
10141011 long hostId = attache .getId ();
10151012
10161013 s_logger .info ("Host " + hostId + " is disconnecting with event " + event );
@@ -1128,7 +1125,7 @@ protected boolean handleDisconnectWithInvestigation(AgentAttache attache, Status
11281125 }
11291126 }
11301127
1131- handleDisconnect (attache , event );
1128+ handleDisconnectWithoutInvestigation (attache , event );
11321129 /*TODO: call HA manager in monitors
11331130 * host = _hostDao.findById(host.getId());
11341131 if (!event.equals(Event.PrepareUnmanaged) && !event.equals(Event.HypervisorVersionChanged) && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) {
@@ -1155,7 +1152,7 @@ public void run() {
11551152 if (_investigate == true ) {
11561153 handleDisconnectWithInvestigation (_attache , _event );
11571154 } else {
1158- handleDisconnect (_attache , _event );
1155+ handleDisconnectWithoutInvestigation (_attache , _event );
11591156 }
11601157 } catch (final Exception e ) {
11611158 s_logger .error ("Exception caught while handling disconnect: " , e );
@@ -1216,7 +1213,7 @@ public Answer[] send(final Long hostId, Commands cmds) throws AgentUnavailableEx
12161213 }
12171214
12181215 @ Override
1219- public boolean reconnect (final long hostId ) throws AgentUnavailableException {
1216+ public boolean reconnect (final long hostId ) {
12201217 HostVO host ;
12211218
12221219 host = _hostDao .findById (hostId );
@@ -1236,46 +1233,25 @@ public boolean reconnect(final long hostId) throws AgentUnavailableException {
12361233 return false ;
12371234 }
12381235
1239- disconnect (attache , Event .ShutdownRequested , false );
1236+ disconnectWithoutInvestigation (attache , Event .ShutdownRequested );
12401237 return true ;
12411238 }
12421239
12431240 @ Override
12441241 public boolean executeUserRequest (long hostId , Event event ) throws AgentUnavailableException {
1245- if (event == Event .MaintenanceRequested ) {
1246- return maintain (hostId );
1247- } else if (event == Event .ResetRequested ) {
1248- return cancelMaintenance (hostId );
1249- } else if (event == Event .PrepareUnmanaged ) {
1250- return disconnect (hostId );
1251- } else if (event == Event .Remove ) {
1252- User caller = _accountMgr .getActiveUser (User .UID_SYSTEM );
1253- return deleteHost (hostId , false , false , caller );
1254- } else if (event == Event .AgentDisconnected ) {
1242+ if (event == Event .AgentDisconnected ) {
12551243 if (s_logger .isDebugEnabled ()) {
12561244 s_logger .debug ("Received agent disconnect event for host " + hostId );
12571245 }
12581246 AgentAttache attache = null ;
12591247 attache = findAttache (hostId );
12601248 if (attache != null ) {
1261- handleDisconnect (attache , Event .AgentDisconnected , false );
1249+ handleDisconnectWithoutInvestigation (attache , Event .AgentDisconnected );
12621250 }
12631251 return true ;
12641252 } else if (event == Event .ShutdownRequested ) {
12651253 return reconnect (hostId );
12661254 }
1267- else if (event == Event .UpdatePassword ) {
1268- AgentAttache attache = findAttache (hostId );
1269- if (attache != null ) {
1270- DetailVO nv = _detailsDao .findDetail (hostId , ApiConstants .USERNAME );
1271- String username = nv .getValue ();
1272- nv = _detailsDao .findDetail (hostId , ApiConstants .PASSWORD );
1273- String password = nv .getValue ();
1274- UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand (username , password );
1275- attache .updatePassword (cmd );
1276- return true ;
1277- }
1278- }
12791255 return false ;
12801256 }
12811257
@@ -1900,9 +1876,9 @@ protected void processRequest(final Link link, final Request request) {
19001876 final String reason = shutdown .getReason ();
19011877 s_logger .info ("Host " + attache .getId () + " has informed us that it is shutting down with reason " + reason + " and detail " + shutdown .getDetail ());
19021878 if (reason .equals (ShutdownCommand .Update )) {
1903- disconnect (attache , Event .UpdateNeeded , false );
1879+ disconnectWithoutInvestigation (attache , Event .UpdateNeeded );
19041880 } else if (reason .equals (ShutdownCommand .Requested )) {
1905- disconnect (attache , Event .ShutdownRequested , false );
1881+ disconnectWithoutInvestigation (attache , Event .ShutdownRequested );
19061882 }
19071883 return ;
19081884 } else if (cmd instanceof AgentControlCommand ) {
@@ -1999,7 +1975,7 @@ protected void doTask(final Task task) throws Exception {
19991975 final Link link = task .getLink ();
20001976 final AgentAttache attache = (AgentAttache ) link .attachment ();
20011977 if (attache != null ) {
2002- disconnect (attache , Event .AgentDisconnected , true );
1978+ disconnectWithInvestigation (attache , Event .AgentDisconnected );
20031979 } else {
20041980 s_logger .info ("Connection from " + link .getIpAddress () + " closed but no cleanup was done." );
20051981 link .close ();
0 commit comments