Updated Branches:
  refs/heads/master 3ceb8d566 -> cefbbb385

moving random storage allocator to plugins/storage-allocators


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

Branch: refs/heads/master
Commit: cefbbb385086a8cd536ca8c7ca43355e651204cb
Parents: 3ceb8d5
Author: Murali reddy <[email protected]>
Authored: Tue Jun 26 15:17:25 2012 -0700
Committer: Murali reddy <[email protected]>
Committed: Tue Jun 26 15:17:25 2012 -0700

----------------------------------------------------------------------
 build/build-cloud-plugins.xml                      |   15 ++-
 plugins/storage-allocators/random/.classpath       |   10 +
 plugins/storage-allocators/random/.project         |   17 ++
 plugins/storage-allocators/random/build.xml        |  128 +++++++++++++++
 .../allocator/RandomStoragePoolAllocator.java      |   85 ++++++++++
 .../allocator/RandomStoragePoolAllocator.java      |   85 ----------
 6 files changed, 253 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/build/build-cloud-plugins.xml
----------------------------------------------------------------------
diff --git a/build/build-cloud-plugins.xml b/build/build-cloud-plugins.xml
index efd8433..7c13c87 100755
--- a/build/build-cloud-plugins.xml
+++ b/build/build-cloud-plugins.xml
@@ -184,9 +184,9 @@
   </path>
 
 
-  <target name="compile-plugins" description="Compile all of the jars 
corresponding to plugins" depends="compile-utils, compile-api, compile-core, 
compile-server, compile-hypervisors, compile-deployment-planners, 
compile-host-allocators, compile-network-elements, compile-user-authenticators 
"/>
+  <target name="compile-plugins" description="Compile all of the jars 
corresponding to plugins" depends="compile-utils, compile-api, compile-core, 
compile-server, compile-hypervisors, compile-deployment-planners, 
compile-host-allocators, compile-network-elements, compile-user-authenticators, 
compile-storage-allocators "/>
 
-  <target name="build-plugins" depends="build-hypervisors, 
build-network-elements, build-deployment-planners, build-host-allocators, 
build-user-authenticators" description="Builds all jar's for the plug-in's"/>
+  <target name="build-plugins" depends="build-hypervisors, 
build-network-elements, build-deployment-planners, build-host-allocators, 
build-storage-allocators, build-user-authenticators" description="Builds all 
jar's for the plug-in's"/>
 
   <target name="clean-plugins" description="Clean all of the generated files 
by the plugins">
       <delete file="${build.log}" />
@@ -234,6 +234,17 @@
   <target name="build-host-allocator-random" 
depends="compile-host-allocator-random" />
 
 
+  <!-- ===================== Storage Allocators ===================== -->
+
+  <target name="compile-storage-allocators" 
depends="compile-storage-allocator-random" description="Compile all storage 
allocators"/>
+  <target name="build-storage-allocators" 
depends="build-storage-allocator-random" description="builds all storage 
allocators"/>
+ 
+  <target name="compile-storage-allocator-random" depends="-init, 
compile-server" description="Compile ">
+       <ant antfile="${base.dir}/plugins/storage-allocators/random/build.xml" 
target="build"/>
+  </target>
+  <target name="build-storage-allocator-random" 
depends="compile-storage-allocator-random" />
+
+
   <!-- ===================== User Authenticators ================== -->
 
   <target name="compile-user-authenticators" 
