Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package org.zstack.compute.allocator;

import org.zstack.header.Component;
import org.zstack.header.allocator.*;
import org.zstack.header.allocator.AllocateHostMsg;
import org.zstack.header.allocator.DesignatedAllocateHostMsg;
import org.zstack.header.allocator.HostAllocatorConstant;
import org.zstack.header.allocator.HostAllocatorSpec;
import org.zstack.header.allocator.HostAllocatorStrategy;
import org.zstack.header.allocator.HostAllocatorStrategyFactory;
import org.zstack.header.allocator.HostAllocatorStrategyType;
import org.zstack.header.allocator.HostSortorStrategy;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@
import org.zstack.header.allocator.AbstractHostAllocatorFlow;
import org.zstack.header.host.HostVO;
import org.zstack.header.host.HostVO_;
import org.zstack.header.network.l2.*;
import org.zstack.header.network.l2.L2NetworkAttachStatus;
import org.zstack.header.network.l2.L2NetworkClusterRefVO;
import org.zstack.header.network.l2.L2NetworkHostRefVO;
import org.zstack.header.network.l2.L2NetworkHostRefVO_;
import org.zstack.header.network.l3.L3NetworkInventory;

import javax.persistence.Tuple;
import javax.persistence.TypedQuery;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.zstack.utils.logging.CLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
import org.zstack.utils.CollectionUtils;
import org.zstack.utils.function.Function;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.zstack.compute.allocator;

import org.zstack.header.allocator.*;
import org.zstack.header.allocator.AllocateHostMsg;
import org.zstack.header.allocator.DesignatedAllocateHostMsg;
import org.zstack.header.allocator.HostAllocatorConstant;
import org.zstack.header.allocator.HostAllocatorSpec;
import org.zstack.header.allocator.HostAllocatorStrategyType;

