diff --git a/server/src/com/cloud/alert/ClusterAlertAdapter.java b/server/src/com/cloud/alert/ClusterAlertAdapter.java index 2bf6b663519..e26ecb13cb5 100644 --- a/server/src/com/cloud/alert/ClusterAlertAdapter.java +++ b/server/src/com/cloud/alert/ClusterAlertAdapter.java @@ -88,30 +88,15 @@ public class ClusterAlertAdapter implements AlertAdapter { for (ManagementServerHostVO mshost : args.getLeftNodes()) { if (mshost.getId() != args.getSelf().longValue()) { - GlobalLock lock = GlobalLock.getInternLock("ManagementAlert." + mshost.getId()); - try { - if (lock.lock(180)) { - try { - ManagementServerHostVO alertHost = _mshostDao.findById(mshost.getId()); - if (alertHost.getAlertCount() == 0) { - _mshostDao.increaseAlertCount(mshost.getId()); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert"); - } - - _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is down", ""); - } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set"); - } - } - } finally { - lock.unlock(); - } + if(_mshostDao.increaseAlertCount(mshost.getId()) > 0) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert"); + } + _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is down", ""); + } else { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set"); } - } finally { - lock.releaseRef(); } } } diff --git a/server/src/com/cloud/cluster/dao/ManagementServerHostDao.java b/server/src/com/cloud/cluster/dao/ManagementServerHostDao.java index b9b7d43abfb..8b5ac4f949c 100644 --- a/server/src/com/cloud/cluster/dao/ManagementServerHostDao.java +++ b/server/src/com/cloud/cluster/dao/ManagementServerHostDao.java @@ -31,7 +31,7 @@ public interface ManagementServerHostDao extends GenericDao _stockMap = new HashMap(); + private int _CHUNKSIZE = 1*1024*1024; // 1M static { try { @@ -267,7 +268,7 @@ public class VmwareContext { InputStream in = conn.getInputStream(); OutputStream out = new FileOutputStream(new File(localFileFullName)); - byte[] buf = new byte[102400]; + byte[] buf = new byte[_CHUNKSIZE]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -289,7 +290,7 @@ public class VmwareContext { try { out = conn.getOutputStream(); in = new FileInputStream(localFile); - byte[] buf = new byte[102400]; + byte[] buf = new byte[_CHUNKSIZE]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -322,8 +323,7 @@ public class VmwareContext { conn.setDoOutput(true); conn.setUseCaches(false); - int CHUCK_LEN = 64*1024; - conn.setChunkedStreamingMode(CHUCK_LEN); + conn.setChunkedStreamingMode(_CHUNKSIZE); conn.setRequestMethod(httpMethod); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "application/x-vnd.vmware-streamVmdk"); @@ -336,7 +336,7 @@ public class VmwareContext { bos = new BufferedOutputStream(conn.getOutputStream()); is = new BufferedInputStream(new FileInputStream(localFileName)); int bytesAvailable = is.available(); - int bufferSize = Math.min(bytesAvailable, CHUCK_LEN); + int bufferSize = Math.min(bytesAvailable, _CHUNKSIZE); byte[] buffer = new byte[bufferSize]; while (true) { int bytesRead = is.read(buffer, 0, bufferSize); @@ -378,7 +378,7 @@ public class VmwareContext { in = conn.getInputStream(); out = new FileOutputStream(new File(localFileName)); - byte[] buf = new byte[64*1024]; + byte[] buf = new byte[_CHUNKSIZE]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -406,7 +406,7 @@ public class VmwareContext { InputStream in = conn.getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buf = new byte[102400]; + byte[] buf = new byte[_CHUNKSIZE]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len);