Author: nzamosenchuk
Date: 2012-01-16 10:01:06 -0500 (Mon, 16 Jan 2012)
New Revision: 5453
Modified:
jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java
Log:
EXOJCR-1709: Added index retrieval on startup. Small refactoring.
Modified:
jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java
===================================================================
---
jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java 2012-01-16
08:06:08 UTC (rev 5452)
+++
jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java 2012-01-16
15:01:06 UTC (rev 5453)
@@ -94,20 +94,40 @@
}
- /**
- * {@inheritDoc}
- */
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void refreshIndexes(Set<String> set)
{
+ triggerRSyncSynchronization();
+ // call super, after indexes are synchronized
+ super.refreshIndexes(set);
+ }
+
+ @Override
+ public void read() throws IOException
+ {
+ // synchronizing indexes on read access to index list for Read-Only mode
+ // allowing to synchronize indexes on startup
+ triggerRSyncSynchronization();
+ super.read();
+ }
+
+ /**
+ * Call to system RSync binary implementation,
+ */
+ private void triggerRSyncSynchronization()
+ {
// Call RSync to retrieve actual index from coordinator
if (modeHandler.getMode() == IndexerIoMode.READ_ONLY)
{
- if (cache.getLocalAddress() instanceof IpAddress)
+ if (((CacheSPI<Serializable,
Object>)cache).getRPCManager().getCoordinator() instanceof IpAddress)
{
// Coordinator's address
String address =
-
((IpAddress)((CacheSPI)cache).getRPCManager().getCoordinator()).getIpAddress().getHostAddress();
+ ((IpAddress)((CacheSPI<Serializable,
Object>)cache).getRPCManager().getCoordinator()).getIpAddress()
+ .getHostAddress();
RSyncJob rSyncJob = new RSyncJob(String.format(urlFormatString, address),
indexPath);
try
{
@@ -122,8 +142,6 @@
}
}
}
- // call super, after indexes are synchronized
- super.refreshIndexes(set);
}
private class RSyncJob
@@ -140,6 +158,7 @@
this.dst = dst;
}
+ // TODO : Use JNI and librsync library? or handle err stream
public void execute() throws IOException
{
Runtime run = Runtime.getRuntime();
Show replies by date