public class DesignatedHostAllocatorStrategyFactory extends AbstractHostAllocatorStrategyFactory {
private static final HostAllocatorStrategyType type = new HostAllocatorStrategyType(HostAllocatorConstant.DESIGNATED_HOST_ALLOCATOR_STRATEGY_TYPE, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,66 @@
import org.zstack.core.thread.ThreadFacade;
import org.zstack.core.workflow.FlowChainBuilder;
import org.zstack.header.AbstractService;
import org.zstack.header.allocator.*;
import org.zstack.header.allocator.APIGetCpuMemoryCapacityMsg;
import org.zstack.header.allocator.APIGetCpuMemoryCapacityReply;
import org.zstack.header.allocator.APIGetHostAllocatorStrategiesMsg;
import org.zstack.header.allocator.APIGetHostAllocatorStrategiesReply;
import org.zstack.header.allocator.AllocateHostDryRunReply;
import org.zstack.header.allocator.AllocateHostMsg;
import org.zstack.header.allocator.AllocateHostReply;
import org.zstack.header.allocator.BackupStorageAllocatorFilterExtensionPoint;
import org.zstack.header.allocator.CollectCapacityUnsupportedVmTypeExtensionPoint;
import org.zstack.header.allocator.DesignatedAllocateHostMsg;
import org.zstack.header.allocator.HostAllocatorConstant;
import org.zstack.header.allocator.HostAllocatorSpec;
import org.zstack.header.allocator.HostAllocatorStrategy;
import org.zstack.header.allocator.HostAllocatorStrategyExtensionPoint;
import org.zstack.header.allocator.HostAllocatorStrategyFactory;
import org.zstack.header.allocator.HostAllocatorStrategyType;
import org.zstack.header.allocator.HostCapacityOverProvisioningManager;
import org.zstack.header.allocator.HostCapacityStruct;
import org.zstack.header.allocator.HostCapacityVO;
import org.zstack.header.allocator.HostCpuOverProvisioningManager;
import org.zstack.header.allocator.HostSortorStrategy;
import org.zstack.header.allocator.ReportHostCapacityExtensionPoint;
import org.zstack.header.allocator.ReservedHostCapacity;
import org.zstack.header.allocator.ReturnHostCapacityMsg;
import org.zstack.header.allocator.UnableToReserveHostCapacityException;
import org.zstack.header.allocator.datatypes.CpuMemoryCapacityData;
import org.zstack.header.cluster.ClusterVO;
import org.zstack.header.cluster.ClusterVO_;
import org.zstack.header.cluster.ReportHostCapacityMessage;
import org.zstack.header.core.Completion;
import org.zstack.header.core.ReturnValueCompletion;
import org.zstack.header.core.workflow.*;
import org.zstack.header.core.workflow.Flow;
import org.zstack.header.core.workflow.FlowChain;
import org.zstack.header.core.workflow.FlowDoneHandler;
import org.zstack.header.core.workflow.FlowErrorHandler;
import org.zstack.header.core.workflow.FlowRollback;
import org.zstack.header.core.workflow.FlowTrigger;
import org.zstack.header.core.workflow.NoRollbackFlow;
import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.exception.CloudRuntimeException;
import org.zstack.header.host.*;
import org.zstack.header.host.Host;
import org.zstack.header.host.HostAllocateExtensionPoint;
import org.zstack.header.host.HostInventory;
import org.zstack.header.host.HostState;
import org.zstack.header.host.HostStatus;
import org.zstack.header.host.HostVO;
import org.zstack.header.host.HostVO_;
import org.zstack.header.host.HypervisorType;
import org.zstack.header.host.RecalculateHostCapacityMsg;
import org.zstack.header.image.APIGetCandidateBackupStorageForCreatingImageMsg;
import org.zstack.header.image.APIGetCandidateBackupStorageForCreatingImageReply;
import org.zstack.header.message.APIMessage;
import org.zstack.header.message.Message;
import org.zstack.header.message.MessageReply;
import org.zstack.header.storage.backup.*;
import org.zstack.header.storage.backup.BackupStorageInventory;
import org.zstack.header.storage.backup.BackupStorageState;
import org.zstack.header.storage.backup.BackupStorageStatus;
import org.zstack.header.storage.backup.BackupStorageVO;
import org.zstack.header.storage.backup.BackupStorageVO_;
import org.zstack.header.storage.backup.BackupStorageZoneRefVO;
import org.zstack.header.storage.primary.PrimaryStorageType;
import org.zstack.header.storage.primary.PrimaryStorageVO;
import org.zstack.header.vm.VmAbnormalLifeCycleExtensionPoint;
Expand All @@ -48,7 +91,13 @@
import javax.persistence.Tuple;
import javax.persistence.TypedQuery;
import java.text.DecimalFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;

import static org.zstack.core.Platform.operr;
Expand Down Expand Up @@ -496,6 +545,7 @@ public void fail(ErrorCode errorCode) {

String allocatedHosts = "HOST_CANDIDATES";
chain.setName("do-handle-allocate-host-flow");
// DEBT: NoRollbackFlow — reason TBD
chain.then(new NoRollbackFlow() {
String __name__ = "allocate-host-candidates";

Expand Down Expand Up @@ -550,6 +600,7 @@ public void rollback(FlowRollback trigger, Map data) {
}
trigger.rollback();
}
// DEBT: NoRollbackFlow — in rollback
}).then(new NoRollbackFlow() {
@Override
public void run(FlowTrigger trigger, Map data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
import org.zstack.core.db.Q;
import org.zstack.header.allocator.AbstractHostAllocatorFlow;
import org.zstack.header.allocator.HostAllocatorConstant;
import org.zstack.header.host.*;
import org.zstack.header.host.HostAO;
import org.zstack.header.host.HostOperationSystem;
import org.zstack.header.host.HostVO;
import org.zstack.header.host.HostVO_;
import org.zstack.header.host.HypervisorFactory;
import org.zstack.header.host.HypervisorType;
import org.zstack.header.vm.VmInstanceInventory;
import org.zstack.header.vo.ResourceVO;
import org.zstack.utils.Utils;
import org.zstack.utils.logging.CLogger;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
import org.zstack.header.allocator.AbstractHostAllocatorFlow;
import org.zstack.header.allocator.HostAllocatorSpec;
import org.zstack.header.host.HostVO;
import org.zstack.header.storage.primary.*;
import org.zstack.header.storage.primary.ImageCacheVO;
import org.zstack.header.storage.primary.ImageCacheVO_;
import org.zstack.header.storage.primary.PrimaryStorageCapacityVO;
import org.zstack.header.storage.primary.PrimaryStorageClusterRefVO;
import org.zstack.header.storage.primary.PrimaryStorageClusterRefVO_;
import org.zstack.header.storage.primary.PrimaryStorageHostRefVO;
import org.zstack.header.storage.primary.PrimaryStorageHostRefVO_;
import org.zstack.header.storage.primary.PrimaryStorageHostStatus;
import org.zstack.header.storage.primary.PrimaryStorageOverProvisioningManager;
import org.zstack.header.storage.primary.PrimaryStorageState;
import org.zstack.header.storage.primary.PrimaryStorageStatus;
import org.zstack.header.storage.primary.PrimaryStorageVO;
import org.zstack.header.vm.VmInstanceConstant.VmOperation;
import org.zstack.header.vo.ResourceVO;
import org.zstack.utils.CollectionUtils;
Expand All @@ -20,7 +31,13 @@

import javax.persistence.Tuple;
import javax.persistence.TypedQuery;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
import org.zstack.core.errorcode.ErrorFacade;
import org.zstack.core.workflow.FlowChainBuilder;
import org.zstack.core.workflow.ShareFlow;
import org.zstack.header.allocator.*;
import org.zstack.header.allocator.AbstractHostSortorFlow;
import org.zstack.header.allocator.HostAllocatorConstant;
import org.zstack.header.allocator.HostAllocatorReserveExtensionPoint;
import org.zstack.header.allocator.HostAllocatorSpec;
import org.zstack.header.allocator.HostSortorStrategy;
import org.zstack.header.allocator.UnableToReserveHostCapacityException;
import org.zstack.header.core.Completion;
import org.zstack.header.core.WhileDoneCompletion;
import org.zstack.header.core.ReturnValueCompletion;
import org.zstack.header.core.workflow.*;
import org.zstack.header.core.workflow.Flow;
import org.zstack.header.core.workflow.FlowChain;
import org.zstack.header.core.workflow.FlowDoneHandler;
import org.zstack.header.core.workflow.FlowErrorHandler;
import org.zstack.header.core.workflow.FlowRollback;
import org.zstack.header.core.workflow.FlowTrigger;
import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.errorcode.ErrorCodeList;
import org.zstack.header.host.HostInventory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
import org.zstack.header.host.HostVO;
import org.zstack.header.image.ImageBackupStorageRefInventory;
import org.zstack.header.image.ImageStatus;
import org.zstack.header.storage.backup.*;
import org.zstack.header.storage.backup.BackupStorageStatus;
import org.zstack.header.storage.backup.BackupStorageVO;
import org.zstack.header.storage.backup.BackupStorageVO_;
import org.zstack.header.storage.backup.BackupStorageZoneRefVO;
import org.zstack.header.storage.backup.BackupStorageZoneRefVO_;
import org.zstack.header.storage.primary.ImageCacheVO;
import org.zstack.header.storage.primary.ImageCacheVO_;
import org.zstack.header.storage.primary.PrimaryStorageClusterRefVO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
import org.zstack.utils.logging.CLogger;

import javax.persistence.Tuple;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.zstack.core.db.SimpleQuery;
import org.zstack.header.host.*;
import javax.persistence.TypedQuery;
import java.util.*;
import java.util.HashSet;
import java.util.Set;


@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import org.zstack.utils.Utils;
import org.zstack.utils.logging.CLogger;
import javax.persistence.Tuple;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.zstack.core.db.DatabaseFacade;
import org.zstack.header.cluster.*;
import org.zstack.header.cluster.Cluster;
import org.zstack.header.cluster.ClusterConstant;
import org.zstack.header.cluster.ClusterFactory;
import org.zstack.header.cluster.ClusterType;
import org.zstack.header.cluster.ClusterVO;
import org.zstack.header.cluster.CreateClusterMessage;
@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
public class BaseClusterFactory implements ClusterFactory {
static final ClusterType type = new ClusterType(ClusterConstant.ZSTACK_CLUSTER_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
import org.zstack.header.apimediator.ApiMessageInterceptionException;
import org.zstack.header.apimediator.ApiMessageInterceptor;
import org.zstack.header.apimediator.StopRoutingException;
import org.zstack.header.cluster.*;
import org.zstack.header.cluster.APICreateClusterMsg;
import org.zstack.header.cluster.APIDeleteClusterEvent;
import org.zstack.header.cluster.APIDeleteClusterMsg;
import org.zstack.header.cluster.APIUpdateClusterOSMsg;
import org.zstack.header.cluster.ClusterConstant;
import org.zstack.header.cluster.ClusterMessage;
import org.zstack.header.cluster.ClusterVO;
import org.zstack.header.cluster.ClusterVO_;
import org.zstack.header.host.HostState;
import org.zstack.header.host.HostStatus;
import org.zstack.header.host.HostVO;
Expand Down
31 changes: 29 additions & 2 deletions compute/src/main/java/org/zstack/compute/cluster/ClusterBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,35 @@
import org.zstack.core.thread.SyncTaskChain;
import org.zstack.core.thread.ThreadFacade;
import org.zstack.core.workflow.FlowChainBuilder;
import org.zstack.header.cluster.*;
import org.zstack.header.cluster.APIChangeClusterStateEvent;
import org.zstack.header.cluster.APIChangeClusterStateMsg;
import org.zstack.header.cluster.APIDeleteClusterEvent;
import org.zstack.header.cluster.APIDeleteClusterMsg;
import org.zstack.header.cluster.APIUpdateClusterEvent;
import org.zstack.header.cluster.APIUpdateClusterMsg;
import org.zstack.header.cluster.APIUpdateClusterOSEvent;
import org.zstack.header.cluster.APIUpdateClusterOSMsg;
import org.zstack.header.cluster.ChangeClusterStateMsg;
import org.zstack.header.cluster.ChangeClusterStateReply;
import org.zstack.header.cluster.Cluster;
import org.zstack.header.cluster.ClusterDeletionMsg;
import org.zstack.header.cluster.ClusterDeletionReply;
import org.zstack.header.cluster.ClusterException;
import org.zstack.header.cluster.ClusterInventory;
import org.zstack.header.cluster.ClusterState;
import org.zstack.header.cluster.ClusterStateEvent;
import org.zstack.header.cluster.ClusterVO;
import org.zstack.header.cluster.UpdateClusterOSMsg;
import org.zstack.header.cluster.UpdateClusterOSReply;
import org.zstack.header.cluster.UpdateClusterOSStruct;
import org.zstack.header.core.Completion;
import org.zstack.header.core.WhileDoneCompletion;
import org.zstack.header.core.NopeCompletion;
import org.zstack.header.core.workflow.*;
import org.zstack.header.core.workflow.FlowChain;
import org.zstack.header.core.workflow.FlowDoneHandler;
import org.zstack.header.core.workflow.FlowErrorHandler;
import org.zstack.header.core.workflow.FlowTrigger;
import org.zstack.header.core.workflow.NoRollbackFlow;
import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.errorcode.ErrorCodeList;
import org.zstack.header.errorcode.SysErrors;
Expand Down Expand Up @@ -180,6 +204,7 @@ protected void handle(final APIDeleteClusterMsg msg) {
FlowChain chain = FlowChainBuilder.newSimpleFlowChain();
chain.setName(String.format("delete-cluster-%s", msg.getUuid()));
if (msg.getDeletionMode() == APIDeleteMessage.DeletionMode.Permissive) {
// DEBT: NoRollbackFlow — reason TBD
chain.then(new NoRollbackFlow() {
@Override
public void run(final FlowTrigger trigger, Map data) {
Expand All @@ -195,6 +220,7 @@ public void fail(ErrorCode errorCode) {
}
});
}
// DEBT: NoRollbackFlow — reason TBD
}).then(new NoRollbackFlow() {
@Override
public void run(final FlowTrigger trigger, Map data) {
Expand All @@ -212,6 +238,7 @@ public void fail(ErrorCode errorCode) {
}
});
} else {
// DEBT: NoRollbackFlow — reason TBD
chain.then(new NoRollbackFlow() {
@Override
public void run(final FlowTrigger trigger, Map data) {
Expand Down
Loading