exo-jcr SVN: r3994 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query: lucene and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 08:38:33 -0500 (Fri, 18 Feb 2011)
New Revision: 3994
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-1193: Index retrieval from coordinator node
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java 2011-02-18 12:52:16 UTC (rev 3993)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java 2011-02-18 13:38:33 UTC (rev 3994)
@@ -33,16 +33,22 @@
{
/**
- * Switch index between RO/RW states.
+ * Switch index offline.
*
- * @param isReadOnly
- * boolean, indicates if need to switch index to RO or RW mode
* @throws RepositoryException
* if any exception occurred
*/
- public void setIndexReadOnly(boolean isReadOnly) throws RepositoryException;
+ public void setIndexOffline() throws RepositoryException;
/**
+ * Switch index online.
+ *
+ * @throws RepositoryException
+ * if any exception occurred
+ */
+ public void setIndexOnline() throws RepositoryException;
+
+ /**
* Get list of relative paths of all files from index directory.
*
* @return List
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java 2011-02-18 12:52:16 UTC (rev 3993)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java 2011-02-18 13:38:33 UTC (rev 3994)
@@ -19,9 +19,13 @@
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
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 java.io.File;
import java.io.IOException;
@@ -41,10 +45,15 @@
* @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
* @version $Id: IndexRetrievalImpl.java 34360 2010-11-11 11:11:11Z tolusha $
*/
-public class IndexRecoveryImpl implements IndexRecovery
+public class IndexRecoveryImpl implements IndexRecovery, TopologyChangeListener
{
/**
+ * Logger instance for this class.
+ */
+ private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.IndexRecoveryImpl");
+
+ /**
* Buffer size.
*/
public static final int BUFFER_SIZE = 1024 * 1024;
@@ -67,9 +76,19 @@
/**
* Remote command to switch index between RO/RW state.
*/
- private RemoteCommand setReadOnly;
+ private RemoteCommand changeIndexMode;
/**
+ * Remote command to check if node responsible for set index online leave the cluster.
+ */
+ private RemoteCommand requestForResponsibleToSetIndexOnline;
+
+ /**
+ * Indicates that node keep responsible to set index online.
+ */
+ protected Boolean isResponsibleToSetIndexOnline = false;
+
+ /**
* Constructor IndexRetrieveImpl.
*
* @throws RepositoryConfigurationException
@@ -82,16 +101,16 @@
final String commandSuffix = searchManager.getWsId() + "-" + (searchManager.parentSearchManager == null);
final File indexDirectory = searchManager.getIndexDirectory();
- setReadOnly = rpcService.registerCommand(new RemoteCommand()
+ changeIndexMode = rpcService.registerCommand(new RemoteCommand()
{
public String getId()
{
- return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-setReadOnly-" + commandSuffix;
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-changeIndexMode-" + commandSuffix;
}
public Serializable execute(Serializable[] args) throws Throwable
{
- boolean isReadOnly = (Boolean)args[0];
+ boolean isOnline = (Boolean)args[0];
// TODO searchManager.setReadOnly(isReadOnly);
@@ -154,6 +173,23 @@
}
}
});
+
+ requestForResponsibleToSetIndexOnline = rpcService.registerCommand(new RemoteCommand()
+ {
+
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-requestForResponsibleToSetIndexOnline-"
+ + commandSuffix;
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ return isResponsibleToSetIndexOnline;
+ }
+ });
+
+ rpcService.registerTopologyChangeListener(this);
}
/**
@@ -178,13 +214,32 @@
/**
* {@inheritDoc}
*/
- public void setIndexReadOnly(boolean isReadOnly) throws RepositoryException
+ public void setIndexOffline() throws RepositoryException
{
try
{
- rpcService.executeCommandOnCoordinator(setReadOnly, true, isReadOnly);
+ isResponsibleToSetIndexOnline = true;
+ rpcService.executeCommandOnCoordinator(changeIndexMode, true, false);
+ }
+ catch (SecurityException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
- // TODO failover
+ /**
+ * {@inheritDoc}
+ */
+ public void setIndexOnline() throws RepositoryException
+ {
+ try
+ {
+ rpcService.executeCommandOnCoordinator(changeIndexMode, true, true);
+ isResponsibleToSetIndexOnline = false;
}
catch (SecurityException e)
{
@@ -240,8 +295,7 @@
@Override
public int read() throws IOException
{
- throw new UnsupportedOperationException(
- "RemoteStream.read(byte b[], int off, int len) method is not supported");
+ throw new UnsupportedOperationException("RemoteStream.read() method is not supported");
}
/**
@@ -311,4 +365,53 @@
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onChange(TopologyChangeEvent event)
+ {
+ try
+ {
+ if (rpcService.isCoordinator())
+ {
+ new Thread()
+ {
+ @Override
+ public synchronized void run()
+ {
+ try
+ {
+ List<Object> results =
+ rpcService.executeCommandOnAllNodes(requestForResponsibleToSetIndexOnline, true);
+
+ for (Object result : results)
+ {
+ if ((Boolean)result)
+ {
+ return;
+ }
+ }
+
+ // node which was responsible for resuming leave the cluster, so resume component
+ // TODO searchManager.setOnline();
+ }
+ catch (SecurityException e1)
+ {
+ log.error("You haven't privileges to execute remote command", e1);
+ }
+ catch (RPCException e1)
+ {
+ log.error("Exception during command execution", e1);
+ }
+ }
+ }.start();
+ }
+ }
+ catch (RPCException e)
+ {
+ log.error("Can't check if node coordinator or not.");
+ }
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 12:52:16 UTC (rev 3993)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 13:38:33 UTC (rev 3994)
@@ -3352,7 +3352,7 @@
try
{
IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
- indexRecovery.setIndexReadOnly(true);
+ indexRecovery.setIndexOffline();
File indexDirectory = new File(handler.getContext().getIndexDirectory());
for (String filePath : indexRecovery.getIndexList())
@@ -3389,7 +3389,7 @@
}
}
- indexRecovery.setIndexReadOnly(false);
+ indexRecovery.setIndexOnline();
}
}
finally
13 years, 2 months
exo-jcr SVN: r3993 - core/trunk/exo.core.component.database/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-02-18 07:52:16 -0500 (Fri, 18 Feb 2011)
New Revision: 3993
Modified:
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-1149: modified test configuration to ensure correct implementation
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2011-02-18 11:11:26 UTC (rev 3992)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2011-02-18 12:52:16 UTC (rev 3993)
@@ -100,7 +100,7 @@
<properties-param>
<name>db-creation</name>
<description>database creation properties</description>
- <property name="scriptPath" value="src/test/resources/dbcreator/test.sql" />
+ <property name="scriptPath" value="classpath:/dbcreator/test.sql" />
<property name="username" value="sa" />
<property name="password" value="" />
</properties-param>
13 years, 2 months
exo-jcr SVN: r3992 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl: rdbms and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 06:11:26 -0500 (Fri, 18 Feb 2011)
New Revision: 3992
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
Log:
EXOJCR-1193: Index retrieval from coordinator node
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java 2011-02-18 11:11:00 UTC (rev 3991)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java 2011-02-18 11:11:26 UTC (rev 3992)
@@ -115,7 +115,7 @@
for (Suspendable component : suspendableComponents)
{
- component.suspend(false);
+ component.suspend();
resumeComponents.add(component);
}
}
@@ -160,11 +160,11 @@
}
// resume components
- for (int i = 0; i < resumeComponents.size() - 1; i++)
+ for (int i = 0; i < resumeComponents.size(); i++)
{
try
{
- resumeComponents.remove(i).resume(false);
+ resumeComponents.remove(i).resume();
}
catch (ResumeException e)
{
@@ -232,7 +232,7 @@
{
try
{
- component.resume(false);
+ component.resume();
}
catch (ResumeException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java 2011-02-18 11:11:00 UTC (rev 3991)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java 2011-02-18 11:11:26 UTC (rev 3992)
@@ -82,7 +82,7 @@
for (Suspendable component : suspendableComponents)
{
- component.suspend(false);
+ component.suspend();
resumeComponents.add(component);
}
@@ -115,11 +115,11 @@
}
// resume components
- for (int i = 0; i < resumeComponents.size() - 1; i++)
+ for (int i = 0; i < resumeComponents.size(); i++)
{
try
{
- resumeComponents.remove(i).resume(false);
+ resumeComponents.remove(i).resume();
}
catch (ResumeException e)
{
@@ -178,7 +178,7 @@
{
try
{
- component.resume(false);
+ component.resume();
}
catch (ResumeException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2011-02-18 11:11:00 UTC (rev 3991)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2011-02-18 11:11:26 UTC (rev 3992)
@@ -129,7 +129,7 @@
// suspend all components
for (Suspendable component : suspendableComponents)
{
- component.suspend(false);
+ component.suspend();
resumeComponents.add(component);
}
@@ -163,7 +163,7 @@
{
try
{
- component.resume(false);
+ component.resume();
}
catch (ResumeException e)
{
13 years, 2 months
exo-jcr SVN: r3991 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/query and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 06:11:00 -0500 (Fri, 18 Feb 2011)
New Revision: 3991
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-1193: Index retrieval from coordinator node
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -29,13 +29,13 @@
*
* @throws SuspendException of error occurred
*/
- void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException;
+ void suspend() throws SuspendException;
/**
* Resume component.
*
* @throws ResumeException of error occurred
*/
- void resume(boolean isResumeCoordinatorOnly) throws ResumeException;
+ void resume() throws ResumeException;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -31,7 +31,18 @@
*/
public interface IndexRecovery
{
+
/**
+ * Switch index between RO/RW states.
+ *
+ * @param isReadOnly
+ * boolean, indicates if need to switch index to RO or RW mode
+ * @throws RepositoryException
+ * if any exception occurred
+ */
+ public void setIndexReadOnly(boolean isReadOnly) throws RepositoryException;
+
+ /**
* Get list of relative paths of all files from index directory.
*
* @return List
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -17,6 +17,7 @@
package org.exoplatform.services.jcr.impl.core.query;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
import org.exoplatform.services.rpc.RPCException;
import org.exoplatform.services.rpc.RPCService;
@@ -64,18 +65,45 @@
private RemoteCommand getIndexFile;
/**
+ * Remote command to switch index between RO/RW state.
+ */
+ private RemoteCommand setReadOnly;
+
+ /**
* Constructor IndexRetrieveImpl.
+ *
+ * @throws RepositoryConfigurationException
*/
- public IndexRecoveryImpl(RPCService rpcService, final String wsId, final boolean isSystem, final File indexDirectory)
+ public IndexRecoveryImpl(RPCService rpcService, final SearchManager searchManager)
+ throws RepositoryConfigurationException
{
this.rpcService = rpcService;
+ final String commandSuffix = searchManager.getWsId() + "-" + (searchManager.parentSearchManager == null);
+ final File indexDirectory = searchManager.getIndexDirectory();
+
+ setReadOnly = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-setReadOnly-" + commandSuffix;
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ boolean isReadOnly = (Boolean)args[0];
+
+ // TODO searchManager.setReadOnly(isReadOnly);
+
+ return null;
+ }
+ });
+
getIndexList = rpcService.registerCommand(new RemoteCommand()
{
public String getId()
{
- return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexList-" + wsId + "-"
- + isSystem;
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-getIndexList-" + commandSuffix;
}
public Serializable execute(Serializable[] args) throws Throwable
@@ -99,8 +127,7 @@
{
public String getId()
{
- return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexFile-" + wsId + "-"
- + isSystem;
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRecoveryImpl-getIndexFile-" + commandSuffix;
}
public Serializable execute(Serializable[] args) throws Throwable
@@ -151,6 +178,27 @@
/**
* {@inheritDoc}
*/
+ public void setIndexReadOnly(boolean isReadOnly) throws RepositoryException
+ {
+ try
+ {
+ rpcService.executeCommandOnCoordinator(setReadOnly, true, isReadOnly);
+
+ // TODO failover
+ }
+ catch (SecurityException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public InputStream getIndexFile(String filePath) throws RepositoryException
{
try
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -688,9 +688,7 @@
throw new RepositoryConfigurationException(e);
}
- IndexRecovery indexRecovery =
- rpcService == null ? null : new IndexRecoveryImpl(rpcService, getWsId(), parentHandler == null,
- getIndexDirectory());
+ IndexRecovery indexRecovery = rpcService == null ? null : new IndexRecoveryImpl(rpcService, this);
QueryHandlerContext context =
new QueryHandlerContext(container, itemMgr, indexingTree, nodeTypeDataManager, nsReg, parentHandler,
@@ -980,7 +978,7 @@
/**
* {@inheritDoc}
*/
- public void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException
+ public void suspend() throws SuspendException
{
isResponsibleForResuming = true;
@@ -988,14 +986,7 @@
{
try
{
- if (isSuspendCoordinatorOnly)
- {
- rpcService.executeCommandOnCoordinator(suspend, true);
- }
- else
- {
- rpcService.executeCommandOnAllNodes(suspend, true);
- }
+ rpcService.executeCommandOnAllNodes(suspend, true);
}
catch (SecurityException e)
{
@@ -1015,20 +1006,13 @@
/**
* {@inheritDoc}
*/
- public void resume(boolean isResumeCoordinatorOnly) throws ResumeException
+ public void resume() throws ResumeException
{
if (rpcService != null)
{
try
{
- if (isResumeCoordinatorOnly)
- {
- rpcService.executeCommandOnCoordinator(resume, true);
- }
- else
- {
- rpcService.executeCommandOnAllNodes(resume, true);
- }
+ rpcService.executeCommandOnAllNodes(resume, true);
}
catch (SecurityException e)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -28,9 +28,8 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.NodeDataIndexing;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.backup.ResumeException;
import org.exoplatform.services.jcr.impl.backup.SuspendException;
-import org.exoplatform.services.jcr.impl.backup.Suspendable;
+import org.exoplatform.services.jcr.impl.core.query.IndexRecovery;
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;
@@ -3350,23 +3349,13 @@
private void recoveryIndexFromCoordinator() throws FileNotFoundException, RepositoryException, IOException,
SuspendException
{
- List<Suspendable> suspendableComponents =
- handler.getContext().getContainer().getComponentInstancesOfType(Suspendable.class);
-
- // the list of components to resume
- List<Suspendable> resumeComponents = new ArrayList<Suspendable>();
-
try
{
- // suspend all components
- for (Suspendable component : suspendableComponents)
- {
- component.suspend(true);
- resumeComponents.add(component);
- }
+ IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
+ indexRecovery.setIndexReadOnly(true);
File indexDirectory = new File(handler.getContext().getIndexDirectory());
- for (String filePath : handler.getContext().getIndexRecovery().getIndexList())
+ for (String filePath : indexRecovery.getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
@@ -3375,7 +3364,7 @@
}
// transfer file
- InputStream in = handler.getContext().getIndexRecovery().getIndexFile(filePath);
+ InputStream in = indexRecovery.getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
@@ -3399,21 +3388,12 @@
out.close();
}
}
+
+ indexRecovery.setIndexReadOnly(false);
}
}
finally
{
- for (Suspendable component : resumeComponents)
- {
- try
- {
- component.resume(true);
- }
- catch (ResumeException e)
- {
- log.error("Can't resume component", e);
- }
- }
}
}
}
\ No newline at end of file
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-02-18 10:09:17 UTC (rev 3990)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-02-18 11:11:00 UTC (rev 3991)
@@ -1095,7 +1095,7 @@
/**
* {@inheritDoc}
*/
- public void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException
+ public void suspend() throws SuspendException
{
isResponsibleForResuming = true;
@@ -1103,14 +1103,7 @@
{
try
{
- if (isSuspendCoordinatorOnly)
- {
- rpcService.executeCommandOnCoordinator(suspend, true);
- }
- else
- {
- rpcService.executeCommandOnAllNodes(suspend, true);
- }
+ rpcService.executeCommandOnAllNodes(suspend, true);
}
catch (SecurityException e)
{
@@ -1130,20 +1123,13 @@
/**
* {@inheritDoc}
*/
- public void resume(boolean isResumeCoordinatorOnly) throws ResumeException
+ public void resume() throws ResumeException
{
if (rpcService != null)
{
try
{
- if (isResumeCoordinatorOnly)
- {
- rpcService.executeCommandOnCoordinator(resume, true);
- }
- else
- {
- rpcService.executeCommandOnAllNodes(resume, true);
- }
+ rpcService.executeCommandOnAllNodes(resume, true);
}
catch (SecurityException e)
{
13 years, 2 months
exo-jcr SVN: r3990 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl: rdbms and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 05:09:17 -0500 (Fri, 18 Feb 2011)
New Revision: 3990
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
Log:
EXOJCR-1193: Index retrieval from coordinator node: suspend only coordinator
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java 2011-02-18 10:08:54 UTC (rev 3989)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestoreSameConfig.java 2011-02-18 10:09:17 UTC (rev 3990)
@@ -115,7 +115,7 @@
for (Suspendable component : suspendableComponents)
{
- component.suspend(Suspendable.SUSPEND_COMPONENT_ON_ALL_NODES);
+ component.suspend(false);
resumeComponents.add(component);
}
}
@@ -164,7 +164,7 @@
{
try
{
- resumeComponents.remove(i).resume();
+ resumeComponents.remove(i).resume(false);
}
catch (ResumeException e)
{
@@ -232,7 +232,7 @@
{
try
{
- component.resume();
+ component.resume(false);
}
catch (ResumeException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java 2011-02-18 10:08:54 UTC (rev 3989)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedWorkspaceRestoreSameConfig.java 2011-02-18 10:09:17 UTC (rev 3990)
@@ -82,7 +82,7 @@
for (Suspendable component : suspendableComponents)
{
- component.suspend(Suspendable.SUSPEND_COMPONENT_ON_ALL_NODES);
+ component.suspend(false);
resumeComponents.add(component);
}
@@ -119,7 +119,7 @@
{
try
{
- resumeComponents.remove(i).resume();
+ resumeComponents.remove(i).resume(false);
}
catch (ResumeException e)
{
@@ -178,7 +178,7 @@
{
try
{
- component.resume();
+ component.resume(false);
}
catch (ResumeException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2011-02-18 10:08:54 UTC (rev 3989)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2011-02-18 10:09:17 UTC (rev 3990)
@@ -129,7 +129,7 @@
// suspend all components
for (Suspendable component : suspendableComponents)
{
- component.suspend(Suspendable.SUSPEND_COMPONENT_ON_ALL_NODES);
+ component.suspend(false);
resumeComponents.add(component);
}
@@ -163,7 +163,7 @@
{
try
{
- component.resume();
+ component.resume(false);
}
catch (ResumeException e)
{
13 years, 2 months
exo-jcr SVN: r3989 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/query and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 05:08:54 -0500 (Fri, 18 Feb 2011)
New Revision: 3989
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-1193: Index retrieval from coordinator node: suspend only coordinator
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-02-18 09:33:14 UTC (rev 3988)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-02-18 10:08:54 UTC (rev 3989)
@@ -24,22 +24,18 @@
*/
public interface Suspendable
{
- public static int SUSPEND_COMPONENT_ON_ALL_NODES = 1;
-
- public static int SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY = 2;
-
/**
* Suspend component.
*
* @throws SuspendException of error occurred
*/
- void suspend(int flag) throws SuspendException;
+ void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException;
/**
* Resume component.
*
* @throws ResumeException of error occurred
*/
- void resume() throws ResumeException;
+ void resume(boolean isResumeCoordinatorOnly) throws ResumeException;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 09:33:14 UTC (rev 3988)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 10:08:54 UTC (rev 3989)
@@ -193,11 +193,6 @@
protected Boolean isResponsibleForResuming = false;
/**
- * Suspend flag.
- */
- protected Integer suspendFlag;
-
- /**
* Suspend remote command.
*/
private RemoteCommand suspend;
@@ -985,16 +980,22 @@
/**
* {@inheritDoc}
*/
- public void suspend(int flag) throws SuspendException
+ public void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException
{
isResponsibleForResuming = true;
- suspendFlag = flag;
if (rpcService != null)
{
try
{
- rpcService.executeCommandOnAllNodes(suspend, true);
+ if (isSuspendCoordinatorOnly)
+ {
+ rpcService.executeCommandOnCoordinator(suspend, true);
+ }
+ else
+ {
+ rpcService.executeCommandOnAllNodes(suspend, true);
+ }
}
catch (SecurityException e)
{
@@ -1014,13 +1015,20 @@
/**
* {@inheritDoc}
*/
- public void resume() throws ResumeException
+ public void resume(boolean isResumeCoordinatorOnly) throws ResumeException
{
if (rpcService != null)
{
try
{
- rpcService.executeCommandOnAllNodes(resume, true);
+ if (isResumeCoordinatorOnly)
+ {
+ rpcService.executeCommandOnCoordinator(resume, true);
+ }
+ else
+ {
+ rpcService.executeCommandOnAllNodes(resume, true);
+ }
}
catch (SecurityException e)
{
@@ -1037,7 +1045,6 @@
}
isResponsibleForResuming = false;
- suspendFlag = null;
}
/**
@@ -1098,11 +1105,6 @@
protected void suspendLocally() throws SuspendException
{
- if (isResponsibleForResuming && suspendFlag == Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY)
- {
- return;
- }
-
if (isSuspended)
{
throw new SuspendException("Component already suspended.");
@@ -1114,11 +1116,6 @@
protected void resumeLocally() throws ResumeException
{
- if (isResponsibleForResuming && suspendFlag == Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY)
- {
- return;
- }
-
if (!isSuspended)
{
throw new ResumeException("Component is not suspended.");
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2011-02-18 09:33:14 UTC (rev 3988)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2011-02-18 10:08:54 UTC (rev 3989)
@@ -28,7 +28,6 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.backup.SuspendException;
-import org.exoplatform.services.jcr.impl.backup.Suspendable;
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
@@ -138,11 +137,6 @@
@Override
protected void suspendLocally() throws SuspendException
{
- if (isResponsibleForResuming && suspendFlag == Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY)
- {
- return;
- }
-
super.suspendLocally();
isStarted = false;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 09:33:14 UTC (rev 3988)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 10:08:54 UTC (rev 3989)
@@ -3361,7 +3361,7 @@
// suspend all components
for (Suspendable component : suspendableComponents)
{
- component.suspend(Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY);
+ component.suspend(true);
resumeComponents.add(component);
}
@@ -3407,7 +3407,7 @@
{
try
{
- component.resume();
+ component.resume(true);
}
catch (ResumeException e)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-02-18 09:33:14 UTC (rev 3988)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-02-18 10:08:54 UTC (rev 3989)
@@ -122,11 +122,6 @@
private RemoteCommand resume;
/**
- * Suspend flag.
- */
- private Integer suspendFlag;
-
- /**
* ItemData request, used on get operations.
*
*/
@@ -1100,16 +1095,22 @@
/**
* {@inheritDoc}
*/
- public void suspend(int flag) throws SuspendException
+ public void suspend(boolean isSuspendCoordinatorOnly) throws SuspendException
{
isResponsibleForResuming = true;
- suspendFlag = flag;
if (rpcService != null)
{
try
{
- rpcService.executeCommandOnAllNodes(suspend, true, null);
+ if (isSuspendCoordinatorOnly)
+ {
+ rpcService.executeCommandOnCoordinator(suspend, true);
+ }
+ else
+ {
+ rpcService.executeCommandOnAllNodes(suspend, true);
+ }
}
catch (SecurityException e)
{
@@ -1129,13 +1130,20 @@
/**
* {@inheritDoc}
*/
- public void resume() throws ResumeException
+ public void resume(boolean isResumeCoordinatorOnly) throws ResumeException
{
if (rpcService != null)
{
try
{
- rpcService.executeCommandOnAllNodes(resume, true, null);
+ if (isResumeCoordinatorOnly)
+ {
+ rpcService.executeCommandOnCoordinator(resume, true);
+ }
+ else
+ {
+ rpcService.executeCommandOnAllNodes(resume, true);
+ }
}
catch (SecurityException e)
{
@@ -1152,16 +1160,10 @@
}
isResponsibleForResuming = false;
- suspendFlag = null;
}
private void suspendLocally() throws SuspendException
{
- if (isResponsibleForResuming && suspendFlag == Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY)
- {
- return;
- }
-
if (isSuspended)
{
throw new SuspendException("Component already suspended.");
@@ -1185,11 +1187,6 @@
private void resumeLocally() throws ResumeException
{
- if (isResponsibleForResuming && suspendFlag == Suspendable.SUSPEND_COMPONENT_ON_OTHERS_NODES_ONLY)
- {
- return;
- }
-
if (!isSuspended)
{
throw new ResumeException("Component is not suspended.");
13 years, 2 months
exo-jcr SVN: r3988 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query: lucene and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-02-18 04:33:14 -0500 (Fri, 18 Feb 2011)
New Revision: 3988
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
Removed:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieve.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieveImpl.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandlerContext.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
Log:
EXOJCR-1193: Index retrieval from coordinator node
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecovery.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.query;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * Date: 16.02.2011
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: IndexRecovery.java 34360 2010-11-11 11:11:11Z tolusha $
+ */
+public interface IndexRecovery
+{
+ /**
+ * Get list of relative paths of all files from index directory.
+ *
+ * @return List
+ * @throws RepositoryException
+ * if any exception occurred
+ */
+ public List<String> getIndexList() throws RepositoryException;
+
+ /**
+ * Get input stream of index file.
+ * @param filePath
+ * String, relative file path
+ * @return InputStream
+ * @throws RepositoryException
+ * if any exception occurred
+ */
+ public InputStream getIndexFile(String filePath) throws RepositoryException;
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRecoveryImpl.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.query;
+
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
+import org.exoplatform.services.rpc.RPCException;
+import org.exoplatform.services.rpc.RPCService;
+import org.exoplatform.services.rpc.RemoteCommand;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * Date: 16.02.2011
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: IndexRetrievalImpl.java 34360 2010-11-11 11:11:11Z tolusha $
+ */
+public class IndexRecoveryImpl implements IndexRecovery
+{
+
+ /**
+ * Buffer size.
+ */
+ public static final int BUFFER_SIZE = 1024 * 1024;
+
+ /**
+ * The service for executing commands on all nodes of cluster.
+ */
+ protected final RPCService rpcService;
+
+ /**
+ * Remote command responsible for getting the list of relative paths of all files from index directory.
+ */
+ private RemoteCommand getIndexList;
+
+ /**
+ * Remote command responsible for getting data of target file.
+ */
+ private RemoteCommand getIndexFile;
+
+ /**
+ * Constructor IndexRetrieveImpl.
+ */
+ public IndexRecoveryImpl(RPCService rpcService, final String wsId, final boolean isSystem, final File indexDirectory)
+ {
+ this.rpcService = rpcService;
+
+ getIndexList = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexList-" + wsId + "-"
+ + isSystem;
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ int indexDirLen = PrivilegedFileHelper.getAbsolutePath(indexDirectory).length();
+
+ ArrayList<String> result = new ArrayList<String>();
+ for (File file : DirectoryHelper.listFiles(indexDirectory))
+ {
+ if (!file.isDirectory())
+ {
+ result.add(PrivilegedFileHelper.getAbsolutePath(file).substring(indexDirLen));
+ }
+ }
+
+ return result;
+ }
+ });
+
+ getIndexFile = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexFile-" + wsId + "-"
+ + isSystem;
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ String filePath = (String)args[0];
+ int offset = (Integer)args[1];
+
+ RandomAccessFile file = new RandomAccessFile(new File(indexDirectory, filePath), "r");
+ file.seek(offset);
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int len = file.read(buffer);
+
+ if (len == -1)
+ {
+ return null;
+ }
+ else
+ {
+ byte[] data = new byte[len];
+ System.arraycopy(buffer, 0, data, 0, len);
+
+ return data;
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<String> getIndexList() throws RepositoryException
+ {
+ try
+ {
+ return (List<String>)rpcService.executeCommandOnCoordinator(getIndexList, true);
+ }
+ catch (SecurityException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InputStream getIndexFile(String filePath) throws RepositoryException
+ {
+ try
+ {
+ return new RemoteInputStream(filePath);
+ }
+ catch (SecurityException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Allows to read data from remote machine.
+ */
+ class RemoteInputStream extends InputStream
+ {
+ private final String filePath;
+
+ private int fileOffset = 0;
+
+ private int bufferOffset = 0;
+
+ private byte[] buffer;
+
+ RemoteInputStream(String filePath) throws SecurityException, RPCException
+ {
+ this.filePath = filePath;
+ readNext();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read() throws IOException
+ {
+ throw new UnsupportedOperationException(
+ "RemoteStream.read(byte b[], int off, int len) method is not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int available() throws IOException
+ {
+ return buffer == null ? 0 : buffer.length - bufferOffset;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read(byte b[]) throws IOException
+ {
+ if (buffer == null)
+ {
+ return -1;
+ }
+ else if (available() == 0)
+ {
+ try
+ {
+ readNext();
+
+ if (buffer == null)
+ {
+ return -1;
+ }
+ }
+ catch (SecurityException e)
+ {
+ throw new IOException(e);
+ }
+ catch (RPCException e)
+ {
+ throw new IOException(e);
+ }
+ }
+
+ int len = Math.min(b.length, available());
+ System.arraycopy(buffer, bufferOffset, b, 0, len);
+ bufferOffset += len;
+
+ return len;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int read(byte b[], int off, int len) throws IOException
+ {
+ throw new UnsupportedOperationException(
+ "RemoteStream.read(byte b[], int off, int len) method is not supported");
+ }
+
+ private void readNext() throws SecurityException, RPCException
+ {
+ this.buffer = (byte[])rpcService.executeCommandOnCoordinator(getIndexFile, true, filePath, fileOffset);
+ if (buffer != null)
+ {
+ this.fileOffset += this.buffer.length;
+ this.bufferOffset = 0;
+ }
+ }
+ }
+}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieve.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieve.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieve.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.core.query;
-
-import java.io.InputStream;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * Date: 16.02.2011
- *
- * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
- * @version $Id: IndexRetrieve.java 34360 2010-11-11 11:11:11Z tolusha $
- */
-public interface IndexRetrieve
-{
- /**
- * Get list of relative paths of all files from index directory.
- *
- * @return List
- * @throws RepositoryException
- * if any exception occurred
- */
- public List<String> getIndexList() throws RepositoryException;
-
- /**
- * Get input stream of index file.
- * @param filePath
- * String, relative file path
- * @return InputStream
- * @throws RepositoryException
- * if any exception occurred
- */
- public InputStream getIndexFile(String filePath) throws RepositoryException;
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieveImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieveImpl.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexRetrieveImpl.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -1,276 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.core.query;
-
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
-import org.exoplatform.services.rpc.RPCException;
-import org.exoplatform.services.rpc.RPCService;
-import org.exoplatform.services.rpc.RemoteCommand;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * Date: 16.02.2011
- *
- * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
- * @version $Id: IndexRetrieveImpl.java 34360 2010-11-11 11:11:11Z tolusha $
- */
-public class IndexRetrieveImpl implements IndexRetrieve
-{
-
- /**
- * Buffer size.
- */
- public static final int BUFFER_SIZE = 1024 * 1024;
-
- /**
- * The service for executing commands on all nodes of cluster.
- */
- protected final RPCService rpcService;
-
- /**
- * Remote command responsible for getting the list of relative paths of all files from index directory.
- */
- private RemoteCommand getIndexList;
-
- /**
- * Remote command responsible for getting data of target file.
- */
- private RemoteCommand getIndexFile;
-
- /**
- * Constructor IndexRetrieveImpl.
- */
- public IndexRetrieveImpl(RPCService rpcService, final String wsId, final boolean isSystem, final File indexDirectory)
- {
- this.rpcService = rpcService;
-
- getIndexList = rpcService.registerCommand(new RemoteCommand()
- {
- public String getId()
- {
- return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexList-" + wsId + "-"
- + isSystem;
- }
-
- public Serializable execute(Serializable[] args) throws Throwable
- {
- int indexDirLen = PrivilegedFileHelper.getAbsolutePath(indexDirectory).length();
-
- StringBuilder result = new StringBuilder();
- for (File file : DirectoryHelper.listFiles(indexDirectory))
- {
- if (!file.isDirectory())
- {
- result.append(PrivilegedFileHelper.getAbsolutePath(file).substring(indexDirLen)).append('\n');
- }
- }
-
- return result.toString();
- }
- });
-
- getIndexFile = rpcService.registerCommand(new RemoteCommand()
- {
- public String getId()
- {
- return "org.exoplatform.services.jcr.impl.core.query.IndexRetrieveImpl-getIndexFile-" + wsId + "-"
- + isSystem;
- }
-
- public Serializable execute(Serializable[] args) throws Throwable
- {
- String filePath = (String)args[0];
- int offset = (Integer)args[1];
-
- RandomAccessFile file = new RandomAccessFile(new File(indexDirectory, filePath), "r");
- file.seek(offset);
-
- byte[] buffer = new byte[BUFFER_SIZE];
- int len = file.read(buffer);
-
- if (len == -1)
- {
- return null;
- }
- else
- {
- byte[] data = new byte[len];
- System.arraycopy(buffer, 0, data, 0, len);
-
- return data;
- }
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public List<String> getIndexList() throws RepositoryException
- {
- try
- {
- List<String> result = new ArrayList<String>();
-
- String data = (String)rpcService.executeCommandOnCoordinator(getIndexList, true);
- String[] files = data.split("\n");
-
- for (String file : files)
- {
- result.add(file);
- }
-
- return result;
- }
- catch (SecurityException e)
- {
- throw new RepositoryException(e);
- }
- catch (RPCException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public InputStream getIndexFile(String filePath) throws RepositoryException
- {
- try
- {
- return new RemoteInputStream(filePath);
- }
- catch (SecurityException e)
- {
- throw new RepositoryException(e);
- }
- catch (RPCException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Allows to read data from remote machine.
- */
- class RemoteInputStream extends InputStream
- {
- private final String filePath;
-
- private int fileOffset = 0;
-
- private int bufferOffset = 0;
-
- private byte[] buffer;
-
- RemoteInputStream(String filePath) throws SecurityException, RPCException
- {
- this.filePath = filePath;
- readNext();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int read() throws IOException
- {
- throw new UnsupportedOperationException(
- "RemoteStream.read(byte b[], int off, int len) method is not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int available() throws IOException
- {
- return buffer == null ? 0 : buffer.length - bufferOffset;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int read(byte b[]) throws IOException
- {
- if (buffer == null)
- {
- return -1;
- }
- else if (available() == 0)
- {
- try
- {
- readNext();
-
- if (buffer == null)
- {
- return -1;
- }
- }
- catch (SecurityException e)
- {
- throw new IOException(e);
- }
- catch (RPCException e)
- {
- throw new IOException(e);
- }
- }
-
- int len = Math.min(b.length, available());
- System.arraycopy(buffer, bufferOffset, b, 0, len);
- bufferOffset += len;
-
- return len;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int read(byte b[], int off, int len) throws IOException
- {
- throw new UnsupportedOperationException(
- "RemoteStream.read(byte b[], int off, int len) method is not supported");
- }
-
- private void readNext() throws SecurityException, RPCException
- {
- this.buffer = (byte[])rpcService.executeCommandOnCoordinator(getIndexFile, true, filePath, fileOffset);
- if (buffer != null)
- {
- this.fileOffset += this.buffer.length;
- this.bufferOffset = 0;
- }
- }
- }
-}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandlerContext.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandlerContext.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandlerContext.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -81,7 +81,7 @@
/**
* The class responsible for index retrieving from other place.
*/
- private final IndexRetrieve indexRetrieve;
+ private final IndexRecovery indexRecovery;
/**
* Creates a new context instance.
@@ -105,15 +105,15 @@
* @param excludedNodeId
* id of the node that should be excluded from indexing. Any
* descendant of that node is also excluded from indexing.
- * @param indexRetrieve
+ * @param indexRecovery
* the index retriever from other place
*/
public QueryHandlerContext(WorkspaceContainerFacade container, ItemDataConsumer stateMgr, IndexingTree indexingTree,
NodeTypeDataManager nodeTypeDataManager, NamespaceRegistryImpl nsRegistry, QueryHandler parentHandler,
String indexDirectory, DocumentReaderService extractor, boolean createInitialIndex,
- LuceneVirtualTableResolver virtualTableResolver, IndexRetrieve indexRetrieve)
+ LuceneVirtualTableResolver virtualTableResolver, IndexRecovery indexRecovery)
{
- this.indexRetrieve = indexRetrieve;
+ this.indexRecovery = indexRecovery;
this.container = container;
this.stateMgr = stateMgr;
this.indexingTree = indexingTree;
@@ -232,9 +232,9 @@
return indexDirectory;
}
- public IndexRetrieve getIndexRetrieve()
+ public IndexRecovery getIndexRecovery()
{
- return indexRetrieve;
+ return indexRecovery;
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -693,14 +693,14 @@
throw new RepositoryConfigurationException(e);
}
- IndexRetrieve indexRetrieve =
- rpcService == null ? null : new IndexRetrieveImpl(rpcService, getWsId(), parentHandler == null,
+ IndexRecovery indexRecovery =
+ rpcService == null ? null : new IndexRecoveryImpl(rpcService, getWsId(), parentHandler == null,
getIndexDirectory());
QueryHandlerContext context =
new QueryHandlerContext(container, itemMgr, indexingTree, nodeTypeDataManager, nsReg, parentHandler,
PrivilegedFileHelper.getAbsolutePath(getIndexDirectory()), extractor, true, virtualTableResolver,
- indexRetrieve);
+ indexRecovery);
return context;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -438,10 +438,10 @@
try
{
if (handler.getIndexRecoveryMode().equals(SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR)
- && handler.getContext().getIndexRetrieve() != null)
+ && handler.getContext().getIndexRecovery() != null)
{
log.info("Retrieving index from coordinator...");
- retreiveIndexFromCoordinator();
+ recoveryIndexFromCoordinator();
indexNames.read();
refreshIndexList();
@@ -3347,7 +3347,7 @@
* @throws RepositoryException.
* @throws FileNotFoundException.
*/
- private void retreiveIndexFromCoordinator() throws FileNotFoundException, RepositoryException, IOException,
+ private void recoveryIndexFromCoordinator() throws FileNotFoundException, RepositoryException, IOException,
SuspendException
{
List<Suspendable> suspendableComponents =
@@ -3366,7 +3366,7 @@
}
File indexDirectory = new File(handler.getContext().getIndexDirectory());
- for (String filePath : handler.getContext().getIndexRetrieve().getIndexList())
+ for (String filePath : handler.getContext().getIndexRecovery().getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
@@ -3375,7 +3375,7 @@
}
// transfer file
- InputStream in = handler.getContext().getIndexRetrieve().getIndexFile(filePath);
+ InputStream in = handler.getContext().getIndexRecovery().getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-02-18 08:30:00 UTC (rev 3987)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-02-18 09:33:14 UTC (rev 3988)
@@ -2932,7 +2932,7 @@
if (mode == IndexerIoMode.READ_WRITE)
{
// reprocess any notfinished notifies;
- log.info("Proceessing error log ...");
+ log.info("Processing error log ...");
recoverErrorLog(errorLog);
}
}
13 years, 2 months
exo-jcr SVN: r3987 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-02-18 03:30:00 -0500 (Fri, 18 Feb 2011)
New Revision: 3987
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
Log:
EXOJCR-1149: added scriptPath loading with ConfigurationManager
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-02-18 08:29:15 UTC (rev 3986)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-02-18 08:30:00 UTC (rev 3987)
@@ -21,6 +21,7 @@
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.configuration.ConfigurationException;
+import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.Property;
@@ -106,8 +107,10 @@
*
* @param params
* Initializations parameters
+ * @configurationManager
+ * configuration manager instance
*/
- public DBCreator(InitParams params) throws ConfigurationException
+ public DBCreator(InitParams params, ConfigurationManager configurationManager) throws ConfigurationException
{
if (params == null)
{
@@ -162,14 +165,23 @@
String scriptPath = prop.getProperty(DB_SCRIPT_PATH);
if (scriptPath != null)
{
+ String dbScript;
try
{
- dbScript = readScriptResource(scriptPath);
+ dbScript = readScriptResource(configurationManager.getInputStream(scriptPath));
}
- catch (IOException e)
+ catch (Exception e)
{
- throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+ try
+ {
+ dbScript = readScriptResource(PrivilegedFileHelper.fileInputStream(scriptPath));
+ }
+ catch (IOException ioe)
+ {
+ throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+ }
}
+ this.dbScript = dbScript;
}
else
{
@@ -438,11 +450,10 @@
}
/**
- * Read SQL script from file resource.
+ * Read SQL script from {@link InputStream}.
*/
- protected String readScriptResource(String path) throws IOException
+ protected String readScriptResource(InputStream is) throws IOException
{
- InputStream is = PrivilegedFileHelper.fileInputStream(path);
InputStreamReader isr = new InputStreamReader(is);
try
{
13 years, 2 months
exo-jcr SVN: r3986 - jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1584.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-02-18 03:29:15 -0500 (Fri, 18 Feb 2011)
New Revision: 3986
Modified:
jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1584/JCR-1584.patch
Log:
JCR-1584: patch updated - test code cleaned
Modified: jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1584/JCR-1584.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1584/JCR-1584.patch 2011-02-18 08:22:57 UTC (rev 3985)
+++ jcr/branches/1.12.x/patch/1.12.8-GA/JCR-1584/JCR-1584.patch 2011-02-18 08:29:15 UTC (rev 3986)
@@ -612,7 +612,7 @@
===================================================================
--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionedChild.java (revision 0)
+++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionedChild.java (revision 0)
-@@ -0,0 +1,770 @@
+@@ -0,0 +1,748 @@
+/*
+ * Copyright (C) 2003-2011 eXo Platform SAS.
+ *
@@ -638,10 +638,7 @@
+import org.exoplatform.services.jcr.util.VersionHistoryImporter;
+
+import java.io.ByteArrayInputStream;
-+import java.io.File;
-+import java.io.FileInputStream;
-+import java.io.FileOutputStream;
-+import java.io.OutputStream;
++import java.io.ByteArrayOutputStream;
+import java.util.Calendar;
+
+import javax.jcr.ImportUUIDBehavior;
@@ -704,13 +701,10 @@
+ wc1.checkout();
+
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
@@ -764,15 +758,16 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
+ wc1 = (NodeImpl)session.getItem("/parent/wc1");
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
@@ -798,17 +793,13 @@
+ picture.checkout();
+
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+ File childvhexport = new File("F:\\temp\\childvhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream childvhout = new FileOutputStream(childvhexport);
++ ByteArrayOutputStream childvhout = new ByteArrayOutputStream();
+ session.exportSystemView(picture.getVersionHistory().getPath(), childvhout, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
@@ -863,7 +854,8 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
@@ -871,14 +863,14 @@
+ picture = wc1.getNode("medias").getNode("picture");
+
+ VersionHistoryImporter chversionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)picture, new FileInputStream(childvhexport), chbaseVersion,
-+ chpredecessorsHistory, chversionHistory);
++ new VersionHistoryImporter((NodeImpl)picture, new ByteArrayInputStream(childvhout.toByteArray()),
++ chbaseVersion, chpredecessorsHistory, chversionHistory);
+ chversionHistoryImporter.doImport();
+ session.save();
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
@@ -940,15 +932,11 @@
+ subNode3.checkin();
+ subNode3.checkout();
+
-+ //TODO file path!!!!!!
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
@@ -1003,7 +991,8 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
@@ -1012,8 +1001,8 @@
+ subNode4 = (NodeImpl)session.getItem("/parent/wc1/medias/subnode1/subnode2/subnode3/subnode4");
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
@@ -1070,13 +1059,10 @@
+ assertTrue(picture.getProperty("jcr:isCheckedOut").getValue().getBoolean());
+
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
@@ -1149,15 +1135,16 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
+ wc1 = (NodeImpl)session.getItem("/parent/wc1");
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
@@ -1228,22 +1215,14 @@
+ wc1.checkin();
+ wc1.checkout();
+
-+ // picture.checkin();
-+ // picture.checkout();
-+
-+ //TODO file path!!!!!!
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
-+
+ String versionHistory = wc1.getProperty("jcr:versionHistory").getValue().getString();
+ String baseVersion = wc1.getProperty("jcr:baseVersion").getValue().getString();
+ Value[] jcrPredecessors = wc1.getProperty("jcr:predecessors").getValues();
@@ -1271,7 +1250,8 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
@@ -1279,8 +1259,8 @@
+ picture = wc1.getNode("medias").getNode("picture");
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
@@ -1320,13 +1300,10 @@
+ wc1.checkout();
+
+ // export import version history and node
-+ File export = new File("F:\\temp\\export.xml");
-+ File vhexport = new File("F:\\temp\\vhexport.xml");
-+
-+ OutputStream out = new FileOutputStream(export);
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/parent/wc1", out, false, false);
+
-+ OutputStream vhout = new FileOutputStream(vhexport);
++ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(wc1.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
@@ -1359,15 +1336,16 @@
+ vhout.close();
+
+ // import
-+ session.importXML("/parent", new FileInputStream(export), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
++ session.importXML("/parent", new ByteArrayInputStream(out.toByteArray()),
++ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
+ wc1 = (NodeImpl)session.getItem("/parent/wc1");
+
+ VersionHistoryImporter versionHistoryImporter =
-+ new VersionHistoryImporter((NodeImpl)wc1, new FileInputStream(vhexport), baseVersion, predecessorsHistory,
-+ versionHistory);
++ new VersionHistoryImporter((NodeImpl)wc1, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
++ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
13 years, 2 months
exo-jcr SVN: r3985 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-02-18 03:22:57 -0500 (Fri, 18 Feb 2011)
New Revision: 3985
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/MockConfigurationManagerImpl.java
Log:
EXOJCR-1149: wrapped to do privileged action
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/MockConfigurationManagerImpl.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/MockConfigurationManagerImpl.java 2011-02-17 16:17:58 UTC (rev 3984)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/MockConfigurationManagerImpl.java 2011-02-18 08:22:57 UTC (rev 3985)
@@ -19,9 +19,11 @@
package org.exoplatform.container.configuration;
import org.exoplatform.commons.utils.PrivilegedSystemHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.ExoContainer;
import java.net.URL;
+import java.security.PrivilegedAction;
import javax.servlet.ServletContext;
@@ -48,9 +50,15 @@
{
if (uri.startsWith("jar:"))
{
- String path = removePrefix("jar:/", uri);
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return cl.getResource(path);
+ final String path = removePrefix("jar:/", uri);
+ final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return SecurityHelper.doPrivilegedAction(new PrivilegedAction<URL>()
+ {
+ public URL run()
+ {
+ return cl.getResource(path);
+ }
+ });
}
else if (uri.startsWith("classpath:"))
{
13 years, 2 months