Exemplo n.º 1
0
 StoreDirectory(Distributor distributor) throws IOException {
   this.distributor = distributor;
   synchronized (mutex) {
     MapBuilder<String, StoreFileMetaData> builder = MapBuilder.newMapBuilder();
     Map<String, String> checksums =
         readChecksums(distributor.all(), new HashMap<String, String>());
     for (Directory delegate : distributor.all()) {
       for (String file : delegate.listAll()) {
         String checksum = checksums.get(file);
         builder.put(
             file, new StoreFileMetaData(file, delegate.fileLength(file), checksum, delegate));
       }
     }
     filesMetadata = builder.immutableMap();
     files = filesMetadata.keySet().toArray(new String[filesMetadata.size()]);
   }
 }
Exemplo n.º 2
0
 @Override
 public void close() throws IOException {
   for (Directory delegate : distributor.all()) {
     delegate.close();
   }
   synchronized (mutex) {
     filesMetadata = ImmutableMap.of();
     files = Strings.EMPTY_ARRAY;
   }
 }
Exemplo n.º 3
0
 /**
  * Creates a new Directory from the given distributor. The default implementation returns a new
  * {@link org.elasticsearch.index.store.DistributorDirectory} if there is more than one data path
  * in the distributor.
  */
 public Directory newFromDistributor(final Distributor distributor) throws IOException {
   if (distributor.all().length == 1) {
     // use filter dir for consistent toString methods
     return new FilterDirectory(distributor.primary()) {
       @Override
       public String toString() {
         return distributor.toString();
       }
     };
   }
   return new DistributorDirectory(distributor);
 }
Exemplo n.º 4
0
 synchronized void closeInternal() throws IOException {
   if (isOpen) {
     isOpen = false;
     for (Directory delegate : distributor.all()) {
       delegate.close();
     }
     synchronized (mutex) {
       filesMetadata = ImmutableOpenMap.of();
       files = Strings.EMPTY_ARRAY;
     }
   }
 }
Exemplo n.º 5
0
 public Directory[] delegates() {
   return distributor.all();
 }