Esempio n. 1
0
  protected List<String> getPaths() throws PNFSException {
    Request request = createGetPathsRequest();
    Response rsp = PNFS.request(request);

    Map<String, String> args = rsp.getArgs();
    int num = 0;

    try {
      num = Integer.parseInt(args.get("paths"));
    } catch (NumberFormatException e) {
      throw new PNFSException("invalid response from ypfs server");
    }

    List<String> paths = new ArrayList<String>(num);

    for (int i = 1; i < num + 1; i++) {
      String path = args.get("path" + i);
      if (path != null) {
        paths.add(path);
      }
    }

    return paths;
  }
Esempio n. 2
0
  protected List<Path> parsePaths(Response response) {
    Map<String, String> args = response.getArgs();

    String fid = args.get("fid");
    List<Path> dists = null;

    if (args.containsKey("dev_count")) {
      int count = Integer.parseInt(args.get("dev_count"));

      dists = new ArrayList<Path>(count);

      for (int i = 1; i <= count; i++) {
        dists.add(new Path(fid, args.get("devid_" + i), args.get("path_" + i)));
      }
    } else {
      dists = new ArrayList<Path>(1);
      dists.add(new Path(fid, args.get("devid"), args.get("path")));
    }
    return dists;
  }
Esempio n. 3
0
 protected Response createOpen() {
   Response rsp = PNFS.request(Command.CREATE_OPEN, this);
   setFilename(rsp.getArgs().get("filename"));
   return rsp;
 }