exo-jcr SVN: r3290 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-10-11 11:59:50 -0400 (Mon, 11 Oct 2010)
New Revision: 3290
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java
Log:
EXOJCR-967: Revert last change, the SingleMethodCallCommand must only allow public methods
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java 2010-10-11 12:57:25 UTC (rev 3289)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java 2010-10-11 15:59:50 UTC (rev 3290)
@@ -88,9 +88,9 @@
}
this.component = component;
this.method = component.getClass().getDeclaredMethod(methodName, parameterTypes);
- if (Modifier.isPrivate(method.getModifiers()))
+ if (!Modifier.isPublic(method.getModifiers()))
{
- throw new IllegalArgumentException("The method '" + methodName + "' cannot be private");
+ throw new IllegalArgumentException("The method '" + methodName + "' is not public");
}
this.id = getId(component, method);
}
15 years, 9 months
exo-jcr SVN: r3289 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-10-11 08:57:25 -0400 (Mon, 11 Oct 2010)
New Revision: 3289
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
Log:
EXOJCR-747: fix doc
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2010-10-11 12:17:47 UTC (rev 3288)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2010-10-11 12:57:25 UTC (rev 3289)
@@ -483,7 +483,7 @@
<section>
<title>Restore existing workspace or repository</title>
- <para>The resore of existing workspace or repositry is avaleble.</para>
+ <para>The resore of existing workspace or repositry is available.</para>
<para>For restore will be used spacial methods:</para>
15 years, 9 months
exo-jcr SVN: r3288 - in jcr/branches/1.14-CNK/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/query/lucene and 1 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-10-11 08:17:47 -0400 (Mon, 11 Oct 2010)
New Revision: 3288
Modified:
jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/branches/1.14-CNK/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java
Log:
EXOJCR-987 Getting rid of Volatile index
Modified: jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
===================================================================
--- jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-10-11 11:27:31 UTC (rev 3287)
+++ jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-10-11 12:17:47 UTC (rev 3288)
@@ -193,18 +193,18 @@
{
setNames(set);
// callback multiIndex to refresh lists
- try
- {
- MultiIndex multiIndex = getMultiIndex();
- if (multiIndex != null)
- {
- multiIndex.refreshIndexList();
- }
- }
- catch (IOException e)
- {
- log.error("Failed to update indexes! " + e.getMessage(), e);
- }
+// try
+// {
+// MultiIndex multiIndex = getMultiIndex();
+// if (multiIndex != null)
+// {
+// //multiIndex.refreshIndexList();
+// }
+// }
+// catch (IOException e)
+// {
+// log.error("Failed to update indexes! " + e.getMessage(), e);
+// }
}
}
}
Modified: jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2010-10-11 11:27:31 UTC (rev 3287)
+++ jcr/branches/1.14-CNK/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2010-10-11 12:17:47 UTC (rev 3288)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.impl.core.query.IndexerIoMode;
import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeHandler;
-import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeListener;
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.DirectoryManager;
import org.exoplatform.services.jcr.impl.util.SecurityHelper;
@@ -46,8 +45,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
+import java.util.Map.Entry;
import javax.jcr.ItemNotFoundException;
import javax.jcr.RepositoryException;
@@ -79,7 +77,7 @@
* thread and reader threads is done using {@link #updateMonitor} and
* {@link #updateInProgress}.
*/
-public class MultiIndex implements IndexerIoModeListener, IndexUpdateMonitorListener
+public class MultiIndex
{
/**
@@ -93,17 +91,12 @@
private IndexInfos indexNames;
/**
- * Names of index directories that can be deleted.
- */
- private final Set deletable = new HashSet();
-
- /**
* List of open persistent indexes. This list may also contain an open
* PersistentIndex owned by the IndexMerger daemon. Such an index is not
* registered with indexNames and <b>must not</b> be used in regular index
* operations (delete node, etc.)!
*/
- private final List indexes = new ArrayList();
+ private final List<PersistentIndex> indexes = new ArrayList<PersistentIndex>();
/**
* The internal namespace mappings of the query manager.
@@ -126,18 +119,6 @@
private final SearchIndex handler;
/**
- * The volatile index.
- */
- private VolatileIndex volatileIndex;
-
- /**
- * Flag indicating whether an update operation is in progress.
- */
- // private boolean updateInProgress = false;
-
- private final IndexUpdateMonitor indexUpdateMonitor;
-
- /**
* If not <code>null</code> points to a valid <code>IndexReader</code> that
* reads from all indexes, including volatile and persistent indexes.
*/
@@ -149,33 +130,6 @@
private final DocNumberCache cache;
/**
- * Monitor to use to synchronize access to {@link #multiReader} and
- * {@link #updateInProgress}.
- */
- private final Object updateMonitor = new Object();
-
- /**
- * The time this index was last flushed or a transaction was committed.
- */
- private long lastFlushTime;
-
- /**
- * The time this index was last flushed or a transaction was committed.
- */
- private long lastFileSystemFlushTime;
-
- /**
- * Timer to schedule flushes of this index after some idle time.
- */
- private static final Timer FLUSH_TIMER = new Timer(true);
-
- /**
- * Task that is periodically called by {@link #FLUSH_TIMER} and checks if
- * index should be flushed.
- */
- private TimerTask flushTask;
-
- /**
* The indexing queue with pending text extraction jobs.
*/
private IndexingQueue indexingQueue;
@@ -186,11 +140,6 @@
private final IndexingTree indexingTree;
/**
- * The next transaction id.
- */
- private long nextTransactionId = 0;
-
- /**
* Flag indicating whether re-indexing is running.
*/
private boolean reindexing = false;
@@ -220,7 +169,6 @@
IndexUpdateMonitor indexUpdateMonitor) throws IOException
{
this.modeHandler = modeHandler;
- this.indexUpdateMonitor = indexUpdateMonitor;
this.directoryManager = handler.getDirectoryManager();
// this method is run in privileged mode internally
this.indexDir = directoryManager.getDirectory(".");
@@ -228,18 +176,15 @@
this.cache = new DocNumberCache(handler.getCacheSize());
this.indexingTree = indexingTree;
this.nsMappings = handler.getNamespaceMappings();
- this.flushTask = null;
this.indexNames = indexInfos;
this.indexNames.setDirectory(indexDir);
// this method is run in privileged mode internally
this.indexNames.read();
+ this.indexNames.addName("1");
+ this.indexNames.addName("2");
+ this.indexNames.addName("3");
+ this.indexNames.addName("4");
- this.lastFileSystemFlushTime = System.currentTimeMillis();
- this.lastFlushTime = System.currentTimeMillis();
-
- modeHandler.addIndexerIoModeListener(this);
- indexUpdateMonitor.addIndexUpdateMonitorListener(this);
-
// this method is run in privileged mode internally
// as of 1.5 deletable file is not used anymore
removeDeletable();
@@ -251,6 +196,7 @@
this.indexingQueue = new IndexingQueue(store);
// copy current index names
Set<String> currentNames = new HashSet<String>(indexNames.getNames());
+ //Set<String> currentNames = new HashSet<String>();
// open persistent indexes
for (String name : currentNames)
@@ -259,12 +205,14 @@
// it is possible that indexNames still contains a name for
// an index that has been deleted, but indexNames has not been
// written to disk.
- if (!directoryManager.hasDirectory(name))
- {
- log.debug("index does not exist anymore: " + name);
- // move on to next index
- continue;
- }
+
+ // TODO THIS CHECK WAS SKIPPED
+ // if (!directoryManager.hasDirectory(name))
+ // {
+ // log.debug("index does not exist anymore: " + name);
+ // // move on to next index
+ // continue;
+ // }
PersistentIndex index =
new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
directoryManager);
@@ -275,7 +223,8 @@
}
// init volatile index
- resetVolatileIndex();
+ // TODO commented line below:
+ //resetVolatileIndex();
// set index format version and at the same time
// initialize hierarchy cache if requested.
@@ -296,10 +245,6 @@
});
}
indexingQueue.initialize(this);
- if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
- {
- setReadWrite();
- }
this.indexNames.setMultiIndex(this);
}
@@ -314,7 +259,9 @@
{
if (indexNames.size() == 0)
{
- return volatileIndex.getNumDocuments();
+ // TODO commented line below:
+ //return volatileIndex.getNumDocuments();
+ return 0;
}
else
{
@@ -362,15 +309,16 @@
*/
void createInitialIndex(ItemDataConsumer stateMgr) throws IOException
{
+
+ // TODO: re-study check!!!
// only do an initial index if there are no indexes at all
- if (indexNames.size() == 0)
+ // if (indexNames.size() == 0)
{
reindexing = true;
try
{
long count = 0;
// traverse and index workspace
-
// TODO: this was removed
//executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
@@ -382,7 +330,8 @@
log.info("Created initial index for {} nodes", new Long(count));
releaseMultiReader();
- scheduleFlushTask();
+ // TODO commented line below:
+ //scheduleFlushTask();
}
catch (Exception e)
{
@@ -396,10 +345,10 @@
reindexing = false;
}
}
- else
- {
- throw new IllegalStateException("Index already present");
- }
+ // else
+ // {
+ // throw new IllegalStateException("Index already present");
+ // }
}
/**
@@ -416,7 +365,7 @@
* @throws IOException
* if an error occurs while updating the index.
*/
- synchronized void update(final Collection remove, final Collection add) throws IOException
+ synchronized void update(final Collection<String> remove, final Collection<Document> add) throws IOException
{
SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
@@ -435,26 +384,18 @@
log.warn("unable to prepare index reader " + "for queries during update", e);
}
}
-
- synchronized (updateMonitor)
- {
- //updateInProgress = true;
- indexUpdateMonitor.setUpdateInProgress(true, false);
- }
- boolean flush = false;
+// boolean flush = false;
try
{
- long transactionId = nextTransactionId++;
-
// TODO: this was removed
//executeAndLog(new Start(transactionId));
- for (Iterator it = remove.iterator(); it.hasNext();)
+ for (Iterator<String> it = remove.iterator(); it.hasNext();)
{
// TODO this was replaced
//executeAndLog(new DeleteNode(transactionId, (String)it.next()));
- String uuidString = (String)it.next();
+ String uuidString = it.next();
// check if indexing queue is still working on
// this node from a previous update
Document doc = indexingQueue.removeDocument(uuidString);
@@ -465,13 +406,15 @@
Term idTerm = new Term(FieldNames.UUID, uuidString);
// if the document cannot be deleted from the volatile index
// delete it from one of the persistent indexes.
- int num = volatileIndex.removeDocument(idTerm);
+
+ // TODO watch here
+ int num = getChunk(uuidString).removeDocument(idTerm);
if (num == 0)
{
for (int i = indexes.size() - 1; i >= 0; i--)
{
// only look in registered indexes
- PersistentIndex idx = (PersistentIndex)indexes.get(i);
+ PersistentIndex idx = indexes.get(i);
if (indexNames.contains(idx.getName()))
{
num = idx.removeDocument(idTerm);
@@ -484,9 +427,9 @@
}
}
- for (Iterator it = add.iterator(); it.hasNext();)
+ for (Iterator<Document> it = add.iterator(); it.hasNext();)
{
- Document doc = (Document)it.next();
+ Document doc = it.next();
if (doc != null)
{
// TODO: ths is replaced
@@ -494,38 +437,27 @@
if (doc != null)
{
- volatileIndex.addDocuments(new Document[]{doc});
+ // TODO watch this
+ String uuid = doc.get(FieldNames.UUID);
+ getChunk(uuid).addDocuments(new Document[]{doc});
}
// commit volatile index if needed
- flush |= checkVolatileCommit();
+ // TODO commented line below:
+ //flush |= checkVolatileCommit();
}
}
// TODO : this was replaced
//executeAndLog(new Commit(transactionId));
- // flush whole index when volatile index has been commited.
- if (flush)
- {
- // if we are going to flush, need to set persistent update
- synchronized (updateMonitor)
- {
- indexUpdateMonitor.setUpdateInProgress(true, true);
- }
- flush();
- }
+ // TODO commented line below:
+ //flush();
+ getChunk(null).commit();
}
finally
{
- synchronized (updateMonitor)
- {
- //updateInProgress = false;
-
- indexUpdateMonitor.setUpdateInProgress(false, flush);
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
+ releaseMultiReader();
}
return null;
}
@@ -569,11 +501,6 @@
*/
synchronized int removeAllDocuments(String uuid) throws IOException
{
- synchronized (updateMonitor)
- {
- //updateInProgress = true;
- indexUpdateMonitor.setUpdateInProgress(true, false);
- }
int num;
try
{
@@ -582,7 +509,8 @@
// TODO: this was removed
//executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- num = volatileIndex.removeDocument(idTerm);
+ // TODO REMOVE WAS HERE
+ num = getChunk(uuid).removeDocument(idTerm);
if (num > 0)
{
// TODO: removed line
@@ -590,7 +518,7 @@
}
for (int i = 0; i < indexes.size(); i++)
{
- PersistentIndex index = (PersistentIndex)indexes.get(i);
+ PersistentIndex index = indexes.get(i);
// only remove documents from registered indexes
if (indexNames.contains(index.getName()))
{
@@ -608,13 +536,7 @@
}
finally
{
- synchronized (updateMonitor)
- {
- //updateInProgress = false;
- indexUpdateMonitor.setUpdateInProgress(false, false);
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
+ releaseMultiReader();
}
return num;
}
@@ -639,14 +561,14 @@
*/
synchronized IndexReader[] getIndexReaders(String[] indexNames, IndexListener listener) throws IOException
{
- Set names = new HashSet(Arrays.asList(indexNames));
- Map indexReaders = new HashMap();
+ Set<String> names = new HashSet<String>(Arrays.asList(indexNames));
+ Map<ReadOnlyIndexReader, PersistentIndex> indexReaders = new HashMap<ReadOnlyIndexReader, PersistentIndex>();
try
{
- for (Iterator it = indexes.iterator(); it.hasNext();)
+ for (Iterator<PersistentIndex> it = indexes.iterator(); it.hasNext();)
{
- PersistentIndex index = (PersistentIndex)it.next();
+ PersistentIndex index = it.next();
if (names.contains(index.getName()))
{
indexReaders.put(index.getReadOnlyIndexReader(listener), index);
@@ -656,10 +578,10 @@
catch (IOException e)
{
// release readers obtained so far
- for (Iterator it = indexReaders.entrySet().iterator(); it.hasNext();)
+ for (Iterator<Entry<ReadOnlyIndexReader, PersistentIndex>> it = indexReaders.entrySet().iterator(); it.hasNext();)
{
- Map.Entry entry = (Map.Entry)it.next();
- final ReadOnlyIndexReader reader = (ReadOnlyIndexReader)entry.getKey();
+ Map.Entry<ReadOnlyIndexReader, PersistentIndex> entry = it.next();
+ final ReadOnlyIndexReader reader = entry.getKey();
try
{
SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
@@ -675,77 +597,15 @@
{
log.warn("Exception releasing index reader: " + ex);
}
- ((PersistentIndex)entry.getValue()).resetListener();
+ (entry.getValue()).resetListener();
}
throw e;
}
- return (IndexReader[])indexReaders.keySet().toArray(new IndexReader[indexReaders.size()]);
+ return indexReaders.keySet().toArray(new IndexReader[indexReaders.size()]);
}
/**
- * Creates a new Persistent index. The new index is not registered with this
- * <code>MultiIndex</code>.
- *
- * @param indexName
- * the name of the index to open, or <code>null</code> if an
- * index with a new name should be created.
- * @return a new <code>PersistentIndex</code>.
- * @throws IOException
- * if a new index cannot be created.
- */
- synchronized PersistentIndex getOrCreateIndex(String indexName) throws IOException
- {
- // check existing
- for (Iterator it = indexes.iterator(); it.hasNext();)
- {
- PersistentIndex idx = (PersistentIndex)it.next();
- if (idx.getName().equals(indexName))
- {
- return idx;
- }
- }
-
- if (modeHandler.getMode() == IndexerIoMode.READ_ONLY)
- {
- throw new UnsupportedOperationException("Can't create index in READ_ONLY mode.");
- }
-
- // otherwise open / create it
- if (indexName == null)
- {
- do
- {
- indexName = indexNames.newName();
- }
- while (directoryManager.hasDirectory(indexName));
- }
- PersistentIndex index;
- try
- {
- index =
- new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
- directoryManager);
- }
- catch (IOException e)
- {
- // do some clean up
- if (!directoryManager.delete(indexName))
- {
- deletable.add(indexName);
- }
- throw e;
- }
- index.setMaxFieldLength(handler.getMaxFieldLength());
- index.setUseCompoundFile(handler.getUseCompoundFile());
- index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
-
- // add to list of open indexes and return it
- indexes.add(index);
- return index;
- }
-
- /**
* Returns <code>true</code> if this multi index has an index segment with
* the given name. This method even returns <code>true</code> if an index
* segments has not yet been loaded / initialized but exists on disk.
@@ -759,9 +619,9 @@
synchronized boolean hasIndex(String indexName) throws IOException
{
// check existing
- for (Iterator it = indexes.iterator(); it.hasNext();)
+ for (Iterator<PersistentIndex> it = indexes.iterator(); it.hasNext();)
{
- PersistentIndex idx = (PersistentIndex)it.next();
+ PersistentIndex idx = it.next();
if (idx.getName().equals(indexName))
{
return true;
@@ -772,131 +632,6 @@
}
/**
- * Replaces the indexes with names <code>obsoleteIndexes</code> with
- * <code>index</code>. Documents that must be deleted in <code>index</code>
- * can be identified with <code>Term</code>s in <code>deleted</code>.
- *
- * @param obsoleteIndexes
- * the names of the indexes to replace.
- * @param index
- * the new index that is the result of a merge of the indexes to
- * replace.
- * @param deleted
- * <code>Term</code>s that identify documents that must be
- * deleted in <code>index</code>.
- * @throws IOException
- * if an exception occurs while replacing the indexes.
- */
- void replaceIndexes(String[] obsoleteIndexes, final PersistentIndex index, Collection deleted) throws IOException
- {
-
- if (handler.isInitializeHierarchyCache())
- {
- // force initializing of caches
- long time = System.currentTimeMillis();
- SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- index.getReadOnlyIndexReader(true).release();
- return null;
- }
- });
- time = System.currentTimeMillis() - time;
- log.debug("hierarchy cache initialized in {} ms", new Long(time));
- }
-
- synchronized (this)
- {
- synchronized (updateMonitor)
- {
- //updateInProgress = true;
- indexUpdateMonitor.setUpdateInProgress(true, true);
- }
- try
- {
- // if we are reindexing there is already an active transaction
- if (!reindexing)
- {
- // TODO: this was removed
- //executeAndLog(new Start(Action.INTERNAL_TRANS_REPL_INDEXES));
- }
- // delete obsolete indexes
- Set names = new HashSet(Arrays.asList(obsoleteIndexes));
- for (Iterator it = names.iterator(); it.hasNext();)
- {
- // do not try to delete indexes that are already gone
- String indexName = (String)it.next();
- if (indexNames.contains(indexName))
- {
- // TODO this was replaced
- //executeAndLog(new DeleteIndex(getTransactionId(), indexName));
-
- for (Iterator it2 = indexes.iterator(); it2.hasNext();)
- {
- PersistentIndex idx = (PersistentIndex)it2.next();
- if (idx.getName().equals(indexName))
- {
- idx.close();
- deleteIndex(idx);
- break;
- }
- }
-
- }
- }
-
- // Index merger does not log an action when it creates the
- // target
- // index of the merge. We have to do this here.
- // TODO this was replaced
- ///executeAndLog(new CreateIndex(getTransactionId(), index.getName()));
-
- PersistentIndex idx = getOrCreateIndex(index.getName());
-
- // TODO: this is replaced
- //executeAndLog(new AddIndex(getTransactionId(), index.getName()));
- if (!indexNames.contains(index.getName()))
- {
- indexNames.addName(index.getName());
- }
-
- // delete documents in index
- for (Iterator it = deleted.iterator(); it.hasNext();)
- {
- Term id = (Term)it.next();
- index.removeDocument(id);
- }
- index.commit();
-
- if (!reindexing)
- {
- // only commit if we are not reindexing
- // when reindexing the final commit is done at the very end
-
- // TODO : this was replaced
- //executeAndLog(new Commit(getTransactionId()));
- }
- }
- finally
- {
- synchronized (updateMonitor)
- {
- //updateInProgress = false;
- indexUpdateMonitor.setUpdateInProgress(false, true);
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- }
- if (reindexing)
- {
- // do some cleanup right away when reindexing
- attemptDelete();
- }
- }
-
- /**
* Returns an read-only <code>IndexReader</code> that spans alls indexes of
* this <code>MultiIndex</code>.
*
@@ -926,74 +661,49 @@
{
public CachingMultiIndexReader run() throws Exception
{
- synchronized (updateMonitor)
+ if (multiReader != null)
{
- if (multiReader != null)
+ multiReader.acquire();
+ return multiReader;
+ }
+ // no reader available
+ // some other read thread might have created the reader in the
+ // meantime -> check again
+ if (multiReader == null)
+ {
+ List<ReadOnlyIndexReader> readerList = new ArrayList<ReadOnlyIndexReader>();
+ for (int i = 0; i < indexes.size(); i++)
{
- multiReader.acquire();
- return multiReader;
- }
- // no reader available
- // wait until no update is in progress
- while (indexUpdateMonitor.getUpdateInProgress())
- {
- try
- {
- updateMonitor.wait();
- }
- catch (InterruptedException e)
- {
- throw new IOException("Interrupted while waiting to aquire reader");
- }
- }
- // some other read thread might have created the reader in the
- // meantime -> check again
- if (multiReader == null)
- {
- List readerList = new ArrayList();
- for (int i = 0; i < indexes.size(); i++)
- {
- PersistentIndex pIdx = (PersistentIndex)indexes.get(i);
+ PersistentIndex pIdx = indexes.get(i);
- if (indexNames.contains(pIdx.getName()))
+ if (indexNames.contains(pIdx.getName()))
+ {
+ try
{
- try
+ readerList.add(pIdx.getReadOnlyIndexReader(initCache));
+ }
+ catch (FileNotFoundException e)
+ {
+ if (directoryManager.hasDirectory(pIdx.getName()))
{
- readerList.add(pIdx.getReadOnlyIndexReader(initCache));
+ throw e;
}
- catch (FileNotFoundException e)
- {
- if (directoryManager.hasDirectory(pIdx.getName()))
- {
- throw e;
- }
- }
}
}
- readerList.add(volatileIndex.getReadOnlyIndexReader());
- ReadOnlyIndexReader[] readers =
- (ReadOnlyIndexReader[])readerList.toArray(new ReadOnlyIndexReader[readerList.size()]);
- multiReader = new CachingMultiIndexReader(readers, cache);
}
- multiReader.acquire();
- return multiReader;
+ // TODO commented line below:
+ //readerList.add(volatileIndex.getReadOnlyIndexReader());
+ ReadOnlyIndexReader[] readers = readerList.toArray(new ReadOnlyIndexReader[readerList.size()]);
+ multiReader = new CachingMultiIndexReader(readers, cache);
}
+ multiReader.acquire();
+ return multiReader;
}
});
}
/**
- * Returns the volatile index.
- *
- * @return the volatile index.
- */
- VolatileIndex getVolatileIndex()
- {
- return volatileIndex;
- }
-
- /**
* Closes this <code>MultiIndex</code>.
*/
void close()
@@ -1007,11 +717,6 @@
synchronized (this)
{
- // stop timer
- if (flushTask != null)
- {
- flushTask.cancel();
- }
// commit / close indexes
try
@@ -1022,18 +727,21 @@
{
log.error("Exception while closing search index.", e);
}
- try
- {
- flush();
- }
- catch (IOException e)
- {
- log.error("Exception while closing search index.", e);
- }
- volatileIndex.close();
+ // try
+ // {
+ // // TODO commented line below:
+ // //flush();
+ // }
+ // catch (IOException e)
+ // {
+ // log.error("Exception while closing search index.", e);
+ // }
+ // TODO commented line below:
+ //volatileIndex.close();
+ // indexes will be closed now:
for (int i = 0; i < indexes.size(); i++)
{
- ((PersistentIndex)indexes.get(i)).close();
+ (indexes.get(i)).close();
}
// close indexing queue
@@ -1112,83 +820,6 @@
}
/**
- * Removes the <code>index</code> from the list of active sub indexes. The
- * Index is not acutally deleted right away, but postponed to the
- * transaction commit.
- * <p/>
- * This method does not close the index, but rather expects that the index
- * has already been closed.
- *
- * @param index
- * the index to delete.
- */
- synchronized void deleteIndex(PersistentIndex index)
- {
- // remove it from the lists if index is registered
- indexes.remove(index);
- indexNames.removeName(index.getName());
- synchronized (deletable)
- {
- log.debug("Moved " + index.getName() + " to deletable");
- deletable.add(index.getName());
- }
- }
-
- /**
- * Flushes this <code>MultiIndex</code>. Persists all pending changes and
- * resets the redo log.
- *
- * @throws IOException
- * if the flush fails.
- */
- public void flush() throws IOException
- {
- synchronized (this)
- {
- // commit volatile index
- // TODO: this was removed
- //executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- commitVolatileIndex();
-
- // commit persistent indexes
- for (int i = indexes.size() - 1; i >= 0; i--)
- {
- PersistentIndex index = (PersistentIndex)indexes.get(i);
- // only commit indexes we own
- // index merger also places PersistentIndex instances in
- // indexes,
- // but does not make them public by registering the name in
- // indexNames
- if (indexNames.contains(index.getName()))
- {
- index.commit();
- // check if index still contains documents
- if (index.getNumDocuments() == 0)
- {
- // TODO THIS was replaced
- //executeAndLog(new DeleteIndex(getTransactionId(), index.getName()));
-
- index.close();
- deleteIndex(index);
-
- }
- }
- }
- // TODO : this was replaced
- //executeAndLog(new Commit(getTransactionId()));
-
- indexNames.write();
-
- // reset redo log
- lastFlushTime = System.currentTimeMillis();
- lastFileSystemFlushTime = System.currentTimeMillis();
- }
-
- // delete obsolete indexes
- attemptDelete();
- }
-
- /**
* Releases the {@link #multiReader} and sets it <code>null</code>. If the
* reader is already <code>null</code> this method does nothing. When this
* method returns {@link #multiReader} is guaranteed to be <code>null</code>
@@ -1227,143 +858,6 @@
// >-------------------------------------
/**
- * Enqueues unused segments for deletion in {@link #deletable}. This method
- * does not synchronize on {@link #deletable}! A caller must ensure that it
- * is the only one acting on the {@link #deletable} map.
- *
- * @throws IOException
- * if an error occurs while reading directories.
- */
- private void enqueueUnusedSegments() throws IOException
- {
- // walk through index segments
- String[] dirNames = directoryManager.getDirectoryNames();
- for (int i = 0; i < dirNames.length; i++)
- {
- if (dirNames[i].startsWith("_") && !indexNames.contains(dirNames[i]))
- {
- deletable.add(dirNames[i]);
- }
- }
- }
-
- /**
- * Cancel flush task and add new one
- */
- private void scheduleFlushTask()
- {
- SecurityHelper.doPriviledgedAction(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- // cancel task
- if (flushTask != null)
- {
- flushTask.cancel();
- }
- // clear canceled tasks
- FLUSH_TIMER.purge();
- // new flush task, cause canceled can't be re-used
- flushTask = new TimerTask()
- {
- @Override
- public void run()
- {
- // check if there are any indexing jobs finished
- checkIndexingQueue();
- // check if volatile index should be flushed
- checkFlush();
- }
- };
- FLUSH_TIMER.schedule(flushTask, 0, 1000);
- lastFlushTime = System.currentTimeMillis();
- lastFileSystemFlushTime = System.currentTimeMillis();
- return null;
- }
- });
- }
-
- /**
- * Resets the volatile index to a new instance.
- */
- private void resetVolatileIndex() throws IOException
- {
- volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity(), indexingQueue);
- volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
- volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
- volatileIndex.setBufferSize(handler.getBufferSize());
- }
-
- /**
- * Checks if it is needed to commit the volatile index according to
- * {@link SearchIndex#getMaxVolatileIndexSize()}.
- *
- * @return <code>true</code> if the volatile index has been committed,
- * <code>false</code> otherwise.
- * @throws IOException
- * if an error occurs while committing the volatile index.
- */
- private boolean checkVolatileCommit() throws IOException
- {
- if (volatileIndex.getRamSizeInBytes() >= handler.getMaxVolatileIndexSize())
- {
- commitVolatileIndex();
- return true;
- }
- return false;
- }
-
- /**
- * Commits the volatile index to a persistent index. The new persistent
- * index is added to the list of indexes but not written to disk. When this
- * method returns a new volatile index has been created.
- *
- * @throws IOException
- * if an error occurs while writing the volatile index to disk.
- */
- private void commitVolatileIndex() throws IOException
- {
-
- // check if volatile index contains documents at all
- if (volatileIndex.getNumDocuments() > 0)
- {
-
- long time = System.currentTimeMillis();
- // create index
-
- //TODO this was replaced
- // CreateIndex create = new CreateIndex(getTransactionId(), null);
- // executeAndLog(create);
-
- PersistentIndex idx = getOrCreateIndex(null);
-
- // commit volatile index
-
- // TODO THIS IS REPLACED
- //executeAndLog(new VolatileCommit(getTransactionId(), idx.getName()));
-
- idx.copyIndex(volatileIndex);
- resetVolatileIndex();
-
- // TODO this is replaced
- // add new index
- // AddIndex add = new AddIndex(getTransactionId(), create.getIndexName());
- // executeAndLog(add);
-
- if (!indexNames.contains(idx.getName()))
- {
- indexNames.addName(idx.getName());
- }
-
- // create new volatile index
- resetVolatileIndex();
-
- time = System.currentTimeMillis() - time;
- log.debug("Committed in-memory index in " + time + "ms.");
- }
- }
-
- /**
* Recursively creates an index starting with the NodeState
* <code>node</code>.
*
@@ -1395,7 +889,7 @@
// TODO: this is replaced
//executeAndLog(new AddNode(getTransactionId(), node.getIdentifier()));
- volatileIndex.addDocuments(new Document[]{createDocument(node)});
+ getChunk(node.getIdentifier()).addDocuments(new Document[]{createDocument(node)});
if (++count % 100 == 0)
{
@@ -1406,7 +900,8 @@
{
checkIndexingQueue(true);
}
- checkVolatileCommit();
+ // TODO commented line below:
+ //checkVolatileCommit();
List<NodeData> children = stateMgr.getChildNodesData(node);
for (NodeData nodeData : children)
{
@@ -1428,28 +923,6 @@
}
/**
- * Attempts to delete all files recorded in {@link #deletable}.
- */
- private void attemptDelete()
- {
- synchronized (deletable)
- {
- for (Iterator it = deletable.iterator(); it.hasNext();)
- {
- String indexName = (String)it.next();
- if (directoryManager.delete(indexName))
- {
- it.remove();
- }
- else
- {
- log.info("Unable to delete obsolete index: " + indexName);
- }
- }
- }
- }
-
- /**
* Removes the deletable file if it exists. The file is not used anymore in
* Jackrabbit versions >= 1.5.
*/
@@ -1477,52 +950,6 @@
}
/**
- * Checks the duration between the last commit to this index and the current
- * time and flushes the index (if there are changes at all) if the duration
- * (idle time) is more than {@link SearchIndex#getVolatileIdleTime()}
- * seconds.
- */
- private synchronized void checkFlush()
- {
- long idleTime = System.currentTimeMillis() - lastFlushTime;
- long volatileTime = System.currentTimeMillis() - lastFileSystemFlushTime;
- // do not flush if volatileIdleTime is zero or negative
- if ((handler.getVolatileIdleTime() > 0 && idleTime > handler.getVolatileIdleTime() * 1000)
- || (handler.getMaxVolatileTime() > 0 && volatileTime > handler.getMaxVolatileTime() * 1000))
- {
- try
- {
- {
- log.debug("Flushing index after being idle for " + idleTime + " ms.");
- synchronized (updateMonitor)
- {
- //updateInProgress = true;
- indexUpdateMonitor.setUpdateInProgress(true, true);
- }
- try
- {
- flush();
- }
- finally
- {
- synchronized (updateMonitor)
- {
- //updateInProgress = false;
- indexUpdateMonitor.setUpdateInProgress(false, true);
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- }
- }
- catch (IOException e)
- {
- log.error("Unable to commit volatile index", e);
- }
- }
- }
-
- /**
* Checks the indexing queue for finished text extrator jobs and updates the
* index accordingly if there are any new ones. This method is synchronized
* and should only be called by the timer task that periodically checks if
@@ -1547,7 +974,7 @@
private void checkIndexingQueue(boolean transactionPresent)
{
Document[] docs = indexingQueue.getFinishedDocuments();
- Map finished = new HashMap();
+ Map<String, Document> finished = new HashMap<String, Document>();
for (int i = 0; i < docs.length; i++)
{
String uuid = docs[i].get(FieldNames.UUID);
@@ -1560,21 +987,21 @@
log.info("updating index with {} nodes from indexing queue.", new Long(finished.size()));
// remove documents from the queue
- for (Iterator it = finished.keySet().iterator(); it.hasNext();)
+ for (Iterator<String> it = finished.keySet().iterator(); it.hasNext();)
{
- indexingQueue.removeDocument(it.next().toString());
+ indexingQueue.removeDocument(it.next());
}
try
{
if (transactionPresent)
{
- for (Iterator it = finished.keySet().iterator(); it.hasNext();)
+ for (Iterator<String> it = finished.keySet().iterator(); it.hasNext();)
{
// TODO this was replaced
//executeAndLog(new DeleteNode(getTransactionId(), (String)it.next()));
- String uuidString = (String)it.next();
+ String uuidString = it.next();
// check if indexing queue is still working on
// this node from a previous update
Document doc = indexingQueue.removeDocument(uuidString);
@@ -1585,13 +1012,13 @@
Term idTerm = new Term(FieldNames.UUID, uuidString);
// if the document cannot be deleted from the volatile index
// delete it from one of the persistent indexes.
- int num = volatileIndex.removeDocument(idTerm);
+ int num = getChunk(uuidString).removeDocument(idTerm);
if (num == 0)
{
for (int i = indexes.size() - 1; i >= 0; i--)
{
// only look in registered indexes
- PersistentIndex idx = (PersistentIndex)indexes.get(i);
+ PersistentIndex idx = indexes.get(i);
if (indexNames.contains(idx.getName()))
{
num = idx.removeDocument(idTerm);
@@ -1604,11 +1031,13 @@
}
}
- for (Iterator it = finished.values().iterator(); it.hasNext();)
+ for (Iterator<Document> it = finished.values().iterator(); it.hasNext();)
{
// TODO this was replaced
//executeAndLog(new AddNode(getTransactionId(), (Document)it.next()));
- volatileIndex.addDocuments(new Document[]{(Document)it.next()});
+ Document doc = it.next();
+ String uuid = doc.get(FieldNames.UUID);
+ getChunk(uuid).addDocuments(new Document[]{doc});
}
}
else
@@ -1627,154 +1056,14 @@
// ------------------------< Actions
// >---------------------------------------
- /**
- * @see org.exoplatform.services.jcr.impl.core.query.IndexerIoModeListener#onChangeMode(org.exoplatform.services.jcr.impl.core.query.IndexerIoMode)
- */
- public void onChangeMode(IndexerIoMode mode)
- {
- try
- {
- switch (mode)
- {
- case READ_ONLY :
- setReadOny();
- break;
- case READ_WRITE :
- setReadWrite();
- break;
- }
- }
- catch (IOException e)
- {
- log.error("An error occurs while changing of mode " + mode, e);
- }
- }
-
- /**
- * Sets mode to READ_ONLY, discarding flush task
- */
- protected void setReadOny()
- {
- // try to stop merger in safe way
- flushTask.cancel();
- FLUSH_TIMER.purge();
- }
-
- /**
- * Sets mode to READ_WRITE, initiating recovery process
- *
- * @throws IOException
- */
- protected void setReadWrite() throws IOException
- {
- // Release all the current threads
- synchronized (updateMonitor)
- {
- indexUpdateMonitor.setUpdateInProgress(false, true);
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
-
- // enqueue unused segments for deletion
- enqueueUnusedSegments();
- attemptDelete();
-
- // now that we are ready, start index merger
- flush();
-
- if (indexNames.size() > 0)
- {
- scheduleFlushTask();
- }
- }
-
- /**
- * Refresh list of indexes. Used to be called asynchronously when list changes. New, actual list is read from
- * IndexInfos.
- * @throws IOException
- */
- public void refreshIndexList() throws IOException
- {
- // TODO: re-study synchronization here.
- synchronized (updateMonitor)
- {
- // release reader if any
- releaseMultiReader();
- // prepare added/removed sets
- Set<String> newList = new HashSet<String>(indexNames.getNames());
-
- // remove removed indexes
- Iterator<PersistentIndex> iterator = indexes.iterator();
- while (iterator.hasNext())
- {
- PersistentIndex index = iterator.next();
- String name = index.getName();
- // if current index not in new list, close it, cause it is deleted.
- if (!newList.contains(name))
- {
- index.close();
- iterator.remove();
- }
- else
- {
- // remove from list, cause this segment of index still present and indexes list contains
- // PersistentIndex instance related to this index..
- newList.remove(name);
- }
- }
- // now newList contains ONLY new, added indexes, deleted indexes, are removed from list.
- for (String name : newList)
- {
- // only open if it still exists
- // it is possible that indexNames still contains a name for
- // an index that has been deleted, but indexNames has not been
- // written to disk.
- if (!directoryManager.hasDirectory(name))
- {
- log.debug("index does not exist anymore: " + name);
- // move on to next index
- continue;
- }
- PersistentIndex index =
- new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
- directoryManager);
- index.setMaxFieldLength(handler.getMaxFieldLength());
- index.setUseCompoundFile(handler.getUseCompoundFile());
- index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
- indexes.add(index);
- }
- }
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitorListener#onUpdateInProgressChange(boolean)
- */
- public void onUpdateInProgressChange(boolean updateInProgress)
- {
- if (modeHandler.getMode() == IndexerIoMode.READ_ONLY)
- {
- if (!updateInProgress)
- {
- // wake up the sleeping threads
- try
- {
- synchronized (updateMonitor)
- {
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- catch (IOException e)
- {
- log.error("An erro occurs while trying to wake up the sleeping threads", e);
- }
- }
- }
- }
-
@Deprecated
public boolean getRedoLogApplied()
{
return false;
}
+
+ private PersistentIndex getChunk(String uuid)
+ {
+ return indexes.get(0);
+ }
}
Modified: jcr/branches/1.14-CNK/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java
===================================================================
--- jcr/branches/1.14-CNK/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java 2010-10-11 11:27:31 UTC (rev 3287)
+++ jcr/branches/1.14-CNK/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java 2010-10-11 12:17:47 UTC (rev 3288)
@@ -106,7 +106,7 @@
{
SearchIndex index = (SearchIndex)getQueryHandler();
IndexingQueue queue = index.getIndex().getIndexingQueue();
- index.getIndex().flush();
+ //index.getIndex().flush();
synchronized (index.getIndex())
{
while (queue.getNumPendingDocuments() > 0)
15 years, 9 months
exo-jcr SVN: r3287 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-10-11 07:27:31 -0400 (Mon, 11 Oct 2010)
New Revision: 3287
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java
Log:
EXOJCR-967: The SingleMethodCallCommand only forbids private method calls
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java 2010-10-11 10:03:48 UTC (rev 3286)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/SingleMethodCallCommand.java 2010-10-11 11:27:31 UTC (rev 3287)
@@ -88,9 +88,9 @@
}
this.component = component;
this.method = component.getClass().getDeclaredMethod(methodName, parameterTypes);
- if (!Modifier.isPublic(method.getModifiers()))
+ if (Modifier.isPrivate(method.getModifiers()))
{
- throw new IllegalArgumentException("The method '" + methodName + "' is not public");
+ throw new IllegalArgumentException("The method '" + methodName + "' cannot be private");
}
this.id = getId(component, method);
}
15 years, 9 months
exo-jcr SVN: r3286 - in jcr/trunk: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-10-11 06:03:48 -0400 (Mon, 11 Oct 2010)
New Revision: 3286
Modified:
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml
Log:
EXOJCR-997: Whole Repository backup support in Backup Console tool
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClient.java 2010-10-11 10:03:48 UTC (rev 3286)
@@ -31,72 +31,108 @@
{
/**
- * Start Backup.
+ * Start backup of repository or workspace.
+ * If workspaceName is 'null', then repository backup will be started.
*
- * @param repositoryName String, the repository name.
- * @param workspaceName String, the workspace name.
- * @param backupDir path to backup folder on remote server.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param repositoryName
+ * String, the repository name.
+ * @param workspaceName
+ * String, the workspace name.
+ * @param backupDir
+ * path to backup folder on remote server
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception.
+ * @throws BackupExecuteException
+ * backup client internal exception.
*/
String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException,
BackupExecuteException;
/**
- * Start Incremental Backup.
+ * Start Incremental Backup of repository or workspace.
+ * If workspaceName is 'null', then repository backup will be started.
*
- * @param repositoryName String, the repository name.
- * @param workspaceName String, the workspace name.
- * @param incr incemental job period.
- * @param backupDir path to backup folder on remote server.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param repositoryName
+ * String, the repository name
+ * @param workspaceName
+ * String, the workspace name
+ * @param incr
+ * incremental job period.
+ * @param backupDir
+ * path to backup folder on remote server
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr)
throws IOException, BackupExecuteException;
/**
- * Get Status.
+ * Get Status of backup.
*
- * @param backupId the backup identifier.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param backupId
+ * the backup identifier.
+ * @return String
+ * result.
+ * @throws IOException
+ * transport exception.
+ * @throws BackupExecuteException
+ * backup client internal exception.
*/
String status(String backupId) throws IOException, BackupExecuteException;
/**
* Get information about backup service.
*
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String info() throws IOException, BackupExecuteException;
/**
- * Get information about current restores.
+ * Get information about current restores of repository or workspace.
+ * If workspaceName is 'null', then will be get status of repository backup.
*
- * @param repositoryName String, the repository name.
- * @param workspaceName String, the workspace name.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param repositoryName
+ * String, the repository name
+ * @param workspaceName
+ * String, the workspace name
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException;
/**
- * Restore repository from backup file.
+ * Restore repository or workspace from backup file.
+ * If workspaceName is 'null', then will be run restore of repository.
*
- * @param repositoryName String, the repository name.
- * @param workspaceName String, the workspace name.
- * @param backupId the backup identifier.
- * @param config InputStream contains workspace configuration.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param repositoryName
+ * String, the repository name
+ * @param workspaceName
+ * String, the workspace name
+ * @param backupId
+ * the backup identifier
+ * @param config
+ * InputStream contains workspace configuration
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String restore(String repositoryName, String workspaceName, String backupId, InputStream config) throws IOException,
BackupExecuteException;
@@ -104,22 +140,33 @@
/**
* Stop backup.
*
- * @param backupId the backup identifier.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param backupId
+ * the backup identifier
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String stop(String backupId) throws IOException, BackupExecuteException;
/**
- * Drop backup.
+ * Drop workspace or repository.
+ * If workspaceName is 'null', then repository will be dropped.
*
- * @param forceClose force sessions close on droped workspace.
- * @param repositoryName String, the repository name.
- * @param workspaceName String, the workspace name.
- * @return String result.
- * @throws IOException transport exception.
- * @throws BackupExecuteException backup client internal exception.
+ * @param forceClose
+ * force sessions close on repository or workspace
+ * @param repositoryName
+ * String, the repository name
+ * @param workspaceName
+ * String, the workspace name
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
BackupExecuteException;
@@ -127,18 +174,24 @@
/**
* Get information about the current backups (in progress).
*
- * @return String result
- * @throws IOException
- * @throws BackupExecuteException
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String list() throws IOException, BackupExecuteException;
/**
* Get information about the completed (ready to restore) backups.
*
- * @return String result
- * @throws IOException
- * @throws BackupExecuteException
+ * @return String
+ * result
+ * @throws IOException
+ * transport exception
+ * @throws BackupExecuteException
+ * backup client internal exception
*/
String listCompleted() throws IOException, BackupExecuteException;
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2010-10-11 10:03:48 UTC (rev 3286)
@@ -18,12 +18,22 @@
*/
package org.exoplatform.jcr.backupconsole;
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.ws.rs.core.Response;
+
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.ext.backup.BackupJob;
import org.exoplatform.services.jcr.ext.backup.BackupManager;
+import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
+import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
import org.exoplatform.services.jcr.ext.backup.server.HTTPBackupAgent;
import org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean;
@@ -31,6 +41,7 @@
import org.exoplatform.services.jcr.ext.backup.server.bean.response.DetailedInfo;
import org.exoplatform.services.jcr.ext.backup.server.bean.response.ShortInfo;
import org.exoplatform.services.jcr.ext.backup.server.bean.response.ShortInfoList;
+import org.exoplatform.services.jcr.ext.repository.RestRepositoryService;
import org.exoplatform.ws.frameworks.json.JsonHandler;
import org.exoplatform.ws.frameworks.json.JsonParser;
import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
@@ -44,550 +55,1080 @@
import org.jibx.runtime.IUnmarshallingContext;
import org.jibx.runtime.JiBXException;
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import javax.ws.rs.core.Response;
-
/**
* Created by The eXo Platform SAS. <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
* @version $Id: BackupClientImpl.java 111 2008-11-11 11:11:11Z serg $
*/
-public class BackupClientImpl implements BackupClient {
+public class BackupClientImpl
+ implements BackupClient
+{
- /**
- * Block size.
- */
- private static final int BLOCK_SIZE = 1024;
+ /**
+ * Block size.
+ */
+ private static final int BLOCK_SIZE = 1024;
- /**
- * Client transport.
- */
- private ClientTransport transport;
-
- /**
- * The URL path.
- */
- private final String path;
+ /**
+ * Client transport.
+ */
+ private ClientTransport transport;
- /**
- * User login.
- */
- private final String userName;
+ /**
+ * The URL path.
+ */
+ private final String path;
- /**
- * User password.
- */
- private final String pass;
-
- /**
- * Constructor.
- *
- * @param transport ClientTransport implementation.
- * @param login user login.
- * @param pass user password.
- */
- public BackupClientImpl(ClientTransport transport, String login, String pass, String urlPath) {
- this.transport = transport;
- this.userName = login;
- this.pass = pass;
-
- if (urlPath == null)
- path = "/rest";
- else
- path = urlPath;
- }
-
- /**
- * {@inheritDoc}
- */
- public String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.START_BACKUP +
- "/" + repositoryName +
- "/" + workspaceName;
+ /**
+ * User login.
+ */
+ private final String userName;
- BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY,
- backupDir);
-
- JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
- JsonValue json;
- try {
- json = generatorImpl.createJsonObject(bean);
- } catch (JsonException e) {
- throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
- }
-
- BackupAgentResponse response = transport.executePOST(sURL, json.toString());
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- return "\nSuccessful : \n" +
- "\tstatus code = " + response.getStatus() + "\n";
- } else {
- return failureProcessing(response);
- }
- }
+ /**
+ * User password.
+ */
+ private final String pass;
- /**
- * {@inheritDoc}
- */
- public String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr) throws IOException,
- BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.START_BACKUP +
- "/" + repositoryName +
- "/" + workspaceName;
+ /**
+ * Constructor.
+ *
+ * @param transport ClientTransport implementation.
+ * @param login user login.
+ * @param pass user password.
+ */
+ public BackupClientImpl(ClientTransport transport, String login, String pass, String urlPath)
+ {
+ this.transport = transport;
+ this.userName = login;
+ this.pass = pass;
- BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL,
- backupDir,
- incr);
-
- JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
- JsonValue json;
- try {
- json = generatorImpl.createJsonObject(bean);
- } catch (JsonException e) {
- throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
- }
-
- BackupAgentResponse response = transport.executePOST(sURL, json.toString());
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- return "\nSuccessful : \n" +
- "\tstatus code = " + response.getStatus() + "\n";
- } else {
- return failureProcessing(response);
- }
- }
+ if (urlPath == null)
+ path = "/rest";
+ else
+ path = urlPath;
+ }
- /**
- * {@inheritDoc}
- */
- public String status(String backupId) throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_INFO +
- "/" + backupId;
+ /**
+ * {@inheritDoc}
+ */
+ public String startBackUp(String repositoryName, String workspaceName, String backupDir) throws IOException,
+ BackupExecuteException
+ {
+ if (workspaceName != null)
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.START_BACKUP
+ + "/" + repositoryName + "/" + workspaceName;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- DetailedInfo info;
- try {
- info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
- } catch (Exception e) {
- throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+ BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
+ try
+ {
+ json = generatorImpl.createJsonObject(bean);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
+ }
+
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
}
-
- if (info.getType() == DetailedInfo.COMPLETED) {
- String result = "\nThe completed (ready to restore) backup information : \n";
-
- BackupConfigBean configBean = info.getBackupConfig();
-
- result += ("\t\tbackup id : " + info.getBackupId() + "\n"
- + "\t\tbackup folder : " + configBean.getBackupDir() + "\n"
- + "\t\trepository name : " + info.getRepositoryName() + "\n"
- + "\t\tworkspace name : " + info.getWorkspaceName() + "\n"
- + "\t\tbackup type : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
- + "\t\tstarted time : " + info.getStartedTime() + "\n"
- + (info.getFinishedTime().equals("") ? "\n" :
- "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
-
- return result;
- } else {
- String result = "\nThe current backup information : \n";
-
- BackupConfigBean configBean = info.getBackupConfig();
-
- result += ("\t\tbackup id : " + info.getBackupId() + "\n"
- + "\t\tbackup folder : " + configBean.getBackupDir() + "\n"
- + "\t\trepository name : " + info.getRepositoryName() + "\n"
- + "\t\tworkspace name : " + info.getWorkspaceName() + "\n"
- + "\t\tbackup type : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
- + "\t\tfull backup state : " + getState(info.getState())) + "\n"
- + (info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? "" :
- "\t\tincremental backup state : " + "working" + "\n")
- + "\t\tstarted time : " + info.getStartedTime() + "\n"
- + (info.getFinishedTime().equals("") ? "\n" :
- "\t\tfinished time : " + info.getFinishedTime() + "\n\n");
-
- return result;
+ else
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;
+
+ BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
+ try
+ {
+ json = generatorImpl.createJsonObject(bean);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
+ }
+
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
}
- } else {
- return failureProcessing(response);
- }
- }
+ }
- /**
- * {@inheritDoc}
- */
- public String stop(String backupId) throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.STOP_BACKUP +
- "/" + backupId;
+ /**
+ * {@inheritDoc}
+ */
+ public String startIncrementalBackUp(String repositoryName, String workspaceName, String backupDir, long incr)
+ throws IOException, BackupExecuteException
+ {
+ if (workspaceName != null)
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.START_BACKUP
+ + "/" + repositoryName + "/" + workspaceName;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- return "\nSuccessful : \n" +
- "\tstatus code = " + response.getStatus() + "\n";
- } else {
- return failureProcessing(response);
- }
- }
+ BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);
- /**
- * {@inheritDoc}
- */
- public String restore(String repositoryName, String workspaceName, String backupId, InputStream config) throws IOException,
- BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.RESTORE +
- "/" + repositoryName +
- "/" + backupId;
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
+ try
+ {
+ json = generatorImpl.createJsonObject(bean);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
+ }
-
- WorkspaceEntry wEntry = null;
- try {
- wEntry = getWorkspaceEntry(config, repositoryName, workspaceName);
- } catch (Throwable e) {
- throw new BackupExecuteException("Can not get WorkspaceEntry for workspace '" + workspaceName + "' from config.", e);
- }
-
- JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
- JsonValue json;
-
- try {
- json = generatorImpl.createJsonObject(wEntry);
- } catch (JsonException e) {
- throw new BackupExecuteException("Can not get json from : " + wEntry.getClass().toString(), e);
- }
-
- BackupAgentResponse response = transport.executePOST(sURL, json.toString());
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- return "\nSuccessful : \n" +
- "\tstatus code = " + response.getStatus() + "\n";
- } else {
- return failureProcessing(response);
- }
- }
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
- /**
- * {@inheritDoc}
- */
- public String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
- BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.DROP_WORKSPACE +
- "/" + repositoryName +
- "/" + workspaceName +
- "/" + forceClose;
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ else
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- return "\nSuccessful : \n" +
- "\tstatus code = " + response.getStatus() + "\n";
- } else {
- return failureProcessing(response);
- }
- }
+ BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);
- /**
- * {@inheritDoc}
- */
- public String info() throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.BACKUP_SERVICE_INFO;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- BackupServiceInfoBean info;
- try {
- info = (BackupServiceInfoBean) getObject(BackupServiceInfoBean.class, response.getResponseData());
- } catch (Exception e) {
- throw new RuntimeException("Can not get BackupServiceInfoBean from responce.", e);
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
+ try
+ {
+ json = generatorImpl.createJsonObject(bean);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + bean.getClass().toString(), e);
+ }
+
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
}
-
- String result = "\nThe backup service information : \n"
- + "\tfull backup type : " + info.getFullBackupType() + "\n"
- + "\tincremetal backup type : " + info.getIncrementalBackupType() + "\n"
- + "\tbackup log folder : " + info.getBackupLogDir() + "\n"
- + "\tdefault incremental job period : " + info.getDefaultIncrementalJobPeriod() + "\n\n";
-
- return result;
- } else {
- return failureProcessing(response);
- }
- }
- /**
- * {@inheritDoc}
- */
- public String list() throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- ShortInfoList infoList;
- try {
- infoList = (ShortInfoList) getObject(ShortInfoList.class, response.getResponseData());
- } catch (Exception e) {
- throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String status(String backupId) throws IOException, BackupExecuteException
+ {
+
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_REPOSITORY_INFO + "/"
+ + backupId;
+
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() != Response.Status.OK.getStatusCode())
+ {
+
+ sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_INFO + "/" + backupId;
+
+ response = transport.executeGET(sURL);
}
-
- String result = "\nThe current backups information : \n";
-
- if (infoList.getBackups().size() == 0)
- result += "\tNo active backups.\n\n";
-
- int count = 1;
- for (ShortInfo shortInfo : infoList.getBackups()) {
- result += "\t" + count + ") Backup with id " + shortInfo.getBackupId() + " :\n";
-
- result += ("\t\trepository name : " + shortInfo.getRepositoryName() + "\n"
- + "\t\tworkspace name : " + shortInfo.getWorkspaceName() + "\n"
- + "\t\tbackup type : " + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
- + "\t\tfull backup state : " + getState(shortInfo.getState())) + "\n"
- + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? "" :
- "\t\tincremental backup state : " + "working" + "\n")
- + "\t\tstarted time : " + shortInfo.getStartedTime() + "\n"
- + (shortInfo.getFinishedTime().equals("") ? "" :
- "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n");
- count++;
- }
-
- return result;
- } else {
- return failureProcessing(response);
- }
- }
- /**
- * {@inheritDoc}
- */
- public String listCompleted() throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- ShortInfoList infoList;
- try {
- infoList = (ShortInfoList) getObject(ShortInfoList.class, response.getResponseData());
- new String(response.getResponseData());
- } catch (Exception e) {e.printStackTrace();
- throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ DetailedInfo info;
+ try
+ {
+ info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+ }
+
+ if (info.getType() == DetailedInfo.COMPLETED)
+ {
+ String result = "\nThe completed (ready to restore) backup information : \n";
+
+ BackupConfigBean configBean = info.getBackupConfig();
+
+ result +=
+ ("\t\tbackup id : "
+ + info.getBackupId()
+ + "\n"
+ + "\t\tbackup folder : "
+ + configBean.getBackupDir()
+ + "\n"
+ + "\t\trepository name : "
+ + info.getRepositoryName()
+ + "\n"
+ + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
+ + info.getWorkspaceName() + "\n")
+ + "\t\tbackup type : "
+ + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tstarted time : " + info.getStartedTime()
+ + "\n" + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
+ + info.getFinishedTime() + "\n\n"));
+
+ return result;
+ }
+ else
+ {
+ String result = "\nThe current backup information : \n";
+
+ BackupConfigBean configBean = info.getBackupConfig();
+
+ result +=
+ ("\t\tbackup id : "
+ + info.getBackupId()
+ + "\n"
+ + "\t\tbackup folder : "
+ + configBean.getBackupDir()
+ + "\n"
+ + "\t\trepository name : "
+ + info.getRepositoryName()
+ + "\n"
+ + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
+ + info.getWorkspaceName() + "\n")
+ + "\t\tbackup type : "
+ + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tfull backup state : " + getState(info
+ .getState()))
+ + "\n"
+ + (info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backup state : " + "working" + "\n")
+ + "\t\tstarted time : "
+ + info.getStartedTime()
+ + "\n"
+ + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
+ + info.getFinishedTime() + "\n\n");
+
+ return result;
+ }
}
-
- String result = "\nThe completed (ready to restore) backups information : \n";
-
- if (infoList.getBackups().size() == 0)
- result += "\tNo completed backups.\n\n";
-
- int count = 1;
- for (ShortInfo shortInfo : infoList.getBackups()) {
- result += "\t" + count + ") Backup with id " + shortInfo.getBackupId() + " :\n";
-
- result += ("\t\trepository name : " + shortInfo.getRepositoryName() + "\n"
- + "\t\tworkspace name : " + shortInfo.getWorkspaceName() + "\n"
- + "\t\tbackup type : " + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
- + "\t\tstarted time : " + shortInfo.getStartedTime() + "\n"
- + (shortInfo.getFinishedTime().equals("") ? "\n" :
- "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n"));
- count++;
- }
-
- return result;
- } else {
- return failureProcessing(response);
- }
- }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException {
- String sURL = path + HTTPBackupAgent.Constants.BASE_URL +
- HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS +
- "/" + repositoryName +
- "/" + workspaceName;
- BackupAgentResponse response = transport.executeGET(sURL);
-
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- DetailedInfo info;
- try {
- info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
- } catch (Exception e) {
- throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+ /**
+ * {@inheritDoc}
+ */
+ public String stop(String backupId) throws IOException, BackupExecuteException
+ {
+ // first try to find current repository backup
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO;
+
+ BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+ if (repositoryResponse.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ ShortInfoList repositoryInfoList;
+ try
+ {
+ repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ for (ShortInfo info : repositoryInfoList.getBackups())
+ {
+ if (info.getBackupId().equals(backupId))
+ {
+ // repository backup
+ sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP_REPOSITORY + "/" + backupId;
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ }
}
-
-
- String result = "\nThe current restores information : \n";
-
- result += "\tRestore with id " + info.getBackupId() + ":\n";
-
- BackupConfigBean configBean = info.getBackupConfig();
-
- result += ("\t\tbackup folder : " + configBean.getBackupDir() + "\n"
- + "\t\trepository name : " + info.getRepositoryName() + "\n"
- + "\t\tworkspace name : " + info.getWorkspaceName() + "\n"
- + "\t\tbackup type : " + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal" : "full only") + "\n"
- + "\t\trestore state : " + getRestoreState(info.getState()) + "\n"
- + "\t\tstarted time : " + info.getStartedTime() + "\n"
- + (info.getFinishedTime().equals("") ? "\n" :
- "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
-
- return result;
- } else {
- return failureProcessing(response);
- }
- }
-
-
- /**
- * Will be created the Object from JSON binary data.
- *
- * @param cl
- * Class
- * @param data
- * binary data (JSON)
- * @return Object
- * @throws Exception
- * will be generated Exception
- */
- private Object getObject(Class cl, byte[] data) throws Exception {
- JsonHandler jsonHandler = new JsonDefaultHandler();
- JsonParser jsonParser = new JsonParserImpl();
- InputStream inputStream = new ByteArrayInputStream(data);
- jsonParser.parse(inputStream, jsonHandler);
- JsonValue jsonValue = jsonHandler.getJsonObject();
- return new BeanBuilder().createObject(cl, jsonValue);
- }
-
-
- private String getRestoreState(int restoreState) {
- String state = "unknown sate of restore";
-
- switch (restoreState) {
- case JobWorkspaceRestore.RESTORE_INITIALIZED:
- state = "initialized";
- break;
-
- case JobWorkspaceRestore.RESTORE_STARTED:
- state = "started";
- break;
-
- case JobWorkspaceRestore.RESTORE_SUCCESSFUL:
- state = "successful";
- break;
-
- case JobWorkspaceRestore.RESTORE_FAIL:
- state = "fail";
- break;
+ // then try to find current workspace backup
+ sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
- default:
- break;
- }
-
- return state;
- }
-
- /**
- * getState.
- *
- * @param state
- * value of state
- * @return String sate
- */
- private String getState(int state) {
- String st = "";
- switch (state) {
+ BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+ if (workspaceResponse.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ ShortInfoList workspaceInfoList;
+ try
+ {
+ workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
- case BackupJob.FINISHED:
- st = "finished";
- break;
+ for (ShortInfo info : workspaceInfoList.getBackups())
+ {
+ if (info.getBackupId().equals(backupId))
+ {
+ // workspace backup
+ sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP
+ + "/" + backupId;
- case BackupJob.WORKING:
- st = "working";
- break;
+ BackupAgentResponse response = transport.executeGET(sURL);
- case BackupJob.WAITING:
- st = "waiting";
- break;
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ }
+ }
- case BackupJob.STARTING:
- st = "starting";
- break;
- default:
- break;
- }
+ return "\nFailure :\n" + "\tmessage : There are no active backup with id " + backupId;
+ }
- return st;
- }
-
- /**
- * failureProcessing.
- *
- * @param data
- * response data
- * @return String
- * result
- * @throws BackupExecuteException
- * will be generated BackupExecuteException
- */
- private String failureProcessing(BackupAgentResponse response) throws BackupExecuteException {
- try {
- String result = "\nFailure :\n"
- + "\tsatatus code : " + response.getStatus() + "\n"
- + "\tmessage : " + new String(response.getResponseData(), "UTF-8") + "\n\n";
-
- return result;
- } catch (UnsupportedEncodingException e) {
- throw new BackupExecuteException("Can not encoded the responce : " + e.getMessage(), e);
- }
- }
-
- /**
- * getWorkspaceEntry.
- *
- * @param wEntryStream
- * InputStream, the workspace configuration
- * @param workspaceName
- * String, the workspace name
- * @return WorkspaceEntry
- * return the workspace entry
- * @throws FileNotFoundException
- * will be generated the FileNotFoundException
- * @throws JiBXException
- * will be generated the JiBXException
- * @throws RepositoryConfigurationException
- * will be generated the RepositoryConfigurationException
- */
- private WorkspaceEntry getWorkspaceEntry(InputStream wEntryStream, String repositoryName, String workspaceName) throws FileNotFoundException,
- JiBXException,
- RepositoryConfigurationException {
- WorkspaceEntry wsEntry = null;
+ /**
+ * {@inheritDoc}
+ */
+ public String restore(String repositoryName, String workspaceName, String backupId, InputStream config)
+ throws IOException, BackupExecuteException
+ {
+ if (workspaceName != null)
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.RESTORE + "/"
+ + repositoryName + "/" + backupId;
- IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
- IUnmarshallingContext uctx = factory.createUnmarshallingContext();
- RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration) uctx.unmarshalDocument(wEntryStream,
- null);
- RepositoryEntry rEntry = conf.getRepositoryConfiguration(repositoryName);
-
- for (WorkspaceEntry wEntry : rEntry.getWorkspaceEntries())
- if (wEntry.getName().equals(workspaceName))
- wsEntry = wEntry;
-
+ WorkspaceEntry wEntry = null;
+ try
+ {
+ wEntry = getWorkspaceEntry(config, repositoryName, workspaceName);
+ }
+ catch (Throwable e)
+ {
+ throw new BackupExecuteException("Can not get WorkspaceEntry for workspace '" + workspaceName
+ + "' from config.", e);
+ }
- if (wsEntry == null)
- throw new RuntimeException("Can not find the workspace '" + workspaceName
- + "' in configuration.");
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
- return wsEntry;
- }
+ try
+ {
+ json = generatorImpl.createJsonObject(wEntry);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + wEntry.getClass().toString(), e);
+ }
+
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ else
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY + "/" + backupId;
+
+ RepositoryEntry wEntry = null;
+ try
+ {
+ wEntry = getRepositoryEntry(config, repositoryName);
+ }
+ catch (Throwable e)
+ {
+ throw new BackupExecuteException("Can not get RepositoryEntry for repository '" + repositoryName
+ + "' from config.", e);
+ }
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json;
+
+ try
+ {
+ json = generatorImpl.createJsonObject(wEntry);
+ }
+ catch (JsonException e)
+ {
+ throw new BackupExecuteException("Can not get json from : " + wEntry.getClass().toString(), e);
+ }
+
+ BackupAgentResponse response = transport.executePOST(sURL, json.toString());
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String drop(boolean forceClose, String repositoryName, String workspaceName) throws IOException,
+ BackupExecuteException
+ {
+ if (workspaceName != null)
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.DROP_WORKSPACE
+ + "/" + repositoryName + "/" + workspaceName + "/" + forceClose;
+
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ else
+ {
+ String sURL =
+ path + RestRepositoryService.Constants.BASE_URL
+ + RestRepositoryService.Constants.OperationType.REMOVE_REPOSITORY + "/" + repositoryName
+ + "/" + forceClose;
+
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String info() throws IOException, BackupExecuteException
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.BACKUP_SERVICE_INFO;
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ BackupServiceInfoBean info;
+ try
+ {
+ info = (BackupServiceInfoBean) getObject(BackupServiceInfoBean.class, response.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get BackupServiceInfoBean from responce.", e);
+ }
+
+ String result =
+ "\nThe backup service information : \n" + "\tfull backup type : "
+ + info.getFullBackupType() + "\n" + "\tincremetal backup type : "
+ + info.getIncrementalBackupType() + "\n" + "\tbackup log folder : "
+ + info.getBackupLogDir() + "\n" + "\tdefault incremental job period : "
+ + info.getDefaultIncrementalJobPeriod() + "\n\n";
+
+ return result;
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String list() throws IOException, BackupExecuteException
+ {
+
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO;
+ BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+ sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_INFO;
+ BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+
+ if ((repositoryResponse.getStatus() == Response.Status.OK.getStatusCode())
+ && (workspaceResponse.getStatus() == Response.Status.OK.getStatusCode()))
+ {
+ ShortInfoList repositoryInfoList;
+ try
+ {
+ repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ ShortInfoList workspaceInfoList;
+ try
+ {
+ workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ String result = "\nThe current backups information : \n";
+
+ if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
+ {
+ result += "\tNo active backups.\n\n";
+ }
+
+ int count = 1;
+ for (ShortInfo shortInfo : repositoryInfoList.getBackups())
+ {
+ result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
+
+ result +=
+ ("\t\trepository name : "
+ + shortInfo.getRepositoryName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tfull backups state : " + getRepositoryBackupToFullState(shortInfo
+ .getState()))
+ + "\n"
+ + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backups state : " + "working" + "\n")
+ + "\t\tstarted time : "
+ + shortInfo.getStartedTime()
+ + "\n"
+ + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
+ + shortInfo.getFinishedTime() + "\n");
+ count++;
+ }
+
+ for (ShortInfo shortInfo : workspaceInfoList.getBackups())
+ {
+ result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+
+ result +=
+ ("\t\trepository name : "
+ + shortInfo.getRepositoryName()
+ + "\n"
+ + "\t\tworkspace name : "
+ + shortInfo.getWorkspaceName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tfull backup state : " + getState(shortInfo
+ .getState()))
+ + "\n"
+ + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backup state : " + "working" + "\n")
+ + "\t\tstarted time : "
+ + shortInfo.getStartedTime()
+ + "\n"
+ + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
+ + shortInfo.getFinishedTime() + "\n");
+ count++;
+ }
+
+ return result;
+ }
+ else
+ {
+ return failureProcessing(workspaceResponse);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String listCompleted() throws IOException, BackupExecuteException
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_REPOSITORY_INFO;
+ BackupAgentResponse repositoryResponse = transport.executeGET(sURL);
+
+ sURL = path + HTTPBackupAgent.Constants.BASE_URL + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO;
+ BackupAgentResponse workspaceResponse = transport.executeGET(sURL);
+
+ if ((workspaceResponse.getStatus() == Response.Status.OK.getStatusCode())
+ && (repositoryResponse.getStatus() == Response.Status.OK.getStatusCode()))
+ {
+
+ ShortInfoList repositoryInfoList;
+ try
+ {
+ repositoryInfoList = (ShortInfoList) getObject(ShortInfoList.class, repositoryResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ ShortInfoList workspaceInfoList;
+ try
+ {
+ workspaceInfoList = (ShortInfoList) getObject(ShortInfoList.class, workspaceResponse.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get ShortInfoList from responce.", e);
+ }
+
+ String result = "\nThe completed (ready to restore) backups information : \n";
+
+ if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
+ {
+ result += "\tNo completed backups.\n\n";
+ }
+
+ int count = 1;
+ for (ShortInfo shortInfo : repositoryInfoList.getBackups())
+ {
+ result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
+
+ result +=
+ ("\t\trepository name : "
+ + shortInfo.getRepositoryName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tstarted time : "
+ + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n"));
+ count++;
+ }
+
+ for (ShortInfo shortInfo : workspaceInfoList.getBackups())
+ {
+ result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+
+ result +=
+ ("\t\trepository name : "
+ + shortInfo.getRepositoryName()
+ + "\n"
+ + "\t\tworkspace name : "
+ + shortInfo.getWorkspaceName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\tstarted time : "
+ + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n"));
+ count++;
+ }
+
+ return result;
+ }
+ else
+ {
+ return failureProcessing(workspaceResponse);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String restores(String repositoryName, String workspaceName) throws IOException, BackupExecuteException
+ {
+ if (workspaceName != null)
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS + "/" + repositoryName
+ + "/" + workspaceName;
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ DetailedInfo info;
+ try
+ {
+ info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+ }
+
+ String result = "\nThe current restores information : \n";
+
+ result += "\tWorkspace restore with id " + info.getBackupId() + ":\n";
+
+ BackupConfigBean configBean = info.getBackupConfig();
+
+ result +=
+ ("\t\tbackup folder : "
+ + configBean.getBackupDir()
+ + "\n"
+ + "\t\trepository name : "
+ + info.getRepositoryName()
+ + "\n"
+ + "\t\tworkspace name : "
+ + info.getWorkspaceName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\trestore state : "
+ + getRestoreState(info.getState()) + "\n" + "\t\tstarted time : "
+ + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
+
+ return result;
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ else
+ {
+ String sURL =
+ path + HTTPBackupAgent.Constants.BASE_URL
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_REPOSITORY + "/"
+ + repositoryName;
+
+ BackupAgentResponse response = transport.executeGET(sURL);
+
+ if (response.getStatus() == Response.Status.OK.getStatusCode())
+ {
+ DetailedInfo info;
+ try
+ {
+ info = (DetailedInfo) getObject(DetailedInfo.class, response.getResponseData());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can not get DetailedInfo from responce.", e);
+ }
+
+ String result = "\nThe current restores information : \n";
+
+ result += "\tRepository restore with id " + info.getBackupId() + ":\n";
+
+ BackupConfigBean configBean = info.getBackupConfig();
+
+ result +=
+ ("\t\tbackup folder : "
+ + configBean.getBackupDir()
+ + "\n"
+ + "\t\trepository name : "
+ + info.getRepositoryName()
+ + "\n"
+ + "\t\tbackup type : "
+ + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremetal"
+ : "full only") + "\n" + "\t\trestore state : "
+ + getRepositoryRestoreState(info.getState()) + "\n" + "\t\tstarted time : "
+ + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
+
+ return result;
+ }
+ else
+ {
+ return failureProcessing(response);
+ }
+ }
+ }
+
+ /**
+ * Will be created the Object from JSON binary data.
+ *
+ * @param cl
+ * Class
+ * @param data
+ * binary data (JSON)
+ * @return Object
+ * @throws Exception
+ * will be generated Exception
+ */
+ private Object getObject(Class cl, byte[] data) throws Exception
+ {
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ JsonParser jsonParser = new JsonParserImpl();
+ InputStream inputStream = new ByteArrayInputStream(data);
+ jsonParser.parse(inputStream, jsonHandler);
+ JsonValue jsonValue = jsonHandler.getJsonObject();
+
+ return new BeanBuilder().createObject(cl, jsonValue);
+ }
+
+ private String getRestoreState(int restoreState)
+ {
+ String state = "unknown sate of restore";
+
+ switch (restoreState)
+ {
+ case JobWorkspaceRestore.RESTORE_INITIALIZED :
+ state = "initialized";
+ break;
+
+ case JobWorkspaceRestore.RESTORE_STARTED :
+ state = "started";
+ break;
+
+ case JobWorkspaceRestore.RESTORE_SUCCESSFUL :
+ state = "successful";
+ break;
+
+ case JobWorkspaceRestore.RESTORE_FAIL :
+ state = "fail";
+ break;
+
+ default :
+ break;
+ }
+
+ return state;
+ }
+
+ private String getRepositoryRestoreState(int restoreState)
+ {
+ String state = "unknown sate of restore";
+
+ switch (restoreState)
+ {
+ case JobRepositoryRestore.REPOSITORY_RESTORE_INITIALIZED :
+ state = "initialized";
+ break;
+
+ case JobRepositoryRestore.REPOSITORY_RESTORE_STARTED :
+ state = "started";
+ break;
+
+ case JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL :
+ state = "successful";
+ break;
+
+ case JobRepositoryRestore.REPOSITORY_RESTORE_FAIL :
+ state = "fail";
+ break;
+
+ default :
+ break;
+ }
+
+ return state;
+ }
+
+ /**
+ * getState.
+ *
+ * @param state
+ * value of state
+ * @return String sate
+ */
+ private String getState(int state)
+ {
+ String st = "";
+ switch (state)
+ {
+
+ case BackupJob.FINISHED :
+ st = "finished";
+ break;
+
+ case BackupJob.WORKING :
+ st = "working";
+ break;
+
+ case BackupJob.WAITING :
+ st = "waiting";
+ break;
+
+ case BackupJob.STARTING :
+ st = "starting";
+ break;
+ default :
+ break;
+ }
+
+ return st;
+ }
+
+ /**
+ * getState.
+ *
+ * @param state
+ * value of state
+ * @return String sate
+ */
+ private String getRepositoryBackupToFullState(int state)
+ {
+ String st = "";
+ switch (state)
+ {
+
+ case RepositoryBackupChain.FINISHED :
+ st = "finished";
+ break;
+
+ case RepositoryBackupChain.WORKING :
+ st = "working";
+ break;
+
+ case RepositoryBackupChain.INITIALIZED :
+ st = "initialized";
+ break;
+
+ case RepositoryBackupChain.FULL_BACKUP_FINISHED_INCREMENTAL_BACKUP_WORKING :
+ st = "finished";
+ break;
+ default :
+ break;
+ }
+
+ return st;
+ }
+
+ /**
+ * failureProcessing.
+ *
+ * @param data
+ * response data
+ * @return String
+ * result
+ * @throws BackupExecuteException
+ * will be generated BackupExecuteException
+ */
+ private String failureProcessing(BackupAgentResponse response) throws BackupExecuteException
+ {
+ try
+ {
+ String result =
+ "\nFailure :\n" + "\tstatus code : " + response.getStatus() + "\n" + "\tmessage : "
+ + new String(response.getResponseData(), "UTF-8") + "\n\n";
+
+ return result;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new BackupExecuteException("Can not encoded the responce : " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * getRepositoryEntry.
+ *
+ * @param wEntryStream
+ * InputStream, the workspace configuration
+ * @return RepositoryEntry
+ * return the workspace entry
+ * @throws FileNotFoundException
+ * will be generated the FileNotFoundException
+ * @throws JiBXException
+ * will be generated the JiBXException
+ * @throws RepositoryConfigurationException
+ * will be generated the RepositoryConfigurationException
+ */
+ private RepositoryEntry getRepositoryEntry(InputStream wEntryStream, String repositoryName)
+ throws FileNotFoundException, JiBXException, RepositoryConfigurationException
+ {
+ IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
+ IUnmarshallingContext uctx = factory.createUnmarshallingContext();
+ RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration) uctx.unmarshalDocument(wEntryStream, null);
+ RepositoryEntry rEntry = conf.getRepositoryConfiguration(repositoryName);
+
+ return rEntry;
+ }
+
+ /**
+ * getWorkspaceEntry.
+ *
+ * @param wEntryStream
+ * InputStream, the workspace configuration
+ * @param workspaceName
+ * String, the workspace name
+ * @return WorkspaceEntry
+ * return the workspace entry
+ * @throws FileNotFoundException
+ * will be generated the FileNotFoundException
+ * @throws JiBXException
+ * will be generated the JiBXException
+ * @throws RepositoryConfigurationException
+ * will be generated the RepositoryConfigurationException
+ */
+ private WorkspaceEntry getWorkspaceEntry(InputStream wEntryStream, String repositoryName, String workspaceName)
+ throws FileNotFoundException, JiBXException, RepositoryConfigurationException
+ {
+ RepositoryEntry rEntry = getRepositoryEntry(wEntryStream, repositoryName);
+
+ WorkspaceEntry wsEntry = null;
+
+ for (WorkspaceEntry wEntry : rEntry.getWorkspaceEntries())
+ if (wEntry.getName().equals(workspaceName))
+ wsEntry = wEntry;
+
+ if (wsEntry == null)
+ throw new RuntimeException("Can not find the workspace '" + workspaceName + "' in configuration.");
+
+ return wsEntry;
+ }
+
}
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupConsole.java 2010-10-11 10:03:48 UTC (rev 3286)
@@ -58,25 +58,33 @@
*/
private static final String HELP_INFO =
"Help info:\n" + " <url> <cmd> \n" + " <url> : http(s)//login:password@host:port/<context> \n"
- + " <cmd> : start <repo/ws> <backup_dir> [<incr>] \n" + " stop <backup_id> \n"
- + " status <backup_id> \n" + " restores <repo/ws> \n"
- + " restore <repo/ws> <backup_id> <pathToConfigFile> \n" + " list [completed] \n"
- + " info \n" + " drop [force-close-session] <repo/ws> \n" + " help \n\n"
+ + " <cmd> : start <repo[/ws]> <backup_dir> [<incr>] \n"
+ + " stop <backup_id> \n"
+ + " status <backup_id> \n"
+ + " restores <repo[/ws]> \n"
+ + " restore <repo[/ws]> <backup_id> <pathToConfigFile> \n"
+ + " list [completed] \n"
+ + " info \n"
+ + " drop [force-close-session] <repo[/ws]> \n"
+ + " help \n\n"
- + " start - start backup \n" + " stop - stop backup \n"
+ + " start - start backup of repositpry or workspace \n"
+ + " stop - stop backup \n"
+ " status - information about the current or completed backup by 'backup_id' \n"
- + " restores - information about the last restore on specific workspace \n"
- + " restore - restore the workspace from specific backup \n"
+ + " restores - information about the last restore on specific repository or workspace \n"
+ + " restore - restore the repository or workspace from specific backup \n"
+ " list - information about the current backups (in progress) \n"
+ " list completed - information about the completed (ready to restore) backups \n"
- + " info - information about the service backup \n" + " drop - delete the workspace \n"
+ + " info - information about the service backup \n"
+ + " drop - delete the repository or workspace \n"
+ " help - print help information about backup console \n\n"
- + " <repo/ws> - /<reponsitory-name>/<workspace-name> the workspace \n"
+ + " <repo[/ws]> - /<reponsitory-name>[/<workspace-name>] the repository or workspace \n"
+ " <backup_dir> - path to folder for backup on remote server \n"
- + " <backup_id> - the identifier for backup \n" + " <incr> - incemental job period \n"
- + " <pathToConfigFile> - path (local) to workspace configuration \n"
- + " force-close-session - close opened sessions on workspace. \n\n";
+ + " <backup_id> - the identifier for backup \n"
+ + " <incr> - incemental job period \n"
+ + " <pathToConfigFile> - path (local) to repository or workspace configuration \n"
+ + " force-close-session - close opened sessions on repositpry or workspace. \n\n";
/**
* Main.
@@ -157,7 +165,7 @@
return;
String repositoryName = getRepositoryName(pathToWS);
- String workspaceName = getWorkspaceName(pathToWS);
+ String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
if (curArg == args.length)
{
@@ -233,7 +241,7 @@
return;
String repositoryName = getRepositoryName(pathToWS);
- String workspaceName = getWorkspaceName(pathToWS);
+ String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
if (curArg < args.length)
{
@@ -276,7 +284,7 @@
return;
String repositoryName = getRepositoryName(pathToWS);
- String workspaceName = getWorkspaceName(pathToWS);
+ String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);;
if (curArg < args.length)
{
@@ -321,7 +329,7 @@
return;
String repositoryName = getRepositoryName(pathToWS);
- String workspaceName = getWorkspaceName(pathToWS);
+ String workspaceName = (pathToWS.split("/").length == 3 ? getWorkspaceName(pathToWS) : null);
// backup id
if (curArg == args.length)
@@ -415,7 +423,7 @@
String repWS = args[curArg];
repWS = repWS.replaceAll("\\\\", "/");
- if (!repWS.matches("[/][^/]+[/][^/]+"))
+ if ( !repWS.matches("[/][^/]+") && !repWS.matches("[/][^/]+[/][^/]+"))
{
System.out.println(INCORRECT_PARAM + "There is incorrect path to workspace parameter: " + repWS);
return null;
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/ClientTransportImpl.java 2010-10-11 10:03:48 UTC (rev 3286)
@@ -57,6 +57,16 @@
* Flag is SSL.
*/
private final String protocol;
+
+ /**
+ * Is realm get.
+ */
+ private boolean isRealmGet = false;
+
+ /**
+ * Realm to connection
+ */
+ private String realm;
/**
* Constructor.
@@ -124,7 +134,13 @@
HTTPConnection connection = new HTTPConnection(url);
connection.removeModule(CookieModule.class);
- connection.addBasicAuthorization(getRealm(complURL), login, password);
+ if (!isRealmGet)
+ {
+ realm = getRealm(complURL);
+ isRealmGet = true;
+ }
+
+ connection.addBasicAuthorization(realm, login, password);
HTTPResponse resp;
if (postData == null)
@@ -164,7 +180,13 @@
HTTPConnection connection = new HTTPConnection(url);
connection.removeModule(CookieModule.class);
- connection.addBasicAuthorization(getRealm(complURL), login, password);
+ if (!isRealmGet)
+ {
+ realm = getRealm(complURL);
+ isRealmGet = true;
+ }
+
+ connection.addBasicAuthorization(realm, login, password);
HTTPResponse resp = connection.Get(url.getFile());
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2010-10-11 10:03:48 UTC (rev 3286)
@@ -18,20 +18,6 @@
*/
package org.exoplatform.services.jcr.ext.repository;
-import org.exoplatform.common.http.HTTPStatus;
-import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.ManageableRepository;
-import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.exoplatform.services.jcr.impl.core.SessionRegistry;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -51,6 +37,20 @@
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.Status;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+
/**
* Created by The eXo Platform SAS.
*
@@ -370,7 +370,7 @@
* @return Response
* return the Response
*/
- @POST
+ @GET
@RolesAllowed("administrators")
@Path("/remove-repository/{repositoryName}/{forseSessionClose}")
public Response removeRepository(@Context UriInfo uriInfo, @PathParam("repositoryName") String repositoryName,
@@ -390,14 +390,16 @@
}
}
- if (repositoryService.canRemoveRepository(repositoryName))
+ if (repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryName))
{
+ ((RepositoryServiceImpl) repositoryService).removeDefaultRepository();
+ }
+ else
+ {
repositoryService.removeRepository(repositoryName);
- repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
- return Response.noContent().build();
}
- return Response.status(HTTPStatus.CONFLICT).entity("Can't remove repository " + repositoryName).cacheControl(
- NO_CACHE).build();
+ repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
+ return Response.ok().build();
}
catch (RepositoryException e)
{
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml 2010-10-11 10:01:45 UTC (rev 3285)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/backup-client.xml 2010-10-11 10:03:48 UTC (rev 3286)
@@ -938,33 +938,33 @@
<programlisting>Help info:
<url> <cmd>
<url> : http(s)//login:password@host:port/<context>
- <cmd> : start <repo/ws> <backup_dir> [<incr>]
+ <cmd> : start <repo[/ws]> <backup_dir> [<incr>]
stop <backup_id>
status <backup_id>
- restores <repo/ws>
- restore <repo/ws> <backup_id> <pathToConfigFile>
+ restores <repo[/ws]>
+ restore <repo[/ws]> <backup_id> <pathToConfigFile>
list [completed]
info
- drop [force-close-session] <repo/ws>
+ drop [force-close-session] <repo[/ws]>
help
- start - start backup
+ start - start backup of repository or workspace
stop - stop backup
status - information about the current or completed backup by 'backup_id'
- restores - information about the last restore on specific workspace
- restore - restore the workspace from specific backup
+ restores - information about the last restore on specific repository or workspace
+ restore - restore the repository or workspace from specific backup
list - information about the current backups (in progress)
list completed - information about the completed (ready to restore) backups
info - information about the service backup
- drop - delete the workspace
+ drop - delete the repository or workspace
help - print help information about backup console
- <repo/ws> - /<reponsitory-name>/<workspace-name> the workspace
+ <repo[/ws]> - /<reponsitory-name>[/<workspace-name>] the repository or workspace
<backup_dir> - path to folder for backup on remote server
<backup_id> - the identifier for backup
<incr> - incemental job period
- <pathToConfigFile> - path (local) to workspace configuration
- force-close-session - close opened sessions on workspace.</programlisting>
+ <pathToConfigFile> - path (local) to repository or workspace configuration
+ force-close-session - close opened sessions on repositpry or workspace</programlisting>
</section>
<section>
@@ -991,7 +991,8 @@
</itemizedlist>
<note>
- <para><emphasis role="bold">${JCR-SRC-HOME}</emphasis> the path where eXo JCR sources located</para>
+ <para><emphasis role="bold">${JCR-SRC-HOME}</emphasis> the path where
+ eXo JCR sources located</para>
</note>
</section>
@@ -1323,4 +1324,244 @@
finished time : Fri, 17 Apr 2009 16:38:00 EEST</programlisting>
</section>
</section>
+
+ <section>
+ <title>Full example about creating backup and restoring it for repository
+ 'repository'</title>
+
+ <section>
+ <title>Creating backup</title>
+
+ <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 start /repository ../temp/backup 10000</programlisting>
+
+ <para>Return :</para>
+
+ <programlisting>Successful :
+ status code = 200</programlisting>
+ </section>
+
+ <section>
+ <title>Getting information about current backups</title>
+
+ <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 list</programlisting>
+
+ <para>Return :</para>
+
+ <programlisting>The current backups information :
+ 1) Repository backup with id 9a4d40fb7f0000012ec8f0a4ec70b3da :
+ repository name : repository
+ backup type : full + incremetal
+ full backups state : finished
+ incremental backups state : working
+ started time : Mon, 11 Oct 2010 10:59:35 EEST</programlisting>
+ </section>
+
+ <section>
+ <title>Stopping backup by id</title>
+
+ <para>Stop backup with id 9a4d40fb7f0000012ec8f0a4ec70b3da :</para>
+
+ <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 stop 9a4d40fb7f0000012ec8f0a4ec70b3da</programlisting>
+
+ <para>Return :</para>
+
+ <programlisting>Successful :
+ status code = 200</programlisting>
+ </section>
+
+ <section>
+ <title>Deleting the repository "repository" and close all opened
+ sessions</title>
+
+ <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 drop force-close-session /repository</programlisting>
+
+ <para>Return :</para>
+
+ <programlisting>Successful :
+ status code = 200</programlisting>
+ </section>
+
+ <section>
+ <title>Restoring the workspace "backup"</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>Delete/clean the database for workspace <emphasis
+ role="bold">"repository"</emphasis> : When we use "single-db", then
+ we will run the SQL queries for clean database :<programlisting> drop table JCR_SREF;
+ drop table JCR_SVALUE;
+ drop table JCR_SITEM;</programlisting></para>
+ </listitem>
+
+ <listitem>
+ <para>Delete the value storage for repository <emphasis
+ role="bold">"repository"</emphasis>;</para>
+ </listitem>
+
+ <listitem>
+ <para>Delete the index data for repository <emphasis
+ role="bold">"repository"</emphasis>;</para>
+ </listitem>
+
+ <listitem>
+ <para>Restore:<programlisting>jcrbackup http://root:exo@127.0.0.1:8080 restore /repository/backup 9a6dba327f000001325dfb228a181b07 /home/rainf0x/exo-jcr-config_backup.xml</programlisting>Return
+ :<programlisting>Successful :
+ status code = 200</programlisting>The
+ /home/rainf0x/exo-jcr-config_backup.xml content the configuration
+ for restored repository <emphasis
+ role="bold">"repository"</emphasis> :<programlisting><repository-service default-repository="repository">
+ <repositories>
+ <repository name="repository" system-workspace="production" default-workspace="production">
+ <security-domain>exo-domain</security-domain>
+ <access-control>optional</access-control>
+ <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="production">
+ <!-- for system storage -->
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr" />
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="../temp/swap/production" />
+ </properties>
+ <value-storages>
+ <value-storage id="system" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="../temp/values/production" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="../temp/jcrlucenedb/production" />
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="../temp/lock/system" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="backup">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr" />
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="../temp/swap/backup" />
+ </properties>
+ <value-storages>
+ <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="../temp/values/backup" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="../temp/jcrlucenedb/backup" />
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="digital-assets">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr" />
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="../temp/swap/digital-assets" />
+ </properties>
+ <value-storages>
+ <value-storage id="digital-assets" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="../temp/values/digital-assets" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:folder" />
+ </properties>
+ </initializer>
+ <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="5k" />
+ <property name="live-time" value="15m" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="../temp/jcrlucenedb/digital-assets" />
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+ </repositories>
+</repository-service>
+</programlisting></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Getting information about restore for repository
+ 'repository'</title>
+
+ <programlisting>jcrbackup http://root:exo@127.0.0.1:8080 restores /repository</programlisting>
+
+ <para>Return:</para>
+
+ <programlisting> Repository restore with id 9a6dba327f000001325dfb228a181b07:
+ backup folder : /home/rainf0x/java/exo-working/JCR-1459/exo-tomcat/bin/../temp/backup/repository_repository_backup_1286786103858
+ repository name : repository
+ backup type : full + incremetal
+ restore state : successful
+ started time : Mon, 11 Oct 2010 11:51:15 EEST
+ finished time : Mon, 11 Oct 2010 11:51:17 EEST</programlisting>
+ </section>
+ </section>
</chapter>
15 years, 9 months
exo-jcr SVN: r3285 - kernel/trunk/exo.kernel.component.common.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-10-11 06:01:45 -0400 (Mon, 11 Oct 2010)
New Revision: 3285
Modified:
kernel/trunk/exo.kernel.component.common/pom.xml
Log:
EXOJCR-967: Parameters for JGroups needed for some Linux Distributions added to the pom file
Modified: kernel/trunk/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/pom.xml 2010-10-11 09:43:42 UTC (rev 3284)
+++ kernel/trunk/exo.kernel.component.common/pom.xml 2010-10-11 10:01:45 UTC (rev 3285)
@@ -104,6 +104,23 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <systemProperties>
+ <!-- We add this system property due to some incompatibility between IPv6 and
+ some JVM of Linux distributions such as Ubuntu and Fedora-->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Avoid the firewall -->
+ <property>
+ <name>bind.address</name>
+ <value>127.0.0.1</value>
+ </property>
+ <property>
+ <name>jgroups.stack</name>
+ <value>udp</value>
+ </property>
+ </systemProperties>
<excludes>
<exclude>**/TransactionTest.java</exclude>
</excludes>
15 years, 9 months
exo-jcr SVN: r3284 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-10-11 05:43:42 -0400 (Mon, 11 Oct 2010)
New Revision: 3284
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/rpc-service.xml
Log:
EXOJCR-967: Doc about the TopologyChangeListener
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/rpc-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/rpc-service.xml 2010-10-11 09:42:23 UTC (rev 3283)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/rpc-service.xml 2010-10-11 09:43:42 UTC (rev 3284)
@@ -18,12 +18,31 @@
something happened or to collect some information from the other
nodes.</para>
- <para>The <emphasis>RPCService</emphasis> relies on 2 main interfaces
- which are the <emphasis>org.exoplatform.services.rpc.RPCService</emphasis>
- that defines the service itslef and the
- <emphasis>org.exoplatform.services.rpc.RemoteCommand</emphasis> that
- defines the command that we can execute on other nodes. The arguments that
- will be given to the <emphasis>RemoteCommand</emphasis> must be
+ <para>The <emphasis>RPCService</emphasis> relies on 3 main interfaces
+ which are:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The <emphasis>org.exoplatform.services.rpc.RPCService</emphasis>
+ that defines the service itslef</para>
+ </listitem>
+
+ <listitem>
+ <para>The
+ <emphasis>org.exoplatform.services.rpc.RemoteCommand</emphasis> that
+ defines the command that we can execute on other nodes.</para>
+ </listitem>
+
+ <listitem>
+ <para>The
+ <emphasis>org.exoplatform.services.rpc.TopologyChangeListener</emphasis>
+ that defines the listeners that will be notified anytime the topology
+ of the cluster changes.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>The arguments that will be given to the
+ <emphasis>RemoteCommand</emphasis> must be
<emphasis>Serializable</emphasis> and its return type also in order to
prevent any issue due to the serialization. To prevent to execute any
<emphasis>RemoteCommand</emphasis> that could be malicious and to allow to
15 years, 9 months
exo-jcr SVN: r3283 - in kernel/trunk/exo.kernel.component.common/src: main/java/org/exoplatform/services/rpc/impl and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-10-11 05:42:23 -0400 (Mon, 11 Oct 2010)
New Revision: 3283
Added:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeEvent.java
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeListener.java
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
Log:
EXOJCR-967: We now allow to listen to any topology changes
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-10-08 21:00:13 UTC (rev 3282)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-10-11 09:42:23 UTC (rev 3283)
@@ -130,5 +130,21 @@
* @return <code>true</code> if the coordinator is the coordinator, <code>false</code> otherwise
* throws RPCException in case the {@link RPCService} is in an illegal state
*/
- boolean isCoordinator() throws RPCException;
+ boolean isCoordinator() throws RPCException;
+
+ /**
+ * Register a new {@link TopologyChangeListener}
+ * @param listener the listener to be registered
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ void registerTopologyChangeListener(TopologyChangeListener listener) throws SecurityException;
+
+ /**
+ * Unregister a {@link TopologyChangeListener} if it exists
+ * @param listener the listener to unregister
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ void unregisterTopologyChangeListener(TopologyChangeListener listener) throws SecurityException;
}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeEvent.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeEvent.java (rev 0)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeEvent.java 2010-10-11 09:42:23 UTC (rev 3283)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 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.rpc;
+
+/**
+ * The event triggered anytime the cluster has changed of topology
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TopologyChangeEvent
+{
+
+ /**
+ * Indicates whether the current node is the coordinator after this topology change
+ */
+ private final boolean coordinator;
+
+ /**
+ * Indicates whether the coordinator has changed
+ */
+ private final boolean coordinatorHasChanged;
+
+ /**
+ * Default constructor
+ * @param coordinatorHasChanged this parameter is set to <code>true</code> if the
+ * coordinator has changed, <code>false</code> otherwise
+ * @param coordinator this parameter is set to <code>true</code> if the current node
+ * is the coordinator, <code>false</code> otherwise
+ */
+ public TopologyChangeEvent(boolean coordinatorHasChanged, boolean coordinator)
+ {
+ this.coordinator = coordinator;
+ this.coordinatorHasChanged = coordinatorHasChanged;
+ }
+
+ /**
+ * Indicates whether the current node is the coordinator or not after the topology change
+ * @return <code>true</code> if the current node is the coordinator, <code>false</code> otherwise.
+ */
+ public boolean isCoordinator()
+ {
+ return coordinator;
+ }
+
+ /**
+ * Indicates whether the coordinator has changed after the topology change
+ * @return <code>true</code> if the coordinator has changed, <code>false</code> otherwise.
+ */
+ public boolean isCoordinatorHasChanged()
+ {
+ return coordinatorHasChanged;
+ }
+}
Added: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeListener.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeListener.java (rev 0)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/TopologyChangeListener.java 2010-10-11 09:42:23 UTC (rev 3283)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 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.rpc;
+
+/**
+ * This interface is used to allow some components to be notified anytime the topology
+ * of the cluster changes, in other words any time a member of the cluster leave or join
+ * the cluster.
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public interface TopologyChangeListener
+{
+
+ /**
+ * Called anytime the topology of the cluster changes
+ * @param event the event triggered when the topology changes
+ */
+ void onChange(TopologyChangeEvent event);
+}
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-10-08 21:00:13 UTC (rev 3282)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-10-11 09:42:23 UTC (rev 3283)
@@ -29,6 +29,8 @@
import org.exoplatform.services.rpc.RPCException;
import org.exoplatform.services.rpc.RPCService;
import org.exoplatform.services.rpc.RemoteCommand;
+import org.exoplatform.services.rpc.TopologyChangeEvent;
+import org.exoplatform.services.rpc.TopologyChangeListener;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelException;
@@ -61,6 +63,7 @@
import java.util.List;
import java.util.Map;
import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
/**
@@ -103,7 +106,7 @@
* The default value of the cluster name
*/
public static final String CLUSTER_NAME = "RPCService-Cluster";
-
+
/**
* The configurator used to create the JGroups Channel
*/
@@ -151,6 +154,11 @@
* incoming messages.
*/
private final CountDownLatch startSignal = new CountDownLatch(1);
+
+ /**
+ * All the registered {@link TopologyChangeListener}
+ */
+ private final List<TopologyChangeListener> listeners = new CopyOnWriteArrayList<TopologyChangeListener>();
/**
* Current State of the {@link RPCServiceImpl}
@@ -434,11 +442,35 @@
public void viewAccepted(View view)
{
this.members = view.getMembers();
+ Address currentCoordinator = coordinator;
this.coordinator = members != null && members.size() > 0 ? members.get(0) : null;
this.isCoordinator = coordinator != null && coordinator.equals(channel.getLocalAddress());
+ onTopologyChange(currentCoordinator != null && !currentCoordinator.equals(coordinator));
}
/**
+ * Called anytime the topology has changed, this method will notify all the listeners
+ * currently registered
+ * @param coordinatorHasChanged this parameter is set to <code>true</code> if the
+ * coordinator has changed, <code>false</code> otherwise
+ */
+ private void onTopologyChange(boolean coordinatorHasChanged)
+ {
+ TopologyChangeEvent event = new TopologyChangeEvent(coordinatorHasChanged, isCoordinator);
+ for (TopologyChangeListener listener : listeners)
+ {
+ try
+ {
+ listener.onChange(event);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("An error occurs with the listener of type " + listener.getClass(), e);
+ }
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public synchronized RemoteCommand registerCommand(RemoteCommand command)
@@ -517,6 +549,40 @@
}
/**
+ * {@inheritDoc}
+ */
+ public void registerTopologyChangeListener(TopologyChangeListener listener) throws SecurityException
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(RPCService.ACCESS_RPC_SERVICE_PERMISSION);
+ }
+ if (listener == null)
+ {
+ return;
+ }
+ listeners.add(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unregisterTopologyChangeListener(TopologyChangeListener listener) throws SecurityException
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(RPCService.ACCESS_RPC_SERVICE_PERMISSION);
+ }
+ if (listener == null)
+ {
+ return;
+ }
+ listeners.remove(listener);
+ }
+
+ /**
* Gives the {@link RemoteCommand} corresponding to the given id
* @param commandId the command id of the command to retrieve
* @return the corresponding {@link RemoteCommand}
Modified: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-10-08 21:00:13 UTC (rev 3282)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-10-11 09:42:23 UTC (rev 3283)
@@ -25,6 +25,8 @@
import org.exoplatform.services.rpc.RPCException;
import org.exoplatform.services.rpc.RemoteCommand;
import org.exoplatform.services.rpc.SingleMethodCallCommand;
+import org.exoplatform.services.rpc.TopologyChangeEvent;
+import org.exoplatform.services.rpc.TopologyChangeListener;
import org.exoplatform.services.rpc.impl.RPCServiceImpl.MemberHasLeftException;
import org.exoplatform.test.BasicTestCase;
import org.jgroups.Address;
@@ -519,7 +521,7 @@
paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
paramConf.setValue("jar:/conf/portal/udp.xml");
params.addParameter(paramConf);
- RPCServiceImpl service1 = null, service2 = null;
+ RPCServiceImpl service1 = null, service2 = null;
try
{
service1 = new RPCServiceImpl(container.getContext(), params, configManager);
@@ -591,7 +593,7 @@
public String execute(Serializable[] args) throws Throwable
{
- Thread.sleep(30000);
+ Thread.sleep(3000);
return "OldCoordinator";
}
});
@@ -675,9 +677,31 @@
return "NewCoordinator";
}
};
- service2.registerCommand(LongTask);
+ service2.registerCommand(LongTask);
+ MyListener listener1 = new MyListener();
+ service1.registerTopologyChangeListener(listener1);
+ MyListener listener2 = new MyListener();
+ service2.registerTopologyChangeListener(listener2);
+ assertFalse(listener1.coordinatorHasChanged);
+ assertFalse(listener1.isCoordinator);
+ assertEquals(0, listener1.count);
+ assertFalse(listener2.coordinatorHasChanged);
+ assertFalse(listener2.isCoordinator);
+ assertEquals(0, listener2.count);
service1.start();
+ assertFalse(listener1.coordinatorHasChanged);
+ assertTrue(listener1.isCoordinator);
+ assertEquals(1, listener1.count);
+ assertFalse(listener2.coordinatorHasChanged);
+ assertFalse(listener2.isCoordinator);
+ assertEquals(0, listener2.count);
service2.start();
+ assertFalse(listener1.coordinatorHasChanged);
+ assertTrue(listener1.isCoordinator);
+ assertEquals(2, listener1.count);
+ assertFalse(listener2.coordinatorHasChanged);
+ assertFalse(listener2.isCoordinator);
+ assertEquals(1, listener2.count);
assertEquals(true, service1.isCoordinator());
assertEquals(false, service2.isCoordinator());
List<Object> result;
@@ -740,6 +764,12 @@
};
t.start();
service1.stop();
+ assertFalse(listener1.coordinatorHasChanged);
+ assertTrue(listener1.isCoordinator);
+ assertEquals(2, listener1.count);
+ assertTrue(listener2.coordinatorHasChanged);
+ assertTrue(listener2.isCoordinator);
+ assertEquals(2, listener2.count);
doneSignal.await();
assertNull(error.get() != null ? error.get().getMessage() : "", error.get());
result = service2.excecuteCommand(allMembers, OK, true, 0);
@@ -1081,4 +1111,22 @@
return (short)(values[0] + 3);
}
}
+
+ private static class MyListener implements TopologyChangeListener
+ {
+
+ private boolean coordinatorHasChanged;
+ private boolean isCoordinator;
+ private int count;
+
+ /**
+ * @see org.exoplatform.services.rpc.TopologyChangeListener#onChange(org.exoplatform.services.rpc.TopologyChangeEvent)
+ */
+ public void onChange(TopologyChangeEvent event)
+ {
+ this.coordinatorHasChanged = event.isCoordinatorHasChanged();
+ this.isCoordinator = event.isCoordinator();
+ count++;
+ }
+ }
}
15 years, 9 months
exo-jcr SVN: r3282 - jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF.
by do-not-reply@jboss.org
Author: aheritier
Date: 2010-10-08 17:00:13 -0400 (Fri, 08 Oct 2010)
New Revision: 3282
Modified:
jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
Log:
version in ra.xml isn't hardcoded any more
Modified: jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-10-08 20:06:42 UTC (rev 3281)
+++ jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-10-08 21:00:13 UTC (rev 3282)
@@ -25,7 +25,7 @@
<display-name>JCR repository</display-name>
<vendor-name>exoplatform</vendor-name>
<eis-type />
- <resourceadapter-version>1.12.6-GA-SNAPSHOT</resourceadapter-version>
+ <resourceadapter-version>${project.version}</resourceadapter-version>
<license>
<license-required>false</license-required>
</license>
15 years, 9 months
exo-jcr SVN: r3281 - in jcr/branches/1.12.x: exo.jcr.connectors.localadapter/src/main/rar/META-INF and 1 other directory.
by do-not-reply@jboss.org
Author: aheritier
Date: 2010-10-08 16:06:42 -0400 (Fri, 08 Oct 2010)
New Revision: 3281
Modified:
jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
jcr/branches/1.12.x/pom.xml
Log:
[EXOJCR-XXX] -mUpgrade to next SNAPSHOTs
Modified: jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-10-08 20:06:07 UTC (rev 3280)
+++ jcr/branches/1.12.x/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-10-08 20:06:42 UTC (rev 3281)
@@ -25,7 +25,7 @@
<display-name>JCR repository</display-name>
<vendor-name>exoplatform</vendor-name>
<eis-type />
- <resourceadapter-version>${project.version}</resourceadapter-version>
+ <resourceadapter-version>1.12.6-GA-SNAPSHOT</resourceadapter-version>
<license>
<license-required>false</license-required>
</license>
Modified: jcr/branches/1.12.x/pom.xml
===================================================================
--- jcr/branches/1.12.x/pom.xml 2010-10-08 20:06:07 UTC (rev 3280)
+++ jcr/branches/1.12.x/pom.xml 2010-10-08 20:06:42 UTC (rev 3281)
@@ -42,9 +42,9 @@
<properties>
<exo.product.name>exo-jcr</exo.product.name>
<exo.product.specification>1.12</exo.product.specification>
- <org.exoplatform.kernel.version>2.2.5-GA-SNAPSHOT</org.exoplatform.kernel.version>
- <org.exoplatform.core.version>2.3.5-GA-SNAPSHOT</org.exoplatform.core.version>
- <org.exoplatform.ws.version>2.1.5-GA-SNAPSHOT</org.exoplatform.ws.version>
+ <org.exoplatform.kernel.version>2.2.6-GA-SNAPSHOT</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.6-GA-SNAPSHOT</org.exoplatform.core.version>
+ <org.exoplatform.ws.version>2.1.6-GA-SNAPSHOT</org.exoplatform.ws.version>
<org.exoplatform.doc-style.version>1</org.exoplatform.doc-style.version>
</properties>
15 years, 9 months