Skip to content

Commit 43ab950

Browse files
committed
Moved HostAllocator and PodAllocator from server to api package, where they are supposed to be. In the process, I had to change the VO objects used by these two itnerfaces to interface equivalent. This makes sense because there's really no reasons why allocators require write access to the database. One of the files have been reformatted because it contained a bunch of tabs instead of spaces for indentation.
1 parent 410dff9 commit 43ab950

14 files changed

Lines changed: 338 additions & 344 deletions

File tree

server/src/com/cloud/agent/manager/allocator/HostAllocator.java renamed to api/src/com/cloud/agent/manager/allocator/HostAllocator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.cloud.deploy.DeploymentPlan;
2222
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
2323
import com.cloud.host.Host;
24-
import com.cloud.host.HostVO;
2524
import com.cloud.host.Host.Type;
2625
import com.cloud.offering.ServiceOffering;
2726
import com.cloud.utils.component.Adapter;
@@ -36,23 +35,23 @@ public interface HostAllocator extends Adapter {
3635
**/
3736
boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
3837

39-
/**
40-
* Determines which physical hosts are suitable to
41-
* allocate the guest virtual machines on
38+
/**
39+
* Determines which physical hosts are suitable to
40+
* allocate the guest virtual machines on
4241
*
4342
* @param VirtualMachineProfile vmProfile
4443
* @param DeploymentPlan plan
4544
* @param GuestType type
4645
* @param ExcludeList avoid
4746
* @param int returnUpTo (use -1 to return all possible hosts)
4847
* @return List<Host> List of hosts that are suitable for VM allocation
49-
**/
48+
**/
5049

5150
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
5251

53-
/**
54-
* Determines which physical hosts are suitable to
55-
* allocate the guest virtual machines on
52+
/**
53+
* Determines which physical hosts are suitable to
54+
* allocate the guest virtual machines on
5655
*
5756
* @param VirtualMachineProfile vmProfile
5857
* @param DeploymentPlan plan
@@ -61,7 +60,7 @@ public interface HostAllocator extends Adapter {
6160
* @param int returnUpTo (use -1 to return all possible hosts)
6261
* @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
6362
* @return List<Host> List of hosts that are suitable for VM allocation
64-
**/
63+
**/
6564

6665
public List<Host> allocateTo(VirtualMachineProfile<?extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
6766

@@ -78,7 +77,8 @@ public interface HostAllocator extends Adapter {
7877
* @param boolean considerReservedCapacity (default should be true, set to false if host capacity calculation should not look at reserved capacity)
7978
* @return List<Host> List of hosts that are suitable for VM allocation
8079
**/
81-
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity);
80+
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
81+
int returnUpTo, boolean considerReservedCapacity);
8282

8383
public static int RETURN_UPTO_ALL = -1;
8484

server/src/com/cloud/agent/manager/allocator/PodAllocator.java renamed to api/src/com/cloud/agent/manager/allocator/PodAllocator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
import java.util.Set;
2020

2121
import com.cloud.dc.DataCenter;
22-
import com.cloud.dc.DataCenterVO;
23-
import com.cloud.dc.HostPodVO;
2422
import com.cloud.dc.Pod;
25-
import com.cloud.service.ServiceOfferingVO;
23+
import com.cloud.offering.ServiceOffering;
2624
import com.cloud.template.VirtualMachineTemplate;
2725
import com.cloud.utils.Pair;
2826
import com.cloud.utils.component.Adapter;
2927
import com.cloud.vm.VirtualMachineProfile;
3028

3129
public interface PodAllocator extends Adapter {
32-
Pair<HostPodVO, Long> allocateTo(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long userId, Set<Long> avoids);
30+
Pair<Pod, Long> allocateTo(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc, long userId, Set<Long> avoids);
3331

3432
Pod allocateTo(VirtualMachineProfile vm, DataCenter dc, Set<? extends Pod> avoids);
3533
}

plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
// Unless required by applicable law or agreed to in writing,
1212
// software distributed under the License is distributed on an
1313
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
// KIND, either express or implied. See the License for the
14+
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
package com.cloud.agent.manager.allocator.impl;
1818

1919
import java.util.ArrayList;
2020
import java.util.Collections;
2121
import java.util.List;
22-
import java.util.Map;
2322

2423
import javax.ejb.Local;
2524
import javax.inject.Inject;
@@ -55,7 +54,7 @@ public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmP
5554

5655
@Override
5756
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
58-
ExcludeList avoid, List<HostVO> hosts, int returnUpTo, boolean considerReservedCapacity) {
57+
ExcludeList avoid, List<? extends Host> hosts, int returnUpTo, boolean considerReservedCapacity) {
5958
long dcId = plan.getDataCenterId();
6059
Long podId = plan.getPodId();
6160
Long clusterId = plan.getClusterId();

0 commit comments

Comments
 (0)