You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/01/15 03:04:55 UTC
[13/44] Revert "Merge remote-tracking branch 'origin/javelin' into
javelin"
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/cluster/ClusterManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/cluster/ClusterManagerImpl.java b/server/src/com/cloud/cluster/ClusterManagerImpl.java
index 013034f..f71a866 100755
--- a/server/src/com/cloud/cluster/ClusterManagerImpl.java
+++ b/server/src/com/cloud/cluster/ClusterManagerImpl.java
@@ -29,7 +29,6 @@ import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -75,8 +74,6 @@ import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Profiler;
import com.cloud.utils.PropertiesUtil;
-import com.cloud.utils.component.Adapters;
-import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.ConnectionConcierge;
import com.cloud.utils.db.DB;
@@ -123,7 +120,7 @@ public class ClusterManagerImpl implements ClusterManager {
private final ExecutorService _executor;
private ClusterServiceAdapter _currentServiceAdapter;
-
+
@Inject
private List<ClusterServiceAdapter> _serviceAdapters;
@@ -149,11 +146,11 @@ public class ClusterManagerImpl implements ClusterManager {
private boolean _agentLBEnabled = false;
private double _connectedAgentsThreshold = 0.7;
private static boolean _agentLbHappened = false;
-
- private List<ClusterServicePdu> _clusterPduOutgoingQueue = new ArrayList<ClusterServicePdu>();
- private List<ClusterServicePdu> _clusterPduIncomingQueue = new ArrayList<ClusterServicePdu>();
- private Map<Long, ClusterServiceRequestPdu> _outgoingPdusWaitingForAck = new HashMap<Long, ClusterServiceRequestPdu>();
-
+
+ private final List<ClusterServicePdu> _clusterPduOutgoingQueue = new ArrayList<ClusterServicePdu>();
+ private final List<ClusterServicePdu> _clusterPduIncomingQueue = new ArrayList<ClusterServicePdu>();
+ private final Map<Long, ClusterServiceRequestPdu> _outgoingPdusWaitingForAck = new HashMap<Long, ClusterServiceRequestPdu>();
+
public ClusterManagerImpl() {
_clusterPeers = new HashMap<String, ClusterService>();
@@ -164,13 +161,13 @@ public class ClusterManagerImpl implements ClusterManager {
//
_executor = Executors.newCachedThreadPool(new NamedThreadFactory("Cluster-Worker"));
}
-
+
private void registerRequestPdu(ClusterServiceRequestPdu pdu) {
synchronized(_outgoingPdusWaitingForAck) {
_outgoingPdusWaitingForAck.put(pdu.getSequenceId(), pdu);
}
}
-
+
private ClusterServiceRequestPdu popRequestPdu(long ackSequenceId) {
synchronized(_outgoingPdusWaitingForAck) {
if(_outgoingPdusWaitingForAck.get(ackSequenceId) != null) {
@@ -179,10 +176,10 @@ public class ClusterManagerImpl implements ClusterManager {
return pdu;
}
}
-
+
return null;
}
-
+
private void cancelClusterRequestToPeer(String strPeer) {
List<ClusterServiceRequestPdu> candidates = new ArrayList<ClusterServiceRequestPdu>();
synchronized(_outgoingPdusWaitingForAck) {
@@ -195,7 +192,7 @@ public class ClusterManagerImpl implements ClusterManager {
_outgoingPdusWaitingForAck.remove(pdu.getSequenceId());
}
}
-
+
for(ClusterServiceRequestPdu pdu : candidates) {
s_logger.warn("Cancel cluster request PDU to peer: " + strPeer + ", pdu: " + _gson.toJson(pdu));
synchronized(pdu) {
@@ -203,76 +200,78 @@ public class ClusterManagerImpl implements ClusterManager {
}
}
}
-
+
private void addOutgoingClusterPdu(ClusterServicePdu pdu) {
- synchronized(_clusterPduOutgoingQueue) {
- _clusterPduOutgoingQueue.add(pdu);
- _clusterPduOutgoingQueue.notifyAll();
- }
+ synchronized(_clusterPduOutgoingQueue) {
+ _clusterPduOutgoingQueue.add(pdu);
+ _clusterPduOutgoingQueue.notifyAll();
+ }
}
-
+
private ClusterServicePdu popOutgoingClusterPdu(long timeoutMs) {
- synchronized(_clusterPduOutgoingQueue) {
- try {
- _clusterPduOutgoingQueue.wait(timeoutMs);
- } catch (InterruptedException e) {
- }
-
- if(_clusterPduOutgoingQueue.size() > 0) {
- ClusterServicePdu pdu = _clusterPduOutgoingQueue.get(0);
- _clusterPduOutgoingQueue.remove(0);
- return pdu;
- }
- }
- return null;
+ synchronized(_clusterPduOutgoingQueue) {
+ try {
+ _clusterPduOutgoingQueue.wait(timeoutMs);
+ } catch (InterruptedException e) {
+ }
+
+ if(_clusterPduOutgoingQueue.size() > 0) {
+ ClusterServicePdu pdu = _clusterPduOutgoingQueue.get(0);
+ _clusterPduOutgoingQueue.remove(0);
+ return pdu;
+ }
+ }
+ return null;
}
private void addIncomingClusterPdu(ClusterServicePdu pdu) {
- synchronized(_clusterPduIncomingQueue) {
- _clusterPduIncomingQueue.add(pdu);
- _clusterPduIncomingQueue.notifyAll();
- }
+ synchronized(_clusterPduIncomingQueue) {
+ _clusterPduIncomingQueue.add(pdu);
+ _clusterPduIncomingQueue.notifyAll();
+ }
}
-
+
private ClusterServicePdu popIncomingClusterPdu(long timeoutMs) {
- synchronized(_clusterPduIncomingQueue) {
- try {
- _clusterPduIncomingQueue.wait(timeoutMs);
- } catch (InterruptedException e) {
- }
-
- if(_clusterPduIncomingQueue.size() > 0) {
- ClusterServicePdu pdu = _clusterPduIncomingQueue.get(0);
- _clusterPduIncomingQueue.remove(0);
- return pdu;
- }
- }
- return null;
+ synchronized(_clusterPduIncomingQueue) {
+ try {
+ _clusterPduIncomingQueue.wait(timeoutMs);
+ } catch (InterruptedException e) {
+ }
+
+ if(_clusterPduIncomingQueue.size() > 0) {
+ ClusterServicePdu pdu = _clusterPduIncomingQueue.get(0);
+ _clusterPduIncomingQueue.remove(0);
+ return pdu;
+ }
+ }
+ return null;
}
-
+
private Runnable getClusterPduSendingTask() {
return new Runnable() {
+ @Override
public void run() {
onSendingClusterPdu();
}
};
}
-
+
private Runnable getClusterPduNotificationTask() {
return new Runnable() {
+ @Override
public void run() {
onNotifyingClusterPdu();
}
};
}
-
+
private void onSendingClusterPdu() {
while(true) {
try {
ClusterServicePdu pdu = popOutgoingClusterPdu(1000);
if(pdu == null)
- continue;
-
+ continue;
+
ClusterService peerService = null;
for(int i = 0; i < 2; i++) {
try {
@@ -285,20 +284,20 @@ public class ClusterManagerImpl implements ClusterManager {
try {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId()
- + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
+ + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
}
long startTick = System.currentTimeMillis();
String strResult = peerService.execute(pdu);
if(s_logger.isDebugEnabled()) {
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " +
- (System.currentTimeMillis() - startTick) + "ms. agent: " + pdu.getAgentId()
- + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
+ (System.currentTimeMillis() - startTick) + "ms. agent: " + pdu.getAgentId()
+ + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
}
-
+
if("true".equals(strResult))
break;
-
+
} catch (RemoteException e) {
invalidatePeerService(pdu.getDestPeer());
if(s_logger.isInfoEnabled()) {
@@ -313,50 +312,51 @@ public class ClusterManagerImpl implements ClusterManager {
}
}
}
-
+
private void onNotifyingClusterPdu() {
while(true) {
try {
final ClusterServicePdu pdu = popIncomingClusterPdu(1000);
if(pdu == null)
- continue;
+ continue;
_executor.execute(new Runnable() {
- public void run() {
- if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_RESPONSE) {
- ClusterServiceRequestPdu requestPdu = popRequestPdu(pdu.getAckSequenceId());
- if(requestPdu != null) {
- requestPdu.setResponseResult(pdu.getJsonPackage());
- synchronized(requestPdu) {
- requestPdu.notifyAll();
- }
- } else {
- s_logger.warn("Original request has already been cancelled. pdu: " + _gson.toJson(pdu));
- }
- } else {
- String result = dispatchClusterServicePdu(pdu);
- if(result == null)
- result = "";
-
- if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_REQUEST) {
- ClusterServicePdu responsePdu = new ClusterServicePdu();
- responsePdu.setPduType(ClusterServicePdu.PDU_TYPE_RESPONSE);
- responsePdu.setSourcePeer(pdu.getDestPeer());
- responsePdu.setDestPeer(pdu.getSourcePeer());
- responsePdu.setAckSequenceId(pdu.getSequenceId());
- responsePdu.setJsonPackage(result);
-
- addOutgoingClusterPdu(responsePdu);
- }
- }
- }
+ @Override
+ public void run() {
+ if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_RESPONSE) {
+ ClusterServiceRequestPdu requestPdu = popRequestPdu(pdu.getAckSequenceId());
+ if(requestPdu != null) {
+ requestPdu.setResponseResult(pdu.getJsonPackage());
+ synchronized(requestPdu) {
+ requestPdu.notifyAll();
+ }
+ } else {
+ s_logger.warn("Original request has already been cancelled. pdu: " + _gson.toJson(pdu));
+ }
+ } else {
+ String result = dispatchClusterServicePdu(pdu);
+ if(result == null)
+ result = "";
+
+ if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_REQUEST) {
+ ClusterServicePdu responsePdu = new ClusterServicePdu();
+ responsePdu.setPduType(ClusterServicePdu.PDU_TYPE_RESPONSE);
+ responsePdu.setSourcePeer(pdu.getDestPeer());
+ responsePdu.setDestPeer(pdu.getSourcePeer());
+ responsePdu.setAckSequenceId(pdu.getSequenceId());
+ responsePdu.setJsonPackage(result);
+
+ addOutgoingClusterPdu(responsePdu);
+ }
+ }
+ }
});
} catch(Throwable e) {
s_logger.error("Unexcpeted exception: ", e);
}
}
}
-
+
private String dispatchClusterServicePdu(ClusterServicePdu pdu) {
if(s_logger.isDebugEnabled()) {
@@ -370,7 +370,7 @@ public class ClusterManagerImpl implements ClusterManager {
assert(false);
s_logger.error("Excection in gson decoding : ", e);
}
-
+
if (cmds.length == 1 && cmds[0] instanceof ChangeAgentCommand) { //intercepted
ChangeAgentCommand cmd = (ChangeAgentCommand)cmds[0];
@@ -416,22 +416,22 @@ public class ClusterManagerImpl implements ClusterManager {
answers[0] = new Answer(cmd, result, null);
return _gson.toJson(answers);
} else if (cmds.length == 1 && cmds[0] instanceof PropagateResourceEventCommand ) {
- PropagateResourceEventCommand cmd = (PropagateResourceEventCommand) cmds[0];
-
- s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId());
-
- boolean result = false;
- try {
- result = executeResourceUserRequest(cmd.getHostId(), cmd.getEvent());
- s_logger.debug("Result is " + result);
- } catch (AgentUnavailableException ex) {
- s_logger.warn("Agent is unavailable", ex);
- return null;
- }
-
- Answer[] answers = new Answer[1];
- answers[0] = new Answer(cmd, result, null);
- return _gson.toJson(answers);
+ PropagateResourceEventCommand cmd = (PropagateResourceEventCommand) cmds[0];
+
+ s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId());
+
+ boolean result = false;
+ try {
+ result = executeResourceUserRequest(cmd.getHostId(), cmd.getEvent());
+ s_logger.debug("Result is " + result);
+ } catch (AgentUnavailableException ex) {
+ s_logger.warn("Agent is unavailable", ex);
+ return null;
+ }
+
+ Answer[] answers = new Answer[1];
+ answers[0] = new Answer(cmd, result, null);
+ return _gson.toJson(answers);
}
try {
@@ -461,14 +461,15 @@ public class ClusterManagerImpl implements ClusterManager {
} catch (OperationTimedoutException e) {
s_logger.warn("Timed Out", e);
}
-
+
return null;
}
+ @Override
public void OnReceiveClusterServicePdu(ClusterServicePdu pdu) {
- addIncomingClusterPdu(pdu);
+ addIncomingClusterPdu(pdu);
}
-
+
@Override
public Answer[] sendToAgent(Long hostId, Command[] cmds, boolean stopOnError) throws AgentUnavailableException, OperationTimedoutException {
Commands commands = new Commands(stopOnError ? OnError.Stop : OnError.Continue);
@@ -558,7 +559,7 @@ public class ClusterManagerImpl implements ClusterManager {
s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " " +
_gson.toJson(cmds, Command[].class));
}
-
+
ClusterServiceRequestPdu pdu = new ClusterServiceRequestPdu();
pdu.setSourcePeer(getSelfPeerName());
pdu.setDestPeer(strPeer);
@@ -567,7 +568,7 @@ public class ClusterManagerImpl implements ClusterManager {
pdu.setStopOnError(stopOnError);
registerRequestPdu(pdu);
addOutgoingClusterPdu(pdu);
-
+
synchronized(pdu) {
try {
pdu.wait();
@@ -577,9 +578,9 @@ public class ClusterManagerImpl implements ClusterManager {
if(s_logger.isDebugEnabled()) {
s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " completed. result: " +
- pdu.getResponseResult());
+ pdu.getResponseResult());
}
-
+
if(pdu.getResponseResult() != null && pdu.getResponseResult().length() > 0) {
try {
return _gson.fromJson(pdu.getResponseResult(), Answer[].class);
@@ -590,7 +591,7 @@ public class ClusterManagerImpl implements ClusterManager {
return null;
}
-
+
@Override
public String getPeerName(long agentHostId) {
@@ -625,18 +626,18 @@ public class ClusterManagerImpl implements ClusterManager {
// Note : we don't check duplicates
synchronized (_listeners) {
- s_logger.info("register cluster listener " + listener.getClass());
-
- _listeners.add(listener);
+ s_logger.info("register cluster listener " + listener.getClass());
+
+ _listeners.add(listener);
}
}
@Override
public void unregisterListener(ClusterManagerListener listener) {
synchronized(_listeners) {
- s_logger.info("unregister cluster listener " + listener.getClass());
-
- _listeners.remove(listener);
+ s_logger.info("unregister cluster listener " + listener.getClass());
+
+ _listeners.remove(listener);
}
}
@@ -663,7 +664,7 @@ public class ClusterManagerImpl implements ClusterManager {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Notify management server node left to listeners.");
}
-
+
for(ManagementServerHostVO mshost : nodeList) {
if(s_logger.isDebugEnabled())
s_logger.debug("Leaving node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid());
@@ -731,32 +732,32 @@ public class ClusterManagerImpl implements ClusterManager {
Profiler profilerHeartbeatUpdate = new Profiler();
Profiler profilerPeerScan = new Profiler();
Profiler profilerAgentLB = new Profiler();
-
+
try {
profiler.start();
-
+
profilerHeartbeatUpdate.start();
txn.transitToUserManagedConnection(getHeartbeatConnection());
if(s_logger.isTraceEnabled()) {
s_logger.trace("Cluster manager heartbeat update, id:" + _mshostId);
}
-
+
_mshostDao.update(_mshostId, getCurrentRunId(), DateUtil.currentGMTTime());
profilerHeartbeatUpdate.stop();
-
+
profilerPeerScan.start();
if (s_logger.isTraceEnabled()) {
s_logger.trace("Cluster manager peer-scan, id:" + _mshostId);
}
-
+
if (!_peerScanInited) {
_peerScanInited = true;
initPeerScan();
}
-
+
peerScan();
profilerPeerScan.stop();
-
+
profilerAgentLB.start();
//initiate agent lb task will be scheduled and executed only once, and only when number of agents loaded exceeds _connectedAgentsThreshold
if (_agentLBEnabled && !_agentLbHappened) {
@@ -764,7 +765,7 @@ public class ClusterManagerImpl implements ClusterManager {
sc.addAnd(sc.getEntity().getManagementServerId(), Op.NNULL);
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
List<HostVO> allManagedRoutingAgents = sc.list();
-
+
sc = SearchCriteria2.create(HostVO.class);
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
List<HostVO> allAgents = sc.list();
@@ -784,16 +785,16 @@ public class ClusterManagerImpl implements ClusterManager {
profilerAgentLB.stop();
} finally {
profiler.stop();
-
+
if(profiler.getDuration() >= _heartbeatInterval) {
if(s_logger.isDebugEnabled())
s_logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() +
- ", profilerHeartbeatUpdate: " + profilerHeartbeatUpdate.toString() +
- ", profilerPeerScan: " + profilerPeerScan.toString() +
- ", profilerAgentLB: " + profilerAgentLB.toString());
+ ", profilerHeartbeatUpdate: " + profilerHeartbeatUpdate.toString() +
+ ", profilerPeerScan: " + profilerPeerScan.toString() +
+ ", profilerAgentLB: " + profilerAgentLB.toString());
}
}
-
+
} catch(CloudRuntimeException e) {
s_logger.error("Runtime DB exception ", e.getCause());
@@ -933,33 +934,33 @@ public class ClusterManagerImpl implements ClusterManager {
this._notificationMsgs.add(msg);
this._notificationMsgs.notifyAll();
}
-
+
switch(msg.getMessageType()) {
case nodeAdded:
- {
- List<ManagementServerHostVO> l = msg.getNodes();
- if(l != null && l.size() > 0) {
- for(ManagementServerHostVO mshost: l) {
- _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up);
- }
+ {
+ List<ManagementServerHostVO> l = msg.getNodes();
+ if(l != null && l.size() > 0) {
+ for(ManagementServerHostVO mshost: l) {
+ _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up);
}
}
- break;
-
+ }
+ break;
+
case nodeRemoved:
- {
- List<ManagementServerHostVO> l = msg.getNodes();
- if(l != null && l.size() > 0) {
- for(ManagementServerHostVO mshost: l) {
- _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down);
- }
+ {
+ List<ManagementServerHostVO> l = msg.getNodes();
+ if(l != null && l.size() > 0) {
+ for(ManagementServerHostVO mshost: l) {
+ _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down);
}
}
- break;
-
+ }
+ break;
+
default :
break;
-
+
}
}
@@ -978,39 +979,39 @@ public class ClusterManagerImpl implements ClusterManager {
// missed cleanup
Date cutTime = DateUtil.currentGMTTime();
List<ManagementServerHostVO> inactiveList = _mshostDao.getInactiveList(new Date(cutTime.getTime() - _heartbeatThreshold));
-
+
// We don't have foreign key constraints to enforce the mgmt_server_id integrity in host table, when user manually
// remove records from mshost table, this will leave orphan mgmt_serve_id reference in host table.
List<Long> orphanList = _mshostDao.listOrphanMsids();
if(orphanList.size() > 0) {
- for(Long orphanMsid : orphanList) {
- // construct fake ManagementServerHostVO based on orphan MSID
- s_logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid);
- inactiveList.add(new ManagementServerHostVO(orphanMsid, 0, "orphan", 0, new Date()));
- }
+ for(Long orphanMsid : orphanList) {
+ // construct fake ManagementServerHostVO based on orphan MSID
+ s_logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid);
+ inactiveList.add(new ManagementServerHostVO(orphanMsid, 0, "orphan", 0, new Date()));
+ }
} else {
- s_logger.info("We are good, no orphan management server msid in host table is found");
+ s_logger.info("We are good, no orphan management server msid in host table is found");
}
-
+
if(inactiveList.size() > 0) {
- if(s_logger.isInfoEnabled()) {
- s_logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp");
- for(ManagementServerHostVO host : inactiveList)
- s_logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + ", version: " + host.getVersion());
- }
+ if(s_logger.isInfoEnabled()) {
+ s_logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp");
+ for(ManagementServerHostVO host : inactiveList)
+ s_logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + ", version: " + host.getVersion());
+ }
- List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>();
+ List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>();
for(ManagementServerHostVO host : inactiveList) {
- if(!pingManagementNode(host)) {
- s_logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable");
- downHostList.add(host);
- }
+ if(!pingManagementNode(host)) {
+ s_logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable");
+ downHostList.add(host);
+ }
}
-
+
if(downHostList.size() > 0)
- this.queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, downHostList));
+ this.queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, downHostList));
} else {
- s_logger.info("No inactive management server node found");
+ s_logger.info("No inactive management server node found");
}
}
@@ -1019,7 +1020,7 @@ public class ClusterManagerImpl implements ClusterManager {
Profiler profiler = new Profiler();
profiler.start();
-
+
Profiler profilerQueryActiveList = new Profiler();
profilerQueryActiveList.start();
List<ManagementServerHostVO> currentList = _mshostDao.getActiveList(new Date(cutTime.getTime() - _heartbeatThreshold));
@@ -1031,13 +1032,13 @@ public class ClusterManagerImpl implements ClusterManager {
List<ManagementServerHostVO> invalidatedNodeList = new ArrayList<ManagementServerHostVO>();
if(_mshostId != null) {
-
+
if(_mshostPeerDao.countStateSeenInPeers(_mshostId, _runId, ManagementServerHost.State.Down) > 0) {
String msg = "We have detected that at least one management server peer reports that this management server is down, perform active fencing to avoid split-brain situation";
s_logger.error(msg);
throw new ActiveFencingException(msg);
}
-
+
// only if we have already attached to cluster, will we start to check leaving nodes
for(Map.Entry<Long, ManagementServerHostVO> entry : _activePeers.entrySet()) {
@@ -1070,7 +1071,7 @@ public class ClusterManagerImpl implements ClusterManager {
}
}
profilerSyncClusterInfo.stop();
-
+
Profiler profilerInvalidatedNodeList = new Profiler();
profilerInvalidatedNodeList.start();
// process invalidated node list
@@ -1134,16 +1135,16 @@ public class ClusterManagerImpl implements ClusterManager {
if(newNodeList.size() > 0) {
this.queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeAdded, newNodeList));
}
-
+
profiler.stop();
-
+
if(profiler.getDuration() >= this._heartbeatInterval) {
if(s_logger.isDebugEnabled())
s_logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString()
- + ", profilerQueryActiveList: " + profilerQueryActiveList.toString()
- + ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString()
- + ", profilerInvalidatedNodeList: " + profilerInvalidatedNodeList.toString()
- + ", profilerRemovedList: " + profilerRemovedList.toString());
+ + ", profilerQueryActiveList: " + profilerQueryActiveList.toString()
+ + ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString()
+ + ", profilerInvalidatedNodeList: " + profilerInvalidatedNodeList.toString()
+ + ", profilerRemovedList: " + profilerRemovedList.toString());
}
}
@@ -1206,7 +1207,7 @@ public class ClusterManagerImpl implements ClusterManager {
if (s_logger.isInfoEnabled()) {
s_logger.info("Management server (host id : " + _mshostId + ") is being started at " + _clusterNodeIP + ":" + _currentServiceAdapter.getServicePort());
}
-
+
_mshostPeerDao.clearPeerInfo(_mshostId);
// use seperate thread for heartbeat updates
@@ -1294,8 +1295,8 @@ public class ClusterManagerImpl implements ClusterManager {
}
for(int i = 0; i < DEFAULT_OUTGOING_WORKERS; i++)
- _executor.execute(getClusterPduSendingTask());
-
+ _executor.execute(getClusterPduSendingTask());
+
// notification task itself in turn works as a task dispatcher
_executor.execute(getClusterPduNotificationTask());
@@ -1309,9 +1310,9 @@ public class ClusterManagerImpl implements ClusterManager {
}
_agentLBEnabled = Boolean.valueOf(_configDao.getValue(Config.AgentLbEnable.key()));
-
+
String connectedAgentsThreshold = configs.get("agent.load.threshold");
-
+
if (connectedAgentsThreshold != null) {
_connectedAgentsThreshold = Double.parseDouble(connectedAgentsThreshold);
}
@@ -1365,7 +1366,7 @@ public class ClusterManagerImpl implements ClusterManager {
s_logger.info("ping management node cluster service can not be performed on self");
return false;
}
-
+
int retry = 10;
while (--retry > 0) {
SocketChannel sch = null;
@@ -1381,7 +1382,7 @@ public class ClusterManagerImpl implements ClusterManager {
} catch (IOException e) {
if (e instanceof ConnectException) {
s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e);
- return false;
+ return false;
}
} finally {
if (sch != null) {
@@ -1397,7 +1398,7 @@ public class ClusterManagerImpl implements ClusterManager {
} catch (InterruptedException ex) {
}
}
-
+
s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " after retries");
return false;
}
@@ -1455,7 +1456,7 @@ public class ClusterManagerImpl implements ClusterManager {
public boolean isAgentRebalanceEnabled() {
return _agentLBEnabled;
}
-
+
@Override
public Boolean propagateResourceEvent(long agentId, ResourceState.Event event) throws AgentUnavailableException {
final String msPeer = getPeerName(agentId);
@@ -1480,7 +1481,7 @@ public class ClusterManagerImpl implements ClusterManager {
return answers[0].getResult();
}
-
+
@Override
public boolean executeResourceUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException {
return _resourceMgr.executeUserRequest(hostId, event);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/cluster/StackMaid.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/cluster/StackMaid.java b/server/src/com/cloud/cluster/StackMaid.java
deleted file mode 100644
index b84d73d..0000000
--- a/server/src/com/cloud/cluster/StackMaid.java
+++ /dev/null
@@ -1,153 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.cluster;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.cluster.dao.StackMaidDao;
-import com.cloud.cluster.dao.StackMaidDaoImpl;
-import com.cloud.serializer.SerializerHelper;
-import com.cloud.utils.CleanupDelegate;
-import com.cloud.utils.db.Transaction;
-
-public class StackMaid {
- protected final static Logger s_logger = Logger.getLogger(StackMaid.class);
-
- private static ThreadLocal<StackMaid> threadMaid = new ThreadLocal<StackMaid>();
-
- private static long msid_setby_manager = 0;
-
- private StackMaidDao maidDao = new StackMaidDaoImpl();
- private int currentSeq = 0;
- private Map<String, Object> context = new HashMap<String, Object>();
-
- public static void init(long msid) {
- msid_setby_manager = msid;
- }
-
- public static StackMaid current() {
- StackMaid maid = threadMaid.get();
- if(maid == null) {
- maid = new StackMaid();
- threadMaid.set(maid);
- }
- return maid;
- }
-
- public void registerContext(String key, Object contextObject) {
- assert(!context.containsKey(key)) : "Context key has already been registered";
- context.put(key, contextObject);
- }
-
- public Object getContext(String key) {
- return context.get(key);
- }
-
- public void expungeMaidItem(long maidId) {
- // this is a bit ugly, but when it is not loaded by component locator, this is just a workable way for now
- Transaction txn = Transaction.open(Transaction.CLOUD_DB);
- try {
- maidDao.expunge(maidId);
- } finally {
- txn.close();
- }
- }
-
- public int push(String delegateClzName, Object context) {
- assert(msid_setby_manager != 0) : "Fatal, make sure StackMaidManager is loaded";
- if(msid_setby_manager == 0)
- s_logger.error("Fatal, make sure StackMaidManager is loaded");
-
- return push(msid_setby_manager, delegateClzName, context);
- }
-
- public int push(long currentMsid, String delegateClzName, Object context) {
- int savePoint = currentSeq;
- maidDao.pushCleanupDelegate(currentMsid, currentSeq++, delegateClzName, context);
- return savePoint;
- }
-
- public void pop(int savePoint) {
- assert(msid_setby_manager != 0) : "Fatal, make sure StackMaidManager is loaded";
- if(msid_setby_manager == 0)
- s_logger.error("Fatal, make sure StackMaidManager is loaded");
-
- pop(msid_setby_manager, savePoint);
- }
-
- public void pop() {
- if(currentSeq > 0)
- pop(currentSeq -1);
- }
-
- /**
- * must be called within thread context
- * @param currentMsid
- */
- public void pop(long currentMsid, int savePoint) {
- while(currentSeq > savePoint) {
- maidDao.popCleanupDelegate(currentMsid);
- currentSeq--;
- }
- }
-
- public void exitCleanup() {
- exitCleanup(msid_setby_manager);
- }
-
- public void exitCleanup(long currentMsid) {
- if(currentSeq > 0) {
- CheckPointVO maid = null;
- while((maid = maidDao.popCleanupDelegate(currentMsid)) != null) {
- doCleanup(maid);
- }
- currentSeq = 0;
- }
-
- context.clear();
- }
-
- public static boolean doCleanup(CheckPointVO maid) {
- if(maid.getDelegate() != null) {
- try {
- Class<?> clz = Class.forName(maid.getDelegate());
- Object delegate = clz.newInstance();
- if(delegate instanceof CleanupDelegate) {
- return ((CleanupDelegate)delegate).cleanup(SerializerHelper.fromSerializedString(maid.getContext()), maid);
- } else {
- assert(false);
- }
- } catch (final ClassNotFoundException e) {
- s_logger.error("Unable to load StackMaid delegate class: " + maid.getDelegate(), e);
- } catch (final SecurityException e) {
- s_logger.error("Security excetion when loading resource: " + maid.getDelegate());
- } catch (final IllegalArgumentException e) {
- s_logger.error("Illegal argument excetion when loading resource: " + maid.getDelegate());
- } catch (final InstantiationException e) {
- s_logger.error("Instantiation excetion when loading resource: " + maid.getDelegate());
- } catch (final IllegalAccessException e) {
- s_logger.error("Illegal access exception when loading resource: " + maid.getDelegate());
- }
-
- return false;
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/configuration/CloudZonesComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/CloudZonesComponentLibrary.java b/server/src/com/cloud/configuration/CloudZonesComponentLibrary.java
deleted file mode 100644
index 13bb16f..0000000
--- a/server/src/com/cloud/configuration/CloudZonesComponentLibrary.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.configuration;
-
-import com.cloud.agent.StartupCommandProcessor;
-import com.cloud.agent.manager.authn.impl.BasicAgentAuthManager;
-
-import com.cloud.hypervisor.CloudZonesStartupProcessor;
-import com.cloud.network.element.CloudZonesNetworkElement;
-import com.cloud.network.element.NetworkElement;
-
-
-
-public class CloudZonesComponentLibrary extends PremiumComponentLibrary {
-
- @Override
- protected void populateAdapters() {
- super.populateAdapters();
- addAdapter(NetworkElement.class, "CloudZones", CloudZonesNetworkElement.class);
- addAdapter(StartupCommandProcessor.class, "BasicAgentAuthorizer", BasicAgentAuthManager.class);
- addAdapter(StartupCommandProcessor.class, "CloudZonesStartupProcessor", CloudZonesStartupProcessor.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index bb943c9..a8c1743 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -39,30 +39,32 @@ import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
+import org.apache.cloudstack.acl.SecurityChecker;
+import org.apache.cloudstack.api.ApiConstants.LDAPParams;
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
-import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
+import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.*;
+import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
-import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
-import org.apache.cloudstack.acl.SecurityChecker;
import com.cloud.alert.AlertManager;
-import org.apache.cloudstack.api.ApiConstants.LDAPParams;
import com.cloud.api.ApiDBUtils;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.configuration.Resource.ResourceType;
@@ -153,8 +155,6 @@ import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.StringUtils;
-import com.cloud.utils.component.Adapters;
-import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Filter;
@@ -216,7 +216,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
// @com.cloud.utils.component.Inject(adapter = SecurityChecker.class)
@Inject
List<SecurityChecker> _secChecker;
-
+
@Inject
CapacityDao _capacityDao;
@Inject
@@ -438,7 +438,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String name = cmd.getCfgName();
String value = cmd.getValue();
UserContext.current().setEventDetails(" Name: " + name + " New Value: " + (((name.toLowerCase()).contains("password")) ? "*****" :
- (((value == null) ? "" : value))));
+ (((value == null) ? "" : value))));
// check if config value exists
ConfigurationVO config = _configDao.findByName(name);
if (config == null) {
@@ -1454,9 +1454,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
if (internalDns2 == null) {
- internalDns2 = zone.getInternalDns2();
+ internalDns2 = zone.getInternalDns2();
}
-
+
if (guestCidr == null) {
guestCidr = zone.getGuestNetworkCidr();
}
@@ -1915,8 +1915,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String description = cmd.getDisplayText();
Long numGibibytes = cmd.getDiskSize();
boolean isCustomized = cmd.isCustomized() != null ? cmd.isCustomized() : false; // false
- // by
- // default
+ // by
+ // default
String tags = cmd.getTags();
// Long domainId = cmd.getDomainId() != null ? cmd.getDomainId() :
// Long.valueOf(DomainVO.ROOT_DOMAIN); // disk offering
@@ -2106,7 +2106,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
physicalNetworkId = network.getPhysicalNetworkId();
}
}
-
+
// Verify that zone exists
DataCenterVO zone = _zoneDao.findById(zoneId);
if (zone == null) {
@@ -2148,8 +2148,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
}
}
-
-
+
+
// Check if zone is enabled
Account caller = UserContext.current().getCaller();
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
@@ -2234,7 +2234,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
//check resource limits
_resourceLimitMgr.checkResourceLimit(vlanOwner, ResourceType.public_ip, accountIpRange);
-
+
associateIpRangeToAccount = true;
}
}
@@ -2272,24 +2272,24 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId,
String startIP, String endIP, String vlanGateway, String vlanNetmask,
String vlanId, Account vlanOwner) {
-
-
+
+
Network network = _networkMgr.getNetwork(networkId);
-
+
//Validate the zone
DataCenterVO zone = _zoneDao.findById(zoneId);
if (zone == null) {
throw new InvalidParameterValueException("Please specify a valid zone.");
}
-
+
// ACL check
checkZoneAccess(UserContext.current().getCaller(), zone);
-
+
//Validate the physical network
if (_physicalNetworkDao.findById(physicalNetworkId) == null) {
throw new InvalidParameterValueException("Please specify a valid physical network id");
}
-
+
//Validate the pod
if (podId != null) {
Pod pod = _podDao.findById(podId);
@@ -2302,10 +2302,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
//pod vlans can be created in basic zone only
if (zone.getNetworkType() != NetworkType.Basic || network.getTrafficType() != TrafficType.Guest) {
throw new InvalidParameterValueException("Pod id can be specified only for the networks of type "
- + TrafficType.Guest + " in zone of type " + NetworkType.Basic);
+ + TrafficType.Guest + " in zone of type " + NetworkType.Basic);
}
}
-
+
//1) if vlan is specified for the guest network range, it should be the same as network's vlan
//2) if vlan is missing, default it to the guest network's vlan
if (network.getTrafficType() == TrafficType.Guest) {
@@ -2315,7 +2315,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String[] vlan = uri.toString().split("vlan:\\/\\/");
networkVlanId = vlan[1];
}
-
+
if (vlanId != null) {
// if vlan is specified, throw an error if it's not equal to network's vlanId
if (networkVlanId != null && !networkVlanId.equalsIgnoreCase(vlanId)) {
@@ -2328,14 +2328,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
//vlan id is required for public network
throw new InvalidParameterValueException("Vlan id is required when add ip range to the public network");
}
-
+
if (vlanId == null) {
vlanId = Vlan.UNTAGGED;
}
VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
-
-
+
+
if (vlanOwner != null && zone.getNetworkType() != NetworkType.Advanced) {
throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced);
}
@@ -2484,7 +2484,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (vlan == null) {
throw new InvalidParameterValueException("Please specify a valid IP range id.");
}
-
+
boolean isAccountSpecific = false;
List<AccountVlanMapVO> acctVln = _accountVlanMapDao.listAccountVlanMapsByVlan(vlan.getId());
// Check for account wide pool. It will have an entry for account_vlan_map.
@@ -2502,25 +2502,25 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (vlan == null) {
throw new CloudRuntimeException("Unable to acquire vlan configuration: " + vlanDbId);
}
-
+
if (s_logger.isDebugEnabled()) {
s_logger.debug("lock vlan " + vlanDbId + " is acquired");
}
-
+
List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
-
+
for (IPAddressVO ip : ips) {
if (ip.isOneToOneNat()) {
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
" as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
}
-
+
if (ip.isSourceNat() && _networkMgr.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
" as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() +
". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
}
-
+
if (_firewallDao.countRulesByIpId(ip.getId()) > 0) {
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
" as ip " + ip + " belonging to the range has firewall rules applied. Cleanup the rules first");
@@ -2613,7 +2613,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
return true;
}
-
+
@DB
protected boolean savePublicIPRange(String startIP, String endIP, long zoneId, long vlanDbId, long sourceNetworkid, long physicalNetworkId) {
@@ -2816,7 +2816,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
}
-
+
private boolean validPod(long podId) {
return (_podDao.findById(podId) != null);
}
@@ -3021,7 +3021,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
// in Acton, don't allow to specify more than 1 provider per service
if (svcPrv.get(serviceStr) != null && svcPrv.get(serviceStr).size() > 1) {
throw new InvalidParameterValueException("In the current release only one provider can be " +
- "specified for the service");
+ "specified for the service");
}
for (String prvNameStr : svcPrv.get(serviceStr)) {
// check if provider is supported
@@ -3033,7 +3033,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (provider == Provider.JuniperSRX) {
firewallProvider = Provider.JuniperSRX;
}
-
+
if ((service == Service.PortForwarding || service == Service.StaticNat) && provider == Provider.VirtualRouter){
firewallProvider = Provider.VirtualRouter;
}
@@ -3053,7 +3053,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
serviceProviderMap.put(service, providers);
} else {
throw new InvalidParameterValueException("Service " + serviceStr + " is not enabled for the network " +
- "offering, can't add a provider to it");
+ "offering, can't add a provider to it");
}
}
}
@@ -3202,7 +3202,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
tags = cleanupTags(tags);
-
+
if (specifyVlan != specifyIpRanges) {
throw new InvalidParameterValueException("SpecifyVlan should be equal to specifyIpRanges which is " + specifyIpRanges);
}
@@ -3211,11 +3211,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (!specifyVlan && type == GuestType.Shared) {
throw new InvalidParameterValueException("SpecifyVlan should be true if network offering's type is " + type);
}
-
+
//specifyIpRanges should always be false for Isolated offering with Source nat service enabled
if (specifyVlan && type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat)) {
throw new InvalidParameterValueException("SpecifyVlan should be false if the network offering type is "
- + type + " and service " + Service.SourceNat.getName() + " is supported");
+ + type + " and service " + Service.SourceNat.getName() + " is supported");
}
// validate availability value
@@ -3235,7 +3235,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
}
-
+
boolean dedicatedLb = false;
boolean elasticLb = false;
boolean sharedSourceNat = false;
@@ -3245,7 +3245,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
boolean inline = false;
if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) {
Map<Capability, String> lbServiceCapabilityMap = serviceCapabilityMap.get(Service.Lb);
-
+
if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
String isolationCapability = lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
if (isolationCapability != null) {
@@ -3259,7 +3259,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (param != null) {
elasticLb = param.contains("true");
}
-
+
String inlineMode = lbServiceCapabilityMap.get(Capability.InlineMode);
if (inlineMode != null) {
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.InlineMode, inlineMode);
@@ -3326,7 +3326,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
_ntwkOffServiceMapDao.persist(offService);
s_logger.trace("Added service for the network offering: " + offService + " with provider " + provider.getName());
}
-
+
if (vpcOff) {
List<Service> supportedSvcs = new ArrayList<Service>();
supportedSvcs.addAll(serviceProviderMap.keySet());
@@ -3547,7 +3547,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (sourceNatSupported != null) {
addOffering = addOffering && (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
}
-
+
if (forVpc != null) {
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
} else if (network != null){
@@ -3666,14 +3666,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
if (availability == null) {
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: "
- + Availability.Required + ", " + Availability.Optional);
+ + Availability.Required + ", " + Availability.Optional);
} else {
if (availability == NetworkOffering.Availability.Required) {
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
&& _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
if (!canOffBeRequired) {
throw new InvalidParameterValueException("Availability can be " +
- NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
+ NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
+ Service.SourceNat.getName() + " enabled");
}
@@ -3681,7 +3681,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
List<NetworkOfferingVO> offerings = _networkOfferingDao.listByAvailability(Availability.Required, false);
if (!offerings.isEmpty() && offerings.get(0).getId() != offeringToUpdate.getId()) {
throw new InvalidParameterValueException("System already has network offering id=" +
- offerings.get(0).getId() + " with availability " + Availability.Required);
+ offerings.get(0).getId() + " with availability " + Availability.Required);
}
}
offering.setAvailability(availability);
@@ -3697,12 +3697,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
@Override
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_MARK_DEFAULT_ZONE, eventDescription = "Marking account with the " +
- "default zone", async=true)
+ "default zone", async=true)
public AccountVO markDefaultZone(String accountName, long domainId, long defaultZoneId) {
-
- // Check if the account exists
- Account account = _accountDao.findEnabledAccount(accountName, domainId);
- if (account == null) {
+
+ // Check if the account exists
+ Account account = _accountDao.findEnabledAccount(accountName, domainId);
+ if (account == null) {
s_logger.error("Unable to find account by name: " + accountName + " in domain " + domainId);
throw new InvalidParameterValueException("Account by name: " + accountName + " doesn't exist in domain " + domainId);
}
@@ -3710,20 +3710,20 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
// Don't allow modification of system account
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
throw new InvalidParameterValueException("Can not modify system account");
- }
-
- AccountVO acctForUpdate = _accountDao.findById(account.getId());
-
- acctForUpdate.setDefaultZoneId(defaultZoneId);
-
- if (_accountDao.update(account.getId(), acctForUpdate)) {
- UserContext.current().setEventDetails("Default zone id= " + defaultZoneId);
- return _accountDao.findById(account.getId());
- } else {
- return null;
- }
- }
-
+ }
+
+ AccountVO acctForUpdate = _accountDao.findById(account.getId());
+
+ acctForUpdate.setDefaultZoneId(defaultZoneId);
+
+ if (_accountDao.update(account.getId(), acctForUpdate)) {
+ UserContext.current().setEventDetails("Default zone id= " + defaultZoneId);
+ return _accountDao.findById(account.getId());
+ } else {
+ return null;
+ }
+ }
+
// Note: This method will be used for entity name validations in the coming
// releases (place holder for now)
private void validateEntityName(String str) {
@@ -3851,31 +3851,31 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
public ClusterVO getCluster(long id) {
return _clusterDao.findById(id);
}
-
+
@Override
public AllocationState findClusterAllocationState(ClusterVO cluster){
-
- if(cluster.getAllocationState() == AllocationState.Disabled){
- return AllocationState.Disabled;
- }else if(ApiDBUtils.findPodById(cluster.getPodId()).getAllocationState() == AllocationState.Disabled){
- return AllocationState.Disabled;
- }else {
- DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());
- return zone.getAllocationState();
- }
+
+ if(cluster.getAllocationState() == AllocationState.Disabled){
+ return AllocationState.Disabled;
+ }else if(ApiDBUtils.findPodById(cluster.getPodId()).getAllocationState() == AllocationState.Disabled){
+ return AllocationState.Disabled;
+ }else {
+ DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());
+ return zone.getAllocationState();
+ }
}
@Override
public AllocationState findPodAllocationState(HostPodVO pod){
-
- if(pod.getAllocationState() == AllocationState.Disabled){
- return AllocationState.Disabled;
- }else {
- DataCenterVO zone = ApiDBUtils.findZoneById(pod.getDataCenterId());
- return zone.getAllocationState();
- }
- }
-
+
+ if(pod.getAllocationState() == AllocationState.Disabled){
+ return AllocationState.Disabled;
+ }else {
+ DataCenterVO zone = ApiDBUtils.findZoneById(pod.getDataCenterId());
+ return zone.getAllocationState();
+ }
+ }
+
private boolean allowIpRangeOverlap(VlanVO vlan, boolean forVirtualNetwork, long networkId) {
// FIXME - delete restriction for virtual network in the future
if (vlan.getVlanType() == VlanType.DirectAttached && !forVirtualNetwork) {