[exo-jcr-commits] exo-jcr SVN: r5594 - in jcr/branches/1.14-RSYNC: exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Feb 9 08:25:01 EST 2012


Author: nzamosenchuk
Date: 2012-02-09 08:25:01 -0500 (Thu, 09 Feb 2012)
New Revision: 5594

Added:
   jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/RsyncIndexInfos.java
   jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RSyncJob.java
Modified:
   jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
   jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
   jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java
Log:
EXOJCR-1745 : ISPN-based RSync indexing concept implementation.

Added: jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RSyncJob.java
===================================================================
--- jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RSyncJob.java	                        (rev 0)
+++ jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RSyncJob.java	2012-02-09 13:25:01 UTC (rev 5594)
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2003-2012 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.jbosscache;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ *          exo at exoplatform.com
+ * Feb 6, 2012  
+ */
+/**
+ * Wrapper of native process calling RSYNC utility 
+ */
+public class RSyncJob
+{
+   final Log log = ExoLogger.getLogger("exo.jcr.component.core.RsyncJob");
+
+   private final static String RSYNC_USER_SYSTEM_PROPERTY = "USER";
+
+   private final static String RSYNC_PASSWORD_SYSTEM_PROPERTY = "RSYNC_PASSWORD";
+
+   private Process process;
+
+   private final String src;
+
+   private final String dst;
+
+   private String userName;
+
+   private String password;
+
+   public RSyncJob(String src, String dst, String userName, String password)
+   {
+      this.src = src.endsWith(File.separator) ? src : src + File.separator;
+      this.dst = dst;
+      this.userName = userName;
+      this.password = password;
+   }
+
+   /**
+    * Executes RSYNC synchronization job 
+    * 
+    * @throws IOException
+    */
+   public void execute() throws IOException
+   {
+      // Future todo: Use JNI and librsync library?
+      Runtime run = Runtime.getRuntime();
+      try
+      {
+         String command = "rsync -rv --delete " + src + " " + dst;
+         if (log.isDebugEnabled())
+         {
+            log.debug("Rsync job started: " + command);
+         }
+         if (userName != null && password != null)
+         {
+            String[] envProperties =
+               new String[]{RSYNC_USER_SYSTEM_PROPERTY + "=" + userName,
+                  RSYNC_PASSWORD_SYSTEM_PROPERTY + "=" + password};
+            process = run.exec(command, envProperties);
+         }
+         else
+         {
+            process = run.exec(command);
+         }
+
+         // Handle process Standard and Error output
+         InputStream stderr = process.getErrorStream();
+         InputStreamReader isrErr = new InputStreamReader(stderr);
+         BufferedReader brErr = new BufferedReader(isrErr);
+
+         InputStream stdout = process.getInputStream();
+         InputStreamReader isrStd = new InputStreamReader(stdout);
+         BufferedReader brStd = new BufferedReader(isrStd);
+
+         String val = null;
+         StringBuilder stringBuilderErr = new StringBuilder();
+         StringBuilder stringBuilderStd = new StringBuilder();
+         while ((val = brStd.readLine()) != null)
+         {
+            stringBuilderStd.append(val);
+            stringBuilderStd.append('\n');
+         }
+
+         while ((val = brErr.readLine()) != null)
+         {
+            stringBuilderErr.append(val);
+            stringBuilderErr.append('\n');
+         }
+
+         Integer returnCode = null;
+         // wait for thread
+         while (returnCode == null)
+         {
+            try
+            {
+               returnCode = process.waitFor();
+            }
+            catch (InterruptedException e)
+            {
+               // oops, this can happen sometimes
+            }
+         }
+         if (log.isDebugEnabled())
+         {
+            log.debug("Rsync job finished: " + returnCode + ". Error stream output \n"
+               + stringBuilderErr.toString() + " Standard stream output \n" + stringBuilderStd.toString());
+         }
+         if (returnCode != 0)
+         {
+            throw new IOException("RSync job finished with exit code is " + returnCode + ". Error stream output: \n"
+               + stringBuilderErr.toString());
+         }
+      }
+      finally
+      {
+         process = null;
+      }
+   }
+
+   public void forceCancel()
+   {
+      if (process != null)
+      {
+         process.destroy();
+      }
+   }
+}
\ No newline at end of file


Property changes on: jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RSyncJob.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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-02-09 12:59:53 UTC (rev 5593)
+++ jcr/branches/1.14-RSYNC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/RsyncIndexInfos.java	2012-02-09 13:25:01 UTC (rev 5594)
@@ -27,11 +27,8 @@
 import org.jboss.cache.notifications.annotation.CacheListener;
 import org.jgroups.stack.IpAddress;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.Serializable;
 import java.util.Set;
 
