예제 #1
0
  public Path[] getListInstalledPlugins() throws IOException {
    if (!Files.exists(environment.pluginsFile())) {
      return new Path[0];
    }

    try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
      return Iterators.toArray(stream.iterator(), Path.class);
    }
  }
예제 #2
0
  @Override
  public void parse() throws IOException {
    if (conservedRegionPath == null
        || !Files.exists(conservedRegionPath)
        || !Files.isDirectory(conservedRegionPath)) {
      throw new IOException(
          "Conservation directory whether does not exist, is not a directory or cannot be read");
    }

    Map<String, Path> files = new HashMap<>();
    String chromosome;
    Set<String> chromosomes = new HashSet<>();

    // Reading all files in phastCons folder
    DirectoryStream<Path> directoryStream =
        Files.newDirectoryStream(conservedRegionPath.resolve("phastCons"));
    for (Path path : directoryStream) {
      chromosome = path.getFileName().toString().split("\\.")[0].replace("chr", "");
      chromosomes.add(chromosome);
      files.put(chromosome + "phastCons", path);
    }

    // Reading all files in phylop folder
    directoryStream = Files.newDirectoryStream(conservedRegionPath.resolve("phylop"));
    for (Path path : directoryStream) {
      chromosome = path.getFileName().toString().split("\\.")[0].replace("chr", "");
      chromosomes.add(chromosome);
      files.put(chromosome + "phylop", path);
    }

    /** Now we can iterate over all the chromosomes found and process the files */
    logger.debug("Chromosomes found {}", chromosomes.toString());
    for (String chr : chromosomes) {
      logger.debug("Processing chromosome {}, file {}", chr, files.get(chr + "phastCons"));
      processFile(files.get(chr + "phastCons"), "phastCons");

      logger.debug("Processing chromosome {}, file {}", chr, files.get(chr + "phylop"));
      processFile(files.get(chr + "phylop"), "phylop");
    }
  }
 private static Set<ShardId> findAllShardsForIndex(Path indexPath) throws IOException {
   Set<ShardId> shardIds = new HashSet<>();
   if (Files.isDirectory(indexPath)) {
     try (DirectoryStream<Path> stream = Files.newDirectoryStream(indexPath)) {
       String currentIndex = indexPath.getFileName().toString();
       for (Path shardPath : stream) {
         if (Files.isDirectory(shardPath)) {
           Integer shardId = Ints.tryParse(shardPath.getFileName().toString());
           if (shardId != null) {
             ShardId id = new ShardId(currentIndex, shardId);
             shardIds.add(id);
           }
         }
       }
     }
   }
   return shardIds;
 }
예제 #4
0
    private int getNumberOfItems(Path quellOrdner) {
      int retValue = 0;

      try {
        DirectoryStream<Path> qstream = Files.newDirectoryStream(quellOrdner);
        for (Path qfile : qstream) {
          if (Files.isDirectory(qfile)) {
            getNumberOfItems(Paths.get(quellOrdner.toString() + "/" + qfile.getFileName()));
          }
          i++;
        }
        qstream.close();
      } catch (IOException e) {
        e.printStackTrace();
      }

      retValue = i;
      return retValue;
    }
 public Set<String> findAllIndices() throws IOException {
   if (nodePaths == null || locks == null) {
     throw new IllegalStateException("node is not configured to store local location");
   }
   assert assertEnvIsLocked();
   Set<String> indices = Sets.newHashSet();
   for (NodePath nodePath : nodePaths) {
     Path indicesLocation = nodePath.indicesPath;
     if (Files.isDirectory(indicesLocation)) {
       try (DirectoryStream<Path> stream = Files.newDirectoryStream(indicesLocation)) {
         for (Path index : stream) {
           if (Files.isDirectory(index)) {
             indices.add(index.getFileName().toString());
           }
         }
       }
     }
   }
   return indices;
 }
 /**
  * Tries to find all allocated shards for the given index on the current node. NOTE: This methods
  * is prone to race-conditions on the filesystem layer since it might not see directories created
  * concurrently or while it's traversing.
  *
  * @param index the index to filter shards
  * @return a set of shard IDs
  * @throws IOException if an IOException occurs
  */
 public Set<ShardId> findAllShardIds(final Index index) throws IOException {
   assert index != null;
   if (nodePaths == null || locks == null) {
     throw new IllegalStateException("node is not configured to store local location");
   }
   assert assertEnvIsLocked();
   final Set<ShardId> shardIds = Sets.newHashSet();
   String indexName = index.name();
   for (final NodePath nodePath : nodePaths) {
     Path location = nodePath.indicesPath;
     if (Files.isDirectory(location)) {
       try (DirectoryStream<Path> indexStream = Files.newDirectoryStream(location)) {
         for (Path indexPath : indexStream) {
           if (indexName.equals(indexPath.getFileName().toString())) {
             shardIds.addAll(findAllShardsForIndex(indexPath));
           }
         }
       }
     }
   }
   return shardIds;
 }
예제 #7
0
    public void cnpStart(Path quellOrdner, Path zielOrdner) {
      try {
        DirectoryStream<Path> qstream = Files.newDirectoryStream(quellOrdner);
        for (Path qfile : qstream) {
          Path target = Paths.get(zielOrdner.toString() + "/" + qfile.getFileName());
          if (abbruch) break;
          if (Files.isDirectory(qfile) && !Files.exists(target)) {
            Files.createDirectory(target);
            textArea.append("Verzeichnis: " + qfile + " wurde erstellt" + System.lineSeparator());
            cnpStart(
                Paths.get(quellOrdner.toString() + "/" + qfile.getFileName()),
                Paths.get(zielOrdner.toString() + "/" + qfile.getFileName()));
          } else if (Files.isDirectory(qfile) && Files.exists(target)) {
            textArea.append("Wechsle in Verzeichnis: " + qfile + System.lineSeparator());
            cnpStart(
                Paths.get(quellOrdner.toString() + "/" + qfile.getFileName()),
                Paths.get(zielOrdner.toString() + "/" + qfile.getFileName()));
          }
          // Wenn die Datei noch nicht existiert
          else if (!Files.exists(target)) {
            textArea.append(
                "Datei " + target.toString() + " wurde erstellt" + System.lineSeparator());
            Files.copy(qfile, target, StandardCopyOption.REPLACE_EXISTING);

          }
          // Wenn Datei im Zielverzeichnis schon existiert
          else if (Files.exists(target)) {
            if (cAUeSchr) {
              textArea.append(
                  "Datei "
                      + target.toString()
                      + " wird absolut überschrieben"
                      + System.lineSeparator());
              Files.copy(qfile, target, StandardCopyOption.REPLACE_EXISTING);
            } else if (cUeSchr) {
              if (checkAlter(
                  Paths.get(quellOrdner.toString() + "/" + qfile.getFileName()),
                  Paths.get(zielOrdner.toString() + "/" + qfile.getFileName()))) {
                textArea.append(
                    target.toString()
                        + " wird mit neuer Datei überschrieben"
                        + System.lineSeparator());
                Files.copy(qfile, target, StandardCopyOption.REPLACE_EXISTING);
              } else {
                textArea.append(
                    target.toString() + " alte Datei bleibt bestehen" + System.lineSeparator());
              }
            } else
              textArea.append(
                  target.toString() + " alte Datei bleibt bestehen" + System.lineSeparator());
          }
          pbCounter++;
          progressBar.setValue(pbCounter);
        }

        qstream.close();
      } catch (IOException e) {

        e.printStackTrace();
      }
    }