mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-6242: exception handling improvements
Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
parent
498cf6183d
commit
c031eb7d38
@ -802,6 +802,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
||||
* Why this can happen? Ask God not me. I hate there was no piece of comment for code handling race condition.
|
||||
* God knew what race condition the code dealt with!
|
||||
*/
|
||||
s_logger.debug("Caught exception while getting agent's next status", ne);
|
||||
}
|
||||
|
||||
if (nextStatus == Status.Alert) {
|
||||
|
||||
@ -79,6 +79,7 @@ import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
|
||||
import com.cloud.cluster.dao.ManagementServerHostDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.UnsupportedVersionException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
@ -412,7 +413,9 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
||||
if (ch == null) {
|
||||
try {
|
||||
logD(bytes, "Unable to route to peer: " + Request.parse(bytes).toString());
|
||||
} catch (Exception e) {
|
||||
} catch (ClassNotFoundException | UnsupportedVersionException e) {
|
||||
// Request.parse thrown exception when we try to log it, log as much as we can
|
||||
logD(bytes, "Unable to route to peer, and Request.parse further caught exception" + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -430,7 +433,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
logI(bytes, "Unable to route to peer: " + Request.parse(bytes).toString() + " due to " + e.getMessage());
|
||||
} catch (Exception ex) {
|
||||
} catch (ClassNotFoundException | UnsupportedVersionException ex) {
|
||||
// Request.parse thrown exception when we try to log it, log as much as we can
|
||||
logI(bytes, "Unable to route to peer due to" + e.getMessage()
|
||||
+ ". Also caught exception when parsing request: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1930,6 +1930,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
throw new CloudRuntimeException("Unable to complete migration for " + vm);
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Error while checking the vm " + vm + " on host " + dstHostId, e);
|
||||
}
|
||||
|
||||
migrated = true;
|
||||
@ -3898,6 +3899,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
throw new CloudRuntimeException("Unable to complete migration for " + vm);
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Error while checking the vm " + vm + " on host " + dstHostId, e);
|
||||
}
|
||||
|
||||
migrated = true;
|
||||
|
||||
@ -270,7 +270,7 @@ public class EngineDataCenterDaoImpl extends GenericDaoBase<EngineDataCenterVO,
|
||||
Long dcId = Long.parseLong(tokenOrIdOrName);
|
||||
return findById(dcId);
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
||||
s_logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
Long dcId = Long.parseLong(tokenOrIdOrName);
|
||||
return findById(dcId);
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
||||
s_logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +871,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
l.add(info);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("SQLException caught", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo
|
||||
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("SQLException: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
l.add(rs.getLong(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Exception: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -986,8 +986,9 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
|
||||
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`networks` DROP COLUMN `switch_to_isolated`");
|
||||
pstmt2Close.add(pstmt);
|
||||
pstmt.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
// do nothing here
|
||||
s_logger.debug("Caught SQLException when trying to drop switch_to_isolated column ", ex);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -217,7 +217,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
@ -242,7 +242,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
@ -261,7 +261,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
return rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -279,7 +279,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
return rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -301,7 +301,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
l.add(info);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Exception: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
@ -323,7 +323,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
l.add(rs.getLong(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
l.add(rs.getLong(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
s_logger.debug("Caught SQLException: ", e);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
try {
|
||||
objectInDataStoreMgr.update(destData, ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
} catch (Exception e1) {
|
||||
|
||||
s_logger.debug("failed to further change state to OperationFailed", e1);
|
||||
}
|
||||
CreateCmdResult res = new CreateCmdResult(null, null);
|
||||
res.setResult("Failed to change state: " + e.toString());
|
||||
@ -234,7 +234,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
try {
|
||||
objectInDataStoreMgr.update(destData, ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
} catch (Exception e1) {
|
||||
|
||||
s_logger.debug("failed to further change state to OperationFailed", e1);
|
||||
}
|
||||
CreateCmdResult res = new CreateCmdResult(null, null);
|
||||
res.setResult("Failed to change state: " + e.toString());
|
||||
@ -272,6 +272,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
try {
|
||||
objectInDataStoreMgr.update(destObj, ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
} catch (Exception e1) {
|
||||
s_logger.debug("failed to further change state to OperationFailed", e1);
|
||||
}
|
||||
CreateCmdResult res = new CreateCmdResult(null, null);
|
||||
res.setResult("Failed to update copying state: " + e.toString());
|
||||
@ -281,6 +282,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
try {
|
||||
objectInDataStoreMgr.update(destObj, ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
} catch (Exception e1) {
|
||||
s_logger.debug("failed to further change state to OperationFailed", e1);
|
||||
}
|
||||
CreateCmdResult res = new CreateCmdResult(null, null);
|
||||
res.setResult("Failed to update copying state: " + e.toString());
|
||||
|
||||
@ -33,12 +33,15 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
//
|
||||
// Finding classes in a given package code is taken and modified from
|
||||
// Credit: http://internna.blogspot.com/2007/11/java-5-retrieving-all-classes-from.html
|
||||
//
|
||||
public class OnwireClassRegistry {
|
||||
private static final Logger s_logger = Logger.getLogger(OnwireClassRegistry.class);
|
||||
|
||||
private List<String> packages = new ArrayList<String>();
|
||||
private final Map<String, Class<?>> registry = new HashMap<String, Class<?>>();
|
||||
@ -121,6 +124,7 @@ public class OnwireClassRegistry {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
s_logger.debug("Encountered IOException", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
return classes;
|
||||
@ -137,6 +141,7 @@ public class OnwireClassRegistry {
|
||||
classes.add(clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Encountered unexpect exception! ", e);
|
||||
}
|
||||
} else {
|
||||
File f = new File(directory.getPath() + "/" + file);
|
||||
|
||||
@ -255,6 +255,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
try {
|
||||
Session.logout(conn);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Caught exception during logout", e);
|
||||
}
|
||||
conn.dispose();
|
||||
conn = null;
|
||||
|
||||
@ -21,6 +21,8 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@ -90,7 +92,10 @@ public class XenServerConnectionPool {
|
||||
}
|
||||
};
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(hv);
|
||||
} catch (Exception e) {
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
//ignore this
|
||||
} catch (KeyManagementException e) {
|
||||
s_logger.debug("Init SSLContext failed ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +233,7 @@ public class XenServerConnectionPool {
|
||||
try{
|
||||
Session.logout(conn);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Caught exception during logout", e);
|
||||
}
|
||||
conn.dispose();
|
||||
}
|
||||
|
||||
@ -982,7 +982,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (Exception e) {
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
TemplateObjectTO newVol = new TemplateObjectTO();
|
||||
|
||||
@ -137,7 +137,10 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
|
||||
if (clusterDefaultMinIops != null && clusterDefaultMinIops.trim().length() > 0) {
|
||||
lClusterDefaultMinIops = Long.parseLong(clusterDefaultMinIops);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS +
|
||||
", using default value: " + lClusterDefaultMinIops +
|
||||
". Exception: " + ex);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -146,7 +149,10 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
|
||||
if (clusterDefaultMaxIops != null && clusterDefaultMaxIops.trim().length() > 0) {
|
||||
lClusterDefaultMaxIops = Long.parseLong(clusterDefaultMaxIops);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS +
|
||||
", using default value: " + lClusterDefaultMaxIops +
|
||||
". Exception: " + ex);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -155,7 +161,10 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
|
||||
if (clusterDefaultBurstIopsPercentOfMaxIops != null && clusterDefaultBurstIopsPercentOfMaxIops.trim().length() > 0) {
|
||||
fClusterDefaultBurstIopsPercentOfMaxIops = Float.parseFloat(clusterDefaultBurstIopsPercentOfMaxIops);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS +
|
||||
", using default value: " + fClusterDefaultBurstIopsPercentOfMaxIops +
|
||||
". Exception: " + ex);
|
||||
}
|
||||
|
||||
if (lClusterDefaultMinIops > lClusterDefaultMaxIops) {
|
||||
|
||||
@ -1591,6 +1591,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
dcId = Long.parseLong(dataCenter);
|
||||
dc = _dcDao.findById(dcId);
|
||||
} catch (final NumberFormatException e) {
|
||||
s_logger.debug("Cannot parse " + dataCenter + " into Long.");
|
||||
}
|
||||
}
|
||||
if (dc == null) {
|
||||
@ -1604,6 +1605,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
final long podId = Long.parseLong(pod);
|
||||
p = _podDao.findById(podId);
|
||||
} catch (final NumberFormatException e) {
|
||||
s_logger.debug("Cannot parse " + pod + " into Long.");
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
@ -464,6 +464,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
s_logger.debug("Caught SQLException when inserting system account ", ex);
|
||||
}
|
||||
// insert system user
|
||||
insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, user.default)"
|
||||
@ -473,6 +474,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
s_logger.debug("Caught SQLException when inserting system user ", ex);
|
||||
}
|
||||
|
||||
// insert admin user, but leave the account disabled until we set a
|
||||
@ -489,6 +491,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
s_logger.debug("Caught SQLException when creating admin account ", ex);
|
||||
}
|
||||
|
||||
// now insert the user
|
||||
@ -499,6 +502,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
s_logger.debug("Caught SQLException when inserting user ", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -508,8 +512,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(checkSql);
|
||||
stmt.executeQuery();
|
||||
tableName = "network_group";
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
// if network_groups table exists, create the default security group there
|
||||
s_logger.debug("Caught SQLException: no network_group ", ex);
|
||||
}
|
||||
|
||||
insertSql = "SELECT * FROM " + tableName + " where account_id=2 and name='default'";
|
||||
|
||||
@ -77,6 +77,7 @@ public class ConsoleProxyThumbnailHandler implements HttpHandler {
|
||||
width = Integer.parseInt(ws);
|
||||
height = Integer.parseInt(hs);
|
||||
} catch (NumberFormatException ex) {
|
||||
s_logger.debug("Cannot parse width: " + ws + " or height: " + hs, ex);
|
||||
}
|
||||
width = Math.min(width, 800);
|
||||
height = Math.min(height, 600);
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package com.cloud.utils.net;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigInteger;
|
||||
@ -172,7 +173,8 @@ public class NetUtils {
|
||||
}
|
||||
line = output.readLine();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
s_logger.debug("Caught IOException", e);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -425,7 +427,8 @@ public class NetUtils {
|
||||
try {
|
||||
byte[] mac = nic.getHardwareAddress();
|
||||
result[1] = byte2Mac(mac);
|
||||
} catch (Exception e) {
|
||||
} catch (SocketException e) {
|
||||
s_logger.debug("Caught exception when trying to get the mac address ", e);
|
||||
}
|
||||
|
||||
result[2] = prefix2Netmask(addr.getNetworkPrefixLength());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user