diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index 9503a6c137e..6cec8b38223 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -37,7 +37,7 @@ - + + - - + - diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java index 7d80e8a69ab..3082d21c1ee 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java @@ -49,13 +49,13 @@ public class VMEntityDaoImpl extends GenericDaoBase implements public static final Logger s_logger = Logger.getLogger(VMEntityDaoImpl.class); - @Inject protected VMReservationDaoImpl _vmReservationDao; + @Inject protected VMReservationDao _vmReservationDao; - @Inject protected VMComputeTagDaoImpl _vmComputeTagDao; + @Inject protected VMComputeTagDao _vmComputeTagDao; - @Inject protected VMRootDiskTagDaoImpl _vmRootDiskTagsDao; + @Inject protected VMRootDiskTagDao _vmRootDiskTagsDao; - @Inject protected VMNetworkMapDaoImpl _vmNetworkMapDao; + @Inject protected VMNetworkMapDao _vmNetworkMapDao; @Inject diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java index 66261dd09b6..dc346cc2423 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java @@ -43,7 +43,7 @@ public class VMReservationDaoImpl extends GenericDaoBase protected SearchBuilder VmIdSearch; - @Inject protected VolumeReservationDaoImpl _volumeReservationDao; + @Inject protected VolumeReservationDao _volumeReservationDao; public VMReservationDaoImpl() { } diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java index ea9a30b969a..e28c6f1d5c1 100755 --- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java @@ -84,9 +84,6 @@ public class CloudOrchestrator implements OrchestrationService { @Inject protected DiskOfferingDao _diskOfferingDao = null; - @Inject - protected VirtualMachineEntityFactory _vmEntityFactory; - @Inject protected NetworkDao _networkDao; @@ -232,7 +229,9 @@ public class CloudOrchestrator implements OrchestrationService { // VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager); VirtualMachineEntityImpl vmEntity = null; try { - vmEntity = _vmEntityFactory.getObject(); + vmEntity = VirtualMachineEntityImpl.class.newInstance(); + vmEntity = ComponentContext.inject(vmEntity); + } catch (Exception e) { // add error handling here } diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java index 81db645938c..575bc8e2ba2 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java @@ -240,4 +240,10 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa return null; } + @Override + public void disconnectWithInvestigation(long hostId, Event event) { + // TODO Auto-generated method stub + + } + } diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java index 301b5861f8c..f43f18d0e6d 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java @@ -56,6 +56,7 @@ import com.cloud.storage.dao.VMTemplateDaoImpl; import com.cloud.storage.dao.VMTemplateDetailsDao; import com.cloud.storage.dao.VMTemplateZoneDao; import com.cloud.tags.ResourceTagVO; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; @@ -115,9 +116,8 @@ public class ImageDataDaoImpl extends GenericDaoBase implemen private GenericSearchBuilder CountTemplatesByAccount; private SearchBuilder updateStateSearch; - //ResourceTagsDaoImpl _tagsDao = ComponentInject.inject(ResourceTagsDaoImpl.class); @Inject - ResourceTagsDaoImpl _tagsDao = null; + ResourceTagDao _tagsDao = null; private String routerTmpltName; private String consoleProxyTmpltName; diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java index 1e12498dff6..d8497e2f3da 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.List; import javax.ejb.Local; +import javax.inject.Inject; import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk; import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType; @@ -36,6 +37,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.server.ResourceTag.TaggedResourceType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Volume; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.Pair; @@ -63,8 +65,7 @@ public class VolumeDao2Impl extends GenericDaoBase implements Vo protected final SearchBuilder InstanceStatesSearch; protected final SearchBuilder AllFieldsSearch; protected GenericSearchBuilder CountByAccount; - //ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class); - ResourceTagsDaoImpl _tagsDao = null; + @Inject ResourceTagDao _tagsDao = null; protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?"; protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?"; diff --git a/server/src/com/cloud/agent/AgentManager.java b/server/src/com/cloud/agent/AgentManager.java index 0053851a6fe..6c300ea76fa 100755 --- a/server/src/com/cloud/agent/AgentManager.java +++ b/server/src/com/cloud/agent/AgentManager.java @@ -156,4 +156,6 @@ public interface AgentManager extends Manager { boolean reconnect(long hostId); Answer sendToSSVM(Long dcId, final Command cmd); + + void disconnectWithInvestigation(final long hostId, final Status.Event event); } diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 3b5d433f1be..5342a4f71f9 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -218,7 +218,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl protected int _pingInterval; protected long _pingTimeout; - @Inject protected AgentMonitor _monitor; + @Inject protected AgentMonitorService _monitor; protected ExecutorService _executor; protected ThreadPoolExecutor _connectExecutor; @@ -668,7 +668,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl public boolean start() { startDirectlyConnectedHosts(); if (_monitor != null) { - _monitor.start(); + _monitor.startMonitoring(); } if (_connection != null) { _connection.start(); @@ -1455,7 +1455,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl _executor.submit(new DisconnectTask(attache, event, false)); } - protected void disconnectWithInvestigation(AgentAttache attache, final Status.Event event) { + public void disconnectWithInvestigation(AgentAttache attache, final Status.Event event) { _executor.submit(new DisconnectTask(attache, event, true)); } diff --git a/server/src/com/cloud/agent/manager/AgentMonitor.java b/server/src/com/cloud/agent/manager/AgentMonitor.java index c019a76eaa8..ae539fd9188 100755 --- a/server/src/com/cloud/agent/manager/AgentMonitor.java +++ b/server/src/com/cloud/agent/manager/AgentMonitor.java @@ -26,6 +26,7 @@ import javax.inject.Inject; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; +import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; import com.cloud.agent.api.AgentControlAnswer; import com.cloud.agent.api.AgentControlCommand; @@ -56,13 +57,13 @@ import com.cloud.vm.VMInstanceVO; import com.cloud.vm.dao.VMInstanceDao; @Component -public class AgentMonitor extends Thread implements Listener { +public class AgentMonitor extends Thread implements AgentMonitorService { private static Logger s_logger = Logger.getLogger(AgentMonitor.class); private static Logger status_Logger = Logger.getLogger(Status.class); private long _pingTimeout; @Inject private HostDao _hostDao; private boolean _stop; - @Inject private AgentManagerImpl _agentMgr; + @Inject private AgentManager _agentMgr; @Inject private VMInstanceDao _vmDao; @Inject private DataCenterDao _dcDao = null; @Inject private HostPodDao _podDao = null; @@ -296,4 +297,8 @@ public class AgentMonitor extends Thread implements Listener { return -1; } + public void startMonitoring() { + start(); + } } + diff --git a/server/src/com/cloud/agent/manager/AgentMonitorService.java b/server/src/com/cloud/agent/manager/AgentMonitorService.java new file mode 100644 index 00000000000..cdb0c1e2cbb --- /dev/null +++ b/server/src/com/cloud/agent/manager/AgentMonitorService.java @@ -0,0 +1,28 @@ +// 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.agent.manager; + +import com.cloud.agent.Listener; + +public interface AgentMonitorService extends Listener { + + public Boolean isAgentBehindOnPing(long agentId); + public Long getAgentPingTime(long agentId); + public void pingBy(long agentId); + public void signalStop(); + public void startMonitoring(); +} diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 8e3c5e01bfd..94abe5033cb 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -133,7 +133,9 @@ public class ApiDispatcher { processParameters(cmd, params); UserContext ctx = UserContext.current(); ctx.setAccountId(cmd.getEntityOwnerId()); - if (cmd instanceof BaseAsyncCmd) { + + BaseCmd realCmdObj = ComponentContext.getTargetObject(cmd); + if (realCmdObj instanceof BaseAsyncCmd) { BaseAsyncCmd asyncCmd = (BaseAsyncCmd) cmd; String startEventId = params.get("ctxStartEventId"); diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 8b14d8268c8..deb5e12f9fc 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -142,7 +142,7 @@ import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; @Component -public class ApiServer implements HttpRequestHandler { +public class ApiServer implements HttpRequestHandler, ApiServerService { private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName()); private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName()); @@ -500,22 +500,22 @@ public class ApiServer implements HttpRequestHandler { // if the command is of the listXXXCommand, we will need to also return the // the job id and status if possible // For those listXXXCommand which we have already created DB views, this step is not needed since async job is joined in their db views. - if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListRoutersCmd) - && !(cmdObj instanceof ListSecurityGroupsCmd) - && !(cmdObj instanceof ListTagsCmd) - && !(cmdObj instanceof ListEventsCmd) - && !(cmdObj instanceof ListVMGroupsCmd) - && !(cmdObj instanceof ListProjectsCmd) - && !(cmdObj instanceof ListProjectAccountsCmd) - && !(cmdObj instanceof ListProjectInvitationsCmd) - && !(cmdObj instanceof ListHostsCmd) - && !(cmdObj instanceof ListVolumesCmd) - && !(cmdObj instanceof ListUsersCmd) - && !(cmdObj instanceof ListAccountsCmd) - && !(cmdObj instanceof ListStoragePoolsCmd) - && !(cmdObj instanceof ListDiskOfferingsCmd) - && !(cmdObj instanceof ListServiceOfferingsCmd) - && !(cmdObj instanceof ListZonesByCmd) + if (realCmdObj instanceof BaseListCmd && !(realCmdObj instanceof ListVMsCmd) && !(realCmdObj instanceof ListRoutersCmd) + && !(realCmdObj instanceof ListSecurityGroupsCmd) + && !(realCmdObj instanceof ListTagsCmd) + && !(realCmdObj instanceof ListEventsCmd) + && !(realCmdObj instanceof ListVMGroupsCmd) + && !(realCmdObj instanceof ListProjectsCmd) + && !(realCmdObj instanceof ListProjectAccountsCmd) + && !(realCmdObj instanceof ListProjectInvitationsCmd) + && !(realCmdObj instanceof ListHostsCmd) + && !(realCmdObj instanceof ListVolumesCmd) + && !(realCmdObj instanceof ListUsersCmd) + && !(realCmdObj instanceof ListAccountsCmd) + && !(realCmdObj instanceof ListStoragePoolsCmd) + && !(realCmdObj instanceof ListDiskOfferingsCmd) + && !(realCmdObj instanceof ListServiceOfferingsCmd) + && !(realCmdObj instanceof ListZonesByCmd) ) { buildAsyncListResponse((BaseListCmd) cmdObj, caller); } diff --git a/server/src/com/cloud/api/ApiServerService.java b/server/src/com/cloud/api/ApiServerService.java new file mode 100644 index 00000000000..12d8b52fa83 --- /dev/null +++ b/server/src/com/cloud/api/ApiServerService.java @@ -0,0 +1,37 @@ +// 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.api; + +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.apache.cloudstack.api.ServerApiException; +import com.cloud.exception.CloudAuthenticationException; + +public interface ApiServerService { + public boolean verifyRequest(Map requestParameters, Long userId) throws ServerApiException; + public Long fetchDomainId(String domainUUID); + public void loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, String loginIpAddress ,Map requestParameters) throws CloudAuthenticationException; + public void logoutUser(long userId); + public boolean verifyUser(Long userId); + + public String getSerializedApiError(int errorCode, String errorText, Map apiCommandParams, String responseType); + public String getSerializedApiError(ServerApiException ex, Map apiCommandParams, String responseType); + + public String handleRequest(Map params, String responseType, StringBuffer auditTrailSb) throws ServerApiException; +} diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java index e5c1db78c7b..03bfb5f2d49 100755 --- a/server/src/com/cloud/api/ApiServlet.java +++ b/server/src/com/cloud/api/ApiServlet.java @@ -50,7 +50,7 @@ public class ApiServlet extends HttpServlet { public static final Logger s_logger = Logger.getLogger(ApiServlet.class.getName()); private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName()); - @Inject ApiServer _apiServer; + @Inject ApiServerService _apiServer; @Inject AccountService _accountMgr; public ApiServlet() { diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 074675cdd33..90e9803b1c2 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -86,6 +86,7 @@ import com.cloud.dc.dao.AccountVlanMapDao; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterIpAddressDao; +import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDao; import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl; import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.PodVlanMapDao; @@ -249,7 +250,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati VpcManager _vpcMgr; // FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao? - @Inject protected DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao; + @Inject protected DataCenterLinkLocalIpAddressDao _LinkLocalIpAllocDao; private int _maxVolumeSizeInGb; private long _defaultPageSize; diff --git a/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java b/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java index 68106f7dd6a..fe5f5aee810 100644 --- a/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java +++ b/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java @@ -65,15 +65,6 @@ public class ConfigurationDaoImpl extends GenericDaoBase private final SearchBuilder AccountSearch; private final SearchBuilder DomainSearch; - //protected final DomainDaoImpl _domainDao = ComponentLocator.inject(DomainDaoImpl.class); - //protected final AccountDaoImpl _accountDao = ComponentLocator.inject(AccountDaoImpl.class); - - @Inject protected DomainDaoImpl _domainDao; - @Inject protected AccountDaoImpl _accountDao; + @Inject protected DomainDao _domainDao; + @Inject protected AccountDao _accountDao; public ResourceCountDaoImpl() { TypeSearch = createSearchBuilder(); diff --git a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java index a63bbd3c068..2a6c2ecb252 100755 --- a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java @@ -63,11 +63,11 @@ public class DataCenterDaoImpl extends GenericDaoBase implem protected SearchBuilder DisabledZonesSearch; protected SearchBuilder TokenSearch; - @Inject protected DataCenterIpAddressDaoImpl _ipAllocDao = null; - @Inject protected DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = null; - @Inject protected DataCenterVnetDaoImpl _vnetAllocDao = null; - @Inject protected PodVlanDaoImpl _podVlanAllocDao = null; - @Inject protected DcDetailsDaoImpl _detailsDao = null; + @Inject protected DataCenterIpAddressDao _ipAllocDao = null; + @Inject protected DataCenterLinkLocalIpAddressDao _LinkLocalIpAllocDao = null; + @Inject protected DataCenterVnetDao _vnetAllocDao = null; + @Inject protected PodVlanDao _podVlanAllocDao = null; + @Inject protected DcDetailsDao _detailsDao = null; protected long _prefix; protected Random _rand = new Random(System.currentTimeMillis()); diff --git a/server/src/com/cloud/dc/dao/DataCenterIpAddressDao.java b/server/src/com/cloud/dc/dao/DataCenterIpAddressDao.java index bf7884466d0..7a19b245d2c 100644 --- a/server/src/com/cloud/dc/dao/DataCenterIpAddressDao.java +++ b/server/src/com/cloud/dc/dao/DataCenterIpAddressDao.java @@ -23,6 +23,12 @@ import com.cloud.utils.db.GenericDao; public interface DataCenterIpAddressDao extends GenericDao { + public DataCenterIpAddressVO takeIpAddress(long dcId, long podId, long instanceId, String reservationId); + public DataCenterIpAddressVO takeDataCenterIpAddress(long dcId, String reservationId); + public void addIpRange(long dcId, long podId, String start, String end); + public void releaseIpAddress(String ipAddress, long dcId, Long instanceId); + public void releaseIpAddress(long nicId, String reservationId); + boolean mark(long dcId, long podId, String ip); List listByPodIdDcIdIpAddress(long podId, long dcId, String ipAddress); List listByPodIdDcId(long podId, long dcId); diff --git a/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDao.java b/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDao.java new file mode 100644 index 00000000000..64fabfbadb4 --- /dev/null +++ b/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDao.java @@ -0,0 +1,16 @@ +package com.cloud.dc.dao; + +import java.util.List; + +import com.cloud.dc.DataCenterLinkLocalIpAddressVO; +import com.cloud.utils.db.GenericDao; + +public interface DataCenterLinkLocalIpAddressDao extends GenericDao{ + public DataCenterLinkLocalIpAddressVO takeIpAddress(long dcId, long podId, long instanceId, String reservationId); + public boolean deleteIpAddressByPod(long podId); + public void addIpRange(long dcId, long podId, String start, String end); + public void releaseIpAddress(String ipAddress, long dcId, long instanceId); + public void releaseIpAddress(long nicId, String reservationId); + public List listByPodIdDcId(long podId, long dcId); + public int countIPs(long podId, long dcId, boolean onlyCountAllocated); +} diff --git a/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java index 6456ebfd5c5..b52e3733a3f 100644 --- a/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterLinkLocalIpAddressDaoImpl.java @@ -42,7 +42,7 @@ import com.cloud.utils.net.NetUtils; @Component @Local(value={DataCenterLinkLocalIpAddressDaoImpl.class}) @DB(txn=false) -public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase implements GenericDao { +public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase implements DataCenterLinkLocalIpAddressDao { private static final Logger s_logger = Logger.getLogger(DataCenterLinkLocalIpAddressDaoImpl.class); private final SearchBuilder AllFieldsSearch; diff --git a/server/src/com/cloud/dc/dao/DataCenterVnetDao.java b/server/src/com/cloud/dc/dao/DataCenterVnetDao.java new file mode 100644 index 00000000000..79e91c4bca8 --- /dev/null +++ b/server/src/com/cloud/dc/dao/DataCenterVnetDao.java @@ -0,0 +1,38 @@ +// 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.DataCenterVnetVO; +import com.cloud.utils.db.GenericDao; + +public interface DataCenterVnetDao extends GenericDao { + public List listAllocatedVnets(long physicalNetworkId); + public List findVnet(long dcId, String vnet); + public int countZoneVlans(long dcId, boolean onlyCountAllocated); + public List findVnet(long dcId, long physicalNetworkId, String vnet); + + public void add(long dcId, long physicalNetworkId, int start, int end); + + public void delete(long physicalNetworkId); + + public DataCenterVnetVO take(long physicalNetworkId, long accountId, String reservationId); + + public void release(String vnet, long physicalNetworkId, long accountId, String reservationId); + +} diff --git a/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java index af8bd25ebc9..5ded0f4ecf5 100755 --- a/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java @@ -41,7 +41,7 @@ import com.cloud.utils.exception.CloudRuntimeException; */ @Component @DB(txn=false) -public class DataCenterVnetDaoImpl extends GenericDaoBase implements GenericDao { +public class DataCenterVnetDaoImpl extends GenericDaoBase implements DataCenterVnetDao { private final SearchBuilder FreeVnetSearch; private final SearchBuilder VnetDcSearch; private final SearchBuilder VnetDcSearchAllocated; diff --git a/server/src/com/cloud/dc/dao/PodVlanDao.java b/server/src/com/cloud/dc/dao/PodVlanDao.java new file mode 100644 index 00000000000..6359dfea83d --- /dev/null +++ b/server/src/com/cloud/dc/dao/PodVlanDao.java @@ -0,0 +1,30 @@ +// 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.PodVlanVO; +import com.cloud.utils.db.GenericDao; + +public interface PodVlanDao extends GenericDao { + public List listAllocatedVnets(long podId); + public void add(long podId, int start, int end); + public void delete(long podId); + public PodVlanVO take(long podId, long accountId); + public void release(String vlan, long podId, long accountId); +} diff --git a/server/src/com/cloud/dc/dao/PodVlanDaoImpl.java b/server/src/com/cloud/dc/dao/PodVlanDaoImpl.java index 96cd42cf31f..413f9ed6c18 100755 --- a/server/src/com/cloud/dc/dao/PodVlanDaoImpl.java +++ b/server/src/com/cloud/dc/dao/PodVlanDaoImpl.java @@ -35,7 +35,7 @@ import com.cloud.utils.exception.CloudRuntimeException; * PodVlanDaoImpl maintains the one-to-many relationship between */ @Component -public class PodVlanDaoImpl extends GenericDaoBase implements GenericDao { +public class PodVlanDaoImpl extends GenericDaoBase implements PodVlanDao { private final SearchBuilder FreeVlanSearch; private final SearchBuilder VlanPodSearch; private final SearchBuilder PodSearchAllocated; diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index d4150d52f59..b0aeffed07b 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -103,6 +103,7 @@ import com.cloud.utils.AnnotationHelper; import com.cloud.utils.Journal; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; +import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.Manager; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.db.*; @@ -2741,10 +2742,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null); // add instance of the provider - VirtualRouterElement element = (VirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName()); - if (element == null) { + NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName()); + if (networkElement == null) { throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider"); } + + VirtualRouterElement element = ComponentContext.getTargetObject(networkElement); element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter); return nsp; @@ -2766,11 +2769,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VPCVirtualRouter.getName(), null, null); - // add instance of the provider - VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName()); - if (element == null) { + + NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName()); + if (networkElement == null) { throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider"); } + + VpcVirtualRouterElement element = ComponentContext.getTargetObject(networkElement); element.addElement(nsp.getId(), VirtualRouterProviderType.VPCVirtualRouter); return nsp; diff --git a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java index 57a5f853fda..45a80685078 100644 --- a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java +++ b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java @@ -30,6 +30,7 @@ import com.cloud.network.rules.FirewallRule.State; import com.cloud.network.rules.FirewallRule.TrafficType; import com.cloud.network.rules.FirewallRuleVO; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; @@ -53,8 +54,8 @@ public class FirewallRulesDaoImpl extends GenericDaoBase i protected final SearchBuilder SystemRuleSearch; protected final GenericSearchBuilder RulesByIpCount; - @Inject protected FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject protected FirewallRulesCidrsDao _firewallRulesCidrsDao; + @Inject ResourceTagDao _tagsDao; @Inject IPAddressDao _ipDao; protected FirewallRulesDaoImpl() { diff --git a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java index e7067d98156..778f15f835e 100755 --- a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java +++ b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java @@ -30,9 +30,11 @@ import org.springframework.stereotype.Component; import com.cloud.dc.Vlan.VlanType; import com.cloud.dc.VlanVO; +import com.cloud.dc.dao.VlanDao; import com.cloud.dc.dao.VlanDaoImpl; import com.cloud.network.IpAddress.State; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; @@ -57,9 +59,9 @@ public class IPAddressDaoImpl extends GenericDaoBase implemen protected GenericSearchBuilder AllocatedIpCount; protected GenericSearchBuilder AllIpCountForDashboard; protected GenericSearchBuilder AllocatedIpCountForAccount; - @Inject protected VlanDaoImpl _vlanDao; + @Inject protected VlanDao _vlanDao; protected GenericSearchBuilder CountFreePublicIps; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; // make it public for JUnit test public IPAddressDaoImpl() { diff --git a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java index 547dc608e73..f211a7f1a79 100644 --- a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java +++ b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java @@ -51,7 +51,7 @@ public class LoadBalancerDaoImpl extends GenericDaoBase im private final SearchBuilder AccountAndNameSearch; protected final SearchBuilder TransitionStateSearch; - @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao; + @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao; protected LoadBalancerDaoImpl() { ListByIp = createSearchBuilder(); diff --git a/server/src/com/cloud/network/dao/NetworkAccountDao.java b/server/src/com/cloud/network/dao/NetworkAccountDao.java new file mode 100644 index 00000000000..c4435c8074e --- /dev/null +++ b/server/src/com/cloud/network/dao/NetworkAccountDao.java @@ -0,0 +1,22 @@ +// 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.network.dao; + +import com.cloud.utils.db.GenericDao; + +public interface NetworkAccountDao extends GenericDao { +} diff --git a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java b/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java index f0b71562f62..09479056f14 100644 --- a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java @@ -22,7 +22,7 @@ import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDaoBase; @Component -public class NetworkAccountDaoImpl extends GenericDaoBase implements GenericDao { +public class NetworkAccountDaoImpl extends GenericDaoBase implements NetworkAccountDao { public NetworkAccountDaoImpl() { super(); } diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java index 43c581f83b9..1bc8973bc50 100644 --- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -39,13 +39,11 @@ import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.NetworkOfferingVO; +import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDaoImpl; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.GenericSearchBuilder; -import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.*; import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchCriteria.Func; @@ -76,13 +74,13 @@ public class NetworkDaoImpl extends GenericDaoBase implements N - @Inject ResourceTagsDaoImpl _tagsDao; - @Inject NetworkAccountDaoImpl _accountsDao; - @Inject NetworkDomainDaoImpl _domainsDao; - @Inject NetworkOpDaoImpl _opDao; - @Inject NetworkServiceMapDaoImpl _ntwkSvcMap; - @Inject NetworkOfferingDaoImpl _ntwkOffDao; - @Inject NetworkOpDaoImpl _ntwkOpDao; + @Inject ResourceTagDao _tagsDao; + @Inject NetworkAccountDao _accountsDao; + @Inject NetworkDomainDao _domainsDao; + @Inject NetworkOpDao _opDao; + @Inject NetworkServiceMapDao _ntwkSvcMap; + @Inject NetworkOfferingDao _ntwkOffDao; + @Inject NetworkOpDao _ntwkOpDao; TableGenerator _tgMacAddress; diff --git a/server/src/com/cloud/network/dao/NetworkOpDao.java b/server/src/com/cloud/network/dao/NetworkOpDao.java new file mode 100644 index 00000000000..f492dbd254f --- /dev/null +++ b/server/src/com/cloud/network/dao/NetworkOpDao.java @@ -0,0 +1,26 @@ +// 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.network.dao; + +import com.cloud.utils.db.GenericDao; + +public interface NetworkOpDao extends GenericDao { + public int getActiveNics(long networkId); + public void changeActiveNicsBy(long networkId, int count); + public void setCheckForGc(long networkId); + public void clearCheckForGc(long networkId); +} diff --git a/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java b/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java index bdc9f50398c..a3f54b78850 100644 --- a/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java @@ -30,7 +30,7 @@ import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.UpdateBuilder; @Component -public class NetworkOpDaoImpl extends GenericDaoBase implements GenericDao { +public class NetworkOpDaoImpl extends GenericDaoBase implements NetworkOpDao { protected final SearchBuilder AllFieldsSearch; protected final GenericSearchBuilder ActiveNicsSearch; protected final Attribute _activeNicsAttribute; diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java b/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java index 8e67d8bb5e8..1e26a51cead 100644 --- a/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java @@ -36,7 +36,7 @@ import com.cloud.utils.db.SearchCriteria.Op; public class PhysicalNetworkDaoImpl extends GenericDaoBase implements PhysicalNetworkDao { final SearchBuilder ZoneSearch; - @Inject protected PhysicalNetworkTrafficTypeDaoImpl _trafficTypeDao; + @Inject protected PhysicalNetworkTrafficTypeDao _trafficTypeDao; protected PhysicalNetworkDaoImpl() { super(); diff --git a/server/src/com/cloud/network/dao/RouterNetworkDao.java b/server/src/com/cloud/network/dao/RouterNetworkDao.java new file mode 100644 index 00000000000..bd275bdd5fc --- /dev/null +++ b/server/src/com/cloud/network/dao/RouterNetworkDao.java @@ -0,0 +1,26 @@ +// 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.network.dao; + +import java.util.List; + +import com.cloud.utils.db.GenericDao; + +public interface RouterNetworkDao extends GenericDao { + public List getRouterNetworks(long routerId); + public RouterNetworkVO findByRouterAndNetwork (long routerId, long networkId); +} diff --git a/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java index e560713aca5..b0b633c55e9 100644 --- a/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java @@ -28,7 +28,7 @@ import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.SearchCriteria.Op; @Component -public class RouterNetworkDaoImpl extends GenericDaoBase implements GenericDao{ +public class RouterNetworkDaoImpl extends GenericDaoBase implements RouterNetworkDao { protected final GenericSearchBuilder RouterNetworksSearch; protected final SearchBuilder AllFieldsSearch; diff --git a/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java b/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java index 2830abe699f..4745f9aad01 100644 --- a/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java +++ b/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java @@ -35,8 +35,8 @@ import com.cloud.utils.db.SearchCriteria; public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase implements Site2SiteVpnConnectionDao { private static final Logger s_logger = Logger.getLogger(Site2SiteVpnConnectionDaoImpl.class); - @Inject protected IPAddressDaoImpl _addrDao; - @Inject protected Site2SiteVpnGatewayDaoImpl _vpnGatewayDao; + @Inject protected IPAddressDao _addrDao; + @Inject protected Site2SiteVpnGatewayDao _vpnGatewayDao; private SearchBuilder AllFieldsSearch; private SearchBuilder VpcSearch; diff --git a/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java b/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java index 8305978f26c..fa4a9fa3df2 100644 --- a/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java +++ b/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java @@ -29,7 +29,7 @@ import com.cloud.utils.db.SearchCriteria; @Component @Local(value={Site2SiteVpnGatewayDao.class}) public class Site2SiteVpnGatewayDaoImpl extends GenericDaoBase implements Site2SiteVpnGatewayDao { - @Inject protected IPAddressDaoImpl _addrDao; + @Inject protected IPAddressDao _addrDao; private static final Logger s_logger = Logger.getLogger(Site2SiteVpnGatewayDaoImpl.class); diff --git a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java index 5406ab624e0..2e54a70b05e 100644 --- a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java +++ b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java @@ -23,6 +23,7 @@ import javax.inject.Inject; import org.springframework.stereotype.Component; +import com.cloud.network.dao.FirewallRulesCidrsDao; import com.cloud.network.dao.FirewallRulesCidrsDaoImpl; import com.cloud.network.rules.FirewallRule.Purpose; import com.cloud.network.rules.FirewallRule.State; @@ -43,7 +44,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase AllRulesSearchByVM; protected final SearchBuilder ActiveRulesSearchByAccount; - @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao; + @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao; protected PortForwardingRulesDaoImpl() { super(); diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java index 68112c0a7c1..dfa6a2e53ad 100644 --- a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java +++ b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java @@ -25,6 +25,7 @@ import org.springframework.stereotype.Component; import com.cloud.network.security.SecurityGroupVO; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; @@ -39,7 +40,7 @@ public class SecurityGroupDaoImpl extends GenericDaoBase private SearchBuilder AccountIdSearch; private SearchBuilder AccountIdNameSearch; private SearchBuilder AccountIdNamesSearch; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; protected SecurityGroupDaoImpl() { diff --git a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java index 0ebccabfa8e..fac35a91a53 100644 --- a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java +++ b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Component; import com.cloud.network.vpc.StaticRoute; import com.cloud.network.vpc.StaticRouteVO; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; @@ -44,7 +45,7 @@ public class StaticRouteDaoImpl extends GenericDaoBase impl protected final SearchBuilder AllFieldsSearch; protected final SearchBuilder NotRevokedSearch; protected final GenericSearchBuilder RoutesByGatewayCount; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; protected StaticRouteDaoImpl() { super(); diff --git a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java index a9b5e182b60..4464641737a 100644 --- a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java +++ b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Component; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.VpcVO; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; @@ -44,7 +45,7 @@ public class VpcDaoImpl extends GenericDaoBase implements VpcDao{ final GenericSearchBuilder CountByOfferingId; final SearchBuilder AllFieldsSearch; final GenericSearchBuilder CountByAccountId; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; protected VpcDaoImpl() { super(); diff --git a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java index e07aecc5ec6..ecf40dacaff 100644 --- a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java +++ b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java @@ -27,6 +27,7 @@ import org.springframework.stereotype.Component; import com.cloud.projects.Project; import com.cloud.projects.ProjectVO; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.db.DB; @@ -45,7 +46,7 @@ public class ProjectDaoImpl extends GenericDaoBase implements P protected GenericSearchBuilder CountByDomain; protected GenericSearchBuilder ProjectAccountSearch; // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class); - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; protected ProjectDaoImpl() { AllFieldsSearch = createSearchBuilder(); diff --git a/server/src/com/cloud/servlet/CloudStartupServlet.java b/server/src/com/cloud/servlet/CloudStartupServlet.java index 46be09387ba..2cabe15e0ac 100755 --- a/server/src/com/cloud/servlet/CloudStartupServlet.java +++ b/server/src/com/cloud/servlet/CloudStartupServlet.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.servlet; +import java.util.Timer; +import java.util.TimerTask; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -31,10 +34,22 @@ public class CloudStartupServlet extends HttpServlet { public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName()); static final long serialVersionUID = SerialVersionUID.CloudStartupServlet; + Timer _timer = new Timer(); + @Override public void init(ServletConfig config) throws ServletException { LogUtils.initLog4j("log4j-cloud.xml"); SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext()); - ComponentContext.initComponentsLifeCycle(); + + // wait when condition is ready for initialization + _timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + if(ComponentContext.getApplicationContext() != null) { + _timer.cancel(); + ComponentContext.initComponentsLifeCycle(); + } + } + }, 0, 1000); } } diff --git a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java index a8a07dcc3a6..ac1fd2d674c 100644 --- a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java +++ b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java @@ -35,16 +35,14 @@ import com.cloud.storage.Snapshot.Type; import com.cloud.storage.SnapshotVO; import com.cloud.storage.Volume; import com.cloud.storage.VolumeVO; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; -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.*; import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchCriteria.Func; import com.cloud.vm.VMInstanceVO; +import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDaoImpl; @Component @@ -66,10 +64,10 @@ public class SnapshotDaoImpl extends GenericDaoBase implements private SearchBuilder InstanceIdSearch; private SearchBuilder StatusSearch; private GenericSearchBuilder CountSnapshotsByAccount; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; - @Inject protected VMInstanceDaoImpl _instanceDao; - @Inject protected VolumeDaoImpl _volumeDao; + @Inject protected VMInstanceDao _instanceDao; + @Inject protected VolumeDao _volumeDao; @Override public SnapshotVO findNextSnapshot(long snapshotId) { diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index 42f10d34c1b..030bd254198 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -55,6 +55,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateZoneVO; import com.cloud.tags.ResourceTagVO; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; @@ -123,7 +124,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem private SearchBuilder UserIsoSearch; private GenericSearchBuilder CountTemplatesByAccount; - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; private String routerTmpltName; diff --git a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java index a189d00fead..8dc07ae8151 100755 --- a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java @@ -37,6 +37,7 @@ import com.cloud.storage.Volume.Event; import com.cloud.storage.Volume.State; import com.cloud.storage.Volume.Type; import com.cloud.storage.VolumeVO; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.utils.Pair; @@ -62,8 +63,7 @@ public class VolumeDaoImpl extends GenericDaoBase implements Vol protected final SearchBuilder InstanceStatesSearch; protected final SearchBuilder AllFieldsSearch; protected GenericSearchBuilder CountByAccount; - // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class); - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?"; protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?"; diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java index 52075880b9c..391fa5895b0 100755 --- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java +++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java @@ -25,15 +25,19 @@ import javax.inject.Inject; import org.springframework.stereotype.Component; import com.cloud.host.HostVO; +import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDaoImpl; import com.cloud.network.Network; +import com.cloud.network.dao.RouterNetworkDao; import com.cloud.network.dao.RouterNetworkDaoImpl; import com.cloud.network.dao.RouterNetworkVO; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.offering.NetworkOffering; +import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDaoImpl; import com.cloud.user.UserStatisticsVO; +import com.cloud.user.dao.UserStatisticsDao; import com.cloud.user.dao.UserStatisticsDaoImpl; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; @@ -57,10 +61,10 @@ public class DomainRouterDaoImpl extends GenericDaoBase im protected SearchBuilder HostUpSearch; protected SearchBuilder StateNetworkTypeSearch; protected SearchBuilder OutsidePodSearch; - @Inject HostDaoImpl _hostsDao; - @Inject RouterNetworkDaoImpl _routerNetworkDao; - @Inject UserStatisticsDaoImpl _userStatsDao; - @Inject NetworkOfferingDaoImpl _offDao; + @Inject HostDao _hostsDao; + @Inject RouterNetworkDao _routerNetworkDao; + @Inject UserStatisticsDao _userStatsDao; + @Inject NetworkOfferingDao _offDao; protected SearchBuilder VpcSearch; public DomainRouterDaoImpl() { diff --git a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java index f2fc10bbaa4..dc804e207fc 100755 --- a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java @@ -35,6 +35,7 @@ import org.springframework.stereotype.Component; import com.cloud.configuration.Resource; import com.cloud.server.ResourceTag.TaggedResourceType; +import com.cloud.tags.dao.ResourceTagDao; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.user.Account; @@ -78,7 +79,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use protected SearchBuilder UserVmSearch; protected Attribute _updateTimeAttr; // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class); - @Inject ResourceTagsDaoImpl _tagsDao; + @Inject ResourceTagDao _tagsDao; private static final String LIST_PODS_HAVING_VMS_FOR_ACCOUNT = "SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND (state = 'Running' OR state = 'Stopped') " + "GROUP BY pod_id HAVING count(id) > 0 ORDER BY count(id) DESC"; diff --git a/server/test/com/cloud/agent/MockAgentManagerImpl.java b/server/test/com/cloud/agent/MockAgentManagerImpl.java index bdacf68e28a..7e3462d8ff8 100755 --- a/server/test/com/cloud/agent/MockAgentManagerImpl.java +++ b/server/test/com/cloud/agent/MockAgentManagerImpl.java @@ -188,4 +188,10 @@ public class MockAgentManagerImpl extends ManagerBase implements AgentManager { return null; } + @Override + public void disconnectWithInvestigation(long hostId, Event event) { + // TODO Auto-generated method stub + + } + } diff --git a/utils/src/com/cloud/utils/component/ComponentContext.java b/utils/src/com/cloud/utils/component/ComponentContext.java index 716abb3fe30..e598b851e77 100644 --- a/utils/src/com/cloud/utils/component/ComponentContext.java +++ b/utils/src/com/cloud/utils/component/ComponentContext.java @@ -55,8 +55,18 @@ public class ComponentContext implements ApplicationContextAware { private static ApplicationContext s_appContext; + private static Advisor s_advisor; + private static ProxyFactory s_pf; + static { + s_advisor = new DefaultPointcutAdvisor(new MatchAnyMethodPointcut(), + new TransactionContextBuilder()); + s_pf = new ProxyFactory(); + s_pf.addAdvisor(s_advisor); + } + @Override - public void setApplicationContext(ApplicationContext applicationContext) { + public void setApplicationContext(ApplicationContext applicationContext) { + s_logger.info("Setup Spring Application context"); s_appContext = applicationContext; } @@ -157,27 +167,24 @@ public class ComponentContext implements ApplicationContextAware { public static T getComponent(Class beanType) { assert(s_appContext != null); - try { - return s_appContext.getBean(beanType); - } catch(NoSuchBeanDefinitionException e) { - Map matchedTypes = getComponentsOfType(beanType); - if(matchedTypes.size() > 0) { - for(Map.Entry entry : matchedTypes.entrySet()) { - Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class); - if(primary != null) - return entry.getValue(); - } - - if(matchedTypes.size() > 1) { - s_logger.warn("Unable to uniquely locate bean type " + beanType.getName()); - for(Map.Entry entry : matchedTypes.entrySet()) { - s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName()); - } - } - - return (T)matchedTypes.values().toArray()[0]; + Map matchedTypes = getComponentsOfType(beanType); + if(matchedTypes.size() > 0) { + for(Map.Entry entry : matchedTypes.entrySet()) { + Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class); + if(primary != null) + return entry.getValue(); } + + if(matchedTypes.size() > 1) { + s_logger.warn("Unable to uniquely locate bean type " + beanType.getName()); + for(Map.Entry entry : matchedTypes.entrySet()) { + s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName()); + } + } + + return (T)matchedTypes.values().toArray()[0]; } + throw new NoSuchBeanDefinitionException(beanType.getName()); } @@ -210,21 +217,17 @@ public class ComponentContext implements ApplicationContextAware { public static T inject(Class clz) { T instance = s_appContext.getAutowireCapableBeanFactory().createBean(clz); - return inject(instance); + return instance; } public static T inject(Object instance) { // autowire dynamically loaded object AutowireCapableBeanFactory beanFactory = s_appContext.getAutowireCapableBeanFactory(); beanFactory.autowireBean(instance); - - Advisor advisor = new DefaultPointcutAdvisor(new MatchAnyMethodPointcut(), - new TransactionContextBuilder()); - - ProxyFactory pf = new ProxyFactory(); - pf.setTarget(instance); - pf.addAdvisor(advisor); - - return (T)pf.getProxy(); + return (T)instance; +/* + s_pf.setTarget(instance); + return (T)s_pf.getProxy(); +*/ } } diff --git a/utils/src/com/cloud/utils/db/GenericDao.java b/utils/src/com/cloud/utils/db/GenericDao.java index c0a9029bf3c..3efc1c5208d 100755 --- a/utils/src/com/cloud/utils/db/GenericDao.java +++ b/utils/src/com/cloud/utils/db/GenericDao.java @@ -277,4 +277,6 @@ public interface GenericDao { * @return */ Pair, Integer> searchAndCount(SearchCriteria sc, Filter filter); + + Map getAllAttributes(); } diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java index cf30474fbbf..afb12471da7 100755 --- a/utils/src/com/cloud/utils/db/GenericDaoBase.java +++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java @@ -68,6 +68,7 @@ import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.Ternary; +import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentLifecycle; import com.cloud.utils.component.ComponentLifecycleBase; import com.cloud.utils.crypt.DBEncryptionUtil; @@ -118,7 +119,7 @@ public abstract class GenericDaoBase extends Compone protected final static TimeZone s_gmtTimeZone = TimeZone.getTimeZone("GMT"); - protected final static Map, GenericDaoBase> s_daoMaps = new ConcurrentHashMap, GenericDaoBase>(71); + protected final static Map, GenericDao> s_daoMaps = new ConcurrentHashMap, GenericDao>(71); protected Class _entityBeanType; protected String _table; @@ -128,8 +129,8 @@ public abstract class GenericDaoBase extends Compone protected Field[] _embeddedFields; // This is private on purpose. Everyone should use createPartialSelectSql() - private final Pair _partialSelectSql; - private final Pair _partialQueryCacheSelectSql; + private Pair _partialSelectSql; + private Pair _partialQueryCacheSelectSql; protected StringBuilder _discriminatorClause; protected Map _discriminatorValues; protected String _selectByIdSql; @@ -141,11 +142,11 @@ public abstract class GenericDaoBase extends Compone protected Pair _removed; protected Pair _removeSql; protected List> _deleteSqls; - protected final Map _idAttributes; - protected final Map _tgs; - protected final Map _allAttributes; - protected final List _ecAttributes; - protected final Map, Attribute> _allColumns; + protected Map _idAttributes; + protected Map _tgs; + protected Map _allAttributes; + protected List _ecAttributes; + protected Map, Attribute> _allColumns; protected Enhancer _enhancer; protected Factory _factory; protected Enhancer _searchEnhancer; @@ -159,9 +160,9 @@ public abstract class GenericDaoBase extends Compone protected static final SequenceFetcher s_seqFetcher = SequenceFetcher.getInstance(); - public static GenericDaoBase getDao(Class entityType) { + public static GenericDao getDao(Class entityType) { @SuppressWarnings("unchecked") - GenericDaoBase dao = (GenericDaoBase)s_daoMaps.get(entityType); + GenericDao dao = (GenericDao)s_daoMaps.get(entityType); assert dao != null : "Unable to find DAO for " + entityType + ". Are you sure you waited for the DAO to be initialized before asking for it?"; return dao; } @@ -192,13 +193,15 @@ public abstract class GenericDaoBase extends Compone ( (Class)((Class)t).getGenericSuperclass()).getGenericSuperclass()).getActualTypeArguments()[0]; } - s_daoMaps.put(_entityBeanType, this); +/* + s_daoMaps.put(_entityBeanType, ComponentContext.getComponent(this.getClass())); Class[] interphaces = _entityBeanType.getInterfaces(); if (interphaces != null) { for (Class interphace : interphaces) { - s_daoMaps.put(interphace, this); + s_daoMaps.put(interphace, ComponentContext.getComponent(this.getClass())); } } +*/ _table = DbUtil.getTableName(_entityBeanType); final SqlGenerator generator = new SqlGenerator(_entityBeanType); @@ -1747,6 +1750,25 @@ public abstract class GenericDaoBase extends Compone public boolean configure(final String name, final Map params) throws ConfigurationException { _name = name; + Class daoInterface = null; + for(Class intf : this.getClass().getInterfaces()) { + if(GenericDao.class.isAssignableFrom(intf)) { + daoInterface = intf; + break; + } + } + + if(daoInterface != null) { + s_logger.info("Register dao interface in GenericDaoBase entity-DAO map. " + daoInterface.getName()); + s_daoMaps.put(_entityBeanType, (GenericDao) ComponentContext.getComponent(daoInterface)); + Class[] interphaces = _entityBeanType.getInterfaces(); + if (interphaces != null) { + for (Class interphace : interphaces) { + s_daoMaps.put(interphace, (GenericDao) ComponentContext.getComponent(daoInterface)); + } + } + } + final String value = (String)params.get("lock.timeout"); _timeoutSeconds = NumbersUtil.parseInt(value, 300); diff --git a/utils/src/com/cloud/utils/db/QueryBuilder.java b/utils/src/com/cloud/utils/db/QueryBuilder.java index 2eb3658a20a..3303fbd5b45 100644 --- a/utils/src/com/cloud/utils/db/QueryBuilder.java +++ b/utils/src/com/cloud/utils/db/QueryBuilder.java @@ -56,21 +56,21 @@ public class QueryBuilder implements MethodInterceptor, SimpleQueryBuilder } } - protected HashMap, Pair, Object>> _entities; + protected HashMap, Pair, Object>> _entities; protected ArrayList _specifiedAttrs = new ArrayList(); protected T _resultSetClass; protected ArrayList> _selects; public QueryBuilder(Class resultSetClass, Class... clazzes) { - _entities = new HashMap, Pair, Object>>(clazzes.length); + _entities = new HashMap, Pair, Object>>(clazzes.length); for (Class clazz : clazzes) { - GenericDaoBase dao = GenericDaoBase.getDao(clazz); + GenericDao dao = GenericDaoBase.getDao(clazz); Enhancer searchEnhancer = new Enhancer(); searchEnhancer.setSuperclass(clazz); searchEnhancer.setCallback(this); Object entity = searchEnhancer.create(); - _entities.put(clazz, new Pair, Object>(dao, entity)); + _entities.put(clazz, new Pair, Object>(dao, entity)); } } @@ -86,14 +86,14 @@ public class QueryBuilder implements MethodInterceptor, SimpleQueryBuilder * @param resultSetClass result class to put the result set in. */ public QueryBuilder(Class entityClass, Class resultSetClass) { - _entities = new HashMap, Pair, Object>>(1); - GenericDaoBase dao = GenericDaoBase.getDao(entityClass); + _entities = new HashMap, Pair, Object>>(1); + GenericDao dao = GenericDaoBase.getDao(entityClass); Enhancer searchEnhancer = new Enhancer(); searchEnhancer.setSuperclass(entityClass); searchEnhancer.setCallback(this); Object entity = searchEnhancer.create(); - _entities.put(entityClass, new Pair, Object>(dao, entity)); + _entities.put(entityClass, new Pair, Object>(dao, entity)); } @Override @@ -114,7 +114,7 @@ public class QueryBuilder implements MethodInterceptor, SimpleQueryBuilder return this; } - protected void set(GenericDaoBase dao , String name) { + protected void set(GenericDao dao , String name) { Attribute attr = dao.getAllAttributes().get(name); assert (attr != null) : "Searching for a field that's not there: " + name; _specifiedAttrs.add(attr); @@ -125,9 +125,9 @@ public class QueryBuilder implements MethodInterceptor, SimpleQueryBuilder public Object intercept(Object entity, Method method, Object[] args, MethodProxy proxy) throws Throwable { Class entityClass = entity.getClass().getSuperclass(); - Pair, Object> daoInfo = _entities.get(entityClass); + Pair, Object> daoInfo = _entities.get(entityClass); assert (daoInfo != null) : "You need to specify " + entityClass + " as one of the entities in the Query"; - GenericDaoBase dao = daoInfo.first(); + GenericDao dao = daoInfo.first(); String name = method.getName(); if (name.startsWith("get")) { diff --git a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java index c8a7f7a0f1b..744e75c7dde 100644 --- a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java +++ b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java @@ -30,7 +30,7 @@ public class TransactionContextBuilder implements MethodInterceptor { public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable { MethodSignature methodSignature = (MethodSignature)call.getSignature(); Method targetMethod = methodSignature.getMethod(); - if(needToIntercept(targetMethod)) { + if(true) { // TODO ??? needToIntercept(targetMethod)) { Transaction txn = Transaction.open(call.getSignature().getName()); Object ret = null; try {