depends="compile-user-authenticator-ldap, compile-user-authenticator-md5, 
compile-user-authenticator-plaintext" description="Compile all user 
authenicators"/>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/plugins/storage-allocators/random/.classpath
----------------------------------------------------------------------
diff --git a/plugins/storage-allocators/random/.classpath 
b/plugins/storage-allocators/random/.classpath
new file mode 100755
index 0000000..e39771a
--- /dev/null
+++ b/plugins/storage-allocators/random/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/api"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/server"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/utils"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/plugins/storage-allocators/random/.project
----------------------------------------------------------------------
diff --git a/plugins/storage-allocators/random/.project 
b/plugins/storage-allocators/random/.project
new file mode 100755
index 0000000..cdb8361
--- /dev/null
+++ b/plugins/storage-allocators/random/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>random-storage-allocator</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/plugins/storage-allocators/random/build.xml
----------------------------------------------------------------------
diff --git a/plugins/storage-allocators/random/build.xml 
b/plugins/storage-allocators/random/build.xml
new file mode 100755
index 0000000..e5fcebe
--- /dev/null
+++ b/plugins/storage-allocators/random/build.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+
+<project name="Cloud Stack Random Storage Allocator" default="help" 
basedir=".">
+  <description>
+               Cloud Stack ant build file
+  </description>
+
+  <dirname property="storage-allocator-random.base.dir" file="${ant.file.Cloud 
Stack Random Storage Allocator}/"/>
+  <!-- This directory must be set -->
+  <property name="top.dir" 
location="${storage-allocator-random.base.dir}/../../.."/>
+  <property name="build.dir" location="${top.dir}/build"/>
+       
+       <echo message="build.dir=${build.dir}; top.dir=${top.dir}; 
storage-allocator-random.base.dir=${storage-allocator-random.base.dir}"/>
+
+  <!-- Import anything that the user wants to set-->
+  <!-- Import properties files and environment variables here -->
+
+  <property environment="env" />
+
+  <condition property="build-cloud.properties.file" 
value="${build.dir}/override/build-cloud.properties" 
else="${build.dir}/build-cloud.properties">
+    <available file="${build.dir}/override/build-cloud.properties" />
+  </condition>
+
+  <condition property="cloud.properties.file" 
value="${build.dir}/override/cloud.properties" 
else="${build.dir}/cloud.properties">
+    <available file="${build.dir}/override/cloud.properties" />
+  </condition>
+
+  <condition property="override.file" 
value="${build.dir}/override/replace.properties" 
else="${build.dir}/replace.properties">
+    <available file="${build.dir}/override/replace.properties" />
+  </condition>
+
+  <echo message="Using build parameters from ${build-cloud.properties.file}" />
+  <property file="${build-cloud.properties.file}" />
+
+  <echo message="Using company info from ${cloud.properties.file}" />
+  <property file="${cloud.properties.file}" />
+
+  <echo message="Using override file from ${override.file}" />
+  <property file="${override.file}" />
+
+  <property file="${build.dir}/build.number" />
+
+  <!-- In case these didn't get defined in the build-cloud.properties -->
+  <property name="branding.name" value="default" />
+  <property name="deprecation" value="off" />
+  <property name="target.compat.version" value="1.6" />
+  <property name="source.compat.version" value="1.6" />
+  <property name="debug" value="true" />
+  <property name="debuglevel" value="lines,source"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+  <!-- directories for build and distribution -->
+  <property name="target.dir" location="${top.dir}/target" />
+  <property name="classes.dir" location="${target.dir}/classes" />
+  <property name="jar.dir" location="${target.dir}/jar" />
+  <property name="dep.cache.dir" location="${target.dir}/dep-cache" />
+  <property name="build.log" location="${target.dir}/ant_verbose.txt" />
+
+  <property name="deps.dir" location="${top.dir}/deps" />
+  
+  <property name="storage-allocator-random.jar" 
value="cloud-storage-allocator-random.jar" />
+  <property name="storage-allocator-random-scripts.dir" 
location="${storage-allocator-random.base.dir}/scripts" />
+       
+  <import file="${build.dir}/build-common.xml"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+       
+  <!-- This section needs to be replaced by some kind of dependency library-->
+  <path id="deps.classpath">
+    <!--filelist files="${deps.classpath}" /-->
+    <fileset dir="${deps.dir}" erroronmissingdir="false">
+      <include name="*.jar" />
+    </fileset>
+  </path>
+       
+  <path id="cloudstack.classpath">
+       <fileset dir="${jar.dir}">
+         <include name="*.jar"/>
+    </fileset>
+  </path>
+       
+  <path id="storage-allocator-random.classpath">
+       <path refid="deps.classpath"/>
+       <path refid="cloudstack.classpath"/>
+  </path>
+       
+  <!-- This section needs to be replaced by some kind of dependency library-->
+       
+       
+  <target name="init" description="Initialize binaries directory">
+       <mkdir dir="${classes.dir}/${storage-allocator-random.jar}"/>
+       <mkdir dir="${jar.dir}"/>
+  </target>
+       
+  <target name="compile-storage-allocator-random" depends="init" 
description="Compile storage-allocator-random">
+    <compile-java jar.name="${storage-allocator-random.jar}" 
top.dir="${storage-allocator-random.base.dir}" 
classpath="storage-allocator-random.classpath" />
+  </target>
+       
+  <target name="clean-storage-allocator-random">
+    <delete dir="${classes.dir}/${storage-allocator-random.jar}"/>
+  </target>
+
+  <target name="help" description="help">
+    <echo level="info" message="This is the build file for 
storage-allocator-random"/>
+    <echo level="info" message="You can do a build by doing ant build or clean 
by ant clean" />
+  </target>
+
+  <target name="build" depends="compile-storage-allocator-random"/>
+  <target name="clean" depends="clean-storage-allocator-random"/>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git 
a/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
 
