Exemplo n.º 1
0
  public void runAsync(final Path root) {
    SimpleAsyncExecutorService.getUnmanagedInstance()
        .execute(
            new DescriptiveRunnable() {
              @Override
              public String getDescription() {
                return "Path BatchIndex [" + root.toString() + "]";
              }

              @Override
              public void run() {
                BatchIndex.this.run(root);
              }
            });
  }
Exemplo n.º 2
0
  public void runAsync(final FileSystem fs) {
    if (fs != null && fs.getRootDirectories().iterator().hasNext()) {
      SimpleAsyncExecutorService.getUnmanagedInstance()
          .execute(
              new DescriptiveRunnable() {
                @Override
                public String getDescription() {
                  return "FS BatchIndex [" + ((FileSystemId) fs).id() + "]";
                }

                @Override
                public void run() {
                  final AtomicBoolean indexFinished = new AtomicBoolean(false);
                  indexEngine.beforeDispose(
                      new Runnable() {
                        @Override
                        public void run() {
                          indexDisposed.set(true);

                          if (!indexFinished.get()) {
                            indexEngine.delete(KObjectUtil.toKCluster(fs));
                          }
                        }
                      });

                  try {
                    for (final Path root : fs.getRootDirectories()) {
                      BatchIndex.this.run(root);
                    }
                    indexFinished.set(true);
                  } catch (Exception ex) {
                    if (!indexDisposed.get()) {
                      LOG.error("FileSystem Index fails. [@" + fs.toString() + "]", ex);
                    }
                  }
                }
              });
    }
  }