Exemplo n.º 1
0
 public boolean delete(boolean recurse) throws VrsException {
   ITaskMonitor monitor =
       getVRSContext()
           .getTaskWatcher()
           .getCurrentThreadTaskMonitor("Deleting (SRM) directory:" + this.getPath(), 1);
   monitor.logPrintf("Deleting SRM Directory:" + this + "\n");
   return srmfs.rmdir(getPath(), recurse);
 }
Exemplo n.º 2
0
  @Override
  public void close() throws IOException {
    try {
      outputStream.close();
    } catch (Exception e) {
      info("Couldn't close outputstream. Already closed ?:" + e);
    }

    try {
      // after closing a stream we can register the replica
      // together with a new LFC entry:
      if (lfcFile.exists() == false) {
        monitor.startSubTask("LFC: Registering new File entry", -1);
        monitor.logPrintf("LFC: Registering new File entry:\n - " + lfcFile + "\n");
        lfcFile.create(); // register new netry without replicas
        monitor.endSubTask("LFC: Registering new File entry");
      }

      // as soon as the replica is created register it
      if (isNewReplica) {
        monitor.startSubTask("LFC: Registering new replica", -1);
        monitor.logPrintf("LFC: Registering new replica:\n - " + replica.getVRL() + "\n");
        this.client.addReplica(monitor, lfcFile, replica, true);

        monitor.endSubTask("LFC: Registering new replica");
      } else {
        // if this is an existing replica just update metadata (checksum
        // , size). This also fixes the bug of getting the correct size
        // after writing twice
        monitor.startSubTask("LFC: Updating replica metadata", -1);
        monitor.logPrintf("LFC: Updating metadata for: \n - " + replica.getVRL() + "\n");
        client.updateReplicaMetaData(monitor, lfcFile, replica);

        monitor.endSubTask("LFC: Updating replica metadata");
      }

      // LinkHandling new or existing file should be resolved link:
      FileDescWrapper wrapperDesc = client.queryPath(lfcFile.getPath(), true);

      lfcFile.setWrapperDesc(wrapperDesc);

      debug("-------------LFC file is:        " + lfcFile.getLength() + " bytes");
      debug("-------------Replica file is      " + replica.getLength() + " bytes");

      if (lfcFile.getLength() != replica.getLength()) {
        error(
            "LFC file and replica file sizes don't match!!! LFC file is "
                + lfcFile.getLength()
                + " bytes and replica "
                + replica.getLength()
                + " bytes");
      }

      monitor.logPrintf(
          "LFC: Finalizing entry: setting new file size (updated from replica) to:"
              + wrapperDesc.getFileDesc().getFileSize()
              + "\n");

      info("Closing OutputStream. Finalizing upload to:" + lfcFile);

    } catch (Exception e) {
      IOException ex = new IOException(e.getMessage());
      ex.initCause(e);
      throw ex;
    } finally {

    }
  }