b/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
new file mode 100644
index 0000000..def048e
--- /dev/null
+++ 
b/plugins/storage-allocators/random/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
@@ -0,0 +1,85 @@
+// Copyright 2012 Citrix Systems, Inc. Licensed under the
+// Apache License, Version 2.0 (the "License"); you may not use this
+// file except in compliance with the License.  Citrix Systems, Inc.
+// reserves all rights not expressly granted by 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.
+// 
+// Automatically generated by addcopyright.py at 04/03/2012
+package com.cloud.storage.allocator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.server.StatsCollector;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolVO;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.vm.DiskProfile;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Local(value=StoragePoolAllocator.class)
+public class RandomStoragePoolAllocator extends AbstractStoragePoolAllocator {
+    private static final Logger s_logger = 
Logger.getLogger(RandomStoragePoolAllocator.class);
+    
+    @Override
+    public boolean allocatorIsCorrectType(DiskProfile dskCh) {
+       return true;
+    }
+    
+    @Override
+    public List<StoragePool> allocateToPool(DiskProfile dskCh, 
VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, 
ExcludeList avoid, int returnUpTo) {
+
+       List<StoragePool> suitablePools = new ArrayList<StoragePool>();
+       
+       VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();          
+       // Check that the allocator type is correct
+        if (!allocatorIsCorrectType(dskCh)) {
+               return suitablePools;
+        }
+               long dcId = plan.getDataCenterId();
+               Long podId = plan.getPodId();
+               Long clusterId = plan.getClusterId();
+        s_logger.debug("Looking for pools in dc: " + dcId + "  pod:" + podId + 
"  cluster:" + clusterId);
+       List<StoragePoolVO> pools = _storagePoolDao.listBy(dcId, podId, 
clusterId);
+        if (pools.size() == 0) {
+               if (s_logger.isDebugEnabled()) {
+                       s_logger.debug("No storage pools available for 
allocation, returning");
+               }
+            return suitablePools;
+        }
+        
+        StatsCollector sc = StatsCollector.getInstance();
+        
+        Collections.shuffle(pools);
+       if (s_logger.isDebugEnabled()) {
+            s_logger.debug("RandomStoragePoolAllocator has " + pools.size() + 
" pools to check for allocation");
+        }
+        for (StoragePoolVO pool: pools) {
+               if(suitablePools.size() == returnUpTo){
+                       break;
+               }               
+               if (checkPool(avoid, pool, dskCh, template, null, sc, plan)) {
+                       suitablePools.add(pool);
+               }
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("RandomStoragePoolAllocator returning 
"+suitablePools.size() +" suitable storage pools");
+        }
+
+        return suitablePools;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cefbbb38/server/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java 
b/server/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
deleted file mode 100644
index def048e..0000000
--- a/server/src/com/cloud/storage/allocator/RandomStoragePoolAllocator.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License.  Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-// 
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.storage.allocator;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
-import com.cloud.server.StatsCollector;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolVO;
-import com.cloud.storage.VMTemplateVO;
-import com.cloud.vm.DiskProfile;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-@Local(value=StoragePoolAllocator.class)
-public class RandomStoragePoolAllocator extends AbstractStoragePoolAllocator {
-    private static final Logger s_logger = 
Logger.getLogger(RandomStoragePoolAllocator.class);
-    
-    @Override
-    public boolean allocatorIsCorrectType(DiskProfile dskCh) {
-       return true;
-    }
-    
-    @Override
-    public List<StoragePool> allocateToPool(DiskProfile dskCh, 
VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, 
ExcludeList avoid, int returnUpTo) {
-
-       List<StoragePool> suitablePools = new ArrayList<StoragePool>();
-       
-       VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();          
-       // Check that the allocator type is correct
-        if (!allocatorIsCorrectType(dskCh)) {
-               return suitablePools;
-        }
-               long dcId = plan.getDataCenterId();
-               Long podId = plan.getPodId();
-               Long clusterId = plan.getClusterId();
-        s_logger.debug("Looking for pools in dc: " + dcId + "  pod:" + podId + 
"  cluster:" + clusterId);
-       List<StoragePoolVO> pools = _storagePoolDao.listBy(dcId, podId, 
clusterId);
-        if (pools.size() == 0) {
-               if (s_logger.isDebugEnabled()) {
-                       s_logger.debug("No storage pools available for 
allocation, returning");
-               }
-            return suitablePools;
-        }
-        
-        StatsCollector sc = StatsCollector.getInstance();
-        
-        Collections.shuffle(pools);
-       if (s_logger.isDebugEnabled()) {
-            s_logger.debug("RandomStoragePoolAllocator has " + pools.size() + 
" pools to check for allocation");
-        }
-        for (StoragePoolVO pool: pools) {
-               if(suitablePools.size() == returnUpTo){
-                       break;
-               }               
-               if (checkPool(avoid, pool, dskCh, template, null, sc, plan)) {
-                       suitablePools.add(pool);
-               }
-        }
-
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("RandomStoragePoolAllocator returning 
"+suitablePools.size() +" suitable storage pools");
-        }
-
-        return suitablePools;
-    }
-}

Reply via email to