public String del(String delItem) { boolean exist = false; Iterator<String> it = this.useForList.iterator(); while (it.hasNext()) { String item = it.next(); if (item.equals(delItem)) { it.remove(); } } return this.toString(); }
public String add(String newItem){ boolean exist = false; Iterator<String> it = this.useForList.iterator(); while (it.hasNext()) { String item = it.next(); if (item.equals(newItem)) { exist = true; break; } } if (!exist) { this.useForList.add(newItem); } return this.toString(); }
protected boolean releaseCheckModifyVipAttributeStruct( ModifyVipAttributesStruct s) { VipUseForList useForList = new VipUseForList(self.getUseFor()); if (s.isUserFor() && s.getUseFor().equals(NetworkServiceType.SNAT.toString())) { useForList.del(s.getUseFor()); if (useForList.getUseForList().isEmpty()){ /* snat is bound to router public interface, it is created automatically, * so it should be deleted automatically, but don't need to remove from backend */ dbf.remove(self); } else { self.setUseFor(useForList.toString()); dbf.update(self); } return false; } for (VipGetServiceReferencePoint ext : pluginRgty.getExtensionList(VipGetServiceReferencePoint.class)) { VipGetServiceReferencePoint.ServiceReference service = ext.getServiceReference(self.getUuid()); if (service.useFor.equals(s.getUseFor()) && service.count <= 1){ useForList.del(s.getUseFor()); self.setUseFor(useForList.toString()); dbf.update(self); } } if (useForList.getUseForList().isEmpty()){ return true; } else { return false; } }
private void validate(APICreateLoadBalancerMsg msg) { SimpleQuery<VipVO> q = dbf.createQuery(VipVO.class); q.select(VipVO_.useFor); q.add(VipVO_.uuid, Op.EQ, msg.getVipUuid()); String useFor = q.findValue(); if(useFor != null){ VipUseForList useForList = new VipUseForList(useFor); if(!useForList.validateNewAdded(LoadBalancerConstants.LB_NETWORK_SERVICE_TYPE_STRING)){ throw new ApiMessageInterceptionException(argerr("the vip[uuid:%s] has been occupied other network service entity[%s]", msg.getVipUuid(), useForList.toString())); } } }
private void validate(APICreateEipMsg msg) { String useFor = Q.New(VipVO.class).select(VipVO_.useFor).eq(VipVO_.uuid, msg.getVipUuid()).findValue(); VipUseForList vipUseForList; if (useFor != null){ vipUseForList = new VipUseForList(useFor); } else { vipUseForList = new VipUseForList(); } if(!vipUseForList.validateNewAdded(EipConstant.EIP_NETWORK_SERVICE_TYPE)){ throw new ApiMessageInterceptionException(operr("the vip[uuid:%s] already has bound to other service[%s]", msg.getVipUuid(), vipUseForList.toString())); } }
@Override public void success() { logger.debug(String.format("successfully acquired vip[uuid:%s, name:%s, ip:%s] on service[%s]", self.getUuid(), self.getName(), self.getIp(), s.getServiceProvider())); VipUseForList useForList = new VipUseForList(self.getUseFor()); useForList.add(s.getUseFor()); VipVO vo = Q.New(VipVO.class).eq(VipVO_.uuid, self.getUuid()).find(); vo.setUseFor(useForList.toString()); dbf.updateAndRefresh(vo); addPeerL3NetworkUuid(s.getPeerL3NetworkUuid()); completion.success(); }
protected boolean acquireCheckModifyVipAttributeStruct(ModifyVipAttributesStruct s) { if (s.isUserFor()) { VipUseForList useForList = new VipUseForList(self.getUseFor()); useForList.add(s.getUseFor()); self.setUseFor(useForList.toString()); } if (s.isServiceProvider()) { if (self.getServiceProvider() != null && s.getServiceProvider() != null && !s.getServiceProvider().equals(self.getServiceProvider())) { throw new OperationFailureException(operr("service provider of the vip[uuid:%s, name:%s, ip: %s] has been set to %s", self.getUuid(), self.getName(), self.getIp(), self.getServiceProvider())); } self.setServiceProvider(s.getServiceProvider()); } if (s.isPeerL3NetworkUuid()) { try { if (s.isServiceProvider()) { addPeerL3NetworkUuid(s.getPeerL3NetworkUuid()); } } catch (CloudRuntimeException e) { throw new OperationFailureException(operr(e.getMessage())); } } self = dbf.updateAndRefresh(self); /* snat service is bound the router interface, don't need to bound to backend */ if (s.getUseFor().equals(NetworkServiceType.SNAT.toString())) { return false; } return s.isPeerL3NetworkUuid() && s.isServiceProvider(); }
VipUseForList useForList = new VipUseForList(useFor); if(!useForList.validateNewAdded(PortForwardingConstant.PORTFORWARDING_NETWORK_SERVICE_TYPE)){ throw new ApiMessageInterceptionException(argerr("the vip[uuid:%s] has been occupied other network service entity[%s]", msg.getVipUuid(), useForList.toString()));