Author: tolusha
Date: 2010-12-29 03:29:37 -0500 (Wed, 29 Dec 2010)
New Revision: 3750
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
Log:
EXOJCR-1078: remove locking tables
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
===================================================================
---
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2010-12-29
08:03:14 UTC (rev 3749)
+++
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2010-12-29
08:29:37 UTC (rev 3750)
@@ -49,7 +49,6 @@
import java.net.URL;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
@@ -137,6 +136,7 @@
*/
public static final int DB_DIALECT_PGSQL = DBConstants.DB_DIALECT_PGSQL.hashCode();
+
/**
* {@inheritDoc}
*/
@@ -266,40 +266,43 @@
backupInfoWriter.setValueTableName(scripts[1][0]);
backupInfoWriter.setRefTableName(scripts[2][0]);
- // Lock tables
- ResultSet rs = null;
- try
- {
- DatabaseMetaData metaData = jdbcConn.getMetaData();
- rs = metaData.getTables(null, null, "%", new
String[]{"TABLE"});
- lockStatemnt = jdbcConn.createStatement();
- int dialect = DialectDetecter.detect(metaData).hashCode();
+ // TODO set workspace waiting
- if (dialect == DB_DIALECT_HSQLDB)
- {
- while (rs.next())
- {
- lockStatemnt.execute("SET TABLE " +
rs.getString("TABLE_NAME") + " READONLY TRUE");
- }
- }
- else if (dialect == DB_DIALECT_MYSQL || dialect == DB_DIALECT_MYSQL_UTF8)
- {
- String lock = "";
- while (rs.next())
- {
- lock += rs.getString("TABLE_NAME") + " READ,";
- }
- lockStatemnt.execute("LOCK TABLES " + lock.substring(0,
lock.length() - 1));
- }
- }
- finally
- {
- if (rs != null)
- {
- rs.close();
- }
- }
+ // Lock tables
+ // ResultSet rs = null;
+ // try
+ // {
+ // DatabaseMetaData metaData = jdbcConn.getMetaData();
+ //
+ // rs = metaData.getTables(null, null, "%", new
String[]{"TABLE"});
+ // lockStatemnt = jdbcConn.createStatement();
+ // int dialect = DialectDetecter.detect(metaData).hashCode();
+ //
+ // if (dialect == DB_DIALECT_HSQLDB)
+ // {
+ // while (rs.next())
+ // {
+ // lockStatemnt.execute("SET TABLE " +
rs.getString("TABLE_NAME") + " READONLY TRUE");
+ // }
+ // }
+ // else if (dialect == DB_DIALECT_MYSQL || dialect ==
DB_DIALECT_MYSQL_UTF8)
+ // {
+ // String lock = "";
+ // while (rs.next())
+ // {
+ // lock += rs.getString("TABLE_NAME") + "
READ,";
+ // }
+ // lockStatemnt.execute("LOCK TABLES " +
lock.substring(0, lock.length() - 1));
+ // }
+ // }
+ // finally
+ // {
+ // if (rs != null)
+ // {
+ // rs.close();
+ // }
+ // }
// dump JCR data
for (String script[] : scripts)
@@ -325,6 +328,9 @@
// write backup information
backupInfoWriter.write();
+
+ // TODO set workspace waiting
+
}
catch (RepositoryConfigurationException e)
{
@@ -363,42 +369,42 @@
try
{
// unlock tables
- if (lockStatemnt != null)
- {
- ResultSet rs = null;
- try
- {
- DatabaseMetaData metaData = jdbcConn.getMetaData();
- int dialect = DialectDetecter.detect(metaData).hashCode();
+ // if (lockStatemnt != null)
+ // {
+ // ResultSet rs = null;
+ // try
+ // {
+ // DatabaseMetaData metaData =
jdbcConn.getMetaData();
+ // int dialect =
DialectDetecter.detect(metaData).hashCode();
+ //
+ // if (dialect == DB_DIALECT_HSQLDB)
+ // {
+ // rs = metaData.getTables(null, null,
"%", new String[]{"TABLE"});
+ // while (rs.next())
+ // {
+ // String tableName =
rs.getString("TABLE_NAME");
+ // lockStatemnt.execute("SET TABLE " +
tableName + " READONLY FALSE");
+ // }
+ // }
+ // else
+ // {
+ // lockStatemnt.execute("UNLOCK
TABLES");
+ // }
+ // }
+ // finally
+ // {
+ // if (rs != null)
+ // {
+ // rs.close();
+ // }
+ //
+ // if (lockStatemnt != null)
+ // {
+ // lockStatemnt.close();
+ // }
+ // }
+ // }
- if (dialect == DB_DIALECT_HSQLDB)
- {
- rs = metaData.getTables(null, null, "%", new
String[]{"TABLE"});
- while (rs.next())
- {
- String tableName = rs.getString("TABLE_NAME");
- lockStatemnt.execute("SET TABLE " + tableName +
" READONLY FALSE");
- }
- }
- else
- {
- lockStatemnt.execute("UNLOCK TABLES");
- }
- }
- finally
- {
- if (rs != null)
- {
- rs.close();
- }
-
- if (lockStatemnt != null)
- {
- lockStatemnt.close();
- }
- }
- }
-
jdbcConn.close();
}
catch (SQLException e)
@@ -656,6 +662,7 @@
if (out != null)
{
+ out.flush();
out.closeEntry();
out.close();
}
Show replies by date