如何进行lucene FileDiRecordy索引的在线热备份?

如何进行lucene FileDiRecordy索引的在线热备份?,lucene,backup,Lucene,Backup,我正在考虑添加JMXbean,以便对lucene索引进行热备份 LuceneMBean mbean=新LuceneMBeanImpl; ObjectName=newObjectNameIndexing.index:type=lucene; MBeanServer mbs=ManagementFactory.getPlatformMBeanServer; mbs.registerMBeanmbean,名称 Lucembean将有一个名为backupIndexString目录的方法 我查阅了luce

我正在考虑添加JMXbean,以便对lucene索引进行热备份

LuceneMBean mbean=新LuceneMBeanImpl; ObjectName=newObjectNameIndexing.index:type=lucene; MBeanServer mbs=ManagementFactory.getPlatformMBeanServer; mbs.registerMBeanmbean,名称

Lucembean将有一个名为backupIndexString目录的方法

我查阅了lucene文档,找到了目录的复制方法。如果我在目录上打开了Writer,这个方法会起作用吗?基本上,我的代码片段如下所示:

public class LuceneMBeanImpl implements LuceneMBean{
     public void backupIndex(String directory){
           Directory fileDirectory =  FSDirectory.getDirectory(directory);
           Directory.copy(masterDirectory, fileDirectory,false);
     }
}

我认为一个开放的Writer应该是可以的,但是当另一个线程修改索引时,您肯定不能复制,否则您可能会遇到FileNotFoundException。来源:

 /**
   * Copy contents of a directory src to a directory dest.
   * If a file in src already exists in dest then the
   * one in dest will be blindly overwritten.
   *
   * <p><b>NOTE:</b> the source directory cannot change
   * while this method is running.  Otherwise the results
   * are undefined and you could easily hit a
   * FileNotFoundException.
   *
   * @param src source directory
   * @param dest destination directory
   * @param closeDirSrc if <code>true</code>, call {@link #close()} method on source directory
   * @throws IOException
   */
  public static void copy(Directory src, Directory dest, boolean closeDirSrc) throws IOException {