diff --git a/client/pom.xml b/client/pom.xml index e62c6a99e20..e4707c00180 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -199,7 +199,7 @@ 60000 - -XX:MaxPermSize=256m -Xmx2g + -XX:MaxPermSize=512m -Xmx2g /client ${basedir}/target/${project.artifactId}-${project.version}/WEB-INF/web.xml ${basedir}/target/${project.artifactId}-${project.version} diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index 60e68e0fd42..34bb853c52e 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -19,8 +19,6 @@ - - diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/HostVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/HostVO.java index 210ed15f3ed..964d7b32e3a 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/HostVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/HostVO.java @@ -720,7 +720,9 @@ public class HostVO implements Host, Identity { } @Override - @Transient + + // TODO, I tempoerary disable it as it breaks GenericSearchBuild when @Transient is applied + // @Transient public Status getState() { return status; } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/ClusterDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/ClusterDaoImpl.java index ff2e911f309..bd4a5ae2939 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/ClusterDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/ClusterDaoImpl.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import javax.ejb.Local; +import javax.inject.Inject; import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity; import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State; @@ -29,6 +30,7 @@ import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEnti import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO; import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO; import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.hypervisor.Hypervisor.HypervisorType; @@ -45,6 +47,7 @@ import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; +@Component(value="EngineClusterDao") @Local(value=ClusterDao.class) public class ClusterDaoImpl extends GenericDaoBase implements ClusterDao { private static final Logger s_logger = Logger.getLogger(ClusterDaoImpl.class); @@ -60,7 +63,7 @@ public class ClusterDaoImpl extends GenericDaoBase implements C private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( "; private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )"; - protected final HostPodDaoImpl _hostPodDao = ComponentLocator.inject(HostPodDaoImpl.class); + @Inject protected HostPodDao _hostPodDao; protected ClusterDaoImpl() { super(); diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DataCenterDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DataCenterDaoImpl.java index a25b3759fc0..61a4bb3e4b1 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DataCenterDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DataCenterDaoImpl.java @@ -18,6 +18,7 @@ import java.util.Map; import java.util.Random; import javax.ejb.Local; +import javax.inject.Inject; import javax.naming.ConfigurationException; import javax.persistence.TableGenerator; @@ -27,6 +28,7 @@ import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEnti import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO; import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.org.Grouping; import com.cloud.utils.NumbersUtil; @@ -48,6 +50,7 @@ import com.cloud.utils.net.NetUtils; * || mac.address.prefix | prefix to attach to all public and private mac addresses | number | 06 || * } **/ +@Component(value="EngineDataCenterDao") @Local(value={DataCenterDao.class}) public class DataCenterDaoImpl extends GenericDaoBase implements DataCenterDao { private static final Logger s_logger = Logger.getLogger(DataCenterDaoImpl.class); @@ -65,7 +68,7 @@ public class DataCenterDaoImpl extends GenericDaoBase implem protected Random _rand = new Random(System.currentTimeMillis()); protected TableGenerator _tgMacAddress; - protected final DcDetailsDaoImpl _detailsDao = ComponentLocator.inject(DcDetailsDaoImpl.class); + @Inject protected DcDetailsDao _detailsDao; @Override diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java index 4092786f87e..60eec4cf913 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import javax.ejb.Local; import org.apache.cloudstack.engine.datacenter.entity.api.db.DcDetailVO; +import org.springframework.stereotype.Component; import com.cloud.utils.db.GenericDaoBase; @@ -26,6 +27,7 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; +@Component(value="EngineDcDetailsDao") @Local(value=DcDetailsDao.class) public class DcDetailsDaoImpl extends GenericDaoBase implements DcDetailsDao { protected final SearchBuilder DcSearch; diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDaoImpl.java index ede5d8cef12..41e6785a95a 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDaoImpl.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.TimeZone; import javax.ejb.Local; +import javax.inject.Inject; import javax.persistence.TableGenerator; import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity; @@ -62,7 +63,7 @@ import com.cloud.utils.db.Transaction; import com.cloud.utils.db.UpdateBuilder; import com.cloud.utils.exception.CloudRuntimeException; - +@Component(value="EngineHostDao") @Local(value = { HostDao.class }) @DB(txn = false) @TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1) @@ -115,9 +116,9 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao protected final Attribute _msIdAttr; protected final Attribute _pingTimeAttr; - protected final HostDetailsDaoImpl _detailsDao = ComponentLocator.inject(HostDetailsDaoImpl.class); - protected final HostTagsDaoImpl _hostTagsDao = ComponentLocator.inject(HostTagsDaoImpl.class); - protected final ClusterDaoImpl _clusterDao = ComponentLocator.inject(ClusterDaoImpl.class); + @Inject protected HostDetailsDao _detailsDao; + @Inject protected HostTagsDao _hostTagsDao; + @Inject protected ClusterDao _clusterDao; public HostDaoImpl() { diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java index 93e728d3130..87d516baddd 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java @@ -31,7 +31,7 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; -@Component +//@Component(value="EngineHostDetailsDao") @Local(value=HostDetailsDao.class) public class HostDetailsDaoImpl extends GenericDaoBase implements HostDetailsDao { protected final SearchBuilder HostSearch; diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostPodDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostPodDaoImpl.java index df52ed626bc..b39fdc3810c 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostPodDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostPodDaoImpl.java @@ -27,6 +27,7 @@ import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEnti import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event; import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO; import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.org.Grouping; @@ -37,7 +38,8 @@ import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.UpdateBuilder; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; - + +@Component(value="EngineHostPodDao") @Local(value={HostPodDao.class}) public class HostPodDaoImpl extends GenericDaoBase implements HostPodDao { private static final Logger s_logger = Logger.getLogger(HostPodDaoImpl.class); diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java index 2ad36319cb7..a70b7d1b234 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java @@ -29,7 +29,7 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; -@Component +@Component(value="EngineHostTagsDao") @Local(value=HostTagsDao.class) public class HostTagsDaoImpl extends GenericDaoBase implements HostTagsDao { protected final SearchBuilder HostSearch; diff --git a/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java new file mode 100644 index 00000000000..e9635ded5c8 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java @@ -0,0 +1,97 @@ +/* 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 org.apache.cloudstack.framework.async; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class AsyncCallFuture implements Future, AsyncCompletionCallback { + + AsyncCompletionCallback _callback; + + Object _completed = new Object(); + boolean _done = false; + T _resultObject; // we will store a copy of the result object + + public AsyncCallFuture(AsyncCompletionCallback callback) { + _callback = callback; + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + // TODO we don't support cancel yet + return false; + } + + @Override + public T get() throws InterruptedException, ExecutionException { + synchronized(_completed) { + if(!_done) + _completed.wait(); + } + + return _resultObject; + } + + @Override + public T get(long timeout, TimeUnit timeUnit) throws InterruptedException, + ExecutionException, TimeoutException { + + TimeUnit milliSecondsUnit = TimeUnit.MILLISECONDS; + + synchronized(_completed) { + if(!_done) + _completed.wait(milliSecondsUnit.convert(timeout, timeUnit)); + } + + return _resultObject; + } + + @Override + public boolean isCancelled() { + // TODO we don't support cancel yet + return false; + } + + @Override + public boolean isDone() { + return _done; + } + + @Override + public void complete(T resultObject) { + _resultObject = resultObject; + synchronized(_completed) { + _done = true; + _completed.notifyAll(); + } + + _callback.complete(resultObject); + } + + public void inplaceComplete(T resultObject) { + _resultObject = resultObject; + synchronized(_completed) { + _done = true; + _completed.notifyAll(); + } + } +} + diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java index 71afd10a696..59461a4efed 100644 --- a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java +++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java @@ -18,19 +18,19 @@ */ package org.apache.cloudstack.framework.codestyle; +import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; public class AsyncSampleCallee { AsyncSampleCallee _driver; - public void createVolume(Object realParam, AsyncCompletionCallback callback) { + public AsyncCallFuture createVolume(Object realParam, AsyncCompletionCallback callback) { - // async executed logic - { - - String resultObject = new String(); - callback.complete(resultObject); + String result = "result object"; + AsyncCallFuture call = new AsyncCallFuture(callback); - } + call.inplaceComplete(result); + return call; } } +