214214import org .w3c .dom .NodeList ;
215215import org .xml .sax .InputSource ;
216216import org .xml .sax .SAXException ;
217+ import java .util .concurrent .TimeoutException ;
217218
218219import javax .ejb .Local ;
219220import javax .naming .ConfigurationException ;
@@ -664,16 +665,11 @@ protected String callHostPluginAsync(Connection conn, String plugin,
664665 + " with args " + getArgsString (args )
665666 + " due to HandleInvalid clazz:" + e .clazz + ", handle:"
666667 + e .handle );
667- } catch (XenAPIException e ) {
668+ } catch (Exception e ) {
668669 s_logger .warn (
669670 "callHostPlugin failed for cmd: " + cmd + " with args "
670671 + getArgsString (args ) + " due to " + e .toString (),
671672 e );
672- } catch (XmlRpcException e ) {
673- s_logger .warn (
674- "callHostPlugin failed for cmd: " + cmd + " with args "
675- + getArgsString (args ) + " due to " + e .getMessage (),
676- e );
677673 } finally {
678674 if (task != null ) {
679675 try {
@@ -3310,7 +3306,7 @@ protected boolean isDmcEnabled(Connection conn, Host host) throws XenAPIExceptio
33103306 return false ;
33113307 }
33123308
3313- protected void waitForTask (Connection c , Task task , long pollInterval , long timeout ) throws XenAPIException , XmlRpcException {
3309+ protected void waitForTask (Connection c , Task task , long pollInterval , long timeout ) throws XenAPIException , XmlRpcException , TimeoutException {
33143310 long beginTime = System .currentTimeMillis ();
33153311 if (s_logger .isTraceEnabled ()) {
33163312 s_logger .trace ("Task " + task .getNameLabel (c ) + " (" + task .getUuid (c ) + ") sent to " + c .getSessionReference () + " is pending completion with a " + timeout +
@@ -3328,7 +3324,7 @@ protected void waitForTask(Connection c, Task task, long pollInterval, long time
33283324 String msg = "Async " + timeout / 1000 + " seconds timeout for task " + task .toString ();
33293325 s_logger .warn (msg );
33303326 task .cancel (c );
3331- throw new Types . BadAsyncResult (msg );
3327+ throw new TimeoutException (msg );
33323328 }
33333329 }
33343330 }
@@ -3347,7 +3343,7 @@ protected void checkForSuccess(Connection c, Task task) throws XenAPIException,
33473343 }
33483344 }
33493345
3350- void rebootVM (Connection conn , VM vm , String vmName ) throws XmlRpcException {
3346+ void rebootVM (Connection conn , VM vm , String vmName ) throws Exception {
33513347 Task task = null ;
33523348 try {
33533349 task = vm .cleanRebootAsync (conn );
@@ -3403,7 +3399,7 @@ void shutdownVM(Connection conn, VM vm, String vmName) throws XmlRpcException {
34033399 //poll every 1 seconds , timeout after 10 minutes
34043400 waitForTask (conn , task , 1000 , 10 * 60 * 1000 );
34053401 checkForSuccess (conn , task );
3406- } catch (Types . HandleInvalid e ) {
3402+ } catch (TimeoutException e ) {
34073403 if (vm .getPowerState (conn ) == Types .VmPowerState .HALTED ) {
34083404 task = null ;
34093405 return ;
@@ -3448,7 +3444,7 @@ void shutdownVM(Connection conn, VM vm, String vmName) throws XmlRpcException {
34483444 }
34493445 }
34503446
3451- void startVM (Connection conn , Host host , VM vm , String vmName ) throws XmlRpcException {
3447+ void startVM (Connection conn , Host host , VM vm , String vmName ) throws Exception {
34523448 Task task = null ;
34533449 try {
34543450 task = vm .startOnAsync (conn , host , false , true );
@@ -3463,7 +3459,7 @@ void startVM(Connection conn, Host host, VM vm, String vmName) throws XmlRpcExce
34633459 return ;
34643460 }
34653461 throw new CloudRuntimeException ("Start VM " + vmName + " catch HandleInvalid and VM is not in RUNNING state" );
3466- } catch (Types . BadAsyncResult e ) {
3462+ } catch (TimeoutException e ) {
34673463 if (vm .getPowerState (conn ) == Types .VmPowerState .RUNNING ) {
34683464 s_logger .debug ("VM " + vmName + " is in Running status" );
34693465 task = null ;
@@ -3486,7 +3482,7 @@ void startVM(Connection conn, Host host, VM vm, String vmName) throws XmlRpcExce
34863482 }
34873483 }
34883484
3489- private void migrateVM (Connection conn , Host destHost , VM vm , String vmName ) throws XmlRpcException {
3485+ private void migrateVM (Connection conn , Host destHost , VM vm , String vmName ) throws Exception {
34903486 Task task = null ;
34913487 try {
34923488 Map <String , String > other = new HashMap <String , String >();
@@ -3519,7 +3515,7 @@ private void migrateVM(Connection conn, Host destHost, VM vm, String vmName) thr
35193515 }
35203516 }
35213517
3522- protected VDI cloudVDIcopy (Connection conn , VDI vdi , SR sr , int wait ) throws XenAPIException , XmlRpcException {
3518+ protected VDI cloudVDIcopy (Connection conn , VDI vdi , SR sr , int wait ) throws Exception {
35233519 Task task = null ;
35243520 if (wait == 0 ) {
35253521 wait = 2 * 60 * 60 ;
@@ -3568,7 +3564,7 @@ protected String callHostPluginAsync(Connection conn, String plugin, String cmd,
35683564 e .handle );
35693565 } catch (XenAPIException e ) {
35703566 s_logger .warn ("callHostPlugin failed for cmd: " + cmd + " with args " + getArgsString (args ) + " due to " + e .toString (), e );
3571- } catch (XmlRpcException e ) {
3567+ } catch (Exception e ) {
35723568 s_logger .warn ("callHostPlugin failed for cmd: " + cmd + " with args " + getArgsString (args ) + " due to " + e .getMessage (), e );
35733569 } finally {
35743570 if (task != null ) {
0 commit comments