Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F33D10F20 for ; Thu, 21 Nov 2013 15:27:57 +0000 (UTC) Received: (qmail 82688 invoked by uid 500); 21 Nov 2013 15:26:57 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 82520 invoked by uid 500); 21 Nov 2013 15:26:51 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 82234 invoked by uid 99); 21 Nov 2013 15:26:49 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Nov 2013 15:26:49 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 23EAF89B2E8; Thu, 21 Nov 2013 15:26:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ahuang@apache.org To: commits@cloudstack.apache.org Date: Thu, 21 Nov 2013 15:26:53 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [06/54] [abbrv] [partial] Reformatted all of the code. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java index 4e55217..93f969f 100755 --- a/engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java @@ -61,15 +61,16 @@ public interface OrchestrationService { @POST @Path("/createvm") VirtualMachineEntity createVirtualMachine(@QueryParam("id") String id, @QueryParam("owner") String owner, @QueryParam("template-id") String templateId, - @QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor, @QueryParam("cpu") int cpu, - @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize, @QueryParam("compute-tags") List computeTags, - @QueryParam("root-disk-tags") List rootDiskTags, @QueryParam("network-nic-map") Map networkNicMap, - @QueryParam("deploymentplan") DeploymentPlan plan, @QueryParam("root-disk-size") Long rootDiskSize) throws InsufficientCapacityException; + @QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor, + @QueryParam("cpu") int cpu, @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize, + @QueryParam("compute-tags") List computeTags, @QueryParam("root-disk-tags") List rootDiskTags, + @QueryParam("network-nic-map") Map networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan, + @QueryParam("root-disk-size") Long rootDiskSize) throws InsufficientCapacityException; @POST VirtualMachineEntity createVirtualMachineFromScratch(@QueryParam("id") String id, @QueryParam("owner") String owner, @QueryParam("iso-id") String isoId, - @QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor, @QueryParam("os") String os, - @QueryParam("cpu") int cpu, @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize, + @QueryParam("host-name") String hostName, @QueryParam("display-name") String displayName, @QueryParam("hypervisor") String hypervisor, + @QueryParam("os") String os, @QueryParam("cpu") int cpu, @QueryParam("speed") int speed, @QueryParam("ram") long memory, @QueryParam("disk-size") Long diskSize, @QueryParam("compute-tags") List computeTags, @QueryParam("root-disk-tags") List rootDiskTags, @QueryParam("network-nic-map") Map networkNicMap, @QueryParam("deploymentplan") DeploymentPlan plan) throws InsufficientCapacityException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java index f73d6aa..3d73721 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java @@ -18,12 +18,13 @@ */ package org.apache.cloudstack.engine.subsystem.api.storage; -import com.cloud.agent.api.to.DataStoreTO; -import com.cloud.agent.api.to.DataTO; +import java.util.Map; + import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.command.CommandResult; -import java.util.Map; +import com.cloud.agent.api.to.DataStoreTO; +import com.cloud.agent.api.to.DataTO; public interface DataStoreDriver { Map getCapabilities(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java index d25e10e..d643d7f 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java @@ -18,8 +18,6 @@ */ package org.apache.cloudstack.engine.subsystem.api.storage; -import java.util.List; - import com.cloud.storage.DataStoreProviderApiService; import com.cloud.utils.component.Manager; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java index 61c9006..b21616a 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java @@ -44,6 +44,14 @@ public interface ObjectInDataStoreStateMachine extends StateObject Wait = new ConfigKey("Advanced", Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return", true); + static final ConfigKey Wait = new ConfigKey("Advanced", Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return", + true); public enum TapAgentsAction { Add, Del, Contains, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/alert/AlertManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/alert/AlertManager.java b/engine/components-api/src/com/cloud/alert/AlertManager.java index 8b22191..a00f3bb 100755 --- a/engine/components-api/src/com/cloud/alert/AlertManager.java +++ b/engine/components-api/src/com/cloud/alert/AlertManager.java @@ -52,13 +52,15 @@ public interface AlertManager extends Manager { public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 26; // Generated when the resource limit exceeds the limit. Currently used for recurring snapshots only static final ConfigKey StorageCapacityThreshold = new ConfigKey(Double.class, "cluster.storage.capacity.notificationthreshold", "Alert", "0.75", - "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", true, ConfigKey.Scope.Cluster, null); + "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", true, ConfigKey.Scope.Cluster, + null); static final ConfigKey CPUCapacityThreshold = new ConfigKey(Double.class, "cluster.cpu.allocated.capacity.notificationthreshold", "Alert", "0.75", "Percentage (as a value between 0 and 1) of cpu utilization above which alerts will be sent about low cpu available.", true, ConfigKey.Scope.Cluster, null); - static final ConfigKey MemoryCapacityThreshold = new ConfigKey(Double.class, "cluster.memory.allocated.capacity.notificationthreshold", "Alert", "0.75", - "Percentage (as a value between 0 and 1) of memory utilization above which alerts will be sent about low memory available.", true, ConfigKey.Scope.Cluster, null); - static final ConfigKey StorageAllocatedCapacityThreshold = new ConfigKey(Double.class, "cluster.storage.allocated.capacity.notificationthreshold", "Alert", - "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", true, + static final ConfigKey MemoryCapacityThreshold = new ConfigKey(Double.class, "cluster.memory.allocated.capacity.notificationthreshold", "Alert", + "0.75", "Percentage (as a value between 0 and 1) of memory utilization above which alerts will be sent about low memory available.", true, + ConfigKey.Scope.Cluster, null); + static final ConfigKey StorageAllocatedCapacityThreshold = new ConfigKey(Double.class, "cluster.storage.allocated.capacity.notificationthreshold", + "Alert", "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", true, ConfigKey.Scope.Cluster, null); void clearAlert(short alertType, long dataCenterId, long podId); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/capacity/CapacityManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/capacity/CapacityManager.java b/engine/components-api/src/com/cloud/capacity/CapacityManager.java index 6032261..4332ede 100755 --- a/engine/components-api/src/com/cloud/capacity/CapacityManager.java +++ b/engine/components-api/src/com/cloud/capacity/CapacityManager.java @@ -41,12 +41,18 @@ public interface CapacityManager { static final ConfigKey MemOverprovisioningFactor = new ConfigKey(Float.class, MemOverprovisioningFactorCK, "Advanced", "1.0", "Used for memory overprovisioning calculation", true, ConfigKey.Scope.Cluster, null); static final ConfigKey StorageCapacityDisableThreshold = new ConfigKey("Alert", Double.class, StorageCapacityDisableThresholdCK, "0.85", - "Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true, ConfigKey.Scope.Zone); + "Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true, + ConfigKey.Scope.Zone); static final ConfigKey StorageOverprovisioningFactor = new ConfigKey("Storage", Double.class, StorageOverprovisioningFactorCK, "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.Zone); - static final ConfigKey StorageAllocatedCapacityDisableThreshold = new ConfigKey("Alert", Double.class, StorageAllocatedCapacityDisableThresholdCK, "0.85", - "Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.", true, - ConfigKey.Scope.Zone); + static final ConfigKey StorageAllocatedCapacityDisableThreshold = + new ConfigKey( + "Alert", + Double.class, + StorageAllocatedCapacityDisableThresholdCK, + "0.85", + "Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.", + true, ConfigKey.Scope.Zone); public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java index 3c53863..13ca3f9 100755 --- a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java +++ b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java @@ -39,10 +39,7 @@ import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.org.Grouping.AllocationState; -import com.cloud.service.ServiceOfferingVO; -import com.cloud.storage.DiskOfferingVO; import com.cloud.user.Account; -import com.cloud.vm.VirtualMachine; /** * ConfigurationManager handles adding pods/zones, changing IP ranges, enabling external firewalls, and editing @@ -137,8 +134,8 @@ public interface ConfigurationManager { * (true if it is ok to not validate that gateway IP address overlap with Start/End IP of the POD) * @return Pod */ - HostPodVO - createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp, String allocationState, boolean skipGatewayOverlapCheck); + HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp, String allocationState, + boolean skipGatewayOverlapCheck); /** * Creates a new zone @@ -162,8 +159,9 @@ public interface ConfigurationManager { * @throws * @throws */ - DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, - NetworkType zoneType, String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2); + DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, + Long domainId, NetworkType zoneType, String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, + String ip6Dns2); /** * Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated @@ -214,9 +212,9 @@ public interface ConfigurationManager { boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, Map details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive); - Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, - String vlanNetmask, String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) throws InsufficientCapacityException, - ConcurrentOperationException, InvalidParameterValueException; + Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, + String vlanGateway, String vlanNetmask, String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) + throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/event/UsageEventUtils.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/event/UsageEventUtils.java b/engine/components-api/src/com/cloud/event/UsageEventUtils.java index 2b7cf3c..e71afb0 100644 --- a/engine/components-api/src/com/cloud/event/UsageEventUtils.java +++ b/engine/components-api/src/com/cloud/event/UsageEventUtils.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; -import com.cloud.event.dao.UsageEventDetailsDao; import org.apache.log4j.Logger; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -39,8 +38,6 @@ import com.cloud.event.dao.UsageEventDao; import com.cloud.user.Account; import com.cloud.user.dao.AccountDao; import com.cloud.utils.component.ComponentContext; -import org.springframework.beans.factory.annotation.Autowire; -import org.springframework.beans.factory.annotation.Autowired; public class UsageEventUtils { @@ -67,14 +64,14 @@ public class UsageEventUtils { _dcDao = dcDao; } - public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size, - String entityType, String entityUUID) { + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + Long size, String entityType, String entityUUID) { saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size); publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); } - public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size, - Long virtualSize, String entityType, String entityUUID) { + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + Long size, Long virtualSize, String entityType, String entityUUID) { saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size, virtualSize); publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); } @@ -107,8 +104,8 @@ public class UsageEventUtils { publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); } - private static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, String resourceType, - Map details) { + private static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + String resourceType, Map details) { UsageEventVO usageEvent = new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType); _usageEventDao.persist(usageEvent); _usageEventDao.saveDetails(usageEvent.getId(), details); @@ -127,11 +124,13 @@ public class UsageEventUtils { _usageEventDao.persist(new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName)); } - public static void saveUsageEvent(String usageType, long accountId, long zoneId, long ipAddressId, String ipAddress, boolean isSourceNat, String guestType, boolean isSystem) { + public static void saveUsageEvent(String usageType, long accountId, long zoneId, long ipAddressId, String ipAddress, boolean isSourceNat, String guestType, + boolean isSystem) { _usageEventDao.persist(new UsageEventVO(usageType, accountId, zoneId, ipAddressId, ipAddress, isSourceNat, guestType, isSystem)); } - public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, String resourceType) { + public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + String resourceType) { _usageEventDao.persist(new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType)); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/IpAddressManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/IpAddressManager.java b/engine/components-api/src/com/cloud/network/IpAddressManager.java index 24ece34..e7061f9 100644 --- a/engine/components-api/src/com/cloud/network/IpAddressManager.java +++ b/engine/components-api/src/com/cloud/network/IpAddressManager.java @@ -40,8 +40,8 @@ import com.cloud.vm.VirtualMachineProfile; public interface IpAddressManager { static final String UseSystemPublicIpsCK = "use.system.public.ips"; static final ConfigKey UseSystemPublicIps = new ConfigKey("Advanced", Boolean.class, UseSystemPublicIpsCK, "true", - "If true, when account has dedicated public ip range(s), once the ips dedicated to the account have been consumed ips will be acquired from the system pool", true, - ConfigKey.Scope.Account); + "If true, when account has dedicated public ip range(s), once the ips dedicated to the account have been consumed ips will be acquired from the system pool", + true, ConfigKey.Scope.Account); /** * Assigns a new public ip address. @@ -73,7 +73,8 @@ public interface IpAddressManager { */ boolean disassociatePublicIpAddress(long id, long userId, Account caller); - boolean applyRules(List rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) throws ResourceUnavailableException; + boolean applyRules(List rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) + throws ResourceUnavailableException; /** * @throws ResourceAllocationException TODO @@ -93,7 +94,8 @@ public interface IpAddressManager { boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException; - boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List publicIps) throws ResourceUnavailableException; + boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List publicIps) + throws ResourceUnavailableException; IPAddressVO markIpAsUnavailable(long addrId); @@ -125,13 +127,13 @@ public interface IpAddressManager { IPAddressVO associateIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException; - IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) throws ConcurrentOperationException, ResourceAllocationException, - InsufficientAddressCapacityException; + IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) throws ConcurrentOperationException, + ResourceAllocationException, InsufficientAddressCapacityException; boolean releasePortableIpAddress(long addrId); - IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException, - InsufficientAddressCapacityException, ConcurrentOperationException; + IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, + ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException; IPAddressVO disassociatePortableIPToGuestNetwork(long ipAddrId, long networkId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException; @@ -159,11 +161,11 @@ public interface IpAddressManager { PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException, InsufficientAddressCapacityException; - IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, - InsufficientAddressCapacityException; + IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone) throws ConcurrentOperationException, + ResourceAllocationException, InsufficientAddressCapacityException; - PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List vlanDbIds, Long networkId, String requestedIp, boolean isSystem) - throws InsufficientAddressCapacityException; + PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List vlanDbIds, Long networkId, String requestedIp, + boolean isSystem) throws InsufficientAddressCapacityException; int getRuleCountForIp(Long addressId, FirewallRule.Purpose purpose, FirewallRule.State state); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/NetworkStateListener.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/NetworkStateListener.java b/engine/components-api/src/com/cloud/network/NetworkStateListener.java index 4f02dc2..1219061 100644 --- a/engine/components-api/src/com/cloud/network/NetworkStateListener.java +++ b/engine/components-api/src/com/cloud/network/NetworkStateListener.java @@ -75,8 +75,8 @@ public class NetworkStateListener implements StateListener eventDescription = new HashMap(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java index 05eb779..6b3ae02 100644 --- a/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java +++ b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java @@ -24,8 +24,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.lb.LoadBalancingRule.LbDestination; import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy; -import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.lb.LoadBalancingRule.LbSslCert; +import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.rules.LbStickinessMethod; import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.LoadBalancerContainer.Scheme; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/rules/FirewallManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/rules/FirewallManager.java b/engine/components-api/src/com/cloud/network/rules/FirewallManager.java index 0f6d0ce..6085b4b 100644 --- a/engine/components-api/src/com/cloud/network/rules/FirewallManager.java +++ b/engine/components-api/src/com/cloud/network/rules/FirewallManager.java @@ -44,8 +44,8 @@ public interface FirewallManager extends FirewallService { */ void detectRulesConflict(FirewallRule newRule) throws NetworkRuleConflictException; - void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer portStart, Integer portEnd, String proto, Purpose purpose, FirewallRuleType type, Long networkid, - FirewallRule.TrafficType trafficType); + void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer portStart, Integer portEnd, String proto, Purpose purpose, FirewallRuleType type, + Long networkid, FirewallRule.TrafficType trafficType); boolean applyRules(List rules, boolean continueOnError, boolean updateRulesInDB) throws ResourceUnavailableException; @@ -72,8 +72,8 @@ public interface FirewallManager extends FirewallService { // FirewallRule.FirewallRuleType type, Long networkId, FirewallRule.TrafficType traffictype) // throws NetworkRuleConflictException; - FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId, - long networkId) throws NetworkRuleConflictException; + FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, + Long relatedRuleId, long networkId) throws NetworkRuleConflictException; boolean revokeAllFirewallRulesForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java index 25dff52..06952fc 100644 --- a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java +++ b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java @@ -16,11 +16,10 @@ // under the License. package com.cloud.network.vpc; +import java.util.List; + import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.dao.NetworkVO; -import com.cloud.user.Account; - -import java.util.List; public interface NetworkACLManager { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/network/vpc/VpcManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/vpc/VpcManager.java b/engine/components-api/src/com/cloud/network/vpc/VpcManager.java index 98bd8e6..ebfa90a 100644 --- a/engine/components-api/src/com/cloud/network/vpc/VpcManager.java +++ b/engine/components-api/src/com/cloud/network/vpc/VpcManager.java @@ -106,8 +106,10 @@ public interface VpcManager { * @throws InsufficientCapacityException * @throws ResourceAllocationException */ - Network createVpcGuestNetwork(long ntwkOffId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId, - PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, long vpcId, Long aclId, Account caller, Boolean displayNetworkEnabled) + Network + createVpcGuestNetwork(long ntwkOffId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, + Long domainId, PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, long vpcId, Long aclId, Account caller, + Boolean displayNetworkEnabled) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; @@ -159,7 +161,8 @@ public interface VpcManager { * @param gateway * @param networkOwner TODO */ - void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId); + void + validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId); List getVpcPrivateGateways(long vpcId); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java b/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java index 3704adf..b0ca283 100755 --- a/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java +++ b/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java @@ -19,9 +19,7 @@ package com.cloud.resource; import java.util.List; import java.util.Map; -import com.cloud.agent.api.StartupAnswer; import com.cloud.agent.api.StartupCommand; -import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.utils.component.Adapter; @@ -55,7 +53,8 @@ public interface ResourceStateAdapter extends Adapter { public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd); - public HostVO createHostVOForDirectConnectAgent(HostVO host, final StartupCommand[] startup, ServerResource resource, Map details, List hostTags); + public HostVO createHostVOForDirectConnectAgent(HostVO host, final StartupCommand[] startup, ServerResource resource, Map details, + List hostTags); public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java index ef7935a..3c31301 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java @@ -32,9 +32,10 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.log4j.Logger; +import org.apache.cloudstack.managed.context.ManagedContextRunnable; + import com.cloud.agent.Listener; import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckHealthCommand; @@ -112,9 +113,9 @@ public abstract class AgentAttache { protected AgentManagerImpl _agentMgr; public final static String[] s_commandsAllowedInMaintenanceMode = new String[] {MaintainCommand.class.toString(), MigrateCommand.class.toString(), - StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), - ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(), - CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString()}; + StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), + ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(), + CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString()}; protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] {StartCommand.class.toString(), CreateCommand.class.toString()}; static { Arrays.sort(s_commandsAllowedInMaintenanceMode); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java index cf85047..1e8b148 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -38,12 +38,13 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; + import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.utils.identity.ManagementServerNode; -import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -97,9 +98,8 @@ import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.db.DB; import com.cloud.utils.db.EntityManager; import com.cloud.utils.db.QueryBuilder; -import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.db.SearchCriteria.Op; -import com.cloud.utils.db.Transaction; +import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.HypervisorVersionChangedException; import com.cloud.utils.fsm.NoTransitionException; @@ -166,8 +166,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl @Inject ResourceManager _resourceMgr; - protected final ConfigKey Workers = new ConfigKey(Integer.class, "workers", "Advanced", "5", "Number of worker threads handling remote agent connections.", - false); + protected final ConfigKey Workers = new ConfigKey(Integer.class, "workers", "Advanced", "5", + "Number of worker threads handling remote agent connections.", false); protected final ConfigKey Port = new ConfigKey(Integer.class, "port", "Advanced", "8250", "Port to listen on for remote agent connections.", false); protected final ConfigKey PingInterval = new ConfigKey(Integer.class, "ping.interval", "Advanced", "60", "Interval to send application level pings to make sure the connection is still working", false); @@ -177,8 +177,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl "Seconds to wait before alerting on a disconnected agent", true); protected final ConfigKey DirectAgentLoadSize = new ConfigKey(Integer.class, "direct.agent.load.size", "Advanced", "16", "The number of direct agents to load each time", false); - protected final ConfigKey DirectAgentPoolSize = new ConfigKey(Integer.class, "direct.agent.pool.size", "Advanced", "500", "Default size for DirectAgentPool", - false); + protected final ConfigKey DirectAgentPoolSize = new ConfigKey(Integer.class, "direct.agent.pool.size", "Advanced", "500", + "Default size for DirectAgentPool", false); protected final ConfigKey DirectAgentThreadCap = new ConfigKey(Float.class, "direct.agent.thread.cap", "Advanced", "0.1", "Percentage (as a value between 0 and 1) of direct.agent.pool.size to be used as upper thread cap for a single direct agent to process requests", false); @@ -494,13 +494,13 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl if (e instanceof ConnectionException) { ConnectionException ce = (ConnectionException)e; if (ce.isSetupError()) { - s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + - e.getMessage()); + s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + + " due to " + e.getMessage()); handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); throw ce; } else { - s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + - e.getMessage()); + s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + + " due to " + e.getMessage()); handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true); return attache; } @@ -508,9 +508,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true); throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); } else { - s_logger.error( - "Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), - e); + s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + + " due to " + e.getMessage(), e); handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); } @@ -1071,6 +1070,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl _request = request; } + @Override protected void runInContext() { _request.logD("Processing the first command "); StartupCommand[] startups = new StartupCommand[_cmds.length]; @@ -1170,7 +1170,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl } else if (cmd instanceof ShutdownCommand) { final ShutdownCommand shutdown = (ShutdownCommand)cmd; final String reason = shutdown.getReason(); - s_logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + shutdown.getDetail()); + s_logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + + shutdown.getDetail()); if (reason.equals(ShutdownCommand.Update)) { //disconnectWithoutInvestigation(attache, Event.UpdateNeeded); throw new CloudRuntimeException("Agent update not implemented"); @@ -1197,17 +1198,18 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl // gateway (cannot ping the default route) DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId()); HostPodVO podVO = _podDao.findById(host.getPodId()); - String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + - podVO.getName(); + String hostDesc = + "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); - _alertMgr.sendAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId(), "Host lost connection to gateway, " + - hostDesc, "Host [" + hostDesc + - "] lost connection to gateway (default route) and is possibly having network connection issues."); + _alertMgr.sendAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId(), + "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc + + "] lost connection to gateway (default route) and is possibly having network connection issues."); } else { _alertMgr.clearAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId()); } } else { - s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + "; can't find the host in the DB"); + s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + + "; can't find the host in the DB"); } } answer = new PingAnswer((PingCommand)cmd); @@ -1330,9 +1332,10 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl try { return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao); } catch (NoTransitionException e1) { - status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + ", mangement server id is " + msId); + status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + + ", mangement server id is " + msId); throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + - e1.getMessage()); + e1.getMessage()); } } finally { _agentStatusLock.unlock(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java index 6896132..23c3f76 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java @@ -20,16 +20,13 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.SocketChannel; -import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedList; import javax.net.ssl.SSLEngine; import org.apache.log4j.Logger; -import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; import com.cloud.agent.api.Command; import com.cloud.agent.transport.Request; @@ -71,6 +68,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout return _forward; } + @Override protected void checkAvailability(final Command[] cmds) throws AgentUnavailableException { if (_transferMode) { @@ -250,6 +248,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout _transferRequests.clear(); } + @Override public void cleanup(final Status state) { super.cleanup(state); _transferRequests.clear(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index 93bf5ea..a73d5a5 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -43,13 +43,16 @@ import javax.naming.ConfigurationException; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; +import org.apache.log4j.Logger; + +import com.google.gson.Gson; + import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.managed.context.ManagedContextTimerTask; import org.apache.cloudstack.utils.identity.ManagementServerNode; -import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -85,12 +88,11 @@ import com.cloud.serializer.GsonHelper; import com.cloud.utils.DateUtil; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.db.QueryBuilder; -import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.db.SearchCriteria.Op; +import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.nio.Link; import com.cloud.utils.nio.Task; -import com.google.gson.Gson; @Local(value = {AgentManager.class, ClusteredAgentRebalanceService.class}) public class ClusteredAgentManagerImpl extends AgentManagerImpl implements ClusterManagerListener, ClusteredAgentRebalanceService { @@ -130,8 +132,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust "Enable agent load balancing between management server nodes", true); protected final ConfigKey ConnectedAgentThreshold = new ConfigKey(Double.class, "agent.load.threshold", "Advanced", "0.7", "What percentage of the agents can be held by one management server before load balancing happens", true); - protected final ConfigKey LoadSize = new ConfigKey(Integer.class, "direct.agent.load.size", "Advanced", "16", "How many agents to connect to in each round", - true); + protected final ConfigKey LoadSize = new ConfigKey(Integer.class, "direct.agent.load.size", "Advanced", "16", + "How many agents to connect to in each round", true); protected final ConfigKey ScanInterval = new ConfigKey(Integer.class, "direct.agent.scan.interval", "Advanced", "90", "Interval between scans to load agents", false, ConfigKey.Scope.Global, 1000); @@ -332,7 +334,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust HostTransferMapVO transferVO = _hostTransferDao.findById(hostId); if (transferVO != null) { if (transferVO.getFutureOwner() == _nodeId && transferVO.getState() == HostTransferState.TransferStarted) { - s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " + _nodeId); + s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " + + _nodeId); return true; } } @@ -342,7 +345,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust //but the host has already reconnected to the current management server if (!attache.forForward()) { s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + - " as the host is directly connected to the current management server " + _nodeId); + " as the host is directly connected to the current management server " + _nodeId); return true; } @@ -388,17 +391,17 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust protected static void logT(byte[] bytes, final String msg) { s_logger.trace("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + - (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); + (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); } protected static void logD(byte[] bytes, final String msg) { s_logger.debug("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + - (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); + (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); } protected static void logI(byte[] bytes, final String msg) { s_logger.info("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + - (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); + (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); } public boolean routeToPeer(String peer, byte[] bytes) { @@ -723,7 +726,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } @Override - public boolean executeRebalanceRequest(long agentId, long currentOwnerId, long futureOwnerId, Event event) throws AgentUnavailableException, OperationTimedoutException { + public boolean executeRebalanceRequest(long agentId, long currentOwnerId, long futureOwnerId, Event event) throws AgentUnavailableException, + OperationTimedoutException { boolean result = false; if (event == Event.RequestAgentRebalance) { return setToWaitForRebalance(agentId, currentOwnerId, futureOwnerId); @@ -790,7 +794,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } else { if (s_logger.isDebugEnabled()) { s_logger.debug("There are no hosts to rebalance in the system. Current number of active management server nodes in the system is " + allMS.size() + - "; number of managed agents is " + allManagedAgents.size()); + "; number of managed agents is " + allManagedAgents.size()); } return; } @@ -942,7 +946,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust // remove the host from re-balance list and delete from op_host_transfer DB // no need to do anything with the real attache as we haven't modified it yet Date cutTime = DateUtil.currentGMTTime(); - HostTransferMapVO transferMap = _hostTransferDao.findActiveHostTransferMapByHostId(hostId, new Date(cutTime.getTime() - rebalanceTimeOut)); + HostTransferMapVO transferMap = + _hostTransferDao.findActiveHostTransferMapByHostId(hostId, new Date(cutTime.getTime() - rebalanceTimeOut)); if (transferMap == null) { s_logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, skipping rebalance for the host"); @@ -960,7 +965,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust ManagementServerHostVO ms = _mshostDao.findByMsid(transferMap.getFutureOwner()); if (ms != null && ms.getState() != ManagementServerHost.State.Up) { - s_logger.debug("Can't transfer host " + hostId + " as it's future owner is not in UP state: " + ms + ", skipping rebalance for the host"); + s_logger.debug("Can't transfer host " + hostId + " as it's future owner is not in UP state: " + ms + + ", skipping rebalance for the host"); iterator.remove(); _hostTransferDao.completeAgentTransfer(hostId); continue; @@ -977,7 +983,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } else { s_logger.debug("Agent " + hostId + " can't be transfered yet as its request queue size is " + attache.getQueueSize() + - " and listener queue size is " + attache.getNonRecurringListenersSize()); + " and listener queue size is " + attache.getNonRecurringListenersSize()); } } } else { @@ -1044,7 +1050,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust if (result) { if (s_logger.isDebugEnabled()) { s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + - " as a part of rebalance process"); + " as a part of rebalance process"); } result = loadDirectlyConnectedHost(host, true); } else { @@ -1053,16 +1059,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust } catch (Exception ex) { s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + - " as a part of rebalance process due to:", ex); + " as a part of rebalance process due to:", ex); result = false; } if (result) { s_logger.debug("Successfully loaded directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + - " as a part of rebalance process"); + " as a part of rebalance process"); } else { s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + - " as a part of rebalance process"); + " as a part of rebalance process"); } } @@ -1093,8 +1099,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust //2) Get all transfer requests and route them to peer Request requestToTransfer = forwardAttache.getRequestToTransfer(); while (requestToTransfer != null) { - s_logger.debug("Forwarding request " + requestToTransfer.getSequence() + " held in transfer attache " + hostId + " from the management server " + _nodeId + " to " + - futureOwnerId); + s_logger.debug("Forwarding request " + requestToTransfer.getSequence() + " held in transfer attache " + hostId + " from the management server " + + _nodeId + " to " + futureOwnerId); boolean routeResult = routeToPeer(Long.toString(futureOwnerId), requestToTransfer.getBytes()); if (!routeResult) { logD(requestToTransfer.getBytes(), "Failed to route request to peer"); @@ -1148,7 +1154,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust s_logger.warn("Attache for the agent " + hostId + " no longer exists on management server " + _nodeId + ", can't start host rebalancing"); } else { s_logger.warn("Attache for the agent " + hostId + " has request queue size= " + attache.getQueueSize() + " and listener queue size " + - attache.getNonRecurringListenersSize() + ", can't start host rebalancing"); + attache.getNonRecurringListenersSize() + ", can't start host rebalancing"); } return false; } @@ -1205,7 +1211,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust // Scheduling host scan task in peer MS is a best effort operation during host add, regular host scan // happens at fixed intervals anyways. So handling any exceptions that may be thrown s_logger.warn("Exception happened while trying to schedule host scan task on mgmt server " + _clusterMgr.getSelfPeerName() + - ", ignoring as regular host scan happens at fixed interval anyways", e); + ", ignoring as regular host scan happens at fixed interval anyways", e); return null; } @@ -1321,15 +1327,15 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust String jsonReturn = _gson.toJson(answers); if (s_logger.isDebugEnabled()) { - s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + (System.currentTimeMillis() - startTick) + - " ms, return result: " + jsonReturn); + s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + + (System.currentTimeMillis() - startTick) + " ms, return result: " + jsonReturn); } return jsonReturn; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + (System.currentTimeMillis() - startTick) + - " ms, return null result"); + s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + + (System.currentTimeMillis() - startTick) + " ms, return null result"); } } } catch (AgentUnavailableException e) { @@ -1379,12 +1385,12 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust double load = managedHostsCount / allHostsCount; if (load >= ConnectedAgentThreshold.value()) { s_logger.debug("Scheduling agent rebalancing task as the average agent load " + load + " is more than the threshold " + - ConnectedAgentThreshold.value()); + ConnectedAgentThreshold.value()); scheduleRebalanceAgents(); _agentLbHappened = true; } else { s_logger.debug("Not scheduling agent rebalancing task as the averages load " + load + " is less than the threshold " + - ConnectedAgentThreshold.value()); + ConnectedAgentThreshold.value()); } } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java index 0f235fa..d7c0827 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java @@ -16,7 +16,6 @@ // under the License. package com.cloud.agent.manager; -import com.cloud.agent.AgentManager; import com.cloud.agent.transport.Request; import com.cloud.agent.transport.Response; import com.cloud.exception.AgentUnavailableException; @@ -28,7 +27,8 @@ public class ClusteredDirectAgentAttache extends DirectAgentAttache implements R private final ClusteredAgentManagerImpl _mgr; private final long _nodeId; - public ClusteredDirectAgentAttache(AgentManagerImpl agentMgr, long id, String name, long mgmtId, ServerResource resource, boolean maintenance, ClusteredAgentManagerImpl mgr) { + public ClusteredDirectAgentAttache(AgentManagerImpl agentMgr, long id, String name, long mgmtId, ServerResource resource, boolean maintenance, + ClusteredAgentManagerImpl mgr) { super(agentMgr, id, name, resource, maintenance, mgr); _mgr = mgr; _nodeId = mgmtId; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java index 29b146a..ef002d0 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java @@ -21,9 +21,10 @@ import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.log4j.Logger; +import org.apache.cloudstack.managed.context.ManagedContextRunnable; + import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.CronCommand; @@ -133,7 +134,8 @@ public class DirectAgentAttache extends AgentAttache { protected synchronized void runInContext() { try { if (_outstandingTaskCount.incrementAndGet() > _agentMgr.getDirectAgentThreadCap()) { - s_logger.warn("Task execution for direct attache(" + _id + ") has reached maximum outstanding limit(" + _agentMgr.getDirectAgentThreadCap() + "), bailing out"); + s_logger.warn("Task execution for direct attache(" + _id + ") has reached maximum outstanding limit(" + _agentMgr.getDirectAgentThreadCap() + + "), bailing out"); return; } @@ -195,7 +197,8 @@ public class DirectAgentAttache extends AgentAttache { long seq = _req.getSequence(); try { if (_outstandingTaskCount.incrementAndGet() > _agentMgr.getDirectAgentThreadCap()) { - s_logger.warn("Task execution for direct attache(" + _id + ") has reached maximum outstanding limit(" + _agentMgr.getDirectAgentThreadCap() + "), bailing out"); + s_logger.warn("Task execution for direct attache(" + _id + ") has reached maximum outstanding limit(" + _agentMgr.getDirectAgentThreadCap() + + "), bailing out"); bailout(); return; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java b/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java index 9d339a1..2146b00 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java +++ b/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java @@ -116,7 +116,8 @@ public class SynchronousListener implements Listener { profiler.stop(); if (s_logger.isTraceEnabled()) { - s_logger.trace("Synchronized command - sending completed, time: " + profiler.getDuration() + ", answer: " + (_answers != null ? _answers[0].toString() : "null")); + s_logger.trace("Synchronized command - sending completed, time: " + profiler.getDuration() + ", answer: " + + (_answers != null ? _answers[0].toString() : "null")); } return _answers; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java index aa30ab0..be75cf2 100755 --- a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java +++ b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java @@ -55,7 +55,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements if (allHosts.size() <= avLoad) { s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + - "; so it doesn't participate in agent rebalancing process"); + "; so it doesn't participate in agent rebalancing process"); return null; } @@ -65,7 +65,8 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements List directHosts = sc.list(); if (directHosts.isEmpty()) { - s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + "; so it doesn't participate in agent rebalancing process"); + s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + + "; so it doesn't participate in agent rebalancing process"); return null; } @@ -91,7 +92,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements List hostsToReturn = new ArrayList(); s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() + - " and the average agent load in the system is " + avLoad + "; finalyzing list of hosts to give away..."); + " and the average agent load in the system is " + avLoad + "; finalyzing list of hosts to give away..."); for (Long cluster : hostToClusterMap.keySet()) { List hostsInCluster = hostToClusterMap.get(cluster); hostsLeft = hostsLeft - hostsInCluster.size();