cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [01/10] Moved the DB layer code into framework-db and change only the necessary projects to refer to it. Cut down on the dependencies introduced with all the code in utils.
Date Fri, 26 Jul 2013 22:01:50 GMT
Updated Branches:
  refs/heads/master 81b121bbe -> f5e5b39c9


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
deleted file mode 100644
index 40fcbbf..0000000
--- a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.lang.reflect.Method;
-
-import com.cloud.utils.component.ComponentMethodInterceptor;
-
-public class TransactionContextBuilder implements ComponentMethodInterceptor {
-	public TransactionContextBuilder() {
-	}
-	
-	@Override
-	public boolean needToIntercept(Method method) {
-        DB db = method.getAnnotation(DB.class);
-        if (db != null) {
-            return true;
-        }
-        
-        Class<?> clazz = method.getDeclaringClass();
-        
-        do {
-            db = clazz.getAnnotation(DB.class);
-            if (db != null) {
-                return true;
-            }
-            clazz = clazz.getSuperclass();
-        } while (clazz != Object.class && clazz != null);
-        
-        return false;
-    }
-
-	@Override
-    public Object interceptStart(Method method, Object target) {
-    	return Transaction.open(method.getName());
-    }
-    
-	@Override
-    public void interceptComplete(Method method, Object target, Object objReturnedInInterceptStart) {
-    	Transaction txn = (Transaction)objReturnedInInterceptStart;
-    	if(txn != null)
-    		txn.close();
-    }
-    
-	@Override
-    public void interceptException(Method method, Object target, Object objReturnedInInterceptStart) {
-    	Transaction txn = (Transaction)objReturnedInInterceptStart;
-    	if(txn != null)
-    		txn.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/src/com/cloud/utils/db/TransactionMBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/TransactionMBean.java b/utils/src/com/cloud/utils/db/TransactionMBean.java
deleted file mode 100644
index b868360..0000000
--- a/utils/src/com/cloud/utils/db/TransactionMBean.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.util.List;
-import java.util.Map;
-
-public interface TransactionMBean {
-    int getTransactionCount();
-    
-    int[] getActiveTransactionCount();
-    
-    List<Map<String, String>> getTransactions();
-    
-    List<Map<String, String>> getActiveTransactions();
-    
-    List<Map<String, String>> getTransactionsWithDatabaseConnection();
-    
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/src/com/cloud/utils/db/TransactionMBeanImpl.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/TransactionMBeanImpl.java b/utils/src/com/cloud/utils/db/TransactionMBeanImpl.java
deleted file mode 100644
index d51a9bd..0000000
--- a/utils/src/com/cloud/utils/db/TransactionMBeanImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.sql.Connection;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.StandardMBean;
-
-import com.cloud.utils.db.Transaction.StackElement;
-
-public class TransactionMBeanImpl extends StandardMBean implements TransactionMBean {
-    
-    Map<Long, Transaction> _txns = new ConcurrentHashMap<Long, Transaction>();
-    
-    public TransactionMBeanImpl() {
-        super(TransactionMBean.class, false);
-    }
-    
-    public void addTransaction(Transaction txn) {
-        _txns.put(txn.getId(), txn);
-    }
-    
-    public void removeTransaction(Transaction txn) {
-        _txns.remove(txn.getId());
-    }
-    
-    @Override
-    public int getTransactionCount() {
-        return _txns.size();
-    }
-    
-    @Override
-    public int[] getActiveTransactionCount() {
-        int[] count = new int[2];
-        count[0] = 0;
-        count[1] = 0;
-        for (Transaction txn : _txns.values()) {
-            if (txn.getStack().size() > 0) {
-                count[0]++;
-            }
-            if (txn.getCurrentConnection() != null) {
-                count[1]++;
-            }
-        }
-        return count;
-    }
-    
-    @Override
-    public List<Map<String, String>> getTransactions() {
-        ArrayList<Map<String, String>> txns = new ArrayList<Map<String, String>>();
-        for (Transaction info : _txns.values()) {
-            txns.add(toMap(info));
-        }
-        return txns;
-    }
-    
-    @Override
-    public List<Map<String, String>> getActiveTransactions() {
-        ArrayList<Map<String, String>> txns = new ArrayList<Map<String, String>>();
-        for (Transaction txn : _txns.values()) {
-            if (txn.getStack().size() > 0 || txn.getCurrentConnection() != null) {
-                txns.add(toMap(txn));
-            }
-        }
-        return txns;
-    }
-    
-    protected Map<String, String> toMap(Transaction txn) {
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("name", txn.getName());
-        map.put("id", Long.toString(txn.getId()));
-        map.put("creator", txn.getCreator());
-        Connection conn = txn.getCurrentConnection();
-        map.put("db", conn != null ? Integer.toString(System.identityHashCode(conn)) : "none");
-        StringBuilder buff = new StringBuilder();
-        for (StackElement element : txn.getStack()) {
-            buff.append(element.toString()).append(",");
-        }
-        map.put("stack", buff.toString());
-        
-        return map;
-    }
-
-    @Override
-    public List<Map<String, String>> getTransactionsWithDatabaseConnection() {
-        ArrayList<Map<String, String>> txns = new ArrayList<Map<String, String>>();
-        for (Transaction txn : _txns.values()) {
-            if (txn.getCurrentConnection() != null) {
-                txns.add(toMap(txn));
-            }
-        }
-        return txns;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/src/com/cloud/utils/db/UpdateBuilder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/UpdateBuilder.java b/utils/src/com/cloud/utils/db/UpdateBuilder.java
deleted file mode 100755
index c13aa51..0000000
--- a/utils/src/com/cloud/utils/db/UpdateBuilder.java
+++ /dev/null
@@ -1,147 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import com.cloud.utils.Ternary;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class UpdateBuilder implements MethodInterceptor {
-    protected Map<String, Ternary<Attribute, Boolean, Object>> _changes;
-    protected HashMap<Attribute, Object> _collectionChanges;
-    protected GenericDaoBase<?, ?> _dao;
-    
-    protected UpdateBuilder(GenericDaoBase<?, ?> dao) {
-        _dao = dao;
-        _changes = new HashMap<String, Ternary<Attribute, Boolean, Object>>();
-    }
-    
-    @Override
-    public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
-        String name = method.getName();
-        if (name.startsWith("set")) {
-        	String field = methodToField(name, 3);
-            makeChange(field, args[0]);
-        } else if (name.startsWith("incr")) {
-        	makeIncrChange(name, args);
-        } else if (name.startsWith("decr")) {
-        	makeDecrChange(name, args);
-        }
-        return methodProxy.invokeSuper(object, args);
-    }
-    
-    private final String methodToField(String method, int start) {
-    	char[] chs = method.toCharArray();
-    	chs[start] = Character.toLowerCase(chs[start]);
-    	return new String(chs, start, chs.length - start);
-    }
-    
-    protected Attribute makeChange(String field, Object value) {
-        Attribute attr = _dao._allAttributes.get(field);
-        
-        assert (attr == null || attr.isUpdatable()) : "Updating an attribute that's not updatable: " + field;
-        if (attr != null) {
-            if (attr.attache == null) {
-                _changes.put(field, new Ternary<Attribute, Boolean, Object>(attr, null, value));
-            } else {
-                if (_collectionChanges == null) {
-                    _collectionChanges = new HashMap<Attribute, Object>();
-                }
-                _collectionChanges.put(attr, value);
-            }
-        }
-        return attr;
-    }
-    
-    protected void makeIncrChange(String method, Object[] args) {
-    	String field = methodToField(method, 4);
-    	Attribute attr = _dao._allAttributes.get(field);
-        assert (attr != null && attr.isUpdatable()) : "Updating an attribute that's not updatable: " + field;
-    	incr(attr, args == null || args.length == 0 ? 1 : args[0]);
-    }
-    
-    protected void makeDecrChange(String method, Object[] args) {
-    	String field = methodToField(method, 4);
-    	Attribute attr = _dao._allAttributes.get(field);
-        assert (attr != null && attr.isUpdatable()) : "Updating an attribute that's not updatable: " + field;
-    	decr(attr, args == null || args.length == 0 ? 1 : args[0]);
-    }
-    
-    public void set(Object entity, String name, Object value) {
-    	Attribute attr = makeChange(name, value);
-
-    	set(entity, attr, value);
-    }
-    
-    public void set(Object entity, Attribute attr, Object value) {
-        _changes.put(attr.field.getName(), new Ternary<Attribute, Boolean, Object>(attr, null, value));
-        try {
-			attr.field.set(entity, value);
-		} catch (IllegalArgumentException e) {
-			throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e);
-		} catch (IllegalAccessException e) {
-			throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e);
-		}
-    }
-    
-    public void incr(Attribute attr, Object value) {
-        _changes.put(attr.field.getName(), new Ternary<Attribute, Boolean, Object>(attr, true, value));
-    }
-    
-    public void decr(Attribute attr, Object value) {
-        _changes.put(attr.field.getName(), new Ternary<Attribute, Boolean, Object>(attr, false, value));
-    }
-    
-    public boolean hasChanges() {
-        return (_changes.size() + (_collectionChanges != null ? _collectionChanges.size() : 0)) != 0;
-    }
-    
-    public boolean has(String name) {
-        return _changes.containsKey(name);
-    }
-    
-    public Map<Attribute, Object> getCollectionChanges() {
-        return _collectionChanges;
-    }
-    
-    public void clear() {
-        _changes.clear();
-        if (_collectionChanges != null) {
-            _collectionChanges.clear();
-            _collectionChanges = null;
-        }
-    }
-    
-    public StringBuilder toSql(String tables) {
-    	if (_changes.isEmpty()) {
-    		return null;
-    	}
-    	
-    	return SqlGenerator.buildMysqlUpdateSql(tables, _changes.values());
-    }
-    
-    public Collection<Ternary<Attribute, Boolean, Object>> getChanges() {
-    	return _changes.values();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/src/com/cloud/utils/db/UpdateFilter.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/UpdateFilter.java b/utils/src/com/cloud/utils/db/UpdateFilter.java
deleted file mode 100644
index 37b35b1..0000000
--- a/utils/src/com/cloud/utils/db/UpdateFilter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.lang.reflect.Method;
-
-import net.sf.cglib.proxy.CallbackFilter;
-
-public class UpdateFilter implements CallbackFilter {
-    @Override
-    public int accept(Method method) {
-        String name = method.getName();
-        return (name.startsWith("set") || name.startsWith("incr") || name.startsWith("decr")) ? 1 : 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DbAnnotatedBase.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DbAnnotatedBase.java b/utils/test/com/cloud/utils/db/DbAnnotatedBase.java
deleted file mode 100644
index f87b20f..0000000
--- a/utils/test/com/cloud/utils/db/DbAnnotatedBase.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-
-import junit.framework.Assert;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-@Component
-@DB
-public class DbAnnotatedBase {
-    private static final Logger s_logger = Logger.getLogger(DbAnnotatedBase.class);
-
-    @Inject DummyComponent _dummy;
-    
-    @PostConstruct
-    public void initTest() {
-    	Assert.assertTrue(true);
-    }
-    
-    public void MethodWithClassDbAnnotated() {
-    	s_logger.info("called");
-    	_dummy.sayHello();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java b/utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
deleted file mode 100644
index 38e045c..0000000
--- a/utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class DbAnnotatedBaseDerived extends DbAnnotatedBase {
-
-	@DB
-	public void DbAnnotatedMethod() {
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DbTestDao.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DbTestDao.java b/utils/test/com/cloud/utils/db/DbTestDao.java
deleted file mode 100644
index 9530b3b..0000000
--- a/utils/test/com/cloud/utils/db/DbTestDao.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.sql.PreparedStatement;
-import java.util.Date;
-import java.util.TimeZone;
-
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class DbTestDao extends GenericDaoBase<DbTestVO, Long> implements GenericDao<DbTestVO, Long> {
-    protected DbTestDao() {
-    }
-
-    @DB
-    public void create(int fldInt, long fldLong, String fldString) {
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        try {
-            txn.start();
-            pstmt = txn
-                    .prepareAutoCloseStatement("insert into cloud.test(fld_int, fld_long, fld_string) values(?, ?, ?)");
-            pstmt.setInt(1, fldInt);
-            pstmt.setLong(2, fldLong);
-            pstmt.setString(3, fldString);
-
-            pstmt.executeUpdate();
-            txn.commit();
-        } catch (Exception e) {
-            throw new CloudRuntimeException("Problem with creating a record in test table", e);
-        }
-    }
-
-    @DB
-    public void update(int fldInt, long fldLong, String fldString) {
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        try {
-            txn.start();
-            pstmt = txn.prepareAutoCloseStatement("update cloud.test set fld_int=?, fld_long=? where fld_string=?");
-            pstmt.setInt(1, fldInt);
-            pstmt.setLong(2, fldLong);
-            pstmt.setString(3, fldString);
-
-            pstmt.executeUpdate();
-            txn.commit();
-        } catch (Exception e) {
-            throw new CloudRuntimeException("Problem with creating a record in test table", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DbTestUtils.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DbTestUtils.java b/utils/test/com/cloud/utils/db/DbTestUtils.java
deleted file mode 100644
index 11ae1aa..0000000
--- a/utils/test/com/cloud/utils/db/DbTestUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import com.cloud.utils.PropertiesUtil;
-
-public class DbTestUtils {
-    
-    public static void executeScript(String file, boolean autoCommit, boolean stopOnError) {
-        File cleanScript = PropertiesUtil.findConfigFile(file);
-        if (cleanScript == null) {
-            throw new RuntimeException("Unable to clean the database because I can't find " + file);
-        }
-        
-        Connection conn = Transaction.getStandaloneConnection();
-        
-        ScriptRunner runner = new ScriptRunner(conn, autoCommit, stopOnError);
-        FileReader reader;
-        try {
-            reader = new FileReader(cleanScript);
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Unable to read " + file, e);
-        } 
-        try {
-            runner.runScript(reader);
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to read " + file, e);
-        } catch (SQLException e) {
-            throw new RuntimeException("Unable to execute " + file, e);
-        }
-        
-        try {
-            conn.close();
-        } catch (SQLException e) {
-            throw new RuntimeException("Unable to close DB connection", e);
-        }
-    }
-
-    public static void executeUsageScript(String file, boolean autoCommit, boolean stopOnError) {
-        File cleanScript = PropertiesUtil.findConfigFile(file);
-        if (cleanScript == null) {
-            throw new RuntimeException("Unable to clean the database because I can't find " + file);
-        }
-        
-        Connection conn = Transaction.getStandaloneUsageConnection();
-        
-        ScriptRunner runner = new ScriptRunner(conn, autoCommit, stopOnError);
-        FileReader reader;
-        try {
-            reader = new FileReader(cleanScript);
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Unable to read " + file, e);
-        } 
-        try {
-            runner.runScript(reader);
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to read " + file, e);
-        } catch (SQLException e) {
-            throw new RuntimeException("Unable to execute " + file, e);
-        }
-        
-        try {
-            conn.close();
-        } catch (SQLException e) {
-            throw new RuntimeException("Unable to close DB connection", e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DbTestVO.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DbTestVO.java b/utils/test/com/cloud/utils/db/DbTestVO.java
deleted file mode 100644
index 5285bfe..0000000
--- a/utils/test/com/cloud/utils/db/DbTestVO.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "test")
-public class DbTestVO {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    long id;
-
-    @Column(name = "fld_int")
-    int fieldInt;
-
-    @Column(name = "fld_long")
-    Long fieldLong;
-
-    @Column(name = "fld_string")
-    String fieldString;
-
-    public String getFieldString() {
-        return fieldString;
-    }
-
-    public int getFieldInt() {
-        return fieldInt;
-    }
-
-    public long getFieldLong() {
-        return fieldLong;
-    }
-
-    public DbTestVO() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/DummyComponent.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/DummyComponent.java b/utils/test/com/cloud/utils/db/DummyComponent.java
deleted file mode 100644
index 2922630..0000000
--- a/utils/test/com/cloud/utils/db/DummyComponent.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class DummyComponent {
-
-	public void sayHello() {
-		System.out.println("Hello, world");
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/ElementCollectionTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/ElementCollectionTest.java b/utils/test/com/cloud/utils/db/ElementCollectionTest.java
deleted file mode 100644
index b860af5..0000000
--- a/utils/test/com/cloud/utils/db/ElementCollectionTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-
-
-public class ElementCollectionTest extends TestCase {
-    static final Logger s_logger = Logger.getLogger(ElementCollectionTest.class);
-    ArrayList<String> ar = null;
-    List<String> lst = null;
-    Collection<String> coll = null;
-    String[] array = null;
-
-    public void testArrayList() throws Exception {
-        Field[] fields = this.getClass().getDeclaredFields();
-        for (Field field : fields) {
-            if (Modifier.isStatic(field.getModifiers())) {
-                continue;
-            }
-            Class<?> type1 = field.getType();
-            Object collection = null;
-            if (!type1.isArray()) {
-                ParameterizedType type = (ParameterizedType)field.getGenericType();
-                Type rawType = type.getRawType();
-                Class<?> rawClazz = (Class<?>)rawType;
-                if (!Modifier.isAbstract(rawClazz.getModifiers()) && !rawClazz.isInterface() && rawClazz.getConstructors().length != 0 && rawClazz.getConstructor() != null) {
-                    collection = rawClazz.newInstance();
-                }
-
-                if (collection == null) {
-                    if (Collection.class.isAssignableFrom(rawClazz)) {
-                        collection = new ArrayList();
-                    } else if (Set.class.isAssignableFrom(rawClazz)) {
-                        collection = new HashSet();
-                    }
-                }
-            } else {
-                collection = Array.newInstance(String.class, 1);
-            }
-            field.set(this, collection);
-            assert (field.get(this) != null);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/GlobalLockTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/GlobalLockTest.java b/utils/test/com/cloud/utils/db/GlobalLockTest.java
deleted file mode 100644
index 01e1e33..0000000
--- a/utils/test/com/cloud/utils/db/GlobalLockTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.db;
-
-import org.apache.log4j.Logger;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import junit.framework.Assert;
-
-import com.cloud.utils.Profiler;
-import com.cloud.utils.testcase.Log4jEnabledTestCase;
-
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/testContext.xml")
-public class GlobalLockTest {
-    public static final Logger s_logger = Logger.getLogger(GlobalLockTest.class);
-    private final static GlobalLock _workLock = GlobalLock.getInternLock("SecurityGroupWork");
-    public static class Worker implements Runnable {
-        int id = 0;
-        int timeoutSeconds = 10;
-        int jobDuration = 2;
-        public Worker(int id, int timeout, int duration) {
-            this.id = id;
-            timeoutSeconds = timeout;
-            jobDuration = duration;
-        }
-        public void run() {
-            boolean locked = false;
-            try {
-                Profiler p = new Profiler();
-                p.start();
-                locked = _workLock.lock(timeoutSeconds);
-                p.stop();
-                System.out.println("Thread " + id + " waited " + p.getDuration() + " ms, locked=" + locked);
-                if (locked) {
-                    Thread.sleep(jobDuration*1000);
-                }
-            } catch (InterruptedException e) {
-            } finally {
-                if (locked) {
-                    boolean unlocked = _workLock.unlock();
-                    System.out.println("Thread " + id + "  unlocked=" + unlocked);
-                }
-            }
-        }
-    }
-
-    @Test
-    public void testTimeout() {
-        Thread [] pool = new Thread[50];
-        for (int i=0; i < pool.length; i++) {
-            pool[i] = new Thread(new Worker(i, 5, 3));
-        }
-        for (int i=0; i < pool.length; i++) {
-            pool[i].start();
-        }
-        for (int i=0; i < pool.length; i++) {
-            try {
-                pool[i].join();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/Merovingian2Test.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/Merovingian2Test.java b/utils/test/com/cloud/utils/db/Merovingian2Test.java
deleted file mode 100644
index 8246faa..0000000
--- a/utils/test/com/cloud/utils/db/Merovingian2Test.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class Merovingian2Test extends TestCase {
-    static final Logger s_logger = Logger.getLogger(Merovingian2Test.class);
-    Merovingian2 _lockMaster = Merovingian2.createLockMaster(1234);
-    
-    @Override @Before
-    protected void setUp() throws Exception {
-        _lockMaster.cleanupThisServer();
-    }
-    
-    @Override @After
-    protected void tearDown() throws Exception {
-        _lockMaster.cleanupThisServer();
-    }
-
-    @Test
-    public void testLockAndRelease() {
-        
-        s_logger.info("Testing first acquire");
-        boolean result = _lockMaster.acquire("first"+1234, 5);
-        Assert.assertTrue(result);
-        
-        s_logger.info("Testing acquire of different lock");
-        result = _lockMaster.acquire("second"+1234, 5);
-        Assert.assertTrue(result);
-        
-        s_logger.info("Testing reacquire of the same lock");
-        result = _lockMaster.acquire("first"+1234, 5);
-        Assert.assertTrue(result);
-        
-        int count = _lockMaster.owns("first"+1234);
-        Assert.assertEquals(count, 2);
-        
-        count = _lockMaster.owns("second"+1234);
-        Assert.assertEquals(count, 1);
-        
-        s_logger.info("Testing release of the first lock");
-        result = _lockMaster.release("first"+1234);
-        Assert.assertTrue(result);
-        
-        count = _lockMaster.owns("first"+1234);
-        Assert.assertEquals(count, 1);
-        
-        s_logger.info("Testing release of the second lock");
-        result = _lockMaster.release("second"+1234);
-        Assert.assertTrue(result);
-        
-        result = _lockMaster.release("first"+1234);
-        Assert.assertTrue(result);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java b/utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java
deleted file mode 100644
index 33e7aa0..0000000
--- a/utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import com.cloud.utils.component.ComponentContext;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/com/cloud/utils/db/transactioncontextBuilderTest.xml")
-public class TransactionContextBuilderTest {
-
-	@Inject
-	DbAnnotatedBaseDerived _derived; 
-	
-	DbAnnotatedBase _base;
-	
-	@Inject
-	List<DbAnnotatedBase> _list;
-	
-	@Test
-	public void test() {
-		// _derived.DbAnnotatedMethod();
-		// _base.MethodWithClassDbAnnotated();
-		
-		// test @DB injection on dynamically constructed objects
-		DbAnnotatedBase base = ComponentContext.inject(new DbAnnotatedBase());
-		base.MethodWithClassDbAnnotated();
-
-/*		
-		Map<String, DbAnnotatedBase> components = ComponentContext.getApplicationContext().getBeansOfType(DbAnnotatedBase.class);
-		for(Map.Entry<String, DbAnnotatedBase> entry : components.entrySet()) {
-			System.out.println(entry.getKey());
-			entry.getValue().MethodWithClassDbAnnotated();
-		}
-*/
-		for(DbAnnotatedBase entry : _list) {
-			entry.MethodWithClassDbAnnotated();
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/db/TransactionTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/db/TransactionTest.java b/utils/test/com/cloud/utils/db/TransactionTest.java
deleted file mode 100644
index 101a533..0000000
--- a/utils/test/com/cloud/utils/db/TransactionTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.db;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-/**
- * A test fixture to test APIs or bugs found for Transaction class. This test fixture will do one time setup before
- * all its testcases to set up a test db table, and then tear down these test db artifacts after all testcases are run.
- *
- */
-public class TransactionTest {
-
-    @BeforeClass
-    public static void oneTimeSetup() {
-        Connection conn = null;
-        PreparedStatement pstmt = null;
-        try {
-            conn = Transaction.getStandaloneConnection();
-
-            pstmt = conn.prepareStatement("CREATE TABLE `cloud`.`test` ("
-                    + "`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT," + "`fld_int` int unsigned,"
-                    + "`fld_long` bigint unsigned," + "`fld_string` varchar(255)," + "PRIMARY KEY (`id`)"
-                    + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-
-            pstmt.execute();
-
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Problem with sql", e);
-        } finally {
-            if (pstmt != null) {
-                try {
-                    pstmt.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (conn != null) {
-                try {
-                    conn.close();
-                } catch (SQLException e) {
-                }
-            }
-        }
-    }
-
-    @Test
-    /**
-     * When a transaction is set to use user-managed db connection, for each following db statement, we should see
-     * that the same db connection is reused rather than acquiring a new one each time in typical transaction model.
-     */
-    public void testUserManagedConnection() {
-        DbTestDao testDao = ComponentContext.inject(DbTestDao.class);
-        Transaction txn = Transaction.open("SingleConnectionThread");
-        Connection conn = null;
-        try {
-            conn = Transaction.getStandaloneConnectionWithException();
-            txn.transitToUserManagedConnection(conn);
-            // try two SQLs to make sure that they are using the same connection
-            // acquired above.
-            testDao.create(1, 1, "Record 1");
-            Connection checkConn = Transaction.currentTxn().getConnection();
-            if (checkConn != conn) {
-                Assert.fail("A new db connection is acquired instead of using old one after create sql");
-            }
-            testDao.update(2, 2, "Record 1");
-            Connection checkConn2 = Transaction.currentTxn().getConnection();
-            if (checkConn2 != conn) {
-                Assert.fail("A new db connection is acquired instead of using old one after update sql");
-            }
-        } catch (SQLException e) {
-            Assert.fail(e.getMessage());
-        } finally {
-            txn.transitToAutoManagedConnection(Transaction.CLOUD_DB);
-            txn.close();
-
-            if (conn != null) {
-                try {
-                    conn.close();
-                } catch (SQLException e) {
-                    throw new CloudRuntimeException("Problem with close db connection", e);
-                }
-            }
-        }
-    }
-
-    @Test
-    /**
-     * This test is simulating ClusterHeartBeat process, where the same transaction and db connection is reused.
-     */
-    public void testTransactionReuse() {
-        DbTestDao testDao = ComponentContext.inject(DbTestDao.class);
-        // acquire a db connection and keep it
-        Connection conn = null;
-        try {
-            conn = Transaction.getStandaloneConnectionWithException();
-        } catch (SQLException ex) {
-            throw new CloudRuntimeException("Problem with getting db connection", ex);
-        }
-
-        // start heartbeat loop, make sure that each loop still use the same
-        // connection
-        Transaction txn = null;
-        for (int i = 0; i < 3; i++) {
-            txn = Transaction.open("HeartbeatSimulator");
-            try {
-
-                txn.transitToUserManagedConnection(conn);
-                testDao.create(i, i, "Record " + i);
-                Connection checkConn = Transaction.currentTxn().getConnection();
-                if (checkConn != conn) {
-                    Assert.fail("A new db connection is acquired instead of using old one in loop " + i);
-                }
-            } catch (SQLException e) {
-                Assert.fail(e.getMessage());
-            } finally {
-                txn.transitToAutoManagedConnection(Transaction.CLOUD_DB);
-                txn.close();
-            }
-        }
-        // close the connection once we are done since we are managing db
-        // connection ourselves.
-        if (conn != null) {
-            try {
-                conn.close();
-            } catch (SQLException e) {
-                throw new CloudRuntimeException("Problem with close db connection", e);
-            }
-        }
-    }
-
-    @After
-    /**
-     * Delete all records after each test, but table is still kept
-     */
-    public void tearDown() {
-        Connection conn = null;
-        PreparedStatement pstmt = null;
-        try {
-            conn = Transaction.getStandaloneConnection();
-
-            pstmt = conn.prepareStatement("truncate table `cloud`.`test`");
-            pstmt.execute();
-
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Problem with sql", e);
-        } finally {
-            if (pstmt != null) {
-                try {
-                    pstmt.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (conn != null) {
-                try {
-                    conn.close();
-                } catch (SQLException e) {
-                }
-            }
-        }
-    }
-
-    @AfterClass
-    public static void oneTimeTearDown() {
-        Connection conn = null;
-        PreparedStatement pstmt = null;
-        try {
-            conn = Transaction.getStandaloneConnection();
-
-            pstmt = conn.prepareStatement("DROP TABLE IF EXISTS `cloud`.`test`");
-            pstmt.execute();
-
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Problem with sql", e);
-        } finally {
-            if (pstmt != null) {
-                try {
-                    pstmt.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (conn != null) {
-                try {
-                    conn.close();
-                } catch (SQLException e) {
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java b/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
deleted file mode 100644
index 5e3571a..0000000
--- a/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.utils.log;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.*;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.exception.CloudRuntimeException;
-import org.apache.log4j.spi.RootLogger;
-import org.apache.log4j.spi.ThrowableRenderer;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.io.CharArrayWriter;
-import java.io.Writer;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/testContext.xml")
-public class CglibThrowableRendererTest extends TestCase {
-    static Logger another = Logger.getLogger("TEST");
-
-    private final static Logger s_logger = Logger.getLogger(CglibThrowableRendererTest.class);
-    public static class TestClass {
-    	
-    	public TestClass() {
-    	}
-    	
-        @DB
-        public void exception1() {
-            throw new IllegalArgumentException("What a bad exception");
-        }
-        public void exception2() {
-            try {
-                exception1();
-            } catch (Exception e) {
-                throw new CloudRuntimeException("exception2", e);
-            }
-        }
-        @DB
-        public void exception() {
-            try {
-                exception2();
-            } catch (Exception e) {
-                throw new CloudRuntimeException("exception", e);
-            }
-        }
-    }
-
-    private Logger getAlternateLogger(Writer writer, ThrowableRenderer renderer) {
-        Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.INFO));
-        if (renderer != null) {
-            hierarchy.setThrowableRenderer(renderer);
-        }
-        Logger alternateRoot = hierarchy.getRootLogger();
-        alternateRoot.addAppender(new WriterAppender(new SimpleLayout(), writer));
-        return alternateRoot;
-    }
-
-    @Test
-    public void testException() {
-        Writer w = new CharArrayWriter();
-        Logger alt = getAlternateLogger(w, null);
-
-        TestClass test = new TestClass();
-        try {
-            test.exception();
-        } catch (Exception e) {
-            alt.warn("exception caught", e);
-        }
-        // first check that we actually have some call traces containing "<generated>"
-       // assertTrue(w.toString().contains("<generated>"));
-
-        w = new CharArrayWriter();
-        alt = getAlternateLogger(w, new CglibThrowableRenderer());
-
-        try {
-            test.exception();
-        } catch (Exception e) {
-            alt.warn("exception caught", e);
-        }
-        // then we check that CglibThrowableRenderer indeed remove those occurrences
-        assertFalse(w.toString().contains("<generated>"));
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java
----------------------------------------------------------------------
diff --git a/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java b/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java
deleted file mode 100644
index 220bd80..0000000
--- a/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// 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.test.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.component.ComponentInstantiationPostProcessor;
-import com.cloud.utils.component.ComponentMethodInterceptor;
-import com.cloud.utils.db.TransactionContextBuilder;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class SpringUtils {
-
-    /**
-     * This method allows you to use @ComponentScan for your unit testing but
-     * it limits the scope of the classes found to the class specified in
-     * the @ComponentScan annotation.
-     *
-     * Without using this method, the default behavior of @ComponentScan is
-     * to actually scan in the package of the class specified rather than
-     * only the class. This can cause extra classes to be loaded which causes
-     * the classes these extra classes depend on to be loaded. The end effect
-     * is often most of the project gets loaded.
-     *
-     * In order to use this method properly, you must do the following: <li>
-     *   - Specify @ComponentScan with basePackageClasses, includeFilters, and
-     *     useDefaultFilters=true.  See the following example.
-     *
-     * <pre>
-     *     @ComponentScan(basePackageClasses={AffinityGroupServiceImpl.class, EventUtils.class},
-     *     includeFilters={@Filter(value=TestConfiguration.Library.class, type=FilterType.CUSTOM)},
-     *     useDefaultFilters=false)
-     * </pre>
-     *
-     *   - Create a Library class and use that to call this method.  See the
-     *     following example.  The Library class you define here is the Library
-     *     class being added in the filter above.
-     *
-     * <pre>
-     * public static class Library implements TypeFilter {
-     *      @Override
-     *      public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
-     *          ComponentScan cs = TestConfiguration.class.getAnnotation(ComponentScan.class);
-     *          return SpringUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
-     *      }
-     * }
-     * </pre>
-     *
-     * @param clazzName name of the class that should be included in the Spring components
-     * @param cs ComponentScan annotation that was declared on the configuration
-     *
-     * @return
-     */
-    public static boolean includedInBasePackageClasses(String clazzName, ComponentScan cs) {
-        Class<?> clazzToCheck;
-        try {
-            clazzToCheck = Class.forName(clazzName);
-        } catch (ClassNotFoundException e) {
-            throw new CloudRuntimeException("Unable to find " + clazzName);
-        }
-        Class<?>[] clazzes = cs.basePackageClasses();
-        for (Class<?> clazz : clazzes) {
-            if (clazzToCheck.isAssignableFrom(clazz)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static class CloudStackTestConfiguration {
-
-        @Bean
-        public ComponentContext componentContext() {
-            return new ComponentContext();
-        }
-
-        @Bean
-        public TransactionContextBuilder transactionContextBuilder() {
-            return new TransactionContextBuilder();
-        }
-
-        @Bean
-        public ComponentInstantiationPostProcessor instantiatePostProcessor() {
-            ComponentInstantiationPostProcessor processor = new ComponentInstantiationPostProcessor();
-
-            List<ComponentMethodInterceptor> interceptors = new ArrayList<ComponentMethodInterceptor>();
-            interceptors.add(new TransactionContextBuilder());
-            processor.setInterceptors(interceptors);
-
-            return processor;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/vmware-base/pom.xml
----------------------------------------------------------------------
diff --git a/vmware-base/pom.xml b/vmware-base/pom.xml
index c5d555e..90e0709 100644
--- a/vmware-base/pom.xml
+++ b/vmware-base/pom.xml
@@ -33,6 +33,11 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-framework-db</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
         <groupId>org.apache.cloudstack</groupId>
         <artifactId>cloud-api</artifactId>
         <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5e5b39c/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index dd0f889..c92b855 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -27,21 +27,6 @@ import java.util.Map;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.hypervisor.vmware.util.VmwareHelper;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.utils.ActionDelegate;
-import com.cloud.utils.Pair;
-import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
-import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
-import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.net.NetUtils;
 import com.vmware.vim25.AlreadyExistsFaultMsg;
 import com.vmware.vim25.BoolPolicy;
 import com.vmware.vim25.DVPortSetting;
@@ -79,6 +64,22 @@ import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
 
+import com.cloud.hypervisor.vmware.util.VmwareContext;
+import com.cloud.hypervisor.vmware.util.VmwareHelper;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.utils.ActionDelegate;
+import com.cloud.utils.Pair;
+import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
+import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
+import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.net.NetUtils;
+
 public class HypervisorHostHelper {
     private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
     private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
@@ -446,29 +447,29 @@ public class HypervisorHostHelper {
         Integer vid = null;
         Integer spvlanid = null;  // secondary pvlan id
 
-        /** This is the list of BroadcastDomainTypes we can actually 
+        /** This is the list of BroadcastDomainTypes we can actually
          * prepare networks for in this function.
          */
-        BroadcastDomainType[] supportedBroadcastTypes = 
-                new BroadcastDomainType[] { BroadcastDomainType.Lswitch, 
-                BroadcastDomainType.LinkLocal, 
-                BroadcastDomainType.Native, 
+        BroadcastDomainType[] supportedBroadcastTypes =
+                new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
+                BroadcastDomainType.LinkLocal,
+                BroadcastDomainType.Native,
                 BroadcastDomainType.Pvlan,
                 BroadcastDomainType.Storage,
                 BroadcastDomainType.UnDecided,
                 BroadcastDomainType.Vlan };
 
         if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
-            throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + 
+            throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
                     " it not supported on a VMWare hypervisor at this time.");
         }
 
         if (broadcastDomainType == BroadcastDomainType.Lswitch) {
             if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
-                throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " + 
+                throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " +
                         broadcastDomainType);
             }
-            /** 
+            /**
              * Nicira NVP requires all vms to be connected to a single port-group.
              * A unique vlan needs to be set per port. This vlan is specific to
              * this implementation and has no reference to other vlans in CS
@@ -552,7 +553,7 @@ public class HypervisorHostHelper {
             }
             long averageBandwidth = 0L;
             if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
-                averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L);
+                averageBandwidth = networkRateMbps.intValue() * 1024L * 1024L;
             }
             // We chose 50% higher allocation than average bandwidth.
             // TODO(sateesh): Optionally let user specify the peak coefficient
@@ -601,7 +602,7 @@ public class HypervisorHostHelper {
         return vCenterApiVersion.compareTo(minVcenterApiVersionForFeature) >= 0 ? true : false;
     }
 
-    private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch, 
+    private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
             Integer vid, Integer spvlanid) throws Exception {
         Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch);
         if (!vlanmap.isEmpty()) {
@@ -664,7 +665,7 @@ public class HypervisorHostHelper {
 
     }
 
-    private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo, 
+    private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
             DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported) throws Exception{
         VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
         VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
@@ -717,7 +718,7 @@ public class HypervisorHostHelper {
                     throw new Exception(msg);
                 }
             }
-        }        
+        }
     }
     
      public static ManagedObjectReference waitForDvPortGroupReady(
@@ -806,12 +807,12 @@ public class HypervisorHostHelper {
         LongPolicy burstSize = new LongPolicy();
 
         isEnabled.setValue(true);
-        averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L);
+        averageBandwidth.setValue(networkRateMbps.intValue() * 1024L * 1024L);
         // We chose 50% higher allocation than average bandwidth.
         // TODO(sateesh): Also let user specify the peak coefficient
         peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5));
         // TODO(sateesh): Also let user specify the burst coefficient
-        burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8));
+        burstSize.setValue(5 * averageBandwidth.getValue() / 8);
 
         shapingPolicy.setEnabled(isEnabled);
         shapingPolicy.setAverageBandwidth(averageBandwidth);
@@ -889,25 +890,25 @@ public class HypervisorHostHelper {
         String networkName;
         Integer vid = null;
 
-        /** This is the list of BroadcastDomainTypes we can actually 
+        /** This is the list of BroadcastDomainTypes we can actually
          * prepare networks for in this function.
          */
-        BroadcastDomainType[] supportedBroadcastTypes = 
-                new BroadcastDomainType[] { BroadcastDomainType.Lswitch, 
-                BroadcastDomainType.LinkLocal, 
-                BroadcastDomainType.Native, 
+        BroadcastDomainType[] supportedBroadcastTypes =
+                new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
+                BroadcastDomainType.LinkLocal,
+                BroadcastDomainType.Native,
                 BroadcastDomainType.Pvlan,
                 BroadcastDomainType.Storage,
                 BroadcastDomainType.UnDecided,
                 BroadcastDomainType.Vlan };
 
         if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
-            throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + 
+            throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
                     " it not supported on a VMWare hypervisor at this time.");
         }
 
         if (broadcastDomainType == BroadcastDomainType.Lswitch) {
-            /** 
+            /**
              * Nicira NVP requires each vm to have its own port-group with a dedicated
              * vlan. We'll set the name of the pg to the uuid of the nic.
              */
@@ -934,7 +935,7 @@ public class HypervisorHostHelper {
         if(networkRateMbps != null && networkRateMbps.intValue() > 0) {
             shapingPolicy = new HostNetworkTrafficShapingPolicy();
             shapingPolicy.setEnabled(true);
-            shapingPolicy.setAverageBandwidth((long)networkRateMbps.intValue()*1024L*1024L);
+            shapingPolicy.setAverageBandwidth(networkRateMbps.intValue()*1024L*1024L);
 
             //
             // TODO : people may have different opinion on how to set the following
@@ -1062,10 +1063,10 @@ public class HypervisorHostHelper {
     }
     
     private static void createNvpPortGroup(HostMO hostMo, HostVirtualSwitch vSwitch, String networkName, HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
-        /** 
+        /**
          * No portgroup created yet for this nic
          * We need to find an unused vlan and create the pg
-         * The vlan is limited to this vSwitch and the NVP vAPP, 
+         * The vlan is limited to this vSwitch and the NVP vAPP,
          * so no relation to the other vlans in use in CloudStack.
          */
         String vSwitchName = vSwitch.getName();
@@ -1096,7 +1097,7 @@ public class HypervisorHostHelper {
         secPolicy.setMacChanges(Boolean.FALSE);
         
         // Create a portgroup with the uuid of the nic and the vlanid found above
-        hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);      
+        hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
     }
 
     public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,


Mime
View raw message