@@ -45,7 +42,7 @@
 public class RsyncIndexInfos extends JBossCacheIndexInfos
 {
 
-   private final Log log = ExoLogger.getLogger("exo.jcr.component.core.RsyncIndexInfos");
+   final Log log = ExoLogger.getLogger("exo.jcr.component.core.RsyncIndexInfos");
 
    private final String indexPath;
 
@@ -156,122 +153,4 @@
       }
    }
 
-   /**
-    * Wrapper of native process calling RSYNC utility 
-    */
-   private class RSyncJob
-   {
-      private final static String RSYNC_USER_SYSTEM_PROPERTY = "USER";
-
-      private final static String RSYNC_PASSWORD_SYSTEM_PROPERTY = "RSYNC_PASSWORD";
-
-      private Process process;
-
-      private final String src;
-
-      private final String dst;
-
-      private String userName;
-
-      private String password;
-
-      public RSyncJob(String src, String dst, String userName, String password)
-      {
-         this.src = src.endsWith(File.separator) ? src : src + File.separator;
-         this.dst = dst;
-         this.userName = userName;
-         this.password = password;
-      }
-
-      /**
-       * Executes RSYNC synchronization job 
-       * 
-       * @throws IOException
-       */
-      public void execute() throws IOException
-      {
-         // Future todo: Use JNI and librsync library?
-         Runtime run = Runtime.getRuntime();
-         try
-         {
-            String command = "rsync -rv --delete " + src + " " + dst;
-            if (log.isDebugEnabled())
-            {
-               log.debug("Rsync job started: " + command);
-            }
-            if (userName != null && password != null)
-            {
-               String[] envProperties =
-                  new String[]{RSYNC_USER_SYSTEM_PROPERTY + "=" + userName,
-                     RSYNC_PASSWORD_SYSTEM_PROPERTY + "=" + password};
-               process = run.exec(command, envProperties);
-            }
-            else
-            {
-               process = run.exec(command);
-            }
-
-            // Handle process Standard and Error output
-            InputStream stderr = process.getErrorStream();
-            InputStreamReader isrErr = new InputStreamReader(stderr);
-            BufferedReader brErr = new BufferedReader(isrErr);
-
-            InputStream stdout = process.getInputStream();
-            InputStreamReader isrStd = new InputStreamReader(stdout);
-            BufferedReader brStd = new BufferedReader(isrStd);
-
-            String val = null;
-            StringBuilder stringBuilderErr = new StringBuilder();
-            StringBuilder stringBuilderStd = new StringBuilder();
-            while ((val = brStd.readLine()) != null)
-            {
-               stringBuilderStd.append(val);
-               stringBuilderStd.append('\n');
-            }
-
-            while ((val = brErr.readLine()) != null)
-            {
-               stringBuilderErr.append(val);
-               stringBuilderErr.append('\n');
-            }
-
-            Integer returnCode = null;
-            // wait for thread
-            while (returnCode == null)
-            {
-               try
-               {
-                  returnCode = process.waitFor();
-               }
-               catch (InterruptedException e)
-               {
-                  // oops, this can happen sometimes
-               }
-            }
-            if (log.isDebugEnabled())
-            {
-               log.debug("Rsync job finished: " + returnCode + ". Error stream output \n" + stringBuilderErr.toString()
-                  + " Standard stream output \n" + stringBuilderStd.toString());
-            }
-            if (returnCode != 0)
-            {
-               throw new IOException("RSync job finished with exit code is " + returnCode + ". Error stream output: \n"
-                  + stringBuilderErr.toString());
-            }
-         }
-         finally
-         {
-            process = null;
-         }
-      }
-
-      public void forceCancel()
-      {
-         if (process != null)
-         {
-            process.destroy();
-         }
-      }
-   }
-
 }

Modified: jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
===================================================================
--- jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	2012-02-09 12:59:53 UTC (rev 5593)
+++ jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	2012-02-09 13:25:01 UTC (rev 5594)
@@ -27,6 +27,8 @@
 import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
 import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
 import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
 import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
 import org.exoplatform.services.jcr.util.IdGenerator;
 import org.exoplatform.services.log.ExoLogger;
@@ -66,7 +68,21 @@
     * Unique workspace identifier.
     */
    private final String wsId;
+   
 
+   // RSYNC SERVER CONFIGURATION
+   public static final String PARAM_RSYNC_ENTRY_NAME = "rsync-entry-name";
+
+   public static final String PARAM_RSYNC_ENTRY_PATH = "rsync-entry-path";
+
+   public static final String PARAM_RSYNC_PORT = "rsync-port";
+
+   public static final int PARAM_RSYNC_PORT_DEFAULT = 873;
+
+   public static final String PARAM_RSYNC_USER = "rsync-user";
+
+   public static final String PARAM_RSYNC_PASSWORD = "rsync-password";
+
    /**
     * ISPNIndexChangesFilter constructor.
     */
