Package org.apache.hadoop.nfs.nfs3.response

Examples of org.apache.hadoop.nfs.nfs3.response.WccData


    if (LOG.isDebugEnabled()) {
      LOG.debug("NFS SYMLINK, target: " + symData + " link: " + linkIdPath);
    }

    try {
      WccData dirWcc = response.getDirWcc();
      WccAttr preOpAttr = Nfs3Utils.getWccAttr(dfsClient, linkDirIdPath);
      dirWcc.setPreOpAttr(preOpAttr);

      dfsClient.createSymlink(symData, linkIdPath, false);
      // Set symlink attr is considered as to change the attr of the target
      // file. So no need to set symlink attr here after it's created.

      HdfsFileStatus linkstat = dfsClient.getFileLinkInfo(linkIdPath);
      Nfs3FileAttributes objAttr = Nfs3Utils.getNfs3FileAttrFromFileStatus(
          linkstat, iug);
      dirWcc
          .setPostOpAttr(Nfs3Utils.getFileAttr(dfsClient, linkDirIdPath, iug));

      return new SYMLINK3Response(Nfs3Status.NFS3_OK, new FileHandle(
          objAttr.getFileid()), objAttr, dirWcc);
View Full Code Here


        LOG.info("Can't get path for fileId:" + handle.getFileId());
        return new COMMIT3Response(Nfs3Status.NFS3ERR_STALE);
      }
     
      if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
        return new COMMIT3Response(Nfs3Status.NFS3ERR_ACCES, new WccData(
            Nfs3Utils.getWccAttr(preOpAttr), preOpAttr),
            Nfs3Constant.WRITE_COMMIT_VERF);
      }
     
      long commitOffset = (request.getCount() == 0) ? 0
          : (request.getOffset() + request.getCount());
     
      int status;
      if (writeManager.handleCommit(handle, commitOffset)) {
        status = Nfs3Status.NFS3_OK;
      } else {
        status = Nfs3Status.NFS3ERR_IO;
      }
      Nfs3FileAttributes postOpAttr = writeManager.getFileAttr(dfsClient,
          handle, iug);
      WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr), postOpAttr);
      return new COMMIT3Response(status, fileWcc,
          Nfs3Constant.WRITE_COMMIT_VERF);

    } catch (IOException e) {
      LOG.warn("Exception ", e);
      Nfs3FileAttributes postOpAttr = null;
      try {
        postOpAttr = writeManager.getFileAttr(dfsClient, handle, iug);
      } catch (IOException e1) {
        LOG.info("Can't get postOpAttr for fileId: " + handle.getFileId());
      }
      WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr), postOpAttr);
      return new COMMIT3Response(Nfs3Status.NFS3ERR_IO, fileWcc,
          Nfs3Constant.WRITE_COMMIT_VERF);
    }
  }
View Full Code Here

      } catch (IOException e) {
        LOG.error("Can't apapend to file:" + fileIdPath + ", error:" + e);
        if (fos != null) {
          fos.close();
        }
        WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr),
            preOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
            fileWcc, count, request.getStableHow(),
            Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
        return;
      }

      // Add open stream
      String writeDumpDir = config.get(Nfs3Constant.FILE_DUMP_DIR_KEY,
          Nfs3Constant.FILE_DUMP_DIR_DEFAULT);
      openFileCtx = new OpenFileCtx(fos, latestAttr, writeDumpDir + "/"
          + fileHandle.getFileId());
      addOpenFileStream(fileHandle, openFileCtx);
      if (LOG.isDebugEnabled()) {
        LOG.debug("opened stream for file:" + fileHandle.getFileId());
      }
    }

    // Add write into the async job queue
    openFileCtx.receivedNewWrite(dfsClient, request, channel, xid,
        asyncDataService, iug);
    // Block stable write
    if (request.getStableHow() != WriteStableHow.UNSTABLE) {
      if (handleCommit(fileHandle, offset + count)) {
        Nfs3FileAttributes postOpAttr = getFileAttr(dfsClient, handle, iug);
        WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr),
            postOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, request.getStableHow(),
            Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
View Full Code Here

    lockCtx();
    try {
      if (!activeState) {
        LOG.info("OpenFileCtx is inactive, fileId:"
            + request.getHandle().getFileId());
        WccData fileWcc = new WccData(latestAttr.getWccAttr(), latestAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
            fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
      } else {
        // Handle repeated write requests(same xid or not).
        // If already replied, send reply again. If not replied, drop the
        // repeated request.
        WriteCtx existantWriteCtx = checkRepeatedWriteRequest(request, channel,
            xid);
        if (existantWriteCtx != null) {
          if (!existantWriteCtx.getReplied()) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Repeated write request which hasn't be served: xid="
                  + xid + ", drop it.");
            }
          } else {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Repeated write request which is already served: xid="
                  + xid + ", resend response.");
            }
            WccData fileWcc = new WccData(latestAttr.getWccAttr(), latestAttr);
            WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
                fileWcc, request.getCount(), request.getStableHow(),
                Nfs3Constant.WRITE_COMMIT_VERF);
            Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
          }
