You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/05/07 16:47:10 UTC
[15/85] [abbrv] [partial] Moved most of the VOs and DAOs from server
package into engine-schema as well
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java b/server/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
deleted file mode 100755
index 782ee0d..0000000
--- a/server/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.dc.dao;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.DataCenterIpAddressVO;
-import com.cloud.dc.StorageNetworkIpAddressVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Component
-@Local(value={StorageNetworkIpAddressDao.class})
-@DB(txn=false)
-public class StorageNetworkIpAddressDaoImpl extends GenericDaoBase<StorageNetworkIpAddressVO, Long> implements StorageNetworkIpAddressDao {
- protected final GenericSearchBuilder<StorageNetworkIpAddressVO, Long> countInUserIp;
- protected final GenericSearchBuilder<StorageNetworkIpAddressVO, String> listInUseIp;
- protected final SearchBuilder<StorageNetworkIpAddressVO> untakenIp;
- protected final SearchBuilder<StorageNetworkIpAddressVO> ipSearch;
-
-
- protected StorageNetworkIpAddressDaoImpl() {
- countInUserIp = createSearchBuilder(Long.class);
- countInUserIp.select(null, Func.COUNT, null);
- countInUserIp.and("rangeId", countInUserIp.entity().getRangeId(), Op.EQ);
- countInUserIp.and("taken", countInUserIp.entity().getTakenAt(), Op.NNULL);
- countInUserIp.done();
-
- listInUseIp = createSearchBuilder(String.class);
- listInUseIp.selectField(listInUseIp.entity().getIpAddress());
- listInUseIp.and("rangeId", listInUseIp.entity().getRangeId(), Op.EQ);
- listInUseIp.and("taken", listInUseIp.entity().getTakenAt(), Op.NNULL);
- listInUseIp.done();
-
- untakenIp = createSearchBuilder();
- untakenIp.and("rangeId", untakenIp.entity().getRangeId(), Op.EQ);
- untakenIp.and("taken", untakenIp.entity().getTakenAt(), Op.NULL);
- untakenIp.done();
-
- ipSearch = createSearchBuilder();
- ipSearch.and("ipAddress", ipSearch.entity().getIpAddress(), Op.EQ);
- ipSearch.done();
- }
-
- @Override
- public long countInUseIpByRangeId(long rangeId) {
- SearchCriteria<Long> sc = countInUserIp.create();
- sc.setParameters("rangeId", rangeId);
- return customSearch(sc, null).get(0);
- }
-
- @Override
- public List<String> listInUseIpByRangeId(long rangeId) {
- SearchCriteria<String> sc = listInUseIp.create();
- sc.setParameters("rangeId", rangeId);
- return customSearch(sc, null);
- }
-
- @Override
- @DB
- public StorageNetworkIpAddressVO takeIpAddress(long rangeId) {
- SearchCriteria<StorageNetworkIpAddressVO> sc = untakenIp.create();
- sc.setParameters("rangeId", rangeId);
- Transaction txn = Transaction.currentTxn();
- txn.start();
- StorageNetworkIpAddressVO ip = lockOneRandomRow(sc, true);
- if (ip == null) {
- txn.rollback();
- return null;
- }
- ip.setTakenAt(new Date());
- update(ip.getId(), ip);
- txn.commit();
- return ip;
- }
-
- @Override
- public void releaseIpAddress(String ip) {
- SearchCriteria<StorageNetworkIpAddressVO> sc = ipSearch.create();
- sc.setParameters("ipAddress", ip);
- StorageNetworkIpAddressVO vo = createForUpdate();
- vo.setTakenAt(null);
- update(vo, sc);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDao.java b/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDao.java
deleted file mode 100755
index 2edd568..0000000
--- a/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDao.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.dc.dao;
-
-import java.util.List;
-
-import com.cloud.dc.StorageNetworkIpRangeVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface StorageNetworkIpRangeDao extends GenericDao<StorageNetworkIpRangeVO, Long> {
- List<StorageNetworkIpRangeVO> listByRangeId(long rangeId);
-
- List<StorageNetworkIpRangeVO> listByPodId(long podId);
-
- List<StorageNetworkIpRangeVO> listByDataCenterId(long dcId);
-
- long countRanges();
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java b/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
deleted file mode 100755
index d732e6f..0000000
--- a/server/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.dc.dao;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.StorageNetworkIpRangeVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Component
-@Local(value={StorageNetworkIpRangeDao.class})
-@DB(txn=false)
-public class StorageNetworkIpRangeDaoImpl extends GenericDaoBase<StorageNetworkIpRangeVO, Long> implements StorageNetworkIpRangeDao {
- protected final GenericSearchBuilder<StorageNetworkIpRangeVO, Long> countRanges;
-
- protected StorageNetworkIpRangeDaoImpl() {
- countRanges = createSearchBuilder(Long.class);
- countRanges.select(null, Func.COUNT, null);
- countRanges.done();
- }
-
- @Override
- public List<StorageNetworkIpRangeVO> listByPodId(long podId) {
- SearchCriteriaService<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = SearchCriteria2.create(StorageNetworkIpRangeVO.class);
- sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
- return sc.list();
- }
-
- @Override
- public List<StorageNetworkIpRangeVO> listByRangeId(long rangeId) {
- SearchCriteriaService<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = SearchCriteria2.create(StorageNetworkIpRangeVO.class);
- sc.addAnd(sc.getEntity().getId(), Op.EQ, rangeId);
- return sc.list();
- }
-
- @Override
- public List<StorageNetworkIpRangeVO> listByDataCenterId(long dcId) {
- SearchCriteriaService<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = SearchCriteria2.create(StorageNetworkIpRangeVO.class);
- sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
- return sc.list();
- }
-
- @Override
- public long countRanges() {
- SearchCriteria<Long> sc = countRanges.create();
- return customSearch(sc, null).get(0);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/dc/dao/VlanDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/VlanDao.java b/server/src/com/cloud/dc/dao/VlanDao.java
deleted file mode 100755
index cc82632..0000000
--- a/server/src/com/cloud/dc/dao/VlanDao.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.dc.dao;
-
-import java.util.List;
-
-import com.cloud.dc.Vlan;
-import com.cloud.dc.Vlan.VlanType;
-import com.cloud.dc.VlanVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface VlanDao extends GenericDao<VlanVO, Long> {
-
- VlanVO findByZoneAndVlanId(long zoneId, String vlanId);
-
- List<VlanVO> listByZone(long zoneId);
-
- List<VlanVO> listByType(Vlan.VlanType vlanType);
-
- List<VlanVO> listByZoneAndType(long zoneId, Vlan.VlanType vlanType);
-
- List<VlanVO> listVlansForPod(long podId);
-
- List<VlanVO> listVlansForPodByType(long podId, Vlan.VlanType vlanType);
-
- void addToPod(long podId, long vlanDbId);
-
- List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType);
-
- boolean zoneHasDirectAttachUntaggedVlans(long zoneId);
-
- List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId);
-
- List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType,String vlanId);
-
- List<VlanVO> listVlansByNetworkId(long networkId);
-
- List<VlanVO> listVlansByPhysicalNetworkId(long physicalNetworkId);
-
- List<VlanVO> listZoneWideNonDedicatedVlans(long zoneId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/dc/dao/VlanDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/VlanDaoImpl.java b/server/src/com/cloud/dc/dao/VlanDaoImpl.java
deleted file mode 100755
index 100295b..0000000
--- a/server/src/com/cloud/dc/dao/VlanDaoImpl.java
+++ /dev/null
@@ -1,334 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.dc.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.AccountVlanMapVO;
-import com.cloud.dc.PodVlanMapVO;
-import com.cloud.dc.Vlan;
-import com.cloud.dc.Vlan.VlanType;
-import com.cloud.dc.VlanVO;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.JoinBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component
-@Local(value={VlanDao.class})
-public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao {
-
- private final String FindZoneWideVlans = "SELECT * FROM vlan WHERE data_center_id=? and vlan_type=? and vlan_id!=? and id not in (select vlan_db_id from account_vlan_map)";
-
- protected SearchBuilder<VlanVO> ZoneVlanIdSearch;
- protected SearchBuilder<VlanVO> ZoneSearch;
- protected SearchBuilder<VlanVO> ZoneTypeSearch;
- protected SearchBuilder<VlanVO> ZoneTypeAllPodsSearch;
- protected SearchBuilder<VlanVO> ZoneTypePodSearch;
- protected SearchBuilder<VlanVO> ZoneVlanSearch;
- protected SearchBuilder<VlanVO> NetworkVlanSearch;
- protected SearchBuilder<VlanVO> PhysicalNetworkVlanSearch;
- protected SearchBuilder<VlanVO> ZoneWideNonDedicatedVlanSearch;
-
- protected SearchBuilder<AccountVlanMapVO> AccountVlanMapSearch;
-
- @Inject protected PodVlanMapDao _podVlanMapDao;
- @Inject protected AccountVlanMapDao _accountVlanMapDao;
- @Inject protected IPAddressDao _ipAddressDao;
-
- @Override
- public VlanVO findByZoneAndVlanId(long zoneId, String vlanId) {
- SearchCriteria<VlanVO> sc = ZoneVlanIdSearch.create();
- sc.setParameters("zoneId", zoneId);
- sc.setParameters("vlanId", vlanId);
- return findOneBy(sc);
- }
-
- @Override
- public List<VlanVO> listByZone(long zoneId) {
- SearchCriteria<VlanVO> sc = ZoneSearch.create();
- sc.setParameters("zoneId", zoneId);
- return listBy(sc);
- }
-
- public VlanDaoImpl() {
- ZoneVlanIdSearch = createSearchBuilder();
- ZoneVlanIdSearch.and("zoneId", ZoneVlanIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneVlanIdSearch.and("vlanId", ZoneVlanIdSearch.entity().getVlanTag(), SearchCriteria.Op.EQ);
- ZoneVlanIdSearch.done();
-
- ZoneSearch = createSearchBuilder();
- ZoneSearch.and("zoneId", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneSearch.done();
-
- ZoneTypeSearch = createSearchBuilder();
- ZoneTypeSearch.and("zoneId", ZoneTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneTypeSearch.and("vlanType", ZoneTypeSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
- ZoneTypeSearch.done();
-
- NetworkVlanSearch = createSearchBuilder();
- NetworkVlanSearch.and("networkOfferingId", NetworkVlanSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
- NetworkVlanSearch.done();
-
- PhysicalNetworkVlanSearch = createSearchBuilder();
- PhysicalNetworkVlanSearch.and("physicalNetworkId", PhysicalNetworkVlanSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
- PhysicalNetworkVlanSearch.done();
- }
-
- @Override
- public List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId){
- SearchCriteria<VlanVO> sc = ZoneVlanSearch.create();
- sc.setParameters("zoneId", zoneId);
- sc.setParameters("vlanId", vlanId);
- sc.setParameters("vlanType", vlanType);
- return listBy(sc);
- }
-
- @Override
- public List<VlanVO> listByZoneAndType(long zoneId, VlanType vlanType) {
- SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
- sc.setParameters("zoneId", zoneId);
- sc.setParameters("vlanType", vlanType);
- return listBy(sc);
- }
-
-
- @Override
- public List<VlanVO> listByType(VlanType vlanType) {
- SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
- sc.setParameters("vlanType", vlanType);
- return listBy(sc);
- }
-
- @Override
- public List<VlanVO> listVlansForPod(long podId) {
- //FIXME: use a join statement to improve the performance (should be minor since we expect only one or two
- List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
- List<VlanVO> result = new ArrayList<VlanVO>();
- for (PodVlanMapVO pvmvo: vlanMaps) {
- result.add(findById(pvmvo.getVlanDbId()));
- }
- return result;
- }
-
- @Override
- public List<VlanVO> listVlansForPodByType(long podId, VlanType vlanType) {
- //FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
- List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
- List<VlanVO> result = new ArrayList<VlanVO>();
- for (PodVlanMapVO pvmvo: vlanMaps) {
- VlanVO vlan =findById(pvmvo.getVlanDbId());
- if (vlan.getVlanType() == vlanType) {
- result.add(vlan);
- }
- }
- return result;
- }
-
- @Override
- public List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType) {
- //FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
- List<AccountVlanMapVO> vlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId);
- List<VlanVO> result = new ArrayList<VlanVO>();
- for (AccountVlanMapVO acvmvo: vlanMaps) {
- VlanVO vlan =findById(acvmvo.getVlanDbId());
- if (vlan.getVlanType() == vlanType && (zoneId == null || vlan.getDataCenterId() == zoneId)) {
- result.add(vlan);
- }
- }
- return result;
- }
-
- @Override
- public void addToPod(long podId, long vlanDbId) {
- PodVlanMapVO pvmvo = new PodVlanMapVO(podId, vlanDbId);
- _podVlanMapDao.persist(pvmvo);
-
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params)
- throws ConfigurationException {
- boolean result = super.configure(name, params);
- ZoneTypeAllPodsSearch = createSearchBuilder();
- ZoneTypeAllPodsSearch.and("zoneId", ZoneTypeAllPodsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneTypeAllPodsSearch.and("vlanType", ZoneTypeAllPodsSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
-
- SearchBuilder<PodVlanMapVO> PodVlanSearch = _podVlanMapDao.createSearchBuilder();
- PodVlanSearch.and("podId", PodVlanSearch.entity().getPodId(), SearchCriteria.Op.NNULL);
- ZoneTypeAllPodsSearch.join("vlan", PodVlanSearch, PodVlanSearch.entity().getVlanDbId(), ZoneTypeAllPodsSearch.entity().getId(), JoinBuilder.JoinType.INNER);
-
- ZoneTypeAllPodsSearch.done();
- PodVlanSearch.done();
-
- ZoneTypePodSearch = createSearchBuilder();
- ZoneTypePodSearch.and("zoneId", ZoneTypePodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneTypePodSearch.and("vlanType", ZoneTypePodSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
-
- SearchBuilder<PodVlanMapVO> PodVlanSearch2 = _podVlanMapDao.createSearchBuilder();
- PodVlanSearch2.and("podId", PodVlanSearch2.entity().getPodId(), SearchCriteria.Op.EQ);
- ZoneTypePodSearch.join("vlan", PodVlanSearch2, PodVlanSearch2.entity().getVlanDbId(), ZoneTypePodSearch.entity().getId(), JoinBuilder.JoinType.INNER);
- PodVlanSearch2.done();
- ZoneTypePodSearch.done();
-
- ZoneWideNonDedicatedVlanSearch = createSearchBuilder();
- ZoneWideNonDedicatedVlanSearch.and("zoneId", ZoneWideNonDedicatedVlanSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- AccountVlanMapSearch = _accountVlanMapDao.createSearchBuilder();
- AccountVlanMapSearch.and("accountId", AccountVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.NULL);
- ZoneWideNonDedicatedVlanSearch.join("AccountVlanMapSearch", AccountVlanMapSearch, ZoneWideNonDedicatedVlanSearch.entity().getId(), AccountVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.LEFTOUTER);
- ZoneWideNonDedicatedVlanSearch.done();
- AccountVlanMapSearch.done();
-
- return result;
- }
-
- private VlanVO findNextVlan(long zoneId, Vlan.VlanType vlanType) {
- List<VlanVO> allVlans = listByZoneAndType(zoneId, vlanType);
- List<VlanVO> emptyVlans = new ArrayList<VlanVO>();
- List<VlanVO> fullVlans = new ArrayList<VlanVO>();
-
- // Try to find a VLAN that is partially allocated
- for (VlanVO vlan : allVlans) {
- long vlanDbId = vlan.getId();
-
- int countOfAllocatedIps = _ipAddressDao.countIPs(zoneId, vlanDbId, true);
- int countOfAllIps = _ipAddressDao.countIPs(zoneId, vlanDbId, false);
-
- if ((countOfAllocatedIps > 0) && (countOfAllocatedIps < countOfAllIps)) {
- return vlan;
- } else if (countOfAllocatedIps == 0) {
- emptyVlans.add(vlan);
- } else if (countOfAllocatedIps == countOfAllIps) {
- fullVlans.add(vlan);
- }
- }
-
- if (emptyVlans.isEmpty()) {
- return null;
- }
-
- // Try to find an empty VLAN with the same tag/subnet as a VLAN that is full
- for (VlanVO fullVlan : fullVlans) {
- for (VlanVO emptyVlan : emptyVlans) {
- if (fullVlan.getVlanTag().equals(emptyVlan.getVlanTag()) &&
- fullVlan.getVlanGateway().equals(emptyVlan.getVlanGateway()) &&
- fullVlan.getVlanNetmask().equals(emptyVlan.getVlanNetmask())) {
- return emptyVlan;
- }
- }
- }
-
- // Return a random empty VLAN
- return emptyVlans.get(0);
- }
-
- @Override
- public boolean zoneHasDirectAttachUntaggedVlans(long zoneId) {
- SearchCriteria<VlanVO> sc = ZoneTypeAllPodsSearch.create();
- sc.setParameters("zoneId", zoneId);
- sc.setParameters("vlanType", VlanType.DirectAttached);
-
- return listIncludingRemovedBy(sc).size() > 0;
- }
-
-
- public Pair<String, VlanVO> assignPodDirectAttachIpAddress(long zoneId,
- long podId, long accountId, long domainId) {
- SearchCriteria<VlanVO> sc = ZoneTypePodSearch.create();
- sc.setParameters("zoneId", zoneId);
- sc.setParameters("vlanType", VlanType.DirectAttached);
- sc.setJoinParameters("vlan", "podId", podId);
-
- VlanVO vlan = findOneIncludingRemovedBy(sc);
- if (vlan == null) {
- return null;
- }
-
- return null;
-// String ipAddress = _ipAddressDao.assignIpAddress(accountId, domainId, vlan.getId(), false).getAddress();
-// if (ipAddress == null) {
-// return null;
-// }
-// return new Pair<String, VlanVO>(ipAddress, vlan);
-
- }
-
- @Override
- @DB
- public List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType, String vlanId){
-
- StringBuilder sql = new StringBuilder(FindZoneWideVlans);
-
- Transaction txn = Transaction.currentTxn();
- PreparedStatement pstmt = null;
- try {
- pstmt = txn.prepareAutoCloseStatement(sql.toString());
- pstmt.setLong(1, dcId);
- pstmt.setString(2, vlanType);
- pstmt.setString(3, vlanId);
-
- ResultSet rs = pstmt.executeQuery();
- List<VlanVO> zoneWideVlans = new ArrayList<VlanVO>();
-
- while (rs.next()) {
- zoneWideVlans.add(toEntityBean(rs, false));
- }
-
- return zoneWideVlans;
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
- }
- }
-
- @Override
- public List<VlanVO> listVlansByNetworkId(long networkOfferingId) {
- SearchCriteria<VlanVO> sc = NetworkVlanSearch.create();
- sc.setParameters("networkOfferingId", networkOfferingId);
- return listBy(sc);
- }
-
- @Override
- public List<VlanVO> listVlansByPhysicalNetworkId(long physicalNetworkId) {
- SearchCriteria<VlanVO> sc = PhysicalNetworkVlanSearch.create();
- sc.setParameters("physicalNetworkId", physicalNetworkId);
- return listBy(sc);
- }
-
- @Override
- public List<VlanVO> listZoneWideNonDedicatedVlans(long zoneId) {
- SearchCriteria<VlanVO> sc = ZoneWideNonDedicatedVlanSearch.create();
- sc.setParameters("ZoneWideNonDedicatedVlanSearch", "zoneId", zoneId);
- return listBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/domain/DomainVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/domain/DomainVO.java b/server/src/com/cloud/domain/DomainVO.java
deleted file mode 100644
index a87bedc..0000000
--- a/server/src/com/cloud/domain/DomainVO.java
+++ /dev/null
@@ -1,215 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.domain;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.apache.cloudstack.api.InternalIdentity;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.Identity;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name="domain")
-public class DomainVO implements Domain {
- public static final Logger s_logger = Logger.getLogger(DomainVO.class.getName());
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="parent")
- private Long parent = null;
-
- @Column(name="name")
- private String name = null;
-
- @Column(name="owner")
- private long accountId;
-
- @Column(name="path")
- private String path = null;
-
- @Column(name="level")
- private int level;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- @Column(name="child_count")
- private int childCount = 0;
-
- @Column(name="next_child_seq")
- private long nextChildSeq = 1L;
-
- @Column(name="state")
- private Domain.State state;
-
- @Column(name="network_domain")
- private String networkDomain;
-
- @Column(name="uuid")
- private String uuid;
-
- public DomainVO() {}
-
- public DomainVO(String name, long owner, Long parentId, String networkDomain) {
- this.parent = parentId;
- this.name = name;
- this.accountId = owner;
- this.path ="";
- this.level = 0;
- this.state = Domain.State.Active;
- this.networkDomain = networkDomain;
- this.uuid = UUID.randomUUID().toString();
- }
-
- public DomainVO(String name, long owner, Long parentId, String networkDomain, String uuid) {
- this.parent = parentId;
- this.name = name;
- this.accountId = owner;
- this.path ="";
- this.level = 0;
- this.state = Domain.State.Active;
- this.networkDomain = networkDomain;
- this.uuid = uuid;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public Long getParent() {
- return parent;
- }
-
- @Override
- public void setParent(Long parent) {
- if(parent == null) {
- this.parent = DomainVO.ROOT_DOMAIN;
- } else {
- if(parent.longValue() <= DomainVO.ROOT_DOMAIN)
- this.parent = DomainVO.ROOT_DOMAIN;
- else
- this.parent = parent;
- }
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public int getLevel() {
- return level;
- }
-
- public void setLevel(int level) {
- this.level = level;
- }
-
- @Override
- public int getChildCount() {
- return childCount;
- }
-
- public void setChildCount(int count) {
- childCount = count;
- }
-
- @Override
- public long getNextChildSeq() {
- return nextChildSeq;
- }
-
- public void setNextChildSeq(long seq) {
- nextChildSeq = seq;
- }
-
- @Override
- public Domain.State getState() {
- return state;
- }
-
- @Override
- public void setState(Domain.State state) {
- this.state = state;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("Domain:").append(id).append(path).toString();
- }
-
- @Override
- public String getNetworkDomain() {
- return networkDomain;
- }
-
- public void setNetworkDomain(String domainSuffix) {
- this.networkDomain = domainSuffix;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/domain/dao/DomainDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/domain/dao/DomainDao.java b/server/src/com/cloud/domain/dao/DomainDao.java
deleted file mode 100644
index afeb0f4..0000000
--- a/server/src/com/cloud/domain/dao/DomainDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.domain.dao;
-
-import java.util.List;
-import java.util.Set;
-
-import com.cloud.domain.DomainVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface DomainDao extends GenericDao<DomainVO, Long> {
- public DomainVO create(DomainVO domain);
- public DomainVO findDomainByPath(String domainPath);
- public boolean isChildDomain(Long parentId, Long childId);
- DomainVO findImmediateChildForParent(Long parentId);
- List<DomainVO> findImmediateChildrenForParent(Long parentId);
- List<DomainVO> findAllChildren(String path, Long parentId);
- List<DomainVO> findInactiveDomains();
- Set<Long> getDomainParentIds(long domainId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/domain/dao/DomainDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/domain/dao/DomainDaoImpl.java b/server/src/com/cloud/domain/dao/DomainDaoImpl.java
deleted file mode 100644
index c30ca5e..0000000
--- a/server/src/com/cloud/domain/dao/DomainDaoImpl.java
+++ /dev/null
@@ -1,278 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.domain.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.domain.Domain;
-import com.cloud.domain.DomainVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value={DomainDao.class})
-public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements DomainDao {
- private static final Logger s_logger = Logger.getLogger(DomainDaoImpl.class);
-
- protected SearchBuilder<DomainVO> DomainNameLikeSearch;
- protected SearchBuilder<DomainVO> ParentDomainNameLikeSearch;
- protected SearchBuilder<DomainVO> DomainPairSearch;
- protected SearchBuilder<DomainVO> ImmediateChildDomainSearch;
- protected SearchBuilder<DomainVO> FindAllChildrenSearch;
- protected SearchBuilder<DomainVO> AllFieldsSearch;
-
- public DomainDaoImpl () {
- DomainNameLikeSearch = createSearchBuilder();
- DomainNameLikeSearch.and("name", DomainNameLikeSearch.entity().getName(), SearchCriteria.Op.LIKE);
- DomainNameLikeSearch.done();
-
- ParentDomainNameLikeSearch = createSearchBuilder();
- ParentDomainNameLikeSearch.and("name", ParentDomainNameLikeSearch.entity().getName(), SearchCriteria.Op.LIKE);
- ParentDomainNameLikeSearch.and("parent", ParentDomainNameLikeSearch.entity().getName(), SearchCriteria.Op.EQ);
- ParentDomainNameLikeSearch.done();
-
- DomainPairSearch = createSearchBuilder();
- DomainPairSearch.and("id", DomainPairSearch.entity().getId(), SearchCriteria.Op.IN);
- DomainPairSearch.done();
-
- ImmediateChildDomainSearch = createSearchBuilder();
- ImmediateChildDomainSearch.and("parent", ImmediateChildDomainSearch.entity().getParent(), SearchCriteria.Op.EQ);
- ImmediateChildDomainSearch.done();
-
- FindAllChildrenSearch = createSearchBuilder();
- FindAllChildrenSearch.and("path", FindAllChildrenSearch.entity().getPath(), SearchCriteria.Op.LIKE);
- FindAllChildrenSearch.and("id", FindAllChildrenSearch.entity().getId(), SearchCriteria.Op.NEQ);
- FindAllChildrenSearch.done();
-
- AllFieldsSearch = createSearchBuilder();
- AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
- AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ);
- AllFieldsSearch.and("owner", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AllFieldsSearch.and("path", AllFieldsSearch.entity().getPath(), SearchCriteria.Op.EQ);
- AllFieldsSearch.and("parent", AllFieldsSearch.entity().getParent(), SearchCriteria.Op.EQ);
- AllFieldsSearch.done();
-
- }
-
-
- private static String allocPath(DomainVO parentDomain, String name) {
- String parentPath = parentDomain.getPath();
- return parentPath + name + "/";
- }
-
- @Override
- public synchronized DomainVO create(DomainVO domain) {
- // make sure domain name is valid
- String domainName = domain.getName();
- if (domainName != null) {
- if (domainName.contains("/")) {
- throw new IllegalArgumentException("Domain name contains one or more invalid characters. Please enter a name without '/' characters.");
- }
- } else {
- throw new IllegalArgumentException("Domain name is null. Please specify a valid domain name.");
- }
-
- long parent = DomainVO.ROOT_DOMAIN;
- if(domain.getParent() != null && domain.getParent().longValue() >= DomainVO.ROOT_DOMAIN) {
- parent = domain.getParent().longValue();
- }
-
- DomainVO parentDomain = findById(parent);
- if(parentDomain == null) {
- s_logger.error("Unable to load parent domain: " + parent);
- return null;
- }
-
- Transaction txn = Transaction.currentTxn();
- try {
- txn.start();
-
- parentDomain = this.lockRow(parent, true);
- if(parentDomain == null) {
- s_logger.error("Unable to lock parent domain: " + parent);
- return null;
- }
-
- domain.setPath(allocPath(parentDomain, domain.getName()));
- domain.setLevel(parentDomain.getLevel() + 1);
-
- parentDomain.setNextChildSeq(parentDomain.getNextChildSeq() + 1); // FIXME: remove sequence number?
- parentDomain.setChildCount(parentDomain.getChildCount() + 1);
- persist(domain);
- update(parentDomain.getId(), parentDomain);
-
- txn.commit();
- return domain;
- } catch(Exception e) {
- s_logger.error("Unable to create domain due to " + e.getMessage(), e);
- txn.rollback();
- return null;
- }
- }
-
- @Override
- @DB
- public boolean remove(Long id) {
- // check for any active users / domains assigned to the given domain id and don't remove the domain if there are any
- if (id != null && id.longValue() == DomainVO.ROOT_DOMAIN) {
- s_logger.error("Can not remove domain " + id + " as it is ROOT domain");
- return false;
- }
-
- DomainVO domain = findById(id);
- if(domain == null) {
- s_logger.error("Unable to remove domain as domain " + id + " no longer exists");
- return false;
- }
-
- if(domain.getParent() == null) {
- s_logger.error("Invalid domain " + id + ", orphan?");
- return false;
- }
-
- String sql = "SELECT * from account where domain_id = " + id + " and removed is null";
- String sql1 = "SELECT * from domain where parent = " + id + " and removed is null";
-
- boolean success = false;
- Transaction txn = Transaction.currentTxn();
- try {
- txn.start();
- DomainVO parentDomain = super.lockRow(domain.getParent(), true);
- if(parentDomain == null) {
- s_logger.error("Unable to load parent domain: " + domain.getParent());
- return false;
- }
-
- PreparedStatement stmt = txn.prepareAutoCloseStatement(sql);
- ResultSet rs = stmt.executeQuery();
- if (rs.next()) {
- return false;
- }
- stmt = txn.prepareAutoCloseStatement(sql1);
- rs = stmt.executeQuery();
- if (rs.next()) {
- return false;
- }
-
- parentDomain.setChildCount(parentDomain.getChildCount() - 1);
- update(parentDomain.getId(), parentDomain);
- success = super.remove(id);
- txn.commit();
- } catch (SQLException ex) {
- success = false;
- s_logger.error("error removing domain: " + id, ex);
- txn.rollback();
- }
- return success;
- }
-
- @Override
- public DomainVO findDomainByPath(String domainPath) {
- SearchCriteria<DomainVO> sc = createSearchCriteria();
- sc.addAnd("path", SearchCriteria.Op.EQ, domainPath);
- return findOneBy(sc);
- }
-
- @Override
- public DomainVO findImmediateChildForParent(Long parentId){
- SearchCriteria<DomainVO> sc = ImmediateChildDomainSearch.create();
- sc.setParameters("parent", parentId);
- return (listBy(sc).size() > 0 ? listBy(sc).get(0) : null);//may need to revisit for multiple children case
- }
-
- @Override
- public List<DomainVO> findImmediateChildrenForParent(Long parentId){
- SearchCriteria<DomainVO> sc = ImmediateChildDomainSearch.create();
- sc.setParameters("parent", parentId);
- return listBy(sc);
- }
-
- @Override
- public List<DomainVO> findAllChildren(String path, Long parentId){
- SearchCriteria<DomainVO> sc = FindAllChildrenSearch.create();
- sc.setParameters("path", "%"+path+"%");
- sc.setParameters("id", parentId);
- return listBy(sc);
- }
-
- @Override
- public boolean isChildDomain(Long parentId, Long childId) {
- if ((parentId == null) || (childId == null)) {
- return false;
- }
-
- if (parentId.equals(childId)) {
- return true;
- }
-
- boolean result = false;
- SearchCriteria<DomainVO> sc = DomainPairSearch.create();
- sc.setParameters("id", parentId, childId);
-
- List<DomainVO> domainPair = listBy(sc);
-
- if ((domainPair != null) && (domainPair.size() == 2)) {
- DomainVO d1 = domainPair.get(0);
- DomainVO d2 = domainPair.get(1);
-
- if (d1.getId() == parentId) {
- result = d2.getPath().startsWith(d1.getPath());
- } else {
- result = d1.getPath().startsWith(d2.getPath());
- }
- }
- return result;
- }
-
- @Override
- public List<DomainVO> findInactiveDomains() {
- SearchCriteria<DomainVO> sc = AllFieldsSearch.create();
- sc.setParameters("state", Domain.State.Inactive);
- return listBy(sc);
- }
-
- @Override
- public Set<Long> getDomainParentIds(long domainId) {
- Set<Long> parentDomains = new HashSet<Long>();
- Domain domain = findById(domainId);
-
- if (domain != null) {
- parentDomains.add(domain.getId());
-
- while (domain.getParent() != null) {
- domain = findById(domain.getParent());
- parentDomains.add(domain.getId());
- }
- }
-
- return parentDomains;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/host/dao/HostDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/host/dao/HostDao.java b/server/src/com/cloud/host/dao/HostDao.java
deleted file mode 100755
index 98bdcb4..0000000
--- a/server/src/com/cloud/host/dao/HostDao.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.host.dao;
-
-import java.util.Date;
-import java.util.List;
-
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.info.RunningHostCountInfo;
-import com.cloud.resource.ResourceState;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-/**
- * Data Access Object for server
- *
- */
-public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Status.Event, Host> {
- long countBy(long clusterId, ResourceState... states);
-
- /**
- * Mark all hosts associated with a certain management server
- * as disconnected.
- *
- * @param msId management server id.
- */
- void markHostsAsDisconnected(long msId, long lastPing);
-
- List<HostVO> findLostHosts(long timeout);
-
- List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
-
- List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
-
- long getNextSequence(long hostId);
-
- void loadDetails(HostVO host);
-
- void saveDetails(HostVO host);
-
- void loadHostTags(HostVO host);
-
- List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
-
- long countRoutingHostsByDataCenter(long dcId);
-
- List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
-
- boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
-
- HostVO findByGuid(String guid);
-
- HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
- List<HostVO> findHypervisorHostInCluster(long clusterId);
-
-
- /**
- * @param type
- * @param clusterId
- * @param podId
- * @param dcId
- * @param haTag TODO
- * @return
- */
- List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
-}