本文整理汇总了Java中com.cloud.offering.ServiceOffering.getHostTag方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceOffering.getHostTag方法的具体用法?Java ServiceOffering.getHostTag怎么用?Java ServiceOffering.getHostTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloud.offering.ServiceOffering
的用法示例。
在下文中一共展示了ServiceOffering.getHostTag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allocateTo
import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Host> allocateTo(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final Type type, final ExcludeList avoid, final List<? extends Host> hosts,
final int returnUpTo,
final boolean considerReservedCapacity) {
final long dcId = plan.getDataCenterId();
final Long podId = plan.getPodId();
final Long clusterId = plan.getClusterId();
final ServiceOffering offering = vmProfile.getServiceOffering();
final VMTemplateVO template = (VMTemplateVO) vmProfile.getTemplate();
final Account account = vmProfile.getOwner();
List<Host> suitableHosts = new ArrayList<>();
final List<Host> hostsCopy = new ArrayList<>(hosts);
if (type == Host.Type.Storage) {
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of
// routing or not.
return suitableHosts;
}
final String hostTagOnOffering = offering.getHostTag();
final String hostTagOnTemplate = template.getTemplateTag();
final boolean hasSvcOfferingTag = hostTagOnOffering != null ? true : false;
final boolean hasTemplateTag = hostTagOnTemplate != null ? true : false;
final String haVmTag = (String) vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
if (haVmTag != null) {
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, haVmTag));
} else {
if (hostTagOnOffering == null && hostTagOnTemplate == null) {
hostsCopy.retainAll(_resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId));
} else {
if (hasSvcOfferingTag) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering);
}
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnOffering));
if (s_logger.isDebugEnabled()) {
s_logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsCopy);
}
}
if (hasTemplateTag) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate);
}
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate));
if (s_logger.isDebugEnabled()) {
s_logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsCopy);
}
}
}
}
if (!hostsCopy.isEmpty()) {
suitableHosts = allocateTo(plan, offering, template, avoid, hostsCopy, returnUpTo, considerReservedCapacity, account);
}
return suitableHosts;
}
示例2: allocateTo
import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Host> allocateTo(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final Type type, final ExcludeList avoid, final int returnUpTo, final boolean
considerReservedCapacity) {
final long dcId = plan.getDataCenterId();
final Long podId = plan.getPodId();
final Long clusterId = plan.getClusterId();
final ServiceOffering offering = vmProfile.getServiceOffering();
final List<Host> suitableHosts = new ArrayList<>();
if (type == Host.Type.Storage) {
return suitableHosts;
}
final String hostTag = offering.getHostTag();
if (hostTag != null) {
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag);
} else {
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
}
// list all computing hosts, regardless of whether they support routing...it's random after all
List<? extends Host> hosts = new ArrayList<HostVO>();
if (hostTag != null) {
hosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTag);
} else {
hosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId);
}
s_logger.debug("Random Allocator found " + hosts.size() + " hosts");
if (hosts.size() == 0) {
return suitableHosts;
}
Collections.shuffle(hosts);
for (final Host host : hosts) {
if (suitableHosts.size() == returnUpTo) {
break;
}
if (!avoid.shouldAvoid(host)) {
suitableHosts.add(host);
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " is in avoid set, skipping this and trying other available hosts");
}
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts");
}
return suitableHosts;
}
示例3: allocateTo
import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
boolean considerReservedCapacity) {
long dcId = plan.getDataCenterId();
Long podId = plan.getPodId();
Long clusterId = plan.getClusterId();
ServiceOffering offering = vmProfile.getServiceOffering();
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
Account account = vmProfile.getOwner();
List<Host> suitableHosts = new ArrayList<Host>();
List<Host> hostsCopy = new ArrayList<Host>(hosts);
if (type == Host.Type.Storage) {
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of
// routing or not.
return suitableHosts;
}
String hostTagOnOffering = offering.getHostTag();
String hostTagOnTemplate = template.getTemplateTag();
boolean hasSvcOfferingTag = hostTagOnOffering != null ? true : false;
boolean hasTemplateTag = hostTagOnTemplate != null ? true : false;
String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
if (haVmTag != null) {
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, haVmTag));
} else {
if (hostTagOnOffering == null && hostTagOnTemplate == null) {
hostsCopy.retainAll(_resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId));
} else {
if (hasSvcOfferingTag) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering);
}
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnOffering));
if (s_logger.isDebugEnabled()) {
s_logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsCopy);
}
}
if (hasTemplateTag) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate);
}
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate));
if (s_logger.isDebugEnabled()) {
s_logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsCopy);
}
}
}
}
if (!hostsCopy.isEmpty()) {
suitableHosts = allocateTo(plan, offering, template, avoid, hostsCopy, returnUpTo, considerReservedCapacity, account);
}
return suitableHosts;
}
示例4: scanClustersForDestinationInZoneOrPod
import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
private List<Long> scanClustersForDestinationInZoneOrPod(long id, boolean isZone, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) {
VirtualMachine vm = vmProfile.getVirtualMachine();
ServiceOffering offering = vmProfile.getServiceOffering();
DataCenter dc = dcDao.findById(vm.getDataCenterId());
int requiredCpu = offering.getCpu() * offering.getSpeed();
long requiredRam = offering.getRamSize() * 1024L * 1024L;
//list clusters under this zone by cpu and ram capacity
Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo = listClustersByCapacity(id, requiredCpu, requiredRam, avoid, isZone);
List<Long> prioritizedClusterIds = clusterCapacityInfo.first();
if (!prioritizedClusterIds.isEmpty()) {
if (avoid.getClustersToAvoid() != null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Removing from the clusterId list these clusters from avoid set: " + avoid.getClustersToAvoid());
}
prioritizedClusterIds.removeAll(avoid.getClustersToAvoid());
}
if (!isRootAdmin(vmProfile)) {
List<Long> disabledClusters = new ArrayList<Long>();
if (isZone) {
disabledClusters = listDisabledClusters(plan.getDataCenterId(), null);
} else {
disabledClusters = listDisabledClusters(plan.getDataCenterId(), id);
}
if (!disabledClusters.isEmpty()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Removing from the clusterId list these clusters that are disabled/clusters under disabled pods: " + disabledClusters);
}
prioritizedClusterIds.removeAll(disabledClusters);
}
}
removeClustersCrossingThreshold(prioritizedClusterIds, avoid, vmProfile, plan);
String hostTagOnOffering = offering.getHostTag();
if (hostTagOnOffering != null) {
removeClustersWithoutMatchingTag(prioritizedClusterIds, hostTagOnOffering);
}
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("No clusters found having a host with enough capacity, returning.");
}
return null;
}
if (!prioritizedClusterIds.isEmpty()) {
List<Long> clusterList = reorderClusters(id, isZone, clusterCapacityInfo, vmProfile, plan);
return clusterList; //return checkClustersforDestination(clusterList, vmProfile, plan, avoid, dc);
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("No clusters found after removing disabled clusters and clusters in avoid list, returning.");
}
return null;
}
}
示例5: allocateTo
import com.cloud.offering.ServiceOffering; //导入方法依赖的package包/类
@Override
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
boolean considerReservedCapacity) {
long dcId = plan.getDataCenterId();
Long podId = plan.getPodId();
Long clusterId = plan.getClusterId();
ServiceOffering offering = vmProfile.getServiceOffering();
List<Host> suitableHosts = new ArrayList<Host>();
List<Host> hostsCopy = new ArrayList<Host>(hosts);
if (type == Host.Type.Storage) {
return suitableHosts;
}
String hostTag = offering.getHostTag();
if (hostTag != null) {
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag);
} else {
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
}
// list all computing hosts, regardless of whether they support routing...it's random after all
if (hostTag != null) {
hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTag));
} else {
hostsCopy.retainAll(_resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId));
}
s_logger.debug("Random Allocator found " + hostsCopy.size() + " hosts");
if (hostsCopy.size() == 0) {
return suitableHosts;
}
Collections.shuffle(hostsCopy);
for (Host host : hostsCopy) {
if (suitableHosts.size() == returnUpTo) {
break;
}
if (!avoid.shouldAvoid(host)) {
suitableHosts.add(host);
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " is in avoid set, " + "skipping this and trying other available hosts");
}
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts");
}
return suitableHosts;
}