@@ -94,19 +110,54 @@
 
       if (!parentHandler.isInitialized())
       {
-         parentHandler.setIndexInfos(new ISPNIndexInfos(searchManager.getWsId(), cache, true, modeHandler));
+         parentHandler.setIndexInfos(createIndexInfos(true, modeHandler, config, parentHandler));
          parentHandler.setIndexUpdateMonitor(new ISPNIndexUpdateMonitor(searchManager.getWsId(), cache, true,
             modeHandler));
          parentHandler.init();
       }
       if (!handler.isInitialized())
       {
-         handler.setIndexInfos(new ISPNIndexInfos(searchManager.getWsId(), cache, false, modeHandler));
+         handler.setIndexInfos(createIndexInfos(false, modeHandler, config, handler));
          handler.setIndexUpdateMonitor(new ISPNIndexUpdateMonitor(searchManager.getWsId(), cache, false, modeHandler));
          handler.init();
       }
    }
    
+
+   /**
+    * Factory method for creating corresponding IndexInfos class. RSyncIndexInfos created if RSync configured
+    * and JBossCacheIndexInfos otherwise
+    * 
+    * @param system
+    * @param modeHandler
+    * @param config
+    * @param handler
+    * @return
+    * @throws RepositoryConfigurationException
+    */
+   private IndexInfos createIndexInfos(Boolean system, IndexerIoModeHandler modeHandler, QueryHandlerEntry config,
+      QueryHandler handler) throws RepositoryConfigurationException
+   {
+      // read RSYNC configuration
+      String rsyncEntryName = config.getParameterValue(PARAM_RSYNC_ENTRY_NAME, null);
+      String rsyncEntryPath = config.getParameterValue(PARAM_RSYNC_ENTRY_PATH, null);
+      String rsyncUserName = config.getParameterValue(PARAM_RSYNC_USER, null);
+      String rsyncPassword = config.getParameterValue(PARAM_RSYNC_PASSWORD, null);
+      int rsyncPort = config.getParameterInteger(PARAM_RSYNC_PORT, PARAM_RSYNC_PORT_DEFAULT);
+
+      // rsync configured
+      if (rsyncEntryName != null)
+      {
+         return new RsyncIndexInfos(wsId, cache, system, modeHandler, ((SearchIndex)handler).getContext()
+            .getIndexDirectory(), rsyncPort, rsyncEntryName, rsyncEntryPath, rsyncUserName, rsyncPassword);
+      }
+      else
+      {
+         return new ISPNIndexInfos(wsId, cache, true, modeHandler);
+      }
+
+   }
+   
    protected Log getLogger()
    {
       return log;

Modified: jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
===================================================================
--- jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java	2012-02-09 12:59:53 UTC (rev 5593)
+++ jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java	2012-02-09 13:25:01 UTC (rev 5594)
@@ -70,17 +70,17 @@
    /**
     * ISPN cache.
     */
-   private final Cache<Serializable, Object> cache;
+   protected final Cache<Serializable, Object> cache;
 
    /**
     * Used to retrieve the current mode.
     */
-   private final IndexerIoModeHandler modeHandler;
+   protected final IndexerIoModeHandler modeHandler;
 
    /**
     * Cache key for storing index names.
     */
-   private final IndexInfosKey namesKey;
+   protected final IndexInfosKey namesKey;
    
    /**
     * Need to write the index info out of the current transaction 
@@ -211,22 +211,39 @@
          Set<String> set = (Set<String>)event.getValue();
          if (set != null)
          {
-            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);
-            }
+            refreshIndexes(set);
          }
       }
    }
+   
+
+
+   /**
+    * Update index configuration, when it changes on persistent storage 
+    * 
+    * @param set
+    */
+  protected void refreshIndexes(Set<String> set)
+  {
+     // do nothing if null is passed
+     if (set == null)
+     {
+        return;
+     }
+     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);
+     }
+  }
+   
 }

