incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [11/50] [abbrv] git commit: refs/heads/master - Put usage server under Spring
Date Fri, 01 Feb 2013 23:27:31 GMT
Put usage server under Spring


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/14505479
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/14505479
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/14505479

Branch: refs/heads/master
Commit: 1450547987e90fb655e376dafe261298bd16c8ab
Parents: 221ac72
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri Jan 25 23:00:33 2013 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri Jan 25 23:00:55 2013 -0800

----------------------------------------------------------------------
 .../storage/volume/test/TestConfiguration.java     |    1 -
 .../cloud/service/dao/ServiceOfferingDaoImpl.java  |    2 +-
 .../com/cloud/tags/dao/ResourceTagsDaoImpl.java    |    2 +-
 server/src/com/cloud/user/dao/AccountDaoImpl.java  |    2 +-
 .../src/com/cloud/user/dao/UserAccountDaoImpl.java |    2 +-
 server/src/com/cloud/vm/dao/NicDaoImpl.java        |    2 +-
 server/src/com/cloud/vm/dao/UserVmDaoImpl.java     |    2 +-
 .../src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java |    2 +-
 usage/conf/usageApplicationContext.xml.in          |   53 +++++
 usage/src/com/cloud/usage/UsageManagerImpl.java    |    3 +-
 usage/src/com/cloud/usage/UsageServer.java         |   44 +++-
 .../cloud/usage/UsageServerComponentConfig.java    |  180 +++++++++++++++
 12 files changed, 279 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/TestConfiguration.java
b/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/TestConfiguration.java
index d519071..1d3202f 100644
--- a/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/TestConfiguration.java
+++ b/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/TestConfiguration.java
@@ -27,7 +27,6 @@ import org.springframework.context.annotation.Configuration;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.ClusterDaoImpl;
 
