[exo-jcr-commits] exo-jcr SVN: r2148 - in jcr/trunk/exo.jcr.component.ext/src: main/java/org/exoplatform/services/jcr/ext/backup/impl and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Mar 26 04:01:56 EDT 2010
Author: areshetnyak
Date: 2010-03-26 04:01:55 -0400 (Fri, 26 Mar 2010)
New Revision: 2148
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-03-26 07:52:01 UTC (rev 2147)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-03-26 08:01:55 UTC (rev 2148)
@@ -97,7 +97,47 @@
writer.flush();
}
+
+ public synchronized void write(RepositoryBackupConfig config, String fullBackupType, String incrementalBackupType)
+ throws XMLStreamException
+ {
+ writer.writeStartElement("repositoy-backup-config");
+ writer.writeStartElement("full-backup-type");
+ writer.writeCharacters(fullBackupType);
+ writer.writeEndElement();
+
+ writer.writeStartElement("incremental-backup-type");
+ writer.writeCharacters(incrementalBackupType);
+ writer.writeEndElement();
+
+ if (config.getBackupDir() != null)
+ {
+ writer.writeStartElement("backup-dir");
+ writer.writeCharacters(config.getBackupDir().getAbsolutePath());
+ writer.writeEndElement();
+ }
+
+ if (config.getRepository() != null)
+ {
+ writer.writeStartElement("repository");
+ writer.writeCharacters(config.getRepository());
+ writer.writeEndElement();
+ }
+
+ writer.writeStartElement("incremental-job-period");
+ writer.writeCharacters(Long.toString(config.getIncrementalJobPeriod()));
+ writer.writeEndElement();
+
+ writer.writeStartElement("incremental-job-number");
+ writer.writeCharacters(Integer.toString(config.getIncrementalJobNumber()));
+ writer.writeEndElement();
+
+ writer.writeEndElement();
+
+ writer.flush();
+ }
+
public synchronized void writeEndLog()
{
try
@@ -132,8 +172,6 @@
public LogReader(File logFile) throws FileNotFoundException, XMLStreamException, FactoryConfigurationError
{
this.logFile = logFile;
- jobEntries = new ArrayList<JobEntryInfo>();
-
reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(logFile));
}
@@ -150,6 +188,9 @@
case StartElement.START_ELEMENT :
String name = reader.getLocalName();
+ if (name.equals("repository-backup-config"))
+ config = readBackupConfig();
+
if (name.equals("system-workspace"))
workspaceSystem = readContent();
@@ -179,16 +220,6 @@
return config;
}
- public Calendar getBeginTime()
- {
- return jobEntries.get(0).getDate();
- }
-
- public Calendar getEndTime()
- {
- return jobEntries.get(jobEntries.size() - 1).getDate();
- }
-
public List<JobEntryInfo> getJobEntryInfoNormalizeList()
{
return jobEntriesNormalize;
@@ -225,7 +256,57 @@
return wsBackupInfo;
}
+
+ private BackupConfig readBackupConfig() throws XMLStreamException
+ {
+ BackupConfig conf = new BackupConfig();
+ boolean endBackupConfig = false;
+
+ while (!endBackupConfig)
+ {
+ int eventCode = reader.next();
+ switch (eventCode)
+ {
+
+ case StartElement.START_ELEMENT :
+ String name = reader.getLocalName();
+
+ if (name.equals("backup-dir"))
+ conf.setBackupDir(new File(readContent()));
+
+ if (name.equals("repository"))
+ conf.setRepository(readContent());
+
+ if (name.equals("workspace"))
+ conf.setWorkspace(readContent());
+
+ if (name.equals("incremental-job-period"))
+ conf.setIncrementalJobPeriod(Long.valueOf(readContent()).longValue());
+
+ if (name.equals("incremental-job-number"))
+ conf.setIncrementalJobNumber(Integer.valueOf(readContent()).intValue());
+
+ if (name.equals("full-backup-type"))
+ fullBackupType = readContent();
+
+ if (name.equals("full-backup-type"))
+ fullBackupType = readContent();
+
+ break;
+
+ case StartElement.END_ELEMENT :
+ String tagName = reader.getLocalName();
+
+ if (tagName.equals("repository-backup-config"))
+ endBackupConfig = true;
+ break;
+ }
+ }
+
+ return conf;
+ }
+
private String readContent() throws XMLStreamException
{
String content = null;
@@ -310,66 +391,6 @@
return type;
}
-
- public BackupConfig readBackupConfig() throws XMLStreamException
- {
- BackupConfig conf = new BackupConfig();
-
- boolean endBackupConfig = false;
-
- while (!endBackupConfig)
- {
- int eventCode = reader.next();
- switch (eventCode)
- {
-
- case StartElement.START_ELEMENT :
- String name = reader.getLocalName();
-
- if (name.equals("backup-dir"))
- conf.setBackupDir(new File(readContent()));
-
- if (name.equals("repository"))
- conf.setRepository(readContent());
-
- if (name.equals("incremental-job-period"))
- conf.setIncrementalJobPeriod(Long.valueOf(readContent()).longValue());
-
- if (name.equals("incremental-job-number"))
- conf.setIncrementalJobNumber(Integer.valueOf(readContent()).intValue());
-
- break;
-
- case StartElement.END_ELEMENT :
- String tagName = reader.getLocalName();
-
- if (tagName.equals("repository-backup-cain-log"))
- endBackupConfig = true;
- break;
- }
- }
-
- return conf;
- }
-
- public void jobEntrysNormalize()
- {
- jobEntriesNormalize = new ArrayList<JobEntryInfo>();
-
- for (int i = 0; i < jobEntries.size(); i++)
- {
- JobEntryInfo entryInfo = jobEntries.get(i);
-
- boolean alreadyExist = false;
-
- for (int j = 0; j < jobEntriesNormalize.size(); j++)
- if (jobEntriesNormalize.get(j).getURL().toString().equals(entryInfo.getURL().toString()))
- alreadyExist = true;
-
- if (!alreadyExist)
- jobEntriesNormalize.add(entryInfo);
- }
- }
}
protected static Log logger = ExoLogger.getLogger("ext.BackupChainLog");
@@ -386,8 +407,6 @@
private RepositoryBackupConfig config;
- private List<JobEntryInfo> jobEntries;
-
private String backupId;
private Calendar startedTime;
@@ -400,6 +419,10 @@
private String workspaceSystem;
+ private String fullBackupType;
+
+ private String increnetalBackupType;
+
/**
* @param logDirectory
* @param config
@@ -409,8 +432,14 @@
* @param startTime
* @throws BackupOperationException
*/
- public RepositoryBackupChainLog(File logDirectory, RepositoryBackupConfig config, String systemWorkspace,
- List<String> wsLogFilePathList, String backupId, Calendar startTime) throws BackupOperationException
+ public RepositoryBackupChainLog(File logDirectory,
+ RepositoryBackupConfig config,
+ String fullBackupType,
+ String incrementalBackupType,
+ String systemWorkspace,
+ List<String> wsLogFilePathList,
+ String backupId,
+ Calendar startTime) throws BackupOperationException
{
try
{
@@ -420,9 +449,11 @@
this.backupId = backupId;
this.config = config;
this.startedTime = Calendar.getInstance();
- this.jobEntries = new ArrayList<JobEntryInfo>();
+ this.fullBackupType = fullBackupType;
+ this.increnetalBackupType = incrementalBackupType;
logWriter = new LogWriter(log);
+ logWriter.write(config, fullBackupType, incrementalBackupType);
logWriter.writeSystemWorkspaceName(systemWorkspace);
logWriter.writeBackupsPath(wsLogFilePathList);
@@ -456,21 +487,6 @@
{
logReader = new LogReader(log);
logReader.readLogFile();
- logReader.jobEntrysNormalize();
-
- this.config = logReader.getBackupConfig();
- this.startedTime = logReader.getBeginTime();
- this.finishedTime = logReader.getEndTime();
- this.jobEntries = logReader.getJobEntryInfoNormalizeList();
-
- for (JobEntryInfo info : jobEntries)
- {
- if (info.getType() == BackupJob.INCREMENTAL)
- {
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- break;
- }
- }
}
catch (FileNotFoundException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-03-26 07:52:01 UTC (rev 2147)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-03-26 08:01:55 UTC (rev 2148)
@@ -96,7 +96,14 @@
workspaceBackups.add(bchain);
}
- this.repositoryChainLog = new RepositoryBackupChainLog(logDirectory, this.config, repository.getConfiguration().getSystemWorkspaceName(), wsLogFilePathList, this.repositoryBackupId, startTime);
+ this.repositoryChainLog = new RepositoryBackupChainLog(logDirectory,
+ this.config,
+ fullBackupType,
+ incrementalBackupType,
+ repository.getConfiguration().getSystemWorkspaceName(),
+ wsLogFilePathList,
+ this.repositoryBackupId,
+ startTime);
state = INITIALIZED;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-03-26 07:52:01 UTC (rev 2147)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-03-26 08:01:55 UTC (rev 2148)
@@ -844,7 +844,7 @@
RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_2";
- RepositoryEntry newRepositoryEntry = makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
+ RepositoryEntry newRepositoryEntry = makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_2", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -926,7 +926,7 @@
RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_3";
- RepositoryEntry newRepositoryEntry = makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
+ RepositoryEntry newRepositoryEntry = makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_3", null);
// create workspace mappingS
Map<String, String> workspaceMapping = new HashedMap();
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-03-26 07:52:01 UTC (rev 2147)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-03-26 08:01:55 UTC (rev 2148)
@@ -1912,6 +1912,60 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr_to_repository_restore_2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr_to_repository_restore_2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr_to_repository_restore_3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr_to_repository_restore_3" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
</external-component-plugins>
</configuration>
More information about the exo-jcr-commits
mailing list