Author: andrew.plotnikov
Date: 2012-01-19 09:28:39 -0500 (Thu, 19 Jan 2012)
New Revision: 5485
Removed:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupScheduler.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupSchedulerException.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupScheduler.java
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/RepositoryService.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/JCRAddSystemNodeTest.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestNodeTypeRegister.java
jcr/branches/1.15.x/exo.jcr.component.ext/pom.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupRestart.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
Log:
EXOJCR-1723: Removed deprecated methods and classes
Modified: jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-01-19 11:37:18 UTC
(rev 5484)
+++ jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-01-19 14:28:39 UTC
(rev 5485)
@@ -7,4 +7,9 @@
* Index JCR_XITEM_PARENT_NAME removed (JCR_IDX_MITEM_PN - for DB2)
* Index JCR_IDX_XITEM_PARENT_N_ORDER_NUM from MySQL scripts.
* We will have RepositoryException when use Session or Node after session.logout
-* Removed SystemIdentity class
\ No newline at end of file
+* Removed SystemIdentity class
+* Removed BackupScheduler class
+* Removed TextFilter interfaces
+* Not supported fields autoInitializedRootNt and autoInitPermissions
+* Removed ValueStorageCleanHelper class
+* Removed BackupSchedulerException class
\ No newline at end of file
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/RepositoryService.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/RepositoryService.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/RepositoryService.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -45,14 +45,6 @@
ManageableRepository getDefaultRepository() throws RepositoryException,
RepositoryConfigurationException;
/**
- * Get default repository.
- *
- * @return ManagableRepository
- * @deprecated use getDefaultRepository() instead
- */
- ManageableRepository getRepository() throws RepositoryException,
RepositoryConfigurationException;
-
- /**
* Get repository by name.
*
* @param name
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -205,15 +205,6 @@
return getRepository(config.getDefaultRepositoryName());
}
- /**
- * @deprecated use getDefaultRepository() instead
- */
- @Deprecated
- public ManageableRepository getRepository() throws RepositoryException
- {
- return getDefaultRepository();
- }
-
// ------------------- Startable ----------------------------
public ManageableRepository getRepository(String name) throws RepositoryException
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -52,7 +52,7 @@
{
RepositoryService service =
(RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
assertNotNull(service);
- RepositoryImpl defRep = (RepositoryImpl)service.getRepository();
+ RepositoryImpl defRep = (RepositoryImpl)service.getDefaultRepository();
assertNotNull(defRep);
String sysWs = defRep.getSystemWorkspaceName();
assertFalse("Sys ws should not be initialized for this test!!",
defRep.isWorkspaceInitialized(sysWs)); // Default Namespaces
@@ -69,7 +69,7 @@
{
RepositoryService service =
(RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
- RepositoryImpl defRep = (RepositoryImpl)service.getRepository();
+ RepositoryImpl defRep = (RepositoryImpl)service.getDefaultRepository();
String sysWs = defRep.getSystemWorkspaceName();
assertFalse("Sys ws should not be initialized for this test!!",
defRep.isWorkspaceInitialized(sysWs));
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/JCRAddSystemNodeTest.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/JCRAddSystemNodeTest.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/JCRAddSystemNodeTest.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -56,7 +56,7 @@
jcrSystem.addNode("Node1", "nt:unstructured");
jcrSystem.save();
session2.save();
- session2 =
repositoryService.getRepository().getSystemSession(repository.getSystemWorkspaceName());
+ session2 =
repositoryService.getDefaultRepository().getSystemSession(repository.getSystemWorkspaceName());
assertTrue(session2.getRootNode().getNode("jcr:system").hasNodes());
Node node1 = (Node)session2.getItem("/jcr:system/Node1");
jcrSystem.save();
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestNodeTypeRegister.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestNodeTypeRegister.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestNodeTypeRegister.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -104,7 +104,7 @@
nodeTypeValue.setDeclaredSupertypeNames(superTypeNames);
nodeTypeValue.setPrimaryItemName("");
- ExtendedNodeTypeManager extNodeTypeManager =
repositoryService.getRepository().getNodeTypeManager();
+ ExtendedNodeTypeManager extNodeTypeManager =
repositoryService.getDefaultRepository().getNodeTypeManager();
try
{
nodeTypeManager.getNodeType("exo:testNodeType2");
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/pom.xml 2012-01-19 11:37:18 UTC (rev 5484)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/pom.xml 2012-01-19 14:28:39 UTC (rev 5485)
@@ -193,8 +193,7 @@
<excludes>
<exclude>**/BaseStandaloneTest.java</exclude>
<exclude>**/backup/AbstractBackupTestCase.java</exclude>
- <exclude>**/backup/BaseRDBMSBackupTest.java</exclude>
- <exclude>**/backup/TestBackupScheduler.java</exclude>
+ <exclude>**/backup/BaseRDBMSBackupTest.java</exclude>
<exclude>**/backup/TestBackupRestart.java</exclude>
<exclude>**/replication/**</exclude>
<exclude>**/repository/creation/cluster/**</exclude>
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -22,7 +22,6 @@
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.ext.backup.impl.BackupMessage;
-import org.exoplatform.services.jcr.ext.backup.impl.BackupScheduler;
import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
@@ -197,14 +196,6 @@
RepositoryConfigurationException;
/**
- * Getting the scheduler.
- *
- * @return BackupScheduler
- * return the BackupScheduler
- */
- BackupScheduler getScheduler();
-
- /**
* Getting the backup messages.
*
* @return BackupMessage[]
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -215,8 +215,6 @@
private final RegistryService registryService;
- private BackupScheduler scheduler;
-
private final BackupMessagesLog messages;
private final MessagesListener messagesListener;
@@ -254,7 +252,6 @@
if (job != null)
{
-
switch (job.getType())
{
case BackupJob.FULL : {
@@ -314,7 +311,6 @@
public String printStackTrace(Throwable error)
{
-
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(out);
error.printStackTrace(writer);
@@ -517,8 +513,6 @@
messages = new BackupMessagesLog(MESSAGES_MAXSIZE);
- scheduler = new BackupScheduler(this, messages);
-
this.restoreJobs = new ArrayList<JobWorkspaceRestore>();
this.restoreRepositoryJobs = new ArrayList<JobRepositoryRestore>();
@@ -647,7 +641,6 @@
throws BackupOperationException, RepositoryException,
RepositoryConfigurationException,
BackupConfigurationException
{
-
List<JobEntryInfo> list = log.getJobEntryInfos();
BackupConfig config = log.getBackupConfig();
@@ -681,7 +674,6 @@
// ws should not exists.
if (!workspaceAlreadyExist(reposytoryName, workspaceName))
{
-
for (int i = 0; i < list.size(); i++)
{
if (i == 0)
@@ -754,7 +746,6 @@
public BackupChain startBackup(BackupConfig config) throws BackupOperationException,
BackupConfigurationException,
RepositoryException, RepositoryConfigurationException
{
-
return startBackup(config, null);
}
@@ -836,7 +827,6 @@
*/
public void start()
{
-
//remove if exists all old jcrrestorewi*.tmp files.
File[] files = PrivilegedFileHelper.listFiles(tempDir, new JcrRestoreWiFilter());
for (int i = 0; i < files.length; i++)
@@ -873,36 +863,6 @@
{
readParamsFromFile();
}
-
- // scan for task files
- File[] tasks = PrivilegedFileHelper.listFiles(this.logsDirectory, new
TaskFilter());
- for (File task : tasks)
- {
- try
- {
- scheduler.restore(task);
- }
- catch (BackupSchedulerException e)
- {
- log.error("Can't restore backup scheduler task from file " +
PrivilegedFileHelper.getAbsolutePath(task), e);
- }
- catch (BackupOperationException e)
- {
- log.error("Can't restore backup scheduler task from file " +
PrivilegedFileHelper.getAbsolutePath(task), e);
- }
- catch (BackupConfigurationException e)
- {
- log.error("Can't restore backup scheduler task from file " +
PrivilegedFileHelper.getAbsolutePath(task), e);
- }
- catch (RepositoryException e)
- {
- log.error("Can't restore backup scheduler task from file " +
PrivilegedFileHelper.getAbsolutePath(task), e);
- }
- catch (RepositoryConfigurationException e)
- {
- log.error("Can't restore backup scheduler task from file " +
PrivilegedFileHelper.getAbsolutePath(task), e);
- }
- }
}
/**
@@ -912,7 +872,6 @@
{
workspaceBackupStopper.close();
repositoryBackupStopper.close();
- scheduler.cancelTimer();
// 1. stop current backup chains
// for (Iterator iterator = currentBackups.iterator(); iterator.hasNext();) {
@@ -924,17 +883,6 @@
// scheduler = null;
}
- @Deprecated
- private void fullRestore(String pathBackupFile, String repositoryName, String
workspaceName,
- WorkspaceEntry workspaceEntry) throws FileNotFoundException, IOException,
RepositoryException,
- RepositoryConfigurationException
- {
-
- RepositoryImpl defRep = (RepositoryImpl)repoService.getRepository(repositoryName);
-
- defRep.importWorkspace(workspaceEntry.getName(),
PrivilegedFileHelper.fileInputStream(pathBackupFile));
- }
-
private void fullRestoreOverInitializer(String pathBackupFile, String repositoryName,
WorkspaceEntry workspaceEntry,
String fBackupType) throws FileNotFoundException, IOException,
RepositoryException,
RepositoryConfigurationException, ClassNotFoundException
@@ -1193,14 +1141,6 @@
}
/**
- * {@inheritDoc}
- */
- public BackupScheduler getScheduler()
- {
- return scheduler;
- }
-
- /**
* getLogsDirectory.
*
* @return File
@@ -2072,5 +2012,4 @@
}
}
-
}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupScheduler.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupScheduler.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupScheduler.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -1,1146 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.jcr.ext.backup.impl;
-
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.ext.backup.BackupChain;
-import org.exoplatform.services.jcr.ext.backup.BackupConfig;
-import org.exoplatform.services.jcr.ext.backup.BackupConfigurationException;
-import org.exoplatform.services.jcr.ext.backup.BackupJobListener;
-import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.net.MalformedURLException;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jcr.RepositoryException;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.stream.events.StartElement;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id: BackupScheduler.java 760 2008-02-07 15:08:07Z pnedonosko $
- */
-public class BackupScheduler
-{
-
- public enum TaskStatus {
- VIRGIN, EXECUTED, FINISHED
- };
-
- protected Log log =
ExoLogger.getLogger("exo.jcr.component.ext.BackupScheduler");
-
- private final BackupManagerImpl backup;
-
- private final BackupMessagesLog messages;
-
- private final Timer timer;
-
- private final List<WeakReference<SchedulerTask>> tasks = new
ArrayList<WeakReference<SchedulerTask>>();
-
- private class TaskConfig
- {
-
- private final DateFormat datef = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
-
- BackupConfig backupConfig;
-
- Date startTime;
-
- Date stopTime;
-
- long chainPeriod;
-
- long incrPeriod;
-
- TaskConfig(BackupConfig backupConfig, Date startTime, Date stopTime, long
chainPeriod, long incrPeriod)
- {
- this.backupConfig = backupConfig;
- this.startTime = startTime;
- this.stopTime = stopTime;
- this.chainPeriod = chainPeriod;
- this.incrPeriod = incrPeriod;
- }
-
- TaskConfig(File taskFile) throws IOException, XMLStreamException,
FactoryConfigurationError, ParseException
- {
- read(taskFile);
- }
-
- Date parseDate(String dateString) throws ParseException
- {
- if ("null".equals(dateString))
- return null;
- else
- return datef.parse(dateString);
- }
-
- String formatDate(Date date)
- {
- return date == null ? "null" : datef.format(date);
- }
-
- void save(File taskFile) throws IOException, XMLStreamException,
FactoryConfigurationError
- {
- TaskConfigWriter w = new TaskConfigWriter(taskFile);
- w.writeBackupConfig(backupConfig);
- w.writeSchedulerConfig(startTime, stopTime, chainPeriod, incrPeriod);
- w.writeEndLog();
- }
-
- void read(File taskFile) throws IOException, XMLStreamException,
FactoryConfigurationError, ParseException
- {
- TaskConfigReader r = new TaskConfigReader(taskFile);
- r.readLogFile();
-
- // done
- this.backupConfig = r.backupConfig;
- this.startTime = r.startTime;
- this.stopTime = r.stopTime;
- this.chainPeriod = r.chainPeriod;
- this.incrPeriod = r.incrPeriod;
- }
-
- @Deprecated
- void read_old(File taskFile) throws IOException, ParseException,
BackupSchedulerException
- {
- char[] cbuf = new char[1024];
- StringBuilder content = new StringBuilder();
-
- // read file
- FileReader fr = new FileReader(taskFile);
- int r = 0;
- while ((r = fr.read(cbuf)) >= 0)
- {
- content.append(cbuf, 0, r);
- };
- fr.close();
-
- // parse file
- String[] fc = content.toString().trim().split("\n");
- if (fc.length > 1)
- {
- File _backupLog = null;
- Date _startTime = null, _stopTime = null;
- long _chainPeriod = -1, _incrPeriod = -1;
-
- String[] terms = fc[fc.length - 1].split(",");
- for (int i = 0; i < terms.length; i++)
- {
- if (i == 0)
- {
- _backupLog = new File(terms[i]);
- }
- else if (i == 1)
- {
- _startTime = datef.parse(terms[i]);
- }
- else if (i == 2)
- {
- String t = terms[i];
- if (!"null".equals(t))
- _stopTime = datef.parse(t);
- }
- else if (i == 3)
- {
- _chainPeriod = Long.parseLong(terms[i]);
- }
- else if (i == 4)
- {
- _incrPeriod = Long.parseLong(terms[i]);
- }
- }
-
- if (PrivilegedFileHelper.exists(_backupLog))
- {
- // this.backupLog = _backupLog;
- this.startTime = _startTime;
- this.stopTime = _stopTime;
- this.chainPeriod = _chainPeriod;
- this.incrPeriod = _incrPeriod;
- }
- else
- throw new BackupSchedulerException(
- "Scheduler task skipped due to the error. Backup log file not
exists "
- + PrivilegedFileHelper.getAbsolutePath(_backupLog) + ". Task
file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile));
- }
- else
- throw new BackupSchedulerException("Scheduler task skipped due to bad
configured task file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile) + ". File
doesn't contains configuration line.");
- }
-
- @Deprecated
- File save_old(File taskFile) throws IOException
- {
- // File taskFile = new File(PrivilegedFileHelper.getAbsolutePath(backupLog) +
".task");
- if (!PrivilegedFileHelper.exists(taskFile))
- {
- FileWriter fw = new FileWriter(taskFile);
- fw.append("LogPath,StartTime,StopTime,ChainPeriod,IncrPeriod\n");
- fw.append(PrivilegedFileHelper.getAbsolutePath(taskFile) + "," +
datef.format(startTime) + ","
- + (stopTime != null ? datef.format(stopTime) : "null") +
"," + chainPeriod + "," + incrPeriod);
- fw.close();
- return taskFile;
- }
-
- return null;
- }
-
- class TaskConfigWriter
- {
-
- Log logger =
ExoLogger.getLogger("exo.jcr.component.ext.TaskConfigWriter");
-
- final FileOutputStream logFile;
-
- final XMLStreamWriter writer;
-
- TaskConfigWriter(final File logFile) throws FileNotFoundException,
XMLStreamException,
- FactoryConfigurationError
- {
- this.logFile = PrivilegedFileHelper.fileOutputStream(logFile);
-
- try
- {
- writer = SecurityHelper.doPrivilegedExceptionAction(new
PrivilegedExceptionAction<XMLStreamWriter>()
- {
- public XMLStreamWriter run() throws Exception
- {
- return XMLOutputFactory.newInstance().createXMLStreamWriter(new
FileOutputStream(logFile));
- }
- });
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof FileNotFoundException)
- {
- throw (FileNotFoundException)cause;
- }
- else if (cause instanceof XMLStreamException)
- {
- throw (XMLStreamException)cause;
- }
- else if (cause instanceof FactoryConfigurationError)
- {
- throw (FactoryConfigurationError)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- };
-
- writer.writeStartDocument();
- writer.writeStartElement("backup-task-config");
- writer.flush();
- }
-
- void writeBackupConfig(BackupConfig config) throws XMLStreamException
- {
- writer.writeStartElement("backup-config");
-
- writer.writeStartElement("full-backup-type");
- writer.writeCharacters(backup.getFullBackupType());
- writer.writeEndElement();
-
- writer.writeStartElement("incremental-backup-type");
- writer.writeCharacters(backup.getIncrementalBackupType());
- writer.writeEndElement();
-
- if (config.getBackupDir() != null)
- {
- writer.writeStartElement("backup-dir");
-
writer.writeCharacters(PrivilegedFileHelper.getAbsolutePath(config.getBackupDir()));
- writer.writeEndElement();
- }
-
- if (config.getRepository() != null)
- {
- writer.writeStartElement("repository");
- writer.writeCharacters(config.getRepository());
- writer.writeEndElement();
- }
-
- if (config.getWorkspace() != null)
- {
- writer.writeStartElement("workspace");
- writer.writeCharacters(config.getWorkspace());
- writer.writeEndElement();
- }
-
- writer.writeStartElement("incremental-job-period");
- writer.writeCharacters(Long.toString(config.getIncrementalJobPeriod()));
- writer.writeEndElement();
-
- writer.writeEndElement();
-
- writer.flush();
- }
-
- void writeSchedulerConfig(Date startTime, Date stopTime, long chainPeriod, long
incrPeriod)
- throws XMLStreamException
- {
- writer.writeStartElement("scheduler-config");
-
- writer.writeStartElement("start-time");
- writer.writeCharacters(formatDate(startTime));
- writer.writeEndElement();
-
- writer.writeStartElement("stop-time");
- writer.writeCharacters(formatDate(stopTime));
- writer.writeEndElement();
-
- writer.writeStartElement("chain-period");
- writer.writeCharacters(String.valueOf(chainPeriod));
- writer.writeEndElement();
-
- writer.writeStartElement("incr-period");
- writer.writeCharacters(String.valueOf(incrPeriod));
- writer.writeEndElement();
-
- writer.writeEndElement();
-
- writer.flush();
- }
-
- void writeEndLog() throws XMLStreamException, IOException
- {
- writer.writeEndElement();
- writer.writeEndDocument();
- writer.flush();
-
- logFile.close();
- }
- }
-
- class TaskConfigReader
- {
- Log logger =
ExoLogger.getLogger("exo.jcr.component.ext.TaskConfigReader");
-
- final FileInputStream logFile;
-
- final XMLStreamReader reader;
-
- BackupConfig backupConfig;
-
- Date startTime;
-
- Date stopTime;
-
- long chainPeriod;
-
- long incrPeriod;
-
- TaskConfigReader(File logFile) throws FileNotFoundException, XMLStreamException,
FactoryConfigurationError
- {
- this.logFile = PrivilegedFileHelper.fileInputStream(logFile);
-
- this.reader =
XMLInputFactory.newInstance().createXMLStreamReader(this.logFile);
- }
-
- void readLogFile() throws XMLStreamException, ParseException, IOException
- {
- try
- {
- while (true)
- {
- int eventCode = reader.next();
- switch (eventCode)
- {
-
- case StartElement.START_ELEMENT :
- String name = reader.getLocalName();
-
- if (name.equals("backup-config"))
- readBackupConfig();
-
- if (name.equals("scheduler-config"))
- readTaskConfig();
-
- break;
-
- case StartElement.END_DOCUMENT :
- return;
- }
- }
- }
- finally
- {
- logFile.close();
- }
- }
-
- private void readTaskConfig() throws XMLStreamException, MalformedURLException,
ParseException
- {
- boolean endJobEntryInfo = false;
-
- while (!endJobEntryInfo)
- {
- int eventCode = reader.next();
- switch (eventCode)
- {
-
- case StartElement.START_ELEMENT :
- String name = reader.getLocalName();
-
- if (name.equals("start-time"))
- startTime = parseDate(readContent());
-
- if (name.equals("stop-time"))
- stopTime = parseDate(readContent());
-
- if (name.equals("chain-period"))
- chainPeriod = Long.valueOf(readContent()).longValue();
-
- if (name.equals("incr-period"))
- incrPeriod = Long.valueOf(readContent()).longValue();
-
- break;
-
- case StartElement.END_ELEMENT :
- String tagName = reader.getLocalName();
-
- if (tagName.equals("scheduler-config"))
- endJobEntryInfo = true;
- break;
- }
- }
- }
-
- private void 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()));
-
- break;
-
- case StartElement.END_ELEMENT :
- String tagName = reader.getLocalName();
-
- if (tagName.equals("backup-config"))
- endBackupConfig = true;
- break;
- }
- }
-
- backupConfig = conf;
- }
-
- // Read CHARACTERS
- private String readContent() throws XMLStreamException
- {
- String content = null;
-
- int eventCode = reader.next();
-
- if (eventCode == StartElement.CHARACTERS)
- content = reader.getText();
-
- return content;
- }
- }
- }
-
- private class TaskThread extends Thread
- {
- private final CountDownLatch latch = new CountDownLatch(1);
-
- public TaskThread(String name)
- {
- super(name);
- }
-
- void markReady()
- {
- latch.countDown();
- }
-
- void await() throws InterruptedException
- {
- latch.await();
- }
- }
-
- class CleanupTasksListTask extends TimerTask
- {
-
- static final int PERIOD = 60000 * 30; // 30 min
-
- @Override
- public void run()
- {
- // pack tasks list if an empty references found
- synchronized (tasks)
- {
- for (Iterator<WeakReference<SchedulerTask>> ti =
tasks.iterator(); ti.hasNext();)
- {
- if (ti.next().get() == null)
- // remove reference
- ti.remove();
- }
- }
- }
- }
-
- private abstract class SchedulerTask extends TimerTask
- {
-
- protected final BackupConfig config;
-
- protected BackupChain chain;
-
- protected TaskStatus status = TaskStatus.VIRGIN;
-
- protected final BackupJobListener listener;
-
- SchedulerTask(BackupConfig config, BackupJobListener listener)
- {
- this.config = config;
- this.listener = listener;
- }
-
- @Override
- public String toString()
- {
- return super.toString() + "-" + getChainName();
- }
-
- public String getChainName()
- {
- return config.getRepository() + "@" + config.getWorkspace();
- }
-
- public BackupChain getChain()
- {
- return chain;
- }
-
- protected TaskThread stop()
- {
- TaskThread stopper = new TaskThread("BackupScheduler_Task_" +
getChainName() + "-stop")
- {
-
- @Override
- public void run()
- {
- try
- {
- synchronized (config)
- {
- backup.stopBackup(chain);
- if (log.isDebugEnabled())
- log.debug("Chain stopped " + chain.getLogFilePath());
- }
- }
- finally
- {
- markReady();
- }
- }
- };
- stopper.start();
-
- return stopper;
- }
-
- protected TaskThread start()
- {
- TaskThread starter = new TaskThread("BackupScheduler_Task_" +
getChainName() + "-start")
- {
-
- @Override
- public void run()
- {
- try
- {
- synchronized (config)
- {
- chain = backup.startBackup(config, listener);
- if (log.isDebugEnabled())
- log.debug("Chain satarted " + chain.getLogFilePath());
- }
- }
- catch (BackupOperationException e)
- {
- postError(getChainName() + " start", e);
- }
- catch (BackupConfigurationException e)
- {
- postError(getChainName() + " start", e);
- }
- catch (RepositoryException e)
- {
- postError(getChainName() + " start", e);
- }
- catch (RepositoryConfigurationException e)
- {
- postError(getChainName() + " start", e);
- }
- finally
- {
- markReady();
- }
- }
- };
- starter.start();
-
- return starter;
- }
-
- protected void postError(String message, Throwable e)
- {
- messages.addError(message, e);
- log.error(message, e);
- if (listener != null)
- listener.onError(null, message, e);
- }
-
- /**
- * Backup task done, i.e. stopped and unscheduled
- */
- protected TaskThread done()
- {
- TaskThread done = new TaskThread("BackupScheduler_Task_" +
getChainName() + "-done")
- {
- @Override
- public void run()
- {
- try
- {
- synchronized (config)
- {
- // cancel timer
- cancel();
-
- // stop the backup chain
- backup.stopBackup(chain);
-
- // remove task file config
- removeTaskConfig();
- if (log.isDebugEnabled())
- log.debug("Task done (stopped and scheduler canceled)
"
- + (chain != null ? chain.getLogFilePath() : "[not
started]"));
- }
- }
- finally
- {
- markReady();
- }
- }
- };
- done.start();
-
- return done;
- }
-
- protected void removeTaskConfig()
- {
- // remove task file config
- File taskFile =
- new File(PrivilegedFileHelper.getAbsolutePath(backup.getLogsDirectory()) +
File.separator
- + config.getRepository() + "-" + config.getWorkspace() +
".task");
- if (PrivilegedFileHelper.exists(taskFile))
- {
- PrivilegedFileHelper.delete(taskFile);
- if (log.isDebugEnabled())
- log.debug("Remove scheduler task " +
PrivilegedFileHelper.getAbsolutePath(taskFile));
- }
- }
-
- @Override
- public boolean cancel()
- {
- status = TaskStatus.FINISHED;
- if (log.isDebugEnabled())
- log.debug("Task scheduling canceled " + (chain != null ?
chain.getLogFilePath() : "[not started]"));
- return super.cancel();
- }
- }
-
- // impl of p.3,4
- private class PeriodTask extends SchedulerTask
- {
-
- PeriodTask(BackupConfig config, BackupJobListener listener)
- {
- super(config, listener);
- }
-
- @Override
- public void run()
- {
- if (status == TaskStatus.VIRGIN)
- {
- // start
- start();
- status = TaskStatus.EXECUTED;
- }
- else if (status == TaskStatus.EXECUTED)
- {
- // stop backup and cancel scheduling
- done();
- }
- else
- {
- // do nothing or warn (shouldn't occurs)
- log.warn("Chain already task finished " + getChainName() + ",
" + this);
- }
- }
- }
-
- // impl of p.5,6
- // &
- // impl of p7,8 (stopTime == null)
- private class PeriodicTask extends SchedulerTask
- {
-
- private final Date stopTime;
-
- PeriodicTask(BackupConfig config, Date stopTime, BackupJobListener listener)
- {
- super(config, listener);
- this.stopTime = stopTime;
- }
-
- @Override
- public void run()
- {
- if (chain != null && chain.isFinished())
- {
- // cancel scheduling
- cancel();
- // remove task file config
- removeTaskConfig();
- }
- else if (stopTime != null && new Date().after(stopTime))
- {
- // stop backup and cancel scheduling
- done();
- }
- else if (status == TaskStatus.VIRGIN)
- {
- // start
- start();
- status = TaskStatus.EXECUTED;
- }
- else if (status == TaskStatus.EXECUTED)
- {
- // stop current
- try
- {
- stop().await(); // wait if stop finished
- }
- catch (InterruptedException e)
- {
- postError("Can't stop task for periodic rotation ", e);
- }
-
- // start next
- start();
- }
- else
- {
- // do nothing or warn (shouldn't occurs)
- log.warn("Chain already task finished " + getChainName() + ",
" + this);
- }
- }
- }
-
- // impl of p.1,2
- private class RunOnceTask extends SchedulerTask
- {
-
- RunOnceTask(BackupConfig config, BackupJobListener listener)
- {
- super(config, listener);
- }
-
- @Override
- public void run()
- {
- // start
- start();
- // remove task file config
- removeTaskConfig();
- }
- }
-
- BackupScheduler(BackupManagerImpl backup, BackupMessagesLog messages)
- {
- this.backup = backup;
- this.timer =
- new Timer("BackupScheduler_Timer_" + new
SimpleDateFormat("yyyyMMdd.HHmmss.SSS").format(new Date()), true);
-
- // tasks list cleanup task
- this.timer.schedule(new CleanupTasksListTask(), CleanupTasksListTask.PERIOD,
CleanupTasksListTask.PERIOD);
-
- this.messages = messages;
-
- // don't ask timer to cancel tasks
- // registerShutdownHook();
- }
-
- public BackupMessage[] getErrors()
- {
- return messages.getMessages();
- }
-
- /**
- * Restore scheduler after system shutdown etc. Called from manager at start.
- *
- * Should restore the scheduler tasks if start and stop time are correct and will be
occured in
- * future. Or should restore and to continue the tasks if start time reached but stop
time in
- * future or periodic scheduling enabled for the task (including incremental
configuration too).
- *
- * @param taskFile
- * @throws ParseException
- * @throws BackupSchedulerException
- * @throws BackupOperationException
- * @throws RepositoryConfigurationException
- * @throws RepositoryException
- * @throws BackupConfigurationException
- * @throws IOException
- */
- void restore(final File taskFile) throws BackupSchedulerException,
BackupOperationException,
- BackupConfigurationException, RepositoryException,
RepositoryConfigurationException
- {
- try
- {
- TaskConfig tconf = new TaskConfig(taskFile);
-
- // check if the task is not expired
- final Date now = new Date();
- // by start time and periodic parameters
- if ((tconf.stopTime != null && tconf.stopTime.after(now)) ||
tconf.chainPeriod > 0 || tconf.incrPeriod > 0)
- {
-
- // by stop time
- // Restore without scheduler now. Add task search capabilities to the
scheduler and add
- // listener to a task
- schedule(tconf.backupConfig, tconf.startTime, tconf.stopTime,
tconf.chainPeriod, tconf.incrPeriod, null);
- } // else - the start time in past and no periodic configuration found
-
- }
- catch (IOException e)
- {
- throw new BackupSchedulerException("Can't restore scheduler from task
file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile), e);
- }
- catch (ParseException e)
- {
- throw new BackupSchedulerException("Can't restore scheduler from task
file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile), e);
- }
- catch (XMLStreamException e)
- {
- throw new BackupSchedulerException("Can't restore scheduler from task
file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile), e);
- }
- catch (FactoryConfigurationError e)
- {
- throw new BackupSchedulerException("Can't restore scheduler from task
file "
- + PrivilegedFileHelper.getAbsolutePath(taskFile), e);
- }
- }
-
- /**
- * Schedule backup task with given configuration and scheduler parameters. The
behaviour of a task
- * vary depending on scheduler parameters. If specified
- * <ul>
- * <li>1. startTime only - run once forever</li>
- * <li>2. startTime + incrementalPeriod - run once forever (with incremental
backup)</li>
- * <li>3. startTime, endTime - run during given period</li>
- * <li>4. startTime, endTime + incrementalPeriod - run during given period (with
incremental
- * backup)</li>
- * <li>5. startTime, endTime, chainPeriod - run periodic during given
period</li>
- * <li>6. startTime, endTime, chainPeriod + incrementalPeriod - run periodic
during given period
- * (with incremental backup)</li>
- * <li>7. startTime, chainPeriod - run periodic forever</li>
- * <li>8. startTime, chainPeriod + incrementalPeriod - run periodic forever
(with incremental
- * backup)</li>
- * </ul>
- *
- * @param config
- * @param startTime
- * - task start time
- * @param stopTime
- * - task stop time, may be null i.e. the task will be executed forever
- * @param chainPeriod
- * - task chain period, means periodic execution of the configured backup
chain
- * @param incrementalPeriod
- * - incr period
- * @param listener
- * - listener for each job produced by an each backup chain
- * @return
- * @throws BackupSchedulerException
- */
- public void schedule(BackupConfig config, Date startTime, Date stopTime, long
chainPeriod, long incrementalPeriod)
- throws BackupSchedulerException
- {
- schedule(config, startTime, stopTime, chainPeriod, incrementalPeriod, null);
- }
-
- /**
- * Schedule backup task with given configuration and scheduler parameters. The
behaviour of a task
- * vary depending on scheduler parameters. If specified
- * <ul>
- * <li>1. startTime only - run once forever</li>
- * <li>2. startTime + incrementalPeriod - run once forever (with incremental
backup)</li>
- * <li>3. startTime, endTime - run during given period</li>
- * <li>4. startTime, endTime + incrementalPeriod - run during given period (with
incremental
- * backup)</li>
- * <li>5. startTime, endTime, chainPeriod - run periodic during given
period</li>
- * <li>6. startTime, endTime, chainPeriod + incrementalPeriod - run periodic
during given period
- * (with incremental backup)</li>
- * <li>7. startTime, chainPeriod - run periodic forever</li>
- * <li>8. startTime, chainPeriod + incrementalPeriod - run periodic forever
(with incremental
- * backup)</li>
- * </ul>
- *
- * The method will return immediate, a task will be scheduled and started as
independent thread.
- *
- * @param config
- * @param startTime
- * - task start time
- * @param stopTime
- * - task stop time, may be null i.e. the task will be executed forever
- * @param chainPeriod
- * - task chain period, means periodic execution of the configured backup
chain
- * @param incrementalPeriod
- * - incr period
- * @param listener
- * - listener for each job produced by an each backup chain
- * @return
- * @throws BackupSchedulerException
- */
- public void schedule(BackupConfig config, Date startTime, Date stopTime, long
chainPeriod, long incrementalPeriod,
- BackupJobListener listener) throws BackupSchedulerException
- {
-
- long chainPeriodMilliseconds = chainPeriod * 1000;
-
- if (incrementalPeriod > 0)
- config.setIncrementalJobPeriod(incrementalPeriod); // override ones from config
-
- SchedulerTask ctask;
-
- if (stopTime != null)
- {
- if (stopTime.after(startTime))
- {
- if (chainPeriodMilliseconds > 0)
- {
- ctask = new PeriodicTask(config, stopTime, listener);
- // the task will be executed each time chainPeriod exceeded and stopped at
stopTime
- timer.schedule(ctask, startTime, chainPeriodMilliseconds);
- }
- else
- {
- long stopPeriod = stopTime.getTime() - startTime.getTime();
- ctask = new PeriodTask(config, listener);
- // the task will be executed twice, second execution will means stop
- timer.schedule(ctask, startTime, stopPeriod);
- }
- }
- else
- throw new BackupSchedulerException("Stop time (" + stopTime +
") should be after the start time ("
- + startTime + ")");
- }
- else
- {
- if (chainPeriodMilliseconds > 0)
- {
- ctask = new PeriodicTask(config, null, listener);
- // the task will be executed each time chainPeriod exceeded and never stopped
there
- timer.schedule(ctask, startTime, chainPeriodMilliseconds);
- }
- else
- {
- ctask = new RunOnceTask(config, listener);
- // the task will executed once at given startTime
- timer.schedule(ctask, startTime);
- }
- }
-
- synchronized (tasks)
- {
- tasks.add(new WeakReference<SchedulerTask>(ctask));
- }
-
- TaskConfig tc = new TaskConfig(config, startTime, stopTime, chainPeriod,
incrementalPeriod);
- try
- {
- // PrivilegedFileHelper.getAbsolutePath(backup.getLogsDirectory())
- File taskFile =
- new File(PrivilegedFileHelper.getAbsolutePath(backup.getLogsDirectory()) +
File.separator
- + config.getRepository() + "-" + config.getWorkspace() +
".task");
-
- if (PrivilegedFileHelper.exists(taskFile))
- {
- throw new BackupSchedulerException("Task for repository '" +
config.getRepository() + "' workspace '"
- + config.getWorkspace() + "' already exists. File " +
PrivilegedFileHelper.getAbsolutePath(taskFile));
- }
- tc.save(taskFile); // save task config
- }
- catch (IOException e)
- {
- throw new BackupSchedulerException("Can't save scheduler task file
" + e, e);
- }
- catch (XMLStreamException e)
- {
- throw new BackupSchedulerException("Can't save scheduler task file
" + e, e);
- }
- catch (FactoryConfigurationError e)
- {
- throw new BackupSchedulerException("Can't save scheduler task file
" + e, e);
- }
- }
-
- /**
- * Search task by repository and workspace names
- *
- * @param repository
- * - name string
- * @param workspace
- * - name string
- *
- * @return SchedulerTask
- */
- public SchedulerTask findTask(String repository, String workspace)
- {
- synchronized (tasks)
- {
- for (Iterator<WeakReference<SchedulerTask>> ti = tasks.iterator();
ti.hasNext();)
- {
- WeakReference<SchedulerTask> tr = ti.next();
- SchedulerTask task = tr.get();
- if (task != null && task.config.getRepository().equals(repository)
- && task.config.getWorkspace().equals(workspace))
- {
- return task;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Unshedule the task scheduled before with the given configuration. The method will
waits till
- * the task will be stopped.
- *
- * @param config
- * - configuration used for a task search
- * @return - true if task was searched and stopped ok
- * @throws BackupSchedulerException
- */
- public boolean unschedule(BackupConfig config) throws BackupSchedulerException
- {
- synchronized (tasks)
- {
- for (Iterator<WeakReference<SchedulerTask>> ti = tasks.iterator();
ti.hasNext();)
- {
- WeakReference<SchedulerTask> tr = ti.next();
- SchedulerTask task = tr.get();
- if (task != null &&
task.config.getRepository().equals(config.getRepository())
- && task.config.getWorkspace().equals(config.getWorkspace()))
- {
- // remove task
- try
- {
- task.done().await();
- }
- catch (InterruptedException e)
- {
- throw new BackupSchedulerException("Task stop operation fails
" + e, e);
- }
- ti.remove();
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Simple method to release the thread used by timer used in scheduler
- */
- public void cancelTimer()
- {
- timer.cancel();
- }
-}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupSchedulerException.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupSchedulerException.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupSchedulerException.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.jcr.ext.backup.impl;
-
-import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
-
-/**
- * Created by The eXo Platform SAS Author : Peter Nedonosko
peter.nedonosko(a)exoplatform.com.ua
- * 06.12.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id: BackupSchedulerException.java 610 2008-01-11 17:01:49Z pnedonosko $
- */
-public class BackupSchedulerException extends BackupOperationException
-{
-
- public BackupSchedulerException(String message)
- {
- super(message);
- }
-
- public BackupSchedulerException(String message, Throwable e)
- {
- super(message, e);
- }
-
- public BackupSchedulerException(Throwable e)
- {
- super(e.getMessage(), e);
- }
-}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/ValueStorageCleanHelper.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not,
see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.ext.backup.impl;
-
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.services.jcr.config.ContainerEntry;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.ValueStorageEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id: ValueStorageCleanerService.java 3219 2010-09-30 07:40:51Z areshetnyak $
- */
-public class ValueStorageCleanHelper
-{
-
- /**
- * Clear workspace value storage.
- *
- * @param wEntry
- * workspace configuration
- * @throws RepositoryConfigurationException
- * @throws IOException
- */
- public void removeWorkspaceValueStorage(WorkspaceEntry wEntry) throws
RepositoryConfigurationException, IOException
- {
- ContainerEntry containerEntry = wEntry.getContainer();
-
- if (containerEntry.getValueStorages() != null)
- {
- for (ValueStorageEntry valueStorageEntry : containerEntry.getValueStorages())
- {
- String valueStorageDirName =
valueStorageEntry.getParameterValue(FileValueStorage.PATH);
-
- File valueStorageDir = new File(valueStorageDirName);
- if (PrivilegedFileHelper.exists(valueStorageDir))
- {
- removeFolder(valueStorageDir);
- }
- }
- }
- }
-
- /**
- * Remove folder
- */
- private void removeFolder(File dir) throws IOException
- {
- if (PrivilegedFileHelper.isDirectory(dir))
- {
- for (File subFile : PrivilegedFileHelper.listFiles(dir))
- {
- removeFolder(subFile);
- }
-
- if (!PrivilegedFileHelper.delete(dir))
- {
- throw new IOException("Value storage folder was not deleted : "
- + PrivilegedFileHelper.getCanonicalPath(dir));
- }
- }
- else
- {
- if (!PrivilegedFileHelper.delete(dir))
- {
- throw new IOException("Value storage file was not deleted : " +
PrivilegedFileHelper.getCanonicalPath(dir));
- }
- }
- }
-
-}
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupRestart.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupRestart.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupRestart.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -18,11 +18,7 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import org.exoplatform.services.jcr.ext.backup.impl.BackupScheduler;
-
import java.io.File;
-import java.util.Calendar;
-import java.util.Date;
/**
* Created by The eXo Platform SAS
@@ -49,54 +45,6 @@
return (ExtendedBackupManager)
container.getComponentInstanceOfType(BackupManager.class);
}
- /**
- * 4. startTime, endTime + incrementalPeriod - run during a given period (with
incremental backup)
- */
- public void _testPeriodicSchedulerPrepare() throws Exception
- {
- Date startTime;
- Date stopTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 10); // 10 min to
stop
- stopTime = calendar.getTime();
-
- File backDir = new File("target/backup/ws1.restored");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setIncrementalJobPeriod(2 * 60); // incrementalPeriod = 2 min
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, stopTime, 0, 0);
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- // play with incremental during 50 sec
- addContent(ws1TestRoot, 1, 50, 1000);
-
- // stop to be restarted
- Thread.sleep(1000);
- }
-
public void _testPeriodicSchedulerRestore() throws Exception
{
BackupChain bch = backup.getCurrentBackups().iterator().next();
@@ -112,5 +60,4 @@
// restore
restoreAndCheck("ws1back.restored", "jdbcjcr9",
bch.getLogFilePath(), backDir, 1, 50);
}
-
}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupScheduler.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupScheduler.java 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupScheduler.java 2012-01-19
14:28:39 UTC (rev 5485)
@@ -1,568 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.jcr.ext.backup;
-
-import org.exoplatform.services.jcr.ext.backup.impl.BackupMessagesLog;
-import org.exoplatform.services.jcr.ext.backup.impl.BackupScheduler;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.File;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created by The eXo Platform SAS
- *
- * Date: 05.12.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id: TestBackupScheduler.java 760 2008-02-07 15:08:07Z pnedonosko $
- */
-public class TestBackupScheduler extends AbstractBackupTestCase
-{
-
- private static final Log log =
ExoLogger.getLogger("exo.jcr.component.ext.TestBackupScheduler");
-
- protected ExtendedBackupManager getBackupManager()
- {
- return (ExtendedBackupManager)
container.getComponentInstanceOfType(BackupManager.class);
- }
-
- class BackupWaiter implements BackupJobListener
- {
-
- private int jobId;
-
- private int jobState;
-
- final BackupMessagesLog errors = new BackupMessagesLog();
-
- private CountDownLatch latch = null;
-
- public void onError(BackupJob job, String message, Throwable error)
- {
- errors.addError(message, error);
- }
-
- public void onStateChanged(BackupJob job)
- {
- if (job.getId() == jobId && job.getState() == jobState && latch
!= null)
- synchronized (latch)
- {
- latch.countDown(); // release waiter
- }
- }
-
- /**
- * @return true - ok, false - fail (tomeout expired)
- * @throws InterruptedException
- */
- boolean await(int jobId, int jobState, long timeout) throws InterruptedException
- {
-
- if (latch != null)
- synchronized (latch)
- {
- latch = new CountDownLatch(1);
- }
- else
- latch = new CountDownLatch(1);
-
- this.jobId = jobId;
- this.jobState = jobState;
- this.errors.clear();
-
- if (timeout > 0)
- {
- return this.latch.await(timeout, TimeUnit.MILLISECONDS);
- }
- else
- {
- this.latch.await();
- return true;
- }
- }
- }
-
- /**
- * 1. startTime only - run once forever
- */
- public void testScheduler_p1() throws Exception
- {
- Date startTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- // full backup & incremental
-
- File backDir = new File("target/backup/ws1.incr5");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, null, 0, 0);
-
- // wait till backup will be started
- while (Calendar.getInstance().getTime().before(startTime))
- Thread.sleep(100);
-
- Thread.sleep(100); // to know the full is started
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- // play with incremental
- addContent(ws1TestRoot, 1, 20, 1);
-
- scheduler.unschedule(config);
-
- log.info("-----------------[ restore ]-------------------------");
- // restore
- restoreAndCheck("ws1back.incr5", "jdbcjcr6",
bch.getLogFilePath(), backDir, 1, 20);
- }
-
- /**
- * 2. startTime + incrementalPeriod - run once forever (with incremental backup)
- *
- */
- public void testScheduler_p2() throws Exception
- {
- Date startTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- // full backup & incremental
-
- File backDir = new File("target/backup/ws1.incr6");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, null, 0, 10); // 10 sec incremental period
-
- // wait till backup will be started
- waitTime(startTime);
-
- Thread.sleep(100); // to know the full is started
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- // play with incremental, each node will be added after 500ms
- addContent(ws1TestRoot, 1, 20, 1100); // 20 * 1100 = 220000 ms = 22sec
-
- scheduler.unschedule(config);
-
- log.info("-----------------[ restore ]-------------------------");
- // restore
- restoreAndCheck("ws1back.incr6", "jdbcjcr7",
bch.getLogFilePath(), backDir, 1, 20);
- }
-
- /**
- * 3. startTime, endTime - run during a given period
- */
- public void testScheduler_p3() throws Exception
- {
- Date startTime;
- Date stopTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 40); // 30 sec to
stop
- stopTime = calendar.getTime();
-
- // full backup & incremental forever (without log rotate)
-
- File backDir = new File("target/backup/ws1.incr4");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, stopTime, 0, 0);
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- // play with incremental during 20 sec
- addContent(ws1TestRoot, 1, 20, 1000);
-
- // wait till backup will be stopped
- waitTime(stopTime);
-
- // wait a bit more
- Thread.sleep(5000);
-
- log.info("-----------------[ restore ]-------------------------");
- // restore
- restoreAndCheck("ws1back.incr4", "jdbcjcr8",
bch.getLogFilePath(), backDir, 1, 20);
- }
-
- /**
- * 4. startTime, endTime + incrementalPeriod - run during a given period (with
incremental backup)
- */
- public void testScheduler_p4() throws Exception
- {
- Date startTime;
- Date stopTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 60); // 60 sec to
stop
- stopTime = calendar.getTime();
-
- // full backup & incremental with log rotation 20sec
-
- File backDir = new File("target/backup/ws1.incr3");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setIncrementalJobPeriod(20); // incrementalPeriod = 20 sec*
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, stopTime, 0, 0); // incrementalPeriod =
20sec* (see
- // before)
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- // play with incremental during 50 sec
- addContent(ws1TestRoot, 1, 50, 1000);
-
- // wait till backup will be stopped
- waitTime(stopTime);
-
- // wait a bit more
- Thread.sleep(5000);
-
- log.info("-----------------[ restore ]-------------------------");
- // restore
- restoreAndCheck("ws1back.incr3", "jdbcjcr9",
bch.getLogFilePath(), backDir, 1, 50);
- }
-
- /**
- * 5. startTime, endTime, chainPeriod - run periodic at given period
- *
- * test with timing - listener to know we have jobs stared in required time
- */
- public void testScheduler_p5_timing() throws Exception
- {
- Date startTime;
- Date stopTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 61);
- stopTime = calendar.getTime();
-
- // full backup each 20sec
- File backDir = new File("target/backup/ws1.incr7");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);;
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- BackupWaiter waiter = new BackupWaiter();
- scheduler.schedule(config, startTime, stopTime, 20, 0, waiter); // 20 sec chain
period
-
- // wait till backup #1 will be started
- assertTrue("Full backup #1 start expired", waiter.await(0,
BackupJob.STARTING, 20500)); // 20.5sec
- // to
- // start
-
- BackupChain bch1 = backup.getCurrentBackups().iterator().next();
- log.info("full #1 " + bch1.getLogFilePath());
-
- final int nodesCount = 20;
- final int nodeTimeout = 500;
- addContent(ws1TestRoot, 11, 10 + nodesCount, nodeTimeout);
-
- // wait till full backup #2 will be started
- assertTrue("Full backup #2 start expired", waiter.await(0,
BackupJob.STARTING, 20500)); // 20.5sec
- // for
- // next
-
- BackupChain bch2 = backup.getCurrentBackups().iterator().next();
- log.info("full #2 " + bch2.getLogFilePath());
-
- addContent(ws1TestRoot, 31, 30 + nodesCount, nodeTimeout);
-
- // wait till full backup #3 will be started
- assertTrue("Full backup #3 start expired", waiter.await(0,
BackupJob.STARTING, 20500)); // 20.5sec
- // for
- // next
-
- BackupChain bch3 = backup.getCurrentBackups().iterator().next();
- log.info("full #3 " + bch3.getLogFilePath());
-
- // wait till backup will be stopped
- waitTime(stopTime);
-
- Thread.sleep(20000); // wait 20 sec if next chain was started before the stop
-
- log.info("-----------------[ restore #1 ]-------------------------");
- restoreAndCheck("ws1back.incr7", "jdbcjcr10",
bch1.getLogFilePath(), backDir, 1, 10);
-
- log.info("-----------------[ restore #2 ]-------------------------");
- restoreAndCheck("ws1back.incr8", "jdbcjcr11",
bch2.getLogFilePath(), backDir, 11, 30);
-
- log.info("-----------------[ restore #3 ]-------------------------");
- restoreAndCheck("ws1back.incr9", "jdbcjcr12",
bch3.getLogFilePath(), backDir, 31, 50);
- }
-
- // 6. startTime, endTime, chainPeriod + incrementalPeriod - run periodic at // given
period (with
- // incremental backup)
- public void testScheduler_p6() throws Exception
- {
-
- Date startTime;
- Date stopTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
-
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 55);
- stopTime = calendar.getTime();
- // full backup & incremental
-
- File backDir = new File("target/backup/ws1.incr10");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, stopTime, 25, 10);
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch = backup.getCurrentBackups().iterator().next();
-
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
-
- BackupChain bch1 = backup.getCurrentBackups().iterator().next();
- log.info(" #1 " + bch1.getLogFilePath());
- // BackupChain bch1 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- // incr works, 15sec+
- addContent(ws1TestRoot, 1, 20, 750);
-
- // wait till next backup chain will be started
- Thread.sleep(10000);
-
- BackupChain bch2 = backup.getCurrentBackups().iterator().next();
- log.info(" #2 " + bch2.getLogFilePath());
- // BackupChain bch2 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- addContent(ws1TestRoot, 21, 40, 750);
-
- // wait till backup will be stopped
- waitTime(stopTime);
-
- Thread.sleep(25000); // wait 25 sec if next chain was started before the stop
-
- log.info(" restore #1 " + bch1.getLogFilePath());
- restoreAndCheck("ws1back.incr10", "jdbcjcr13",
bch1.getLogFilePath(), backDir, 1, 20);
-
- log.info(" restore #2 " + bch2.getLogFilePath());
- restoreAndCheck("ws1back.incr11", "jdbcjcr14",
bch2.getLogFilePath(), backDir, 21, 40);
- }
-
- /**
- * 7. startTime, chainPeriod - run periodic forever
- */
- public void testScheduler_p7() throws Exception
- {
- Date startTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
-
- startTime = calendar.getTime();
- // full backup & incremental
-
- File backDir = new File("target/backup/ws1.incr11");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, null, 10, 0);
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch1 = backup.getCurrentBackups().iterator().next();
- // BackupChain bch1 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- addContent(ws1TestRoot, 1, 20, 10);
- // wait till next backup will be started
- Thread.sleep(11000);
-
- BackupChain bch2 = backup.getCurrentBackups().iterator().next();
- // BackupChain bch2 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- addContent(ws1TestRoot, 21, 40, 1);
-
- // Stop backup
- Thread.sleep(10000); // for last started chain
- scheduler.unschedule(config);
-
- log.info("-----------------[ restore #1 ]-------------------------");
- restoreAndCheck("ws1back.incr12", "jdbcjcr15",
bch1.getLogFilePath(), backDir, 1, 20);
-
- log.info("-----------------[ restore #2 ]-------------------------");
- restoreAndCheck("ws1back.incr13", "jdbcjcr16",
bch2.getLogFilePath(), backDir, 21, 40);
- }
-
- // 8. startTime, chainPeriod + incrementalPeriod - run periodic forever (with
incremental backup)
- public void testScheduler_p8() throws Exception
- {
-
- Date startTime;
-
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 10);
- startTime = calendar.getTime();
- // full backup & incremental
-
- File backDir = new File("target/backup/ws1.incr13");
- backDir.mkdirs();
-
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getName());
- config.setWorkspace("ws1");
- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
- config.setBackupDir(backDir);
-
- BackupScheduler scheduler = backup.getScheduler();
-
- scheduler.schedule(config, startTime, null, 10, 6);
-
- // wait till backup will be started
- waitTime(startTime);
-
- BackupChain bch1 = backup.getCurrentBackups().iterator().next();
- // BackupChain bch1 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- addContent(ws1TestRoot, 1, 20, 15);
- // wait till next backup will be started
- Thread.sleep(11000);
-
- BackupChain bch2 = backup.getCurrentBackups().iterator().next();
- // BackupChain bch2 = backup.findBackup(config.getRepository(),
config.getWorkspace());
-
- addContent(ws1TestRoot, 21, 40, 15);
-
- // Stop backup
- Thread.sleep(10000); // for last started chain
- scheduler.unschedule(config);
-
- log.info("-----------------[ restore #1 ]-------------------------");
- restoreAndCheck("ws1back.incr14", "jdbcjcr17",
bch1.getLogFilePath(), backDir, 1, 20);
-
- log.info("-----------------[ restore #2 ]-------------------------");
- restoreAndCheck("ws1back.incr15", "jdbcjcr18",
bch2.getLogFilePath(), backDir, 21, 40);
- }
-
-}
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -51,8 +51,8 @@
<property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
<property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
- <!-- property name="log4j.category.ext.BackupScheduler"
value="DEBUG"/>
- <property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.ext.BackupManagerImpl"
value="DEBUG"/ -->
<property name="log4j.category.jcr.ext.RestRepositoryService"
value="DEBUG"/>
<!-- property
name="log4j.category.org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyResourceLoader"
value="DEBUG" / -->
Modified:
jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2012-01-19
11:37:18 UTC (rev 5484)
+++
jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2012-01-19
14:28:39 UTC (rev 5485)
@@ -608,104 +608,6 @@
</section>
<section>
- <title>Scheduling (experimental)</title>
-
- <para>The Backup service has an additional feature that can be useful for
- a production level backup implementation. When you need to organize a
- backup of a repository, it's necessary to have a tool which will be able
- to create and manage a cycle of Full and Incremental backups in periodic
- manner.</para>
-
- <para>The service has internal BackupScheduler which can run a
- configurable cycle of BackupChains as if they have been executed by a user
- during some period of time. I.e. BackupScheduler is a user-like daemon
- which asks the BackupManager to start or stop backup operations.</para>
-
- <para>For that purpose, BackupScheduler has the method.</para>
-
- <para>BackupScheduler.schedule(backupConfig, startDate, stopDate,
- chainPeriod, incrementalPeriod)</para>
-
- <para>where</para>
-
- <itemizedlist>
- <listitem>
- <para>backupConfig: A ready configuration which will be given to the
- BackupManager.startBackup() method</para>
- </listitem>
-
- <listitem>
- <para>startDate: The date and time of the backup start</para>
- </listitem>
-
- <listitem>
- <para>stopDate: The date and time of the backup stop</para>
- </listitem>
-
- <listitem>
- <para>chainPeriod: A period after which a current BackupChain will be
- stopped and a new one will be started in seconds</para>
- </listitem>
-
- <listitem>
- <para>incrementalPeriod: If it is greater than 0, it will be used to
- override the same value in backupConfig.</para>
- </listitem>
- </itemizedlist>
-
- <programlisting language="java">// geting the scheduler from the
BackupManager
- BackupScheduler scheduler = backup.getScheduler();
-
-// schedule backup using a ready configuration (Full + Incrementals) to run from
startTime
-// to stopTime. Full backuop will be performed every 24 hours (BackupChain lifecycle),
-// incremental will rotate result files every 3 hours.
- scheduler.schedule(config, startTime, stopTime, 3600 * 24, 3600 * 3);
-
-// it's possible to run the scheduler for an uncertain period of time (i.e. without
stop time).
-// schedule backup to run from startTime till it will be stopped manually
-// also there, the incremental will rotate result files as it configured in BackupConfig
- scheduler.schedule(config, startTime, null, 3600 * 24, 0);
-
-// to unschedule backup simply call the scheduler with the configuration describing the
-// already planned backup cycle.
-// the scheduler will search in internal tasks list for task with repository and
-// workspace name from the configuration and will stop that task.
- scheduler.unschedule(config);</programlisting>
-
- <para>When the BackupScheduler starts the scheduling, it uses the internal
- Timer with startDate for the first (or just once) execution. If
- chainPeriod is greater than 0, then the task is repeated with this value
- used as a period starting from startDate. Otherwise, the task will be
- executed once at startDate time. If the scheduler has stopDate, it will
- stop the task ( the chain cycle) after stopDate. And the last parameter
- incrementalPeriod will be used instead of the same from BackupConfig if
- its values are greater than 0.</para>
-
- <para>Starting each task (BackupScheduler.schedule(...)), the scheduler
- creates a task file in the service working directory (see <emphasis
- role="bold">Configuration</emphasis>, backup-dir) which describes
the task
- backup configuration and periodic values. These files will be used at the
- backup service start (JVM start) to reinitialize BackupScheduler for
- continuous task scheduling. Only tasks that don't have a stopDate or a
- stopDate not expired will be reinitialized.</para>
-
- <para>There is one notice about BackupScheduler task reinitialization in
- the current implementation. It comes from the BackupScheduler nature and
- its implemented behaviour. As the scheduler is just a virtual user which
- asks the BackupManager to start or stop backup operations, it isn't able
- to reinitialize each existing BackupChain before the service (JVM) is
- stopped. But it's possible to start a new operation with the same
- configuration via BackupManager (that was configured before and stored in
- a task file).</para>
-
- <para>This is a main detail of the BackupScheduler which should be taken
- into suggestion of a backup operation design now. In case of
- reinitialization, the task will have new time values for the backup
- operation cycle as the chainPeriod and incrementalPeriod will be applied
- again. That behaviour may be changed in the future.</para>
- </section>
-
- <section>
<title>Restore existing workspace or repository</title>
<para>The resore of existing workspace or repositry is available.</para>