http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/NetworkUsageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/NetworkUsageManagerImpl.java b/server/src/com/cloud/network/NetworkUsageManagerImpl.java index ebfeed1..fa4eb16 100644 --- a/server/src/com/cloud/network/NetworkUsageManagerImpl.java +++ b/server/src/com/cloud/network/NetworkUsageManagerImpl.java @@ -29,6 +29,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd; @@ -98,6 +99,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage TrafficSentinel; } + private static final org.apache.log4j.Logger s_logger = Logger.getLogger(NetworkUsageManagerImpl.class); @Inject HostDao _hostDao; @Inject @@ -150,7 +152,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage try { uri = new URI(cmd.getUrl()); } catch (Exception e) { - logger.debug(e); + s_logger.debug(e); throw new InvalidParameterValueException(e.getMessage()); } @@ -276,11 +278,11 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage HostVO host = _hostDao.findById(agentId); if (host != null) { if ((host.getManagementServerId() == null) || (mgmtSrvrId != host.getManagementServerId())) { - logger.warn("Not the owner. Not collecting Direct Network usage from TrafficMonitor : " + agentId); + s_logger.warn("Not the owner. Not collecting Direct Network usage from TrafficMonitor : " + agentId); return false; } } else { - logger.warn("Agent not found. Not collecting Direct Network usage from TrafficMonitor : " + agentId); + s_logger.warn("Agent not found. Not collecting Direct Network usage from TrafficMonitor : " + agentId); return false; } @@ -300,12 +302,12 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage } private boolean collectDirectNetworkUsage(final HostVO host) { - logger.debug("Direct Network Usage stats collector is running..."); + s_logger.debug("Direct Network Usage stats collector is running..."); final long zoneId = host.getDataCenterId(); final DetailVO lastCollectDetail = _detailsDao.findDetail(host.getId(), "last_collection"); if (lastCollectDetail == null) { - logger.warn("Last collection time not available. Skipping direct usage collection for Traffic Monitor: " + host.getId()); + s_logger.warn("Last collection time not available. Skipping direct usage collection for Traffic Monitor: " + host.getId()); return false; } Date lastCollection = new Date(Long.parseLong(lastCollectDetail.getValue())); @@ -321,7 +323,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage final Date now = rightNow.getTime(); if (lastCollection.after(now)) { - logger.debug("Current time is less than 2 hours after last collection time : " + lastCollection.toString() + + s_logger.debug("Current time is less than 2 hours after last collection time : " + lastCollection.toString() + ". Skipping direct network usage collection"); return false; } @@ -380,7 +382,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage if (answer == null || !answer.getResult()) { String details = (answer != null) ? answer.getDetails() : "details unavailable"; String msg = "Unable to get network usage stats from " + host.getId() + " due to: " + details + "."; - logger.error(msg); + s_logger.error(msg); return false; } else { for (UsageIPAddressVO usageIp : fullDurationIpUsage) { @@ -389,11 +391,11 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage Long bytesSent = bytesSentRcvd[0]; Long bytesRcvd = bytesSentRcvd[1]; if (bytesSent == null || bytesRcvd == null) { - logger.debug("Incorrect bytes for IP: " + publicIp); + s_logger.debug("Incorrect bytes for IP: " + publicIp); continue; } if (bytesSent == 0L && bytesRcvd == 0L) { - logger.trace("Ignore zero bytes for IP: " + publicIp); + s_logger.trace("Ignore zero bytes for IP: " + publicIp); continue; } UserStatisticsVO stats = new UserStatisticsVO(usageIp.getAccountId(), zoneId, null, null, null, null); @@ -413,7 +415,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage if (answer == null || !answer.getResult()) { String details = (answer != null) ? answer.getDetails() : "details unavailable"; String msg = "Unable to get network usage stats from " + host.getId() + " due to: " + details + "."; - logger.error(msg); + s_logger.error(msg); return false; } else { String publicIp = usageIp.getAddress(); @@ -421,11 +423,11 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage Long bytesSent = bytesSentRcvd[0]; Long bytesRcvd = bytesSentRcvd[1]; if (bytesSent == null || bytesRcvd == null) { - logger.debug("Incorrect bytes for IP: " + publicIp); + s_logger.debug("Incorrect bytes for IP: " + publicIp); continue; } if (bytesSent == 0L && bytesRcvd == 0L) { - logger.trace("Ignore zero bytes for IP: " + publicIp); + s_logger.trace("Ignore zero bytes for IP: " + publicIp); continue; } UserStatisticsVO stats = new UserStatisticsVO(usageIp.getAccountId(), zoneId, null, null, null, null); @@ -437,7 +439,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage } if (collectedStats.size() == 0) { - logger.debug("No new direct network stats. No need to persist"); + s_logger.debug("No new direct network stats. No need to persist"); return false; } //Persist all the stats and last_collection time in a single transaction @@ -477,8 +479,8 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage @Override public boolean processDisconnect(long agentId, Status state) { - if (logger.isDebugEnabled()) { - logger.debug("Disconnected called on " + agentId + " with status " + state.toString()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Disconnected called on " + agentId + " with status " + state.toString()); } return true; } @@ -487,12 +489,12 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance) { if (cmd instanceof StartupTrafficMonitorCommand) { long agentId = agent.getId(); - logger.debug("Sending RecurringNetworkUsageCommand to " + agentId); + s_logger.debug("Sending RecurringNetworkUsageCommand to " + agentId); RecurringNetworkUsageCommand watch = new RecurringNetworkUsageCommand(_interval); try { _agentMgr.send(agentId, new Commands(watch), this); } catch (AgentUnavailableException e) { - logger.debug("Can not process connect for host " + agentId, e); + s_logger.debug("Can not process connect for host " + agentId, e); } } return;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/StorageNetworkManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/StorageNetworkManagerImpl.java b/server/src/com/cloud/network/StorageNetworkManagerImpl.java index d155376..76a51d9 100644 --- a/server/src/com/cloud/network/StorageNetworkManagerImpl.java +++ b/server/src/com/cloud/network/StorageNetworkManagerImpl.java @@ -24,6 +24,7 @@ import java.util.List; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.network.CreateStorageNetworkIpRangeCmd; @@ -60,6 +61,7 @@ import com.cloud.vm.dao.SecondaryStorageVmDao; @Component @Local(value = {StorageNetworkManager.class, StorageNetworkService.class}) public class StorageNetworkManagerImpl extends ManagerBase implements StorageNetworkManager, StorageNetworkService { + private static final Logger s_logger = Logger.getLogger(StorageNetworkManagerImpl.class); @Inject StorageNetworkIpAddressDao _sNwIpDao; @@ -238,7 +240,7 @@ public class StorageNetworkManagerImpl extends ManagerBase implements StorageNet err.append("endIp=" + endIpFinal); err.append("netmask=" + netmask); err.append("zoneId=" + zoneId); - logger.debug(err.toString(), e); + s_logger.debug(err.toString(), e); throw e; } @@ -278,7 +280,7 @@ public class StorageNetworkManagerImpl extends ManagerBase implements StorageNet range = _sNwIpRangeDao.acquireInLockTable(rangeId); if (range == null) { String msg = "Unable to acquire lock on storage network ip range id=" + rangeId + ", delete failed"; - logger.warn(msg); + s_logger.warn(msg); throw new CloudRuntimeException(msg); } /* @@ -330,7 +332,7 @@ public class StorageNetworkManagerImpl extends ManagerBase implements StorageNet r = _sNwIpRangeDao.acquireInLockTable(rangeId); if (r == null) { String msg = "Unable to acquire lock on storage network ip range id=" + rangeId + ", delete failed"; - logger.warn(msg); + s_logger.warn(msg); throw new CloudRuntimeException(msg); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/as/AutoScaleManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index d372f81..01c1486 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -126,6 +127,7 @@ import com.cloud.vm.UserVmService; @Local(value = {AutoScaleService.class, AutoScaleManager.class}) public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScaleManager, AutoScaleService { + private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class); private ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1); @Inject @@ -380,7 +382,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } profileVO = checkValidityAndPersist(profileVO); - logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId()); + s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId()); return profileVO; } @@ -431,7 +433,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } vmProfile = checkValidityAndPersist(vmProfile); - logger.info("Updated Auto Scale Vm Profile id:" + vmProfile.getId()); + s_logger.info("Updated Auto Scale Vm Profile id:" + vmProfile.getId()); return vmProfile; } @@ -446,7 +448,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } boolean success = _autoScaleVmProfileDao.remove(id); if (success) { - logger.info("Successfully deleted AutoScale Vm Profile with Id: " + id); + s_logger.info("Successfully deleted AutoScale Vm Profile with Id: " + id); } return success; } @@ -575,7 +577,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale AutoScalePolicyVO policyVO = new AutoScalePolicyVO(cmd.getDomainId(), cmd.getAccountId(), duration, quietTime, null, action); policyVO = checkValidityAndPersist(policyVO, cmd.getConditionIds()); - logger.info("Successfully created AutoScale Policy with Id: " + policyVO.getId()); + s_logger.info("Successfully created AutoScale Policy with Id: " + policyVO.getId()); return policyVO; } @@ -596,15 +598,15 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale boolean success = true; success = _autoScalePolicyDao.remove(id); if (!success) { - logger.warn("Failed to remove AutoScale Policy db object"); + s_logger.warn("Failed to remove AutoScale Policy db object"); return false; } success = _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(id); if (!success) { - logger.warn("Failed to remove AutoScale Policy Condition mappings"); + s_logger.warn("Failed to remove AutoScale Policy Condition mappings"); return false; } - logger.info("Successfully deleted autoscale policy id : " + id); + s_logger.info("Successfully deleted autoscale policy id : " + id); return success; } @@ -736,7 +738,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale for (AutoScaleVmGroupPolicyMapVO vmGroupPolicy : vmGroupPolicyList) { AutoScaleVmGroupVO vmGroupVO = _autoScaleVmGroupDao.findById(vmGroupPolicy.getVmGroupId()); if (vmGroupVO == null) { - logger.warn("Stale database entry! There is an entry in VmGroupPolicyMap but the vmGroup is missing:" + vmGroupPolicy.getVmGroupId()); + s_logger.warn("Stale database entry! There is an entry in VmGroupPolicyMap but the vmGroup is missing:" + vmGroupPolicy.getVmGroupId()); continue; @@ -750,7 +752,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } policy = checkValidityAndPersist(policy, conditionIds); - logger.info("Successfully updated Auto Scale Policy id:" + policyId); + s_logger.info("Successfully updated Auto Scale Policy id:" + policyId); return policy; } @@ -787,7 +789,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } vmGroupVO = checkValidityAndPersist(vmGroupVO, cmd.getScaleUpPolicyIds(), cmd.getScaleDownPolicyIds()); - logger.info("Successfully created Autoscale Vm Group with Id: " + vmGroupVO.getId()); + s_logger.info("Successfully created Autoscale Vm Group with Id: " + vmGroupVO.getId()); return vmGroupVO; } @@ -811,7 +813,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } catch (ResourceUnavailableException re) { throw re; } catch (Exception e) { - logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e); + s_logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e); return false; } } @@ -842,7 +844,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale _autoScaleVmGroupDao.persist(autoScaleVmGroupVO); } finally { if (!success) { - logger.warn("Could not delete AutoScale Vm Group id : " + id); + s_logger.warn("Could not delete AutoScale Vm Group id : " + id); return false; } } @@ -853,17 +855,17 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale boolean success = _autoScaleVmGroupDao.remove(id); if (!success) { - logger.warn("Failed to remove AutoScale Group db object"); + s_logger.warn("Failed to remove AutoScale Group db object"); return false; } success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id); if (!success) { - logger.warn("Failed to remove AutoScale Group Policy mappings"); + s_logger.warn("Failed to remove AutoScale Group Policy mappings"); return false; } - logger.info("Successfully deleted autoscale vm group id : " + id); + s_logger.info("Successfully deleted autoscale vm group id : " + id); return success; // Successfull } }); @@ -1037,7 +1039,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale vmGroupVO = checkValidityAndPersist(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds); if (vmGroupVO != null) { - logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId); + s_logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId); return vmGroupVO; } else return null; @@ -1062,10 +1064,10 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale _autoScaleVmGroupDao.persist(vmGroup); } finally { if (!success) { - logger.warn("Failed to enable AutoScale Vm Group id : " + id); + s_logger.warn("Failed to enable AutoScale Vm Group id : " + id); return null; } - logger.info("Successfully enabled AutoScale Vm Group with Id:" + id); + s_logger.info("Successfully enabled AutoScale Vm Group with Id:" + id); } return vmGroup; } @@ -1089,10 +1091,10 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale _autoScaleVmGroupDao.persist(vmGroup); } finally { if (!success) { - logger.warn("Failed to disable AutoScale Vm Group id : " + id); + s_logger.warn("Failed to disable AutoScale Vm Group id : " + id); return null; } - logger.info("Successfully disabled AutoScale Vm Group with Id:" + id); + s_logger.info("Successfully disabled AutoScale Vm Group with Id:" + id); } return vmGroup; } @@ -1113,7 +1115,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale CounterVO counter = null; - logger.debug("Adding Counter " + name); + s_logger.debug("Adding Counter " + name); counter = _counterDao.persist(new CounterVO(src, name, cmd.getValue())); CallContext.current().setEventDetails(" Id: " + counter.getId() + " Name: " + name); @@ -1144,7 +1146,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale ConditionVO condition = null; condition = _conditionDao.persist(new ConditionVO(cid, threshold, cmd.getEntityOwnerId(), cmd.getDomainId(), op)); - logger.info("Successfully created condition with Id: " + condition.getId()); + s_logger.info("Successfully created condition with Id: " + condition.getId()); CallContext.current().setEventDetails(" Id: " + condition.getId()); return condition; @@ -1213,13 +1215,13 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale ConditionVO condition = _conditionDao.findByCounterId(counterId); if (condition != null) { - logger.info("Cannot delete counter " + counter.getName() + " as it is being used in a condition."); + s_logger.info("Cannot delete counter " + counter.getName() + " as it is being used in a condition."); throw new ResourceInUseException("Counter is in use."); } boolean success = _counterDao.remove(counterId); if (success) { - logger.info("Successfully deleted counter with Id: " + counterId); + s_logger.info("Successfully deleted counter with Id: " + counterId); } return success; @@ -1236,12 +1238,12 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale // Verify if condition is used in any autoscale policy if (_autoScalePolicyConditionMapDao.isConditionInUse(conditionId)) { - logger.info("Cannot delete condition " + conditionId + " as it is being used in a condition."); + s_logger.info("Cannot delete condition " + conditionId + " as it is being used in a condition."); throw new ResourceInUseException("Cannot delete Condition when it is in use by one or more AutoScale Policies."); } boolean success = _conditionDao.remove(conditionId); if (success) { - logger.info("Successfully deleted condition " + condition.getId()); + s_logger.info("Successfully deleted condition " + condition.getId()); } return success; } @@ -1252,15 +1254,15 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale int count = 0; count = _autoScaleVmProfileDao.removeByAccountId(accountId); if (count > 0) { - logger.debug("Deleted " + count + " AutoScale Vm Profile for account Id: " + accountId); + s_logger.debug("Deleted " + count + " AutoScale Vm Profile for account Id: " + accountId); } count = _autoScalePolicyDao.removeByAccountId(accountId); if (count > 0) { - logger.debug("Deleted " + count + " AutoScale Policies for account Id: " + accountId); + s_logger.debug("Deleted " + count + " AutoScale Policies for account Id: " + accountId); } count = _conditionDao.removeByAccountId(accountId); if (count > 0) { - logger.debug("Deleted " + count + " Conditions for account Id: " + accountId); + s_logger.debug("Deleted " + count + " Conditions for account Id: " + accountId); } } @@ -1269,7 +1271,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId()); Integer maxVm = asGroup.getMaxMembers(); if (currentVM + numVm > maxVm) { - logger.warn("number of VM will greater than the maximum in this group if scaling up, so do nothing more"); + s_logger.warn("number of VM will greater than the maximum in this group if scaling up, so do nothing more"); return false; } return true; @@ -1279,7 +1281,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId()); Integer minVm = asGroup.getMinMembers(); if (currentVM - 1 < minVm) { - logger.warn("number of VM will less than the minimum in this group if scaling down, so do nothing more"); + s_logger.warn("number of VM will less than the minimum in this group if scaling down, so do nothing more"); return false; } return true; @@ -1347,17 +1349,17 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale return -1; } } catch (InsufficientCapacityException ex) { - logger.info(ex); - logger.trace(ex.getMessage(), ex); + s_logger.info(ex); + s_logger.trace(ex.getMessage(), ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (ResourceUnavailableException ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (ResourceAllocationException ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage()); } } @@ -1374,10 +1376,10 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale CallContext.current().setEventDetails("Vm Id: " + vmId); _userVmManager.startVirtualMachine(vmId, null, null, null); } catch (final ResourceUnavailableException ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); @@ -1386,8 +1388,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); } } - logger.info(ex); - logger.info(message.toString(), ex); + s_logger.info(ex); + s_logger.info(message.toString(), ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); } return true; @@ -1402,7 +1404,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale for (LoadBalancerVMMapVO LbVmMapVo : LbVmMapVos) { long instanceId = LbVmMapVo.getInstanceId(); if (instanceId == vmId) { - logger.warn("the new VM is already mapped to LB rule. What's wrong?"); + s_logger.warn("the new VM is already mapped to LB rule. What's wrong?"); return true; } } @@ -1435,7 +1437,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale public void doScaleUp(long groupId, Integer numVm) { AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId); if (asGroup == null) { - logger.error("Can not find the groupid " + groupId + " for scaling up"); + s_logger.error("Can not find the groupid " + groupId + " for scaling up"); return; } if (!checkConditionUp(asGroup, numVm)) { @@ -1444,7 +1446,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale for (int i = 0; i < numVm; i++) { long vmId = createNewVM(asGroup); if (vmId == -1) { - logger.error("Can not deploy new VM for scaling up in the group " + s_logger.error("Can not deploy new VM for scaling up in the group " + asGroup.getId() + ". Waiting for next round"); break; } @@ -1467,11 +1469,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale } } } else { - logger.error("Can not assign LB rule for this new VM"); + s_logger.error("Can not assign LB rule for this new VM"); break; } } else { - logger.error("Can not deploy new VM for scaling up in the group " + s_logger.error("Can not deploy new VM for scaling up in the group " + asGroup.getId() + ". Waiting for next round"); break; } @@ -1482,7 +1484,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale public void doScaleDown(final long groupId) { AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId); if (asGroup == null) { - logger.error("Can not find the groupid " + groupId + " for scaling up"); + s_logger.error("Can not find the groupid " + groupId + " for scaling up"); return; } if (!checkConditionDown(asGroup)) { @@ -1525,7 +1527,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale }, destroyVmGracePeriod, TimeUnit.SECONDS); } } else { - logger.error("Can not remove LB rule for the VM being destroyed. Do nothing more."); + s_logger.error("Can not remove LB rule for the VM being destroyed. Do nothing more."); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/element/CloudZonesNetworkElement.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java index 0346fd5..5dfc127 100644 --- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java +++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java @@ -23,6 +23,7 @@ import java.util.Set; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -61,6 +62,7 @@ import com.cloud.vm.dao.UserVmDao; @Local(value = NetworkElement.class) public class CloudZonesNetworkElement extends AdapterBase implements NetworkElement, UserDataServiceProvider { + private static final Logger s_logger = Logger.getLogger(CloudZonesNetworkElement.class); private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities(); @@ -225,15 +227,15 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem try { _agentManager.send(dest.getHost().getId(), cmds); } catch (OperationTimedoutException e) { - logger.debug("Unable to send vm data command to host " + dest.getHost()); + s_logger.debug("Unable to send vm data command to host " + dest.getHost()); return false; } Answer dataAnswer = cmds.getAnswer("vmdata"); if (dataAnswer != null && dataAnswer.getResult()) { - logger.info("Sent vm data successfully to vm " + uservm.getInstanceName()); + s_logger.info("Sent vm data successfully to vm " + uservm.getInstanceName()); return true; } - logger.info("Failed to send vm data to vm " + uservm.getInstanceName()); + s_logger.info("Failed to send vm data to vm " + uservm.getInstanceName()); return false; } return false; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/element/HAProxyLBRule.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/element/HAProxyLBRule.java b/server/src/com/cloud/network/element/HAProxyLBRule.java deleted file mode 100644 index 406ef27..0000000 --- a/server/src/com/cloud/network/element/HAProxyLBRule.java +++ /dev/null @@ -1,134 +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.network.element; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.network.lb.LoadBalancingRule; -import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; -import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType; -import com.cloud.utils.Pair; -import com.cloud.utils.net.NetUtils; - -@Component -public class HAProxyLBRule { - - private Logger logger = Logger.getLogger(getClass()); - - public boolean validateHAProxyLBRule(final LoadBalancingRule rule) { - final String timeEndChar = "dhms"; - - if (rule.getSourcePortStart() == NetUtils.HAPROXY_STATS_PORT) { - logger.debug("Can't create LB on port 8081, haproxy is listening for LB stats on this port"); - return false; - } - - for (final LbStickinessPolicy stickinessPolicy : rule.getStickinessPolicies()) { - final List<Pair<String, String>> paramsList = stickinessPolicy.getParams(); - - if (StickinessMethodType.LBCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { - - } else if (StickinessMethodType.SourceBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { - String tablesize = "200k"; // optional - String expire = "30m"; // optional - - /* overwrite default values with the stick parameters */ - for (final Pair<String, String> paramKV : paramsList) { - final String key = paramKV.first(); - final String value = paramKV.second(); - if ("tablesize".equalsIgnoreCase(key)) { - tablesize = value; - } - if ("expire".equalsIgnoreCase(key)) { - expire = value; - } - } - if (expire != null && !containsOnlyNumbers(expire, timeEndChar)) { - throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: expire is not in timeformat: " + expire); - } - if (tablesize != null && !containsOnlyNumbers(tablesize, "kmg")) { - throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: tablesize is not in size format: " + tablesize); - - } - } else if (StickinessMethodType.AppCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { - String length = null; // optional - String holdTime = null; // optional - - for (final Pair<String, String> paramKV : paramsList) { - final String key = paramKV.first(); - final String value = paramKV.second(); - if ("length".equalsIgnoreCase(key)) { - length = value; - } - if ("holdtime".equalsIgnoreCase(key)) { - holdTime = value; - } - } - - if (length != null && !containsOnlyNumbers(length, null)) { - throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: length is not a number: " + length); - } - if (holdTime != null && !containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(holdTime, null)) { - throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: holdtime is not in timeformat: " + holdTime); - } - } - } - return true; - } - - /** - * This function detects numbers like 12 ,32h ,42m .. etc,. 1) plain number - * like 12 2) time or tablesize like 12h, 34m, 45k, 54m , here last - * character is non-digit but from known characters . - */ - private static boolean containsOnlyNumbers(final String str, final String endChar) { - if (str == null) { - return false; - } - - String number = str; - if (endChar != null) { - boolean matchedEndChar = false; - if (str.length() < 2) { - return false; // at least one numeric and one char. example: - } - // 3h - final char strEnd = str.toCharArray()[str.length() - 1]; - for (final char c : endChar.toCharArray()) { - if (strEnd == c) { - number = str.substring(0, str.length() - 1); - matchedEndChar = true; - break; - } - } - if (!matchedEndChar) { - return false; - } - } - try { - Integer.parseInt(number); - } catch (final NumberFormatException e) { - return false; - } - return true; - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/element/VirtualRouterElement.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index feb4cc7..1a340fa 100644 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -33,6 +33,7 @@ import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsC import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.network.topology.NetworkTopology; import org.apache.cloudstack.network.topology.NetworkTopologyContext; +import org.apache.log4j.Logger; import org.cloud.network.router.deployment.RouterDeploymentDefinition; import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder; @@ -72,6 +73,7 @@ import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.OvsProviderDao; import com.cloud.network.dao.VirtualRouterProviderDao; import com.cloud.network.lb.LoadBalancingRule; +import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.lb.LoadBalancingRulesManager; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; @@ -88,11 +90,13 @@ import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; +import com.cloud.utils.Pair; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.QueryBuilder; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.net.NetUtils; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; @@ -110,6 +114,7 @@ import com.google.gson.Gson; public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, NetworkMigrationResponder, AggregatedCommandExecutor { + private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class); public static final AutoScaleCounterType AutoScaleCounterCpu = new AutoScaleCounterType("cpu"); public static final AutoScaleCounterType AutoScaleCounterMemory = new AutoScaleCounterType("memory"); protected static final Map<Service, Map<Capability, String>> capabilities = setCapabilities(); @@ -159,9 +164,6 @@ NetworkMigrationResponder, AggregatedCommandExecutor { @Inject protected RouterDeploymentDefinitionBuilder routerDeploymentDefinitionBuilder; - @Inject - private HAProxyLBRule haProxyLBRule; - protected boolean canHandle(final Network network, final Service service) { final Long physicalNetworkId = _networkMdl.getPhysicalNetworkId(network); if (physicalNetworkId == null) { @@ -178,12 +180,12 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (service == null) { if (!_networkMdl.isProviderForNetwork(getProvider(), network.getId())) { - logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); + s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); return false; } } else { if (!_networkMdl.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) { - logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network); + s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network); return false; } } @@ -263,7 +265,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.Firewall)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -289,6 +291,104 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } } + /* + * This function detects numbers like 12 ,32h ,42m .. etc,. 1) plain number + * like 12 2) time or tablesize like 12h, 34m, 45k, 54m , here last + * character is non-digit but from known characters . + */ + private static boolean containsOnlyNumbers(final String str, final String endChar) { + if (str == null) { + return false; + } + + String number = str; + if (endChar != null) { + boolean matchedEndChar = false; + if (str.length() < 2) { + return false; // at least one numeric and one char. example: + } + // 3h + final char strEnd = str.toCharArray()[str.length() - 1]; + for (final char c : endChar.toCharArray()) { + if (strEnd == c) { + number = str.substring(0, str.length() - 1); + matchedEndChar = true; + break; + } + } + if (!matchedEndChar) { + return false; + } + } + try { + Integer.parseInt(number); + } catch (final NumberFormatException e) { + return false; + } + return true; + } + + public static boolean validateHAProxyLBRule(final LoadBalancingRule rule) { + final String timeEndChar = "dhms"; + + if (rule.getSourcePortStart() == NetUtils.HAPROXY_STATS_PORT) { + s_logger.debug("Can't create LB on port 8081, haproxy is listening for LB stats on this port"); + return false; + } + + for (final LbStickinessPolicy stickinessPolicy : rule.getStickinessPolicies()) { + final List<Pair<String, String>> paramsList = stickinessPolicy.getParams(); + + if (StickinessMethodType.LBCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { + + } else if (StickinessMethodType.SourceBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { + String tablesize = "200k"; // optional + String expire = "30m"; // optional + + /* overwrite default values with the stick parameters */ + for (final Pair<String, String> paramKV : paramsList) { + final String key = paramKV.first(); + final String value = paramKV.second(); + if ("tablesize".equalsIgnoreCase(key)) { + tablesize = value; + } + if ("expire".equalsIgnoreCase(key)) { + expire = value; + } + } + if (expire != null && !containsOnlyNumbers(expire, timeEndChar)) { + throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: expire is not in timeformat: " + expire); + } + if (tablesize != null && !containsOnlyNumbers(tablesize, "kmg")) { + throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: tablesize is not in size format: " + tablesize); + + } + } else if (StickinessMethodType.AppCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) { + String length = null; // optional + String holdTime = null; // optional + + for (final Pair<String, String> paramKV : paramsList) { + final String key = paramKV.first(); + final String value = paramKV.second(); + if ("length".equalsIgnoreCase(key)) { + length = value; + } + if ("holdtime".equalsIgnoreCase(key)) { + holdTime = value; + } + } + + if (length != null && !containsOnlyNumbers(length, null)) { + throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: length is not a number: " + length); + } + if (holdTime != null && !containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(holdTime, null)) { + throw new InvalidParameterValueException("Failed LB in validation rule id: " + rule.getId() + " Cause: holdtime is not in timeformat: " + holdTime); + } + } + } + return true; + } + @Override public boolean validateLBRule(final Network network, final LoadBalancingRule rule) { final List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>(); @@ -298,7 +398,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (routers == null || routers.isEmpty()) { return true; } - return haProxyLBRule.validateHAProxyLBRule(rule); + return validateHAProxyLBRule(rule); } return true; } @@ -312,7 +412,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply lb rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply lb rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -339,7 +439,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.Vpn)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router" + " doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router" + " doesn't exist in the network " + network.getId()); return null; } @@ -348,7 +448,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { return networkTopology.applyVpnUsers(network, users, routers); } else { - logger.debug("Element " + getName() + " doesn't handle applyVpnUsers command"); + s_logger.debug("Element " + getName() + " doesn't handle applyVpnUsers command"); return null; } } @@ -363,12 +463,12 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.Vpn)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't" + " exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't" + " exist in the network " + network.getId()); return true; } return _routerMgr.startRemoteAccessVpn(network, vpn, routers); } else { - logger.debug("Element " + getName() + " doesn't handle createVpn command"); + s_logger.debug("Element " + getName() + " doesn't handle createVpn command"); return false; } } @@ -383,12 +483,12 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.Vpn)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't " + "exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need stop vpn on the backend; virtual router doesn't " + "exist in the network " + network.getId()); return true; } return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers); } else { - logger.debug("Element " + getName() + " doesn't handle removeVpn command"); + s_logger.debug("Element " + getName() + " doesn't handle removeVpn command"); return false; } } @@ -405,7 +505,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to associate ip addresses on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to associate ip addresses on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -562,7 +662,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.StaticNat)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -586,11 +686,11 @@ NetworkMigrationResponder, AggregatedCommandExecutor { result = result && _routerMgr.stop(router, false, context.getCaller(), context.getAccount()) != null; if (cleanup) { if (!result) { - logger.warn("Failed to stop virtual router element " + router + ", but would try to process clean up anyway."); + s_logger.warn("Failed to stop virtual router element " + router + ", but would try to process clean up anyway."); } result = _routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null; if (!result) { - logger.warn("Failed to clean up virtual router element " + router); + s_logger.warn("Failed to clean up virtual router element " + router); } } } @@ -622,7 +722,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Can't find virtual router element in network " + network.getId()); + s_logger.debug("Can't find virtual router element in network " + network.getId()); return true; } @@ -659,7 +759,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Can't find virtual router element in network " + network.getId()); + s_logger.debug("Can't find virtual router element in network " + network.getId()); return true; } @@ -678,7 +778,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Can't find virtual router element in network " + network.getId()); + s_logger.debug("Can't find virtual router element in network " + network.getId()); return true; } @@ -703,7 +803,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { public VirtualRouterProvider configure(final ConfigureVirtualRouterElementCmd cmd) { final VirtualRouterProviderVO element = _vrProviderDao.findById(cmd.getId()); if (element == null || !(element.getType() == Type.VirtualRouter || element.getType() == Type.VPCVirtualRouter)) { - logger.debug("Can't find Virtual Router element with network service provider id " + cmd.getId()); + s_logger.debug("Can't find Virtual Router element with network service provider id " + cmd.getId()); return null; } @@ -717,7 +817,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { public OvsProvider configure(final ConfigureOvsElementCmd cmd) { final OvsProviderVO element = _ovsProviderDao.findById(cmd.getId()); if (element == null) { - logger.debug("Can't find Ovs element with network service provider id " + cmd.getId()); + s_logger.debug("Can't find Ovs element with network service provider id " + cmd.getId()); return null; } @@ -734,7 +834,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, providerType); if (element != null) { - logger.debug("There is already a virtual router element with service provider id " + nspId); + s_logger.debug("There is already a virtual router element with service provider id " + nspId); return null; } element = new VirtualRouterProviderVO(nspId, providerType); @@ -747,7 +847,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (canHandle(network, Service.PortForwarding)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -851,7 +951,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { try { return _routerMgr.removeDhcpSupportForSubnet(network, routers); } catch (final ResourceUnavailableException e) { - logger.debug("Router resource unavailable "); + s_logger.debug("Router resource unavailable "); } } return false; @@ -890,7 +990,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { } if (network.getIp6Gateway() != null) { - logger.info("Skip password and userdata service setup for IPv6 VM"); + s_logger.info("Skip password and userdata service setup for IPv6 VM"); return true; } @@ -1017,7 +1117,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { if (schemeCaps != null) { for (final LoadBalancingRule rule : rules) { if (!schemeCaps.contains(rule.getScheme().toString())) { - logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + getName()); + s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + getName()); return false; } } @@ -1041,7 +1141,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { try { networkTopology.setupDhcpForPvlan(false, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { - logger.warn("Timed Out", e); + s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; @@ -1066,7 +1166,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { try { networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { - logger.warn("Timed Out", e); + s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; @@ -1090,7 +1190,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor { try { networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { - logger.warn("Timed Out", e); + s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/element/VpcVirtualRouterElement.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java index 9e5d81b..078eab3 100644 --- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java @@ -25,6 +25,7 @@ import javax.ejb.Local; import javax.inject.Inject; import org.apache.cloudstack.network.topology.NetworkTopology; +import org.apache.log4j.Logger; import org.cloud.network.router.deployment.RouterDeploymentDefinition; import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder; import org.springframework.beans.factory.annotation.Autowired; @@ -82,6 +83,7 @@ import com.cloud.vm.VirtualMachineProfile; NetworkACLServiceProvider.class }) public class VpcVirtualRouterElement extends VirtualRouterElement implements VpcProvider, Site2SiteVpnServiceProvider, NetworkACLServiceProvider { + private static final Logger s_logger = Logger.getLogger(VpcVirtualRouterElement.class); private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities(); @@ -134,12 +136,12 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc if (service == null) { if (!_networkMdl.isProviderForNetwork(getProvider(), network.getId())) { - logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); + s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); return false; } } else { if (!_networkMdl.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) { - logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network); + s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network); return false; } } @@ -182,13 +184,13 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final Long vpcId = network.getVpcId(); if (vpcId == null) { - logger.trace("Network " + network + " is not associated with any VPC"); + s_logger.trace("Network " + network + " is not associated with any VPC"); return false; } final Vpc vpc = _vpcMgr.getActiveVpc(vpcId); if (vpc == null) { - logger.warn("Unable to find Enabled VPC by id " + vpcId); + s_logger.warn("Unable to find Enabled VPC by id " + vpcId); return false; } @@ -217,7 +219,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc protected void configureGuestNetwork(final Network network, final List<DomainRouterVO> routers ) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); + s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); for (final DomainRouterVO router : routers) { if (!_networkMdl.isVmPartOfNetwork(router.getId(), network.getId())) { @@ -226,9 +228,9 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc paramsForRouter.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); } if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(router, network, paramsForRouter)) { - logger.error("Failed to add VPC router " + router + " to guest network " + network); + s_logger.error("Failed to add VPC router " + router + " to guest network " + network); } else { - logger.debug("Successfully added VPC router " + router + " to guest network " + network); + s_logger.debug("Successfully added VPC router " + router + " to guest network " + network); } } } @@ -240,13 +242,13 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final Long vpcId = network.getVpcId(); if (vpcId == null) { - logger.trace("Network " + network + " is not associated with any VPC"); + s_logger.trace("Network " + network + " is not associated with any VPC"); return false; } final Vpc vpc = _vpcMgr.getActiveVpc(vpcId); if (vpc == null) { - logger.warn("Unable to find Enabled VPC by id " + vpcId); + s_logger.warn("Unable to find Enabled VPC by id " + vpcId); return false; } @@ -279,7 +281,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc boolean success = true; final Long vpcId = network.getVpcId(); if (vpcId == null) { - logger.debug("Network " + network + " doesn't belong to any vpc, so skipping unplug nic part"); + s_logger.debug("Network " + network + " doesn't belong to any vpc, so skipping unplug nic part"); return success; } @@ -287,15 +289,15 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc for (final VirtualRouter router : routers) { // 1) Check if router is already a part of the network if (!_networkMdl.isVmPartOfNetwork(router.getId(), network.getId())) { - logger.debug("Router " + router + " is not a part the network " + network); + s_logger.debug("Router " + router + " is not a part the network " + network); continue; } // 2) Call unplugNics in the network service success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, network); if (!success) { - logger.warn("Failed to unplug nic in network " + network + " for virtual router " + router); + s_logger.warn("Failed to unplug nic in network " + network + " for virtual router " + router); } else { - logger.debug("Successfully unplugged nic in network " + network + " for virtual router " + router); + s_logger.debug("Successfully unplugged nic in network " + network + " for virtual router " + router); } } @@ -307,7 +309,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc boolean success = true; final Long vpcId = config.getVpcId(); if (vpcId == null) { - logger.debug("Network " + config + " doesn't belong to any vpc, so skipping unplug nic part"); + s_logger.debug("Network " + config + " doesn't belong to any vpc, so skipping unplug nic part"); return success; } @@ -315,15 +317,15 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc for (final VirtualRouter router : routers) { // 1) Check if router is already a part of the network if (!_networkMdl.isVmPartOfNetwork(router.getId(), config.getId())) { - logger.debug("Router " + router + " is not a part the network " + config); + s_logger.debug("Router " + router + " is not a part the network " + config); continue; } // 2) Call unplugNics in the network service success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config); if (!success) { - logger.warn("Failed to unplug nic in network " + config + " for virtual router " + router); + s_logger.warn("Failed to unplug nic in network " + config + " for virtual router " + router); } else { - logger.debug("Successfully unplugged nic in network " + config + " for virtual router " + router); + s_logger.debug("Successfully unplugged nic in network " + config + " for virtual router " + router); } } @@ -347,13 +349,13 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc //For the 2nd time it returns the VPC routers. final Long vpcId = network.getVpcId(); if (vpcId == null) { - logger.error("Network " + network + " is not associated with any VPC"); + s_logger.error("Network " + network + " is not associated with any VPC"); return routers; } final Vpc vpc = _vpcMgr.getActiveVpc(vpcId); if (vpc == null) { - logger.warn("Unable to find Enabled VPC by id " + vpcId); + s_logger.warn("Unable to find Enabled VPC by id " + vpcId); return routers; } @@ -367,11 +369,11 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc try { routers = routerDeploymentDefinition.deployVirtualRouter(); } catch (final ConcurrentOperationException e) { - logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); + s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); } catch (final InsufficientCapacityException e) { - logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); + s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); } catch (final ResourceUnavailableException e) { - logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); + s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e); } return routers; @@ -411,17 +413,17 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc @Override public boolean createPrivateGateway(final PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException { if (gateway.getType() != VpcGateway.Type.Private) { - logger.warn("Type of vpc gateway is not " + VpcGateway.Type.Private); + s_logger.warn("Type of vpc gateway is not " + VpcGateway.Type.Private); return false; } final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId()); if (routers == null || routers.isEmpty()) { - logger.debug(getName() + " element doesn't need to create Private gateway on the backend; VPC virtual " + "router doesn't exist in the vpc id=" + gateway.getVpcId()); + s_logger.debug(getName() + " element doesn't need to create Private gateway on the backend; VPC virtual " + "router doesn't exist in the vpc id=" + gateway.getVpcId()); return true; } - logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); + s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); final DataCenterVO dcVO = _dcDao.findById(gateway.getZoneId()); final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO); @@ -431,15 +433,15 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc try { final List<NetworkACLItemVO> rules = _networkACLItemDao.listByACL(gateway.getNetworkACLId()); if (!applyACLItemsToPrivateGw(gateway, rules)) { - logger.debug("Failed to apply network acl id " + gateway.getNetworkACLId() + " on gateway "); + s_logger.debug("Failed to apply network acl id " + gateway.getNetworkACLId() + " on gateway "); return false; } } catch (final Exception ex) { - logger.debug("Failed to apply network acl id " + gateway.getNetworkACLId() + " on gateway "); + s_logger.debug("Failed to apply network acl id " + gateway.getNetworkACLId() + " on gateway "); return false; } } else { - logger.debug("Failed to setup private gateway " + gateway); + s_logger.debug("Failed to setup private gateway " + gateway); return false; } } @@ -450,17 +452,17 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc @Override public boolean deletePrivateGateway(final PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException { if (gateway.getType() != VpcGateway.Type.Private) { - logger.warn("Type of vpc gateway is not " + VpcGateway.Type.Private); + s_logger.warn("Type of vpc gateway is not " + VpcGateway.Type.Private); return false; } final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId()); if (routers == null || routers.isEmpty()) { - logger.debug(getName() + " element doesn't need to delete Private gateway on the backend; VPC virtual " + "router doesn't exist in the vpc id=" + gateway.getVpcId()); + s_logger.debug(getName() + " element doesn't need to delete Private gateway on the backend; VPC virtual " + "router doesn't exist in the vpc id=" + gateway.getVpcId()); return true; } - logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); + s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); int result = 0; for (final DomainRouterVO domainRouterVO : routers) { @@ -484,7 +486,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc if (canHandle) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " + "router doesn't exist in the network " + s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -503,7 +505,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc if (canHandle(network, Service.NetworkACL)) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -517,7 +519,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc return true; } } catch (final Exception ex) { - logger.debug("Failed to apply network acl in network " + network.getId()); + s_logger.debug("Failed to apply network acl in network " + network.getId()); return false; } } else { @@ -534,7 +536,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc public boolean applyStaticRoutes(final Vpc vpc, final List<StaticRouteProfile> routes) throws ResourceUnavailableException { final List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId()); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router elemnt doesn't need to static routes on the backend; virtual " + "router doesn't exist in the vpc " + vpc); + s_logger.debug("Virtual router elemnt doesn't need to static routes on the backend; virtual " + "router doesn't exist in the vpc " + vpc); return true; } @@ -544,7 +546,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc if (!networkTopology.applyStaticRoutes(routes, routers)) { throw new CloudRuntimeException("Failed to apply static routes in vpc " + vpc); } else { - logger.debug("Applied static routes on vpc " + vpc); + s_logger.debug("Applied static routes on vpc " + vpc); return true; } } @@ -556,7 +558,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId()); if (routers == null || routers.isEmpty()) { - logger.debug("Virtual router element doesn't need to apply network acl rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); + s_logger.debug("Virtual router element doesn't need to apply network acl rules on the backend; virtual " + "router doesn't exist in the network " + network.getId()); return true; } @@ -577,7 +579,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn); if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) { - logger.error("try to start site 2 site vpn on unsupported network element?"); + s_logger.error("try to start site 2 site vpn on unsupported network element?"); return false; } @@ -608,7 +610,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final Map<Capability, String> vpnCapabilities = capabilities.get(Service.Vpn); if (!vpnCapabilities.get(Capability.VpnTypes).contains("s2svpn")) { - logger.error("try to stop site 2 site vpn on unsupported network element?"); + s_logger.error("try to stop site 2 site vpn on unsupported network element?"); return false; } @@ -641,7 +643,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpn.getVpcId()); if (routers == null) { - logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); + s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); return null; } @@ -664,7 +666,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpn.getVpcId()); if (routers == null) { - logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); + s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); return false; } @@ -683,7 +685,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpn.getVpcId()); if (routers == null) { - logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); + s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpn.getVpcId()); return false; }