Added: jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/RsyncIndexInfos.java
===================================================================
--- jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/RsyncIndexInfos.java	                        (rev 0)
+++ jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/RsyncIndexInfos.java	2012-02-09 13:25:01 UTC (rev 5594)
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2003-2012 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.ispn;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+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.jbosscache.RSyncJob;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.Cache;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.remoting.transport.jgroups.JGroupsAddress;
+import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jgroups.Channel;
+import org.jgroups.Event;
+import org.jgroups.stack.IpAddress;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ *          exo at exoplatform.com
+ * Jan 11, 2012  
+ */
+ at CacheListener
+public class RsyncIndexInfos extends ISPNIndexInfos
+{
+
+   private final Log log = ExoLogger.getLogger("exo.jcr.component.core.RsyncIndexInfos");
+
+   private final String indexPath;
+
+   private final String urlFormatString;
+
+   private final String rsyncUserName;
+
+   private final String rsyncPassword;
+
+   public RsyncIndexInfos(String wsId, Cache<Serializable, Object> cache, boolean system,
+      IndexerIoModeHandler modeHandler, String indexPath, int rsyncPort, String rsyncEntryName, String rsyncEntryPath,
+      String rsyncUserName, String rsyncPassword) throws RepositoryConfigurationException
+   {
+      super(wsId, cache, system, modeHandler);
+      this.rsyncUserName = rsyncUserName;
+      this.rsyncPassword = rsyncPassword;
+
+      String absoluteRsyncEntryPath;
+      try
+      {
+         this.indexPath = new File(indexPath).getCanonicalPath();
+         absoluteRsyncEntryPath = new File(rsyncEntryPath).getCanonicalPath();
+      }
+      catch (IOException e)
+      {
+         throw new RepositoryConfigurationException("Index path or rsyncEntry path is invalid.", e);
+      }
+
+      if (this.indexPath.startsWith(absoluteRsyncEntryPath))
+      {
+         // in relation to RSync Server Entry
+         // i.e. absolute index path is /var/portal/data/index/repo1/ws2
+         // i.e. RSync Server Entry is "index" pointing to /var/portal/data/index
+         // then relative path is repo1/ws2
+         // and whole url is "rsync://<addr>:<port>/<entryName>/repo1/ws2"
+         String relativeIndexPath = this.indexPath.substring(absoluteRsyncEntryPath.length());
+
+         // if client is Windows OS, need to replace all '\' with '/' used in url
+         if (File.separatorChar == '\\')
+         {
+            relativeIndexPath = relativeIndexPath.replace(File.separatorChar, '/');
+         }
+         // generate ready-to-use formatter string with address variable 
+         urlFormatString = "rsync://%s:" + rsyncPort + "/" + rsyncEntryName + relativeIndexPath + "/";
+      }
+      else
+      {
+         throw new RepositoryConfigurationException(
+            "Invalid RSync configuration. Index must be placed in folder that is a descendant of RSync Server Entry. Current RSync Server Entry Path is : "
+               + absoluteRsyncEntryPath
+               + " but it doesnt hold Index folder, that is : "
+               + this.indexPath
+               + ". Please fix configuration according to JCR Documentation and restart application.");
+      }
+
+   }
+
+   /**
+   * {@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)
+      {
+         EmbeddedCacheManager cacheManager = cache.getCacheManager();
+
+         if (cacheManager.getCoordinator() instanceof JGroupsAddress
+            && cacheManager.getTransport() instanceof JGroupsTransport)
+         {
+            JGroupsTransport transport = (JGroupsTransport)cacheManager.getTransport();
+            // Coordinator's address
+            org.jgroups.Address jgAddress = ((JGroupsAddress)cacheManager.getCoordinator()).getJGroupsAddress();
+            // if jgAddress is UUID address, not the physical one, then retrieve via channel
+            if (!(jgAddress instanceof IpAddress))
+            {
+               // this is the only way of getting physical address. 
+               Channel channel = transport.getChannel();
+               jgAddress = (org.jgroups.Address)channel.down(new Event(Event.GET_PHYSICAL_ADDRESS, jgAddress));
+            }
+            if (jgAddress instanceof IpAddress)
+            {
+               String address = ((IpAddress)jgAddress).getIpAddress().getHostAddress();
+               RSyncJob rSyncJob =
+                  new RSyncJob(String.format(urlFormatString, address), indexPath, rsyncUserName, rsyncPassword);
+               try
+               {
+                  // synchronizing access to RSync Job.
+                  // No parallel jobs allowed
+                  synchronized (this)
+                  {
+                     rSyncJob.execute();
+                  }
+               }
+               catch (IOException e)
+               {
+                  log.error("Failed to retrieve index using RSYNC", e);
+               }
+            }
+            else
+            {
+               log.error("Error triggering RSync synchronization, skipped. Unsupported Address object : "
+                  + jgAddress.getClass().getName());
+            }
+         }
+         else
+         {
+            log.error("Error triggering RSync synchronization, skipped. Unsupported Address object : "
+               + cacheManager.getCoordinator().getClass().getName());
+         }
+      }
+   }
+}


Property changes on: jcr/branches/1.14-RSYNC/exo.jcr.component.core.impl.infinispan.v5/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/RsyncIndexInfos.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the exo-jcr-commits mailing list