-
 @Configuration
 public class TestConfiguration {
     @Bean

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
index a43c2b3..062103e 100644
--- a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
+++ b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
@@ -43,7 +43,7 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO,
Lo
     protected final SearchBuilder<ServiceOfferingVO> ServiceOfferingsByKeywordSearch;
     protected final SearchBuilder<ServiceOfferingVO> PublicServiceOfferingSearch;
     
-    protected ServiceOfferingDaoImpl() {
+    public ServiceOfferingDaoImpl() {
         super();
         
         UniqueNameSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java b/server/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
index 2eb729f..9763956 100644
--- a/server/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
+++ b/server/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
@@ -34,7 +34,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 public class ResourceTagsDaoImpl extends GenericDaoBase<ResourceTagVO, Long> implements
ResourceTagDao{
     final SearchBuilder<ResourceTagVO> AllFieldsSearch;
     
-    protected ResourceTagsDaoImpl() {
+    public ResourceTagsDaoImpl() {
         AllFieldsSearch = createSearchBuilder();
         AllFieldsSearch.and("resourceId", AllFieldsSearch.entity().getResourceId(), Op.EQ);
         AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getResourceUuid(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/user/dao/AccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/dao/AccountDaoImpl.java b/server/src/com/cloud/user/dao/AccountDaoImpl.java
index ae102a3..c8bf46a 100755
--- a/server/src/com/cloud/user/dao/AccountDaoImpl.java
+++ b/server/src/com/cloud/user/dao/AccountDaoImpl.java
@@ -55,7 +55,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long>
implements A
     protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
     protected final SearchBuilder<AccountVO> NonProjectAccountSearch;
     
-    protected AccountDaoImpl() {
+    public AccountDaoImpl() {
         AllFieldsSearch = createSearchBuilder();
         AllFieldsSearch.and("accountName", AllFieldsSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
         AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/user/dao/UserAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/dao/UserAccountDaoImpl.java b/server/src/com/cloud/user/dao/UserAccountDaoImpl.java
index 9edfe4a..fa87d86 100644
--- a/server/src/com/cloud/user/dao/UserAccountDaoImpl.java
+++ b/server/src/com/cloud/user/dao/UserAccountDaoImpl.java
@@ -32,7 +32,7 @@ public class UserAccountDaoImpl extends GenericDaoBase<UserAccountVO,
Long> impl
 	
 	protected final SearchBuilder<UserAccountVO> userAccountSearch;
 	
-    protected UserAccountDaoImpl() {
+    public UserAccountDaoImpl() {
     	userAccountSearch = createSearchBuilder();
     	userAccountSearch.and("apiKey", userAccountSearch.entity().getApiKey(), SearchCriteria.Op.EQ);
         userAccountSearch.done();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/vm/dao/NicDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/NicDaoImpl.java b/server/src/com/cloud/vm/dao/NicDaoImpl.java
index e09b0ab..5cf152f 100644
--- a/server/src/com/cloud/vm/dao/NicDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/NicDaoImpl.java
@@ -42,7 +42,7 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements
NicDao {
     final GenericSearchBuilder<NicVO, Integer> CountBy;
 
     
-    protected NicDaoImpl() {
+    public NicDaoImpl() {
         super();
         
         AllFieldsSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
index 13883cf..93780b1 100755
--- a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
@@ -116,7 +116,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long>
implements Use
     @Inject protected UserVmDetailsDao _detailsDao;
     @Inject protected NicDao _nicDao;
     
-    protected UserVmDaoImpl() {
+    public UserVmDaoImpl() {
     }
     
     @PostConstruct

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/server/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
index 93c481e..6ec6f68 100644
--- a/server/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
@@ -36,7 +36,7 @@ public class UserVmDetailsDaoImpl extends GenericDaoBase<UserVmDetailVO,
Long> i
     protected final SearchBuilder<UserVmDetailVO> VmSearch;
     protected final SearchBuilder<UserVmDetailVO> DetailSearch;
 
-	protected UserVmDetailsDaoImpl() {
+	public UserVmDetailsDaoImpl() {
 		VmSearch = createSearchBuilder();
 		VmSearch.and("vmId", VmSearch.entity().getVmId(), SearchCriteria.Op.EQ);
         VmSearch.done();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/usage/conf/usageApplicationContext.xml.in
----------------------------------------------------------------------
diff --git a/usage/conf/usageApplicationContext.xml.in b/usage/conf/usageApplicationContext.xml.in
new file mode 100644
index 0000000..32da93e
--- /dev/null
+++ b/usage/conf/usageApplicationContext.xml.in
@@ -0,0 +1,53 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+  xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:tx="http://www.springframework.org/schema/tx" 
+  xmlns:aop="http://www.springframework.org/schema/aop"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/tx 
+                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+                      http://www.springframework.org/schema/aop
+                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                    
+
+  <context:annotation-config />
+  <context:component-scan base-package="com.cloud.usage" />
+  
+  <!--
+    @DB support
+  -->
+  <aop:config proxy-target-class="true">
+    <aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
+        <aop:pointcut id="captureAnyMethod"
+            expression="execution(* *(..))" 
+        />
+        <aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/> 
+    </aop:aspect>
+
+  </aop:config>
+  
+  <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
+  <bean id="ComponentContext" class="com.cloud.utils.component.ComponentContext" />
+  <bean id="UsageServerConfig" class="com.cloud.usage.UsageServerComponentConfig" />
+ 
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index 4944a14..438ab72 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -144,7 +144,8 @@ public class UsageManagerImpl implements UsageManager, Runnable {
         final Class<?> c = UsageServer.class;
         m_version = c.getPackage().getImplementationVersion();
         if (m_version == null) {
-            throw new CloudRuntimeException("Unable to find the implementation version of
this usage server");
+            // TODO
+        	// throw new CloudRuntimeException("Unable to find the implementation version of
this usage server");
         }
 
         if (s_logger.isInfoEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/usage/src/com/cloud/usage/UsageServer.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageServer.java b/usage/src/com/cloud/usage/UsageServer.java
index eaf9132..ce87b88 100644
--- a/usage/src/com/cloud/usage/UsageServer.java
+++ b/usage/src/com/cloud/usage/UsageServer.java
@@ -16,31 +16,47 @@
 // under the License.
 package com.cloud.usage;
 
-import javax.inject.Inject;
+import java.io.File;
 
 import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-
+import com.cloud.utils.PropertiesUtil;
+import com.cloud.utils.component.ComponentContext;
 
 public class UsageServer {
     private static final Logger s_logger = Logger.getLogger(UsageServer.class.getName());
     public static final String Name = "usage-server";
-
-    @Inject UsageManager mgr; 
+    
+    UsageManager mgr; 
+    
     /**
      * @param args
      */
     public static void main(String[] args) {
+    	initLog4j();
+    	ApplicationContext appContext = new ClassPathXmlApplicationContext("usageApplicationContext.xml");
+	    
         UsageServer usage = new UsageServer();
         usage.init(args);
-        usage.start();
+        usage.start(appContext);
     }
 
     public void init(String[] args) {
-
     }
 
-    public void start() {
+    public void start(ApplicationContext appContext) {
+    	try {
+    		ComponentContext.initComponentsLifeCycle();
+    	} catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    	
+    	mgr = appContext.getBean(UsageManager.class);
+    	
         if (mgr != null) {
             if (s_logger.isInfoEnabled()) {
                 s_logger.info("UsageServer ready...");
@@ -55,4 +71,18 @@ public class UsageServer {
     public void destroy() {
 
     }
+
+    static private void initLog4j() {
+    	File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
+    	if (file != null) {
+        s_logger.info("log4j configuration found at " + file.getAbsolutePath());
+        DOMConfigurator.configureAndWatch(file.getAbsolutePath());
+	    } else {
+	        file = PropertiesUtil.findConfigFile("log4j-cloud.properties");
+	        if (file != null) {
+	            s_logger.info("log4j configuration found at " + file.getAbsolutePath());
+	            PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
+	        }
+	    }
+   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/14505479/usage/src/com/cloud/usage/UsageServerComponentConfig.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageServerComponentConfig.java b/usage/src/com/cloud/usage/UsageServerComponentConfig.java
new file mode 100644
index 0000000..aa8682c
--- /dev/null
+++ b/usage/src/com/cloud/usage/UsageServerComponentConfig.java
@@ -0,0 +1,180 @@
+// 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
+// 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.usage;
+
+import org.springframework.context.annotation.Bean;
+
+import org.springframework.context.annotation.Configuration;
+
+import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
+import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
+import com.cloud.dc.dao.*;
+import com.cloud.service.dao.ServiceOfferingDaoImpl;
+import com.cloud.vm.dao.*;
+import com.cloud.network.dao.*;
+import com.cloud.host.dao.*;
+
+import com.cloud.utils.crypt.EncryptionSecretKeyChecker;  
+import com.cloud.vm.dao.VMInstanceDaoImpl; 
+import com.cloud.vm.dao.UserVmDaoImpl;
+import com.cloud.event.dao.EventDaoImpl; 
+import com.cloud.user.dao.UserStatisticsDaoImpl; 
+import com.cloud.network.dao.IPAddressDaoImpl; 
+import com.cloud.domain.dao.DomainDaoImpl; 
+import com.cloud.user.dao.AccountDaoImpl; 
+import com.cloud.user.dao.UserAccountDaoImpl; 
+import com.cloud.configuration.dao.ConfigurationDaoImpl; 
+import com.cloud.alert.dao.AlertDaoImpl;
+import com.cloud.event.dao.UsageEventDaoImpl; 
+import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.event.dao.EventDao;
+import com.cloud.user.dao.UserStatisticsDao;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.user.dao.*;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.alert.dao.AlertDao;
+import com.cloud.event.dao.UsageEventDao;
+import com.cloud.tags.dao.*;
+
+@Configuration
+public class UsageServerComponentConfig {
+
+	@Bean
+	public HostTransferMapDao HostTransferDao() {
+		return new HostTransferMapDaoImpl();
+	}
+
+	@Bean
+	public ClusterDao ClusterDao() {
+		return new ClusterDaoImpl();
+	}
+
+	@Bean
+	public HostPodDao HostPodDao() {
+		return new HostPodDaoImpl();
+	}
+	
+	@Bean
+	public UserVmDetailsDao UserVmDetailsDao() {
+		return new UserVmDetailsDaoImpl();
+	}
+	
+	@Bean
+	public VlanDaoImpl VlanDaoImpl() {
+		return new VlanDaoImpl();
+	}
+	
+	@Bean
+	public PodVlanMapDao PodVlanMapDao() {
+		return new PodVlanMapDaoImpl();
+	}
+	
+	@Bean
+	public AccountVlanMapDao AccountVlanMapDao() {
+		return new AccountVlanMapDaoImpl();
+	}
+
+	@Bean
+	public EncryptionSecretKeyChecker EncryptionSecretKeyChecker() {
+		return new EncryptionSecretKeyChecker();
+	}
+	
+	@Bean
+	public VMInstanceDao VmInstanceDao() {
+		return new VMInstanceDaoImpl();
+	}
+
+	@Bean
+	public UserVmDao UserVmDao() {
+		return new UserVmDaoImpl();
+	}
+
+	@Bean
+	public ServiceOfferingDao ServiceOfferingDao() {
+		return new ServiceOfferingDaoImpl();
+	}
+	
+	@Bean
+	public EventDao EventDao() {
+		return new EventDaoImpl();
+	}
+
+	@Bean
+	public UserStatisticsDao UserStatisticsDao() {
+		return new UserStatisticsDaoImpl();
+	}
+
+	@Bean
+	public IPAddressDao IPAddressDao() {
+		return new IPAddressDaoImpl();
+	}
+	
+	@Bean
+	public DomainDao DomainDao() {
+		return new DomainDaoImpl();
+	}
+
+	@Bean
+	public AccountDao AccountDao() {
+		return new AccountDaoImpl();
+	}
+
+	@Bean
+	public UserAccountDao UserAccountDao() {
+		return new UserAccountDaoImpl();
+	}
+
+	@Bean
+	public ConfigurationDao ConfigurationDao() {
+		return new ConfigurationDaoImpl();
+	}
+
+	@Bean
+	public AlertDao AlertDao() {
+		return new AlertDaoImpl();
+	}
+
+	@Bean
+	public UsageEventDao UsageEventDao() {
+		return new UsageEventDaoImpl();
+	}
+
+	@Bean
+	public ResourceTagsDaoImpl ResourceTagsDaoImpl() {
+		return new ResourceTagsDaoImpl();
+	}
+
+	@Bean
+	public NicDao NicDao() {
+		return new NicDaoImpl();
+	}
+
+	@Bean
+	public HostDao HostDao() {
+		return new HostDaoImpl();
+	}
+
+	@Bean
+	public HostDetailsDao HostDetailsDao() {
+		return new HostDetailsDaoImpl();
+	}
+
+	@Bean
+	public HostTagsDao HostTagsDao() {
+		return new HostTagsDaoImpl();
+	}
+}


Mime
View raw message