mirror of https://github.com/apache/cloudstack.git
bug 9154: Replace domain_router.is_master with domain_router.redundant_state in DB
Then we can distingush BACKUP state from UNKNOWN state(which means we didn't get valid answer from CheckRouterCommand).
This commit is contained in:
parent
770c5cd377
commit
aef562c69d
|
|
@ -29,4 +29,9 @@ public interface VirtualRouter extends VirtualMachine {
|
|||
DHCP_USERDATA
|
||||
}
|
||||
Role getRole();
|
||||
public enum RedundantState {
|
||||
MASTER,
|
||||
BACKUP,
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
@Column(name="priority")
|
||||
int priority;
|
||||
|
||||
@Column(name="is_master")
|
||||
boolean isMaster;
|
||||
@Column(name="redundant_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private RedundantState redundantState;
|
||||
|
||||
@Column(name="role")
|
||||
@Enumerated(EnumType.STRING)
|
||||
|
|
@ -75,13 +76,13 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
long networkId,
|
||||
boolean isRedundantRouter,
|
||||
int priority,
|
||||
boolean isMaster,
|
||||
RedundantState redundantState,
|
||||
boolean haEnabled) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.networkId = networkId;
|
||||
this.isRedundantRouter = isRedundantRouter;
|
||||
this.priority = priority;
|
||||
this.isMaster = isMaster;
|
||||
this.redundantState = redundantState;
|
||||
}
|
||||
|
||||
public void setPublicIpAddress(String publicIpAddress) {
|
||||
|
|
@ -159,12 +160,12 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
this.priority = priority;
|
||||
}
|
||||
|
||||
public boolean getIsMaster() {
|
||||
return this.isMaster;
|
||||
public RedundantState getRedundantState() {
|
||||
return this.redundantState;
|
||||
}
|
||||
|
||||
public void setIsMaster(boolean isMaster) {
|
||||
this.isMaster = isMaster;
|
||||
public void setRedundantState(RedundantState redundantState) {
|
||||
this.redundantState = redundantState;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ import com.cloud.network.dao.VpnUserDao;
|
|||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualRouter.RedundantState;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
|
|
@ -730,12 +731,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
final CheckRouterAnswer answer = (CheckRouterAnswer) _agentMgr.easySend(router.getHostId(), command);
|
||||
if (answer != null) {
|
||||
if (answer.getResult()) {
|
||||
router.setIsMaster(answer.getIsMaster());
|
||||
if (answer.getIsMaster()) {
|
||||
router.setRedundantState(RedundantState.MASTER);
|
||||
} else {
|
||||
router.setRedundantState(RedundantState.BACKUP);
|
||||
}
|
||||
} else {
|
||||
router.setIsMaster(false);
|
||||
router.setRedundantState(RedundantState.UNKNOWN);
|
||||
}
|
||||
} else {
|
||||
router.setIsMaster(false);
|
||||
router.setRedundantState(RedundantState.UNKNOWN);
|
||||
}
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
try {
|
||||
|
|
@ -849,7 +854,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
priority = 100 - routers.size() * 20;
|
||||
}
|
||||
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(), template.getGuestOSId(),
|
||||
owner.getDomainId(), owner.getId(), guestNetwork.getId(), offering.isRedundantRouterEnabled(), priority, false, _offering.getOfferHA());
|
||||
owner.getDomainId(), owner.getId(), guestNetwork.getId(), offering.isRedundantRouterEnabled(), priority, RedundantState.UNKNOWN, _offering.getOfferHA());
|
||||
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
|
||||
routers.add(router);
|
||||
}
|
||||
|
|
@ -943,7 +948,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
VMTemplateVO template = _templateDao.findRoutingTemplate(dest.getCluster().getHypervisorType());
|
||||
|
||||
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(), template.getGuestOSId(),
|
||||
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, _offering.getOfferHA());
|
||||
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, RedundantState.UNKNOWN, _offering.getOfferHA());
|
||||
router.setRole(Role.DHCP_USERDATA);
|
||||
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -896,7 +896,7 @@ CREATE TABLE `cloud`.`domain_router` (
|
|||
`network_id` bigint unsigned NOT NULL COMMENT 'network configuration that this domain router belongs to',
|
||||
`is_redundant_router` int(1) unsigned NOT NULL COMMENT 'if in redundant router mode',
|
||||
`priority` int(4) unsigned COMMENT 'priority of router in the redundant router mode',
|
||||
`is_master` int(1) unsigned DEFAULT 0 COMMENT 'if the router is master in redundant router mode',
|
||||
`redundant_state` varchar(64) NOT NULL COMMENT 'the state of redundant virtual router',
|
||||
`role` varchar(64) NOT NULL COMMENT 'type of role played by this router',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_domain_router__id` FOREIGN KEY `fk_domain_router__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
|
||||
|
|
|
|||
Loading…
Reference in New Issue