View Full Code Here

      updateLastAccessTime();
      Nfs3FileAttributes postOpAttr = new Nfs3FileAttributes(latestAttr);

      // Send response immediately for unstable write
      if (request.getStableHow() == WriteStableHow.UNSTABLE) {
        WccData fileWcc = new WccData(preOpAttr, postOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
        writeCtx.setReplied(true);
      }

    } else if (offset > nextOffset) {
      LOG.info("Add new write to the list but not update nextOffset:"
          + nextOffset);
      WriteCtx writeCtx = new WriteCtx(request.getHandle(),
          request.getOffset(), request.getCount(), request.getStableHow(),
          request.getData().array(), channel, xid, false, DataState.ALLOW_DUMP);
      addWrite(writeCtx);

      // Check if need to dump some pending requests to file
      checkDump(request.getCount());
      updateLastAccessTime();
      Nfs3FileAttributes postOpAttr = new Nfs3FileAttributes(latestAttr);
     
      // In test, noticed some Linux client sends a batch (e.g., 1MB)
      // of reordered writes and won't send more writes until it gets
      // responses of the previous batch. So here send response immediately for
      // unstable non-sequential write
      if (request.getStableHow() == WriteStableHow.UNSTABLE) {
        WccData fileWcc = new WccData(preOpAttr, postOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
        writeCtx.setReplied(true);
      }

    } else {
      // offset < nextOffset
      LOG.warn("(offset,count,nextOffset):" + "(" + offset + "," + count + ","
          + nextOffset + ")");
      WccData wccData = new WccData(preOpAttr, null);
      WRITE3Response response;

      if (offset + count > nextOffset) {
        LOG.warn("Haven't noticed any partial overwrite out of a sequential file"
            + "write requests, so treat it as a real random write, no support.");
View Full Code Here

        updateNonSequentialWriteInMemory(-count);
      }
     
      if (!writeCtx.getReplied()) {
        WccAttr preOpAttr = latestAttr.getWccAttr();
        WccData fileWcc = new WccData(preOpAttr, latestAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
      }
View Full Code Here

      LOG.info("Fail pending write: (" + key.getMin() + "," + key.getMax()
          + "), nextOffset=" + getNextOffsetUnprotected());
     
      WriteCtx writeCtx = pendingWrites.remove(key);
      if (!writeCtx.getReplied()) {
        WccData fileWcc = new WccData(preOpAttr, latestAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
            fileWcc, 0, writeCtx.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(writeCtx.getChannel(),
            response.send(new XDR(), writeCtx.getXid()));
      }
View Full Code Here

  // TODO: maybe not efficient
  public static WccData createWccData(final WccAttr preOpAttr,
      DFSClient dfsClient, final String fileIdPath, final IdUserGroup iug)
      throws IOException {
    Nfs3FileAttributes postOpDirAttr = getFileAttr(dfsClient, fileIdPath, iug);
    return new WccData(preOpAttr, postOpDirAttr);
  }
View Full Code Here

    lockCtx();
    try {
      if (!activeState) {
        LOG.info("OpenFileCtx is inactive, fileId:"
            + request.getHandle().getFileId());
        WccData fileWcc = new WccData(latestAttr.getWccAttr(), latestAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
            fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
      } else {
        // Handle repeated write requests(same xid or not).
        // If already replied, send reply again. If not replied, drop the
        // repeated request.
        WriteCtx existantWriteCtx = checkRepeatedWriteRequest(request, channel,
            xid);
        if (existantWriteCtx != null) {
          if (!existantWriteCtx.getReplied()) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Repeated write request which hasn't be served: xid="
                  + xid + ", drop it.");
            }
          } else {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Repeated write request which is already served: xid="
                  + xid + ", resend response.");
            }
            WccData fileWcc = new WccData(latestAttr.getWccAttr(), latestAttr);
            WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
                fileWcc, request.getCount(), request.getStableHow(),
                Nfs3Constant.WRITE_COMMIT_VERF);
            Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
          }
View Full Code Here

      updateLastAccessTime();
      Nfs3FileAttributes postOpAttr = new Nfs3FileAttributes(latestAttr);

      // Send response immediately for unstable write
      if (request.getStableHow() == WriteStableHow.UNSTABLE) {
        WccData fileWcc = new WccData(preOpAttr, postOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
        writeCtx.setReplied(true);
      }

    } else if (offset > nextOffset) {
      LOG.info("Add new write to the list but not update nextOffset:"
          + nextOffset);
      WriteCtx writeCtx = new WriteCtx(request.getHandle(),
          request.getOffset(), request.getCount(), request.getStableHow(),
          request.getData().array(), channel, xid, false, WriteCtx.ALLOW_DUMP);
      addWrite(writeCtx);

      // Check if need to dump some pending requests to file
      checkDump(request.getCount());
      updateLastAccessTime();
      Nfs3FileAttributes postOpAttr = new Nfs3FileAttributes(latestAttr);
     
      // In test, noticed some Linux client sends a batch (e.g., 1MB)
      // of reordered writes and won't send more writes until it gets
      // responses of the previous batch. So here send response immediately for
      // unstable non-sequential write
      if (request.getStableHow() == WriteStableHow.UNSTABLE) {
        WccData fileWcc = new WccData(preOpAttr, postOpAttr);
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
            fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
        Nfs3Utils.writeChannel(channel, response.send(new XDR(), xid));
        writeCtx.setReplied(true);
      }

    } else {
      // offset < nextOffset
      LOG.warn("(offset,count,nextOffset):" + "(" + offset + "," + count + ","
          + nextOffset + ")");
      WccData wccData = new WccData(preOpAttr, null);
      WRITE3Response response;

      if (offset + count > nextOffset) {
        LOG.warn("Haven't noticed any partial overwrite out of a sequential file"
            + "write requests, so treat it as a real random write, no support.");
View Full Code Here

TOP

Related Classes of org.apache.hadoop.nfs.nfs3.response.WccData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.