[jboss-svn-commits] JBL Code SVN: r30169 - labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Nov 16 07:50:18 EST 2009
Author: whitingjr
Date: 2009-11-16 07:50:18 -0500 (Mon, 16 Nov 2009)
New Revision: 30169
Added:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/AbstractVendorControl.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Constraint.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Purge.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/SequenceSynchronizer.java
Removed:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/IntegrityConstraint.java
Modified:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/HSQLDB.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/MySQL.java
labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/OracleConstraint.java
Log:
Added configuration instructions.
Added sequence initialisation.
Copied: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/AbstractVendorControl.java (from rev 30093, labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/AbstractConstraint.java)
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/AbstractVendorControl.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/AbstractVendorControl.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -0,0 +1,35 @@
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jbossts.performance.persistence.vendor;
+
+import java.util.Set;
+
+public abstract class AbstractVendorControl implements Constraint, Purge, SequenceSynchronizer
+{
+ protected Set<String> tableNames;
+ public void setTableNames(Set<String> names)
+ {
+ this.tableNames = names;
+ }
+
+}
Copied: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Constraint.java (from rev 29927, labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/IntegrityConstraint.java)
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Constraint.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Constraint.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -0,0 +1,32 @@
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jbossts.performance.persistence.vendor;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface Constraint
+{
+ public void relax(Connection connection) throws SQLException;
+ public void constrain(Connection connection) throws SQLException;
+}
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/HSQLDB.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/HSQLDB.java 2009-11-16 12:49:35 UTC (rev 30168)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/HSQLDB.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -23,23 +23,67 @@
package org.jboss.jbossts.performance.persistence.vendor;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.SQLException;
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.log4j.Logger;
-public class HSQLDB implements IntegrityConstraint
+
+public class HSQLDB extends AbstractVendorControl implements Purge
{
-
+ private static final Logger logger = Logger.getLogger(HSQLDB.class);
+
@Override
public void constrain(Connection connection)
throws SQLException
{
- connection.prepareStatement("set referential_integrity TRUE").execute();
+
+ PreparedStatement statement = null;
+ try
+ {
+ statement = connection.prepareStatement("set referential_integrity TRUE");
+ statement.execute();
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle.getMessage(), sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(statement);
+ }
}
@Override
public void relax(Connection connection)
throws SQLException
{
- connection.prepareStatement("set referential_integrity FALSE").execute();
+ PreparedStatement statement = null;
+ try
+ {
+ statement = connection.prepareStatement("set referential_integrity FALSE");
+ statement.execute();
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle.getMessage(), sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(statement);
+ }
+
}
+
+ @Override
+ public void purge(Connection connection)
+ {
+
+ }
+ @Override
+ public void synchronize(Connection connection)
+ {
+
+ }
}
Deleted: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/IntegrityConstraint.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/IntegrityConstraint.java 2009-11-16 12:49:35 UTC (rev 30168)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/IntegrityConstraint.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -1,32 +0,0 @@
- /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jbossts.performance.persistence.vendor;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public interface IntegrityConstraint
-{
- public void relax(Connection connection) throws SQLException;
- public void constrain(Connection connection) throws SQLException;
-}
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/MySQL.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/MySQL.java 2009-11-16 12:49:35 UTC (rev 30168)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/MySQL.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -23,20 +23,61 @@
package org.jboss.jbossts.performance.persistence.vendor;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.SQLException;
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.log4j.Logger;
-public class MySQL implements IntegrityConstraint
+
+public class MySQL extends AbstractVendorControl
{
+ private static final Logger logger = Logger.getLogger(MySQL.class);
@Override
public void constrain(Connection connection) throws SQLException
{
- connection.prepareStatement("SET foreign_key_checks = 1").execute();
+ PreparedStatement statement = null;
+ try
+ {
+ statement = connection.prepareStatement("SET foreign_key_checks = 1");
+ statement.execute();
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle.getMessage(), sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(statement);
+ }
}
@Override
public void relax(Connection connection) throws SQLException
{
- connection.prepareStatement("SET foreign_key_checks = 0").execute();
+ PreparedStatement statement = null;
+ try
+ {
+ statement = connection.prepareStatement("SET foreign_key_checks = 0");
+ statement.execute();
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle.getMessage(), sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(statement);
+ }
}
+ @Override
+ public void purge(Connection connection)
+ {
+
+ }
+ @Override
+ public void synchronize(Connection connection)
+ {
+
+ }
}
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/OracleConstraint.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/OracleConstraint.java 2009-11-16 12:49:35 UTC (rev 30168)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/OracleConstraint.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -33,7 +33,7 @@
import org.apache.commons.dbutils.DbUtils;
import org.apache.log4j.Logger;
-public class OracleConstraint extends AbstractConstraint
+public class OracleConstraint extends AbstractVendorControl
{
private static final Logger logger = Logger.getLogger(OracleConstraint.class);
private Map<String, List<String>> disabled; // keyed by table, listed by constraint
@@ -56,6 +56,7 @@
@Override
public void relax(Connection connection) throws SQLException
{
+
if (null != this.tableNames && !this.tableNames.isEmpty())
{
PreparedStatement enabledConstraintsByTable = connection.prepareStatement("SELECT constraint_name FROM user_constraints WHERE (table_name=?) AND (status='ENABLED') AND (constraint_type='R')");
@@ -140,4 +141,85 @@
DbUtils.closeQuietly(statement);
}
}
+
+ /**
+ * Added the behaviour to this class
+ */
+ @Override
+ public void purge(Connection connection)
+ {
+ PreparedStatement purgeStatement = null;
+ try
+ {
+ purgeStatement = connection.prepareStatement("PURGE user_recyclebin");
+ purgeStatement.execute();
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(purgeStatement);
+ }
+ }
+
+ @Override
+ public void synchronize(Connection connection)
+ {
+ PreparedStatement queryAllSequencesStatement = null;
+ ResultSet allSequencesResultSet = null;
+ List<String> sequenceNames = null;
+ try
+ {
+ queryAllSequencesStatement = connection.prepareStatement("SELECT sequence_name from user_sequences");
+ allSequencesResultSet = queryAllSequencesStatement.executeQuery();
+ sequenceNames = new ArrayList<String>();
+ while (allSequencesResultSet.next())
+ {
+ sequenceNames.add(allSequencesResultSet.getString("sequence_name"));
+ }
+ }
+ catch (SQLException sqle)
+ {
+ logger.error(sqle);
+ }
+ finally
+ {
+ DbUtils.closeQuietly(allSequencesResultSet);
+ DbUtils.closeQuietly(queryAllSequencesStatement);
+ }
+ if (null != sequenceNames && !sequenceNames.isEmpty())
+ {
+ for (String sequenceName : sequenceNames)
+ {
+ initialise(connection, sequenceName);
+ }
+ }
+ }
+ private void initialise(Connection conn, String name)
+ {
+ PreparedStatement alterIncrememntUpStatement = null;
+ PreparedStatement nextvalStatement = null;
+ PreparedStatement alterIncrememntDownStatement = null;
+ try
+ {
+ alterIncrememntUpStatement = conn.prepareStatement("ALTER SEQUENCE "+name+" INCREMENT BY 1000");
+ alterIncrememntUpStatement.execute();
+ nextvalStatement = conn.prepareStatement("SELECT "+name+".nextval FROM dual");
+ nextvalStatement.execute();
+ alterIncrememntDownStatement = conn.prepareStatement("ALTER SEQUENCE "+name+" INCREMENT BY 1");
+ alterIncrememntDownStatement.execute();
+ }
+ catch (Exception e)
+ {
+ // TODO: handle exception
+ }
+ finally
+ {
+ DbUtils.closeQuietly(alterIncrememntUpStatement);
+ DbUtils.closeQuietly(nextvalStatement);
+ DbUtils.closeQuietly(alterIncrememntDownStatement);
+ }
+ }
}
Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Purge.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Purge.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/Purge.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -0,0 +1,31 @@
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jbossts.performance.persistence.vendor;
+
+import java.sql.Connection;
+
+public interface Purge
+{
+
+ public void purge(Connection connection);
+}
Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/SequenceSynchronizer.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/SequenceSynchronizer.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/main/java/org/jboss/jbossts/performance/persistence/vendor/SequenceSynchronizer.java 2009-11-16 12:50:18 UTC (rev 30169)
@@ -0,0 +1,30 @@
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jbossts.performance.persistence.vendor;
+
+import java.sql.Connection;
+
+public interface SequenceSynchronizer
+{
+ public void synchronize(Connection connection);
+}
More information about the jboss-svn-commits
mailing list