Exemplo n.º 1
0
  @Override
  public void execute(Controller controller) {
    FSImage fsi = controller.fsImages.get(fsiUuid);
    cm = controller.getCommandManager();
    FileTransferManager ftm = controller.getFileTransferManager();

    if (!fsi.isLocal()) {
      String message = "No such FSImage on the target side";
      failed(new IllegalStateException(), message);
      return;
    }

    Path pathToRoot = fsi.getPathToRoot();
    Path fullPath = pathToRoot.resolve(path.toPath());

    // save memo about this operation on the target side
    ftm.addTarget(operationUuid, fullPath);
    try (RandomAccessFile f = new RandomAccessFile(fullPath.toFile(), "rw")) {
      f.setLength(size);
      // will send next command to the source
      cm.sendCommand(new QueryDownloadFile(operationUuid));
    } catch (IOException e) {
      String message = String.format("Allocation memory failed: \r\n %s", e.toString());
      failed(e, message);
    }
  }
Exemplo n.º 2
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    FSImage fsImage = (FSImage) o;

    String thisXml = this.toXml();
    String thatXml = fsImage.toXml();

    if (!thisXml.equals(thatXml)) return false;

    return true;
  }