当前位置: 首页>>代码示例>>Java>>正文


Java XDR类代码示例

本文整理汇总了Java中org.apache.hadoop.oncrpc.XDR的典型用法代码示例。如果您正苦于以下问题:Java XDR类的具体用法?Java XDR怎么用?Java XDR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XDR类属于org.apache.hadoop.oncrpc包,在下文中一共展示了XDR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
public static READ3Response deserialize(XDR xdr) {
  int status = xdr.readInt();
  xdr.readBoolean();
  Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.deserialize(xdr);
  int count = 0;
  boolean eof = false;
  byte[] data = new byte[0];

  if (status == Nfs3Status.NFS3_OK) {
    count = xdr.readInt();
    eof = xdr.readBoolean();
    int len = xdr.readInt();
    assert (len == count);
    data = xdr.readFixedOpaque(count);
  }

  return new READ3Response(status, postOpAttr, count, eof,
      ByteBuffer.wrap(data));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:READ3Response.java

示例2: deserialize

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
public static READDIR3Response deserialize(XDR xdr) {
  int status = xdr.readInt();
  xdr.readBoolean();
  Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.deserialize(xdr);
  long cookieVerf = 0;
  ArrayList<Entry3> entries = new ArrayList<Entry3>();
  DirList3 dirList = null;

  if (status == Nfs3Status.NFS3_OK) {
    cookieVerf = xdr.readHyper();
    while (xdr.readBoolean()) {
      Entry3 e =  Entry3.deserialzie(xdr);
      entries.add(e);
    }
    boolean eof = xdr.readBoolean();
    Entry3[] allEntries = new Entry3[entries.size()];
    entries.toArray(allEntries);
    dirList = new DirList3(allEntries, eof);
  }
  return new READDIR3Response(status, postOpDirAttr, cookieVerf, dirList);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:READDIR3Response.java

示例3: deserialize

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
public static PATHCONF3Response deserialize(XDR xdr) {
  int status = xdr.readInt();
  xdr.readBoolean();
  Nfs3FileAttributes objPostOpAttr = Nfs3FileAttributes.deserialize(xdr);
  int linkMax = 0;
  int nameMax = 0;
  boolean noTrunc = false;
  boolean chownRestricted = false;
  boolean caseInsensitive = false;
  boolean casePreserving = false;

  if (status == Nfs3Status.NFS3_OK) {
    linkMax = xdr.readInt();
    nameMax = xdr.readInt();
    noTrunc = xdr.readBoolean();
    chownRestricted = xdr.readBoolean();
    caseInsensitive = xdr.readBoolean();
    casePreserving = xdr.readBoolean();
  }
  return new PATHCONF3Response(status, objPostOpAttr, linkMax, nameMax,
      noTrunc, chownRestricted, caseInsensitive, casePreserving);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:PATHCONF3Response.java

示例4: testStart

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test
public void testStart() throws IOException {
  // Start minicluster
  NfsConfiguration config = new NfsConfiguration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(config).numDataNodes(1)
      .build();
  cluster.waitActive();
  
  // Use emphral port in case tests are running in parallel
  config.setInt("nfs3.mountd.port", 0);
  config.setInt("nfs3.server.port", 0);
  
  // Start nfs
  Nfs3 nfs3 = new Nfs3(config);
  nfs3.startServiceInternal(false);

  RpcProgramMountd mountd = (RpcProgramMountd) nfs3.getMountd()
      .getRpcProgram();
  mountd.nullOp(new XDR(), 1234, InetAddress.getByName("localhost"));
  
  RpcProgramNfs3 nfsd = (RpcProgramNfs3) nfs3.getRpcProgram();
  nfsd.nullProcedure();
  
  cluster.shutdown();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestMountd.java

示例5: testGetattr

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testGetattr() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
  long dirId = status.getFileId();
  FileHandle handle = new FileHandle(dirId);
  XDR xdr_req = new XDR();
  GETATTR3Request req = new GETATTR3Request(handle);
  req.serialize(xdr_req);
  
  // Attempt by an unpriviledged user should fail.
  GETATTR3Response response1 = nfsd.getattr(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  GETATTR3Response response2 = nfsd.getattr(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java

示例6: testSetattr

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSetattr() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
  long dirId = status.getFileId();
  XDR xdr_req = new XDR();
  FileHandle handle = new FileHandle(dirId);
  SetAttr3 symAttr = new SetAttr3(0, 1, 0, 0, null, null,
      EnumSet.of(SetAttrField.UID));
  SETATTR3Request req = new SETATTR3Request(handle, symAttr, false, null);
  req.serialize(xdr_req);

  // Attempt by an unprivileged user should fail.
  SETATTR3Response response1 = nfsd.setattr(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  SETATTR3Response response2 = nfsd.setattr(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRpcProgramNfs3.java

示例7: testAccess

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testAccess() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
  long dirId = status.getFileId();
  FileHandle handle = new FileHandle(dirId);
  XDR xdr_req = new XDR();
  ACCESS3Request req = new ACCESS3Request(handle);
  req.serialize(xdr_req);

  // Attempt by an unpriviledged user should fail.
  ACCESS3Response response1 = nfsd.access(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  ACCESS3Response response2 = nfsd.access(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java

示例8: testRead

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testRead() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
  long dirId = status.getFileId();
  FileHandle handle = new FileHandle(dirId);

  READ3Request readReq = new READ3Request(handle, 0, 5);
  XDR xdr_req = new XDR();
  readReq.serialize(xdr_req);

  // Attempt by an unpriviledged user should fail.
  READ3Response response1 = nfsd.read(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  READ3Response response2 = nfsd.read(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRpcProgramNfs3.java

示例9: createFileUsingNfs

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
private void createFileUsingNfs(String fileName, byte[] buffer)
    throws Exception {
  DFSTestUtil.createFile(hdfs, new Path(fileName), 0, (short) 1, 0);

  final HdfsFileStatus status = nn.getRpcServer().getFileInfo(fileName);
  final long dirId = status.getFileId();
  final FileHandle handle = new FileHandle(dirId);

  final WRITE3Request writeReq = new WRITE3Request(handle, 0,
      buffer.length, WriteStableHow.DATA_SYNC, ByteBuffer.wrap(buffer));
  final XDR xdr_req = new XDR();
  writeReq.serialize(xdr_req);

  final WRITE3Response response = nfsd.write(xdr_req.asReadOnlyWrap(),
      null, 1, securityHandler,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect response: ", null, response);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRpcProgramNfs3.java

示例10: testCreate

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testCreate() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
  long dirId = status.getFileId();
  XDR xdr_req = new XDR();
  FileHandle handle = new FileHandle(dirId);
  CREATE3Request req = new CREATE3Request(handle, "fubar",
      Nfs3Constant.CREATE_UNCHECKED, new SetAttr3(), 0);
  req.serialize(xdr_req);
  
  // Attempt by an unpriviledged user should fail.
  CREATE3Response response1 = nfsd.create(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  CREATE3Response response2 = nfsd.create(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRpcProgramNfs3.java

示例11: testSymlink

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testSymlink() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
  long dirId = status.getFileId();
  XDR xdr_req = new XDR();
  FileHandle handle = new FileHandle(dirId);
  SYMLINK3Request req = new SYMLINK3Request(handle, "fubar", new SetAttr3(),
      "bar");
  req.serialize(xdr_req);

  // Attempt by an unprivileged user should fail.
  SYMLINK3Response response1 = nfsd.symlink(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a privileged user should pass.
  SYMLINK3Response response2 = nfsd.symlink(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRpcProgramNfs3.java

示例12: testRmdir

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testRmdir() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
  long dirId = status.getFileId();
  XDR xdr_req = new XDR();
  FileHandle handle = new FileHandle(dirId);
  RMDIR3Request req = new RMDIR3Request(handle, "foo");
  req.serialize(xdr_req);

  // Attempt by an unprivileged user should fail.
  RMDIR3Response response1 = nfsd.rmdir(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a privileged user should pass.
  RMDIR3Response response2 = nfsd.rmdir(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java

示例13: testRename

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testRename() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
  long dirId = status.getFileId();
  XDR xdr_req = new XDR();
  FileHandle handle = new FileHandle(dirId);
  RENAME3Request req = new RENAME3Request(handle, "bar", handle, "fubar");
  req.serialize(xdr_req);
  
  // Attempt by an unprivileged user should fail.
  RENAME3Response response1 = nfsd.rename(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a privileged user should pass.
  RENAME3Response response2 = nfsd.rename(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java

示例14: testFsstat

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testFsstat() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
  long dirId = status.getFileId();
  FileHandle handle = new FileHandle(dirId);
  XDR xdr_req = new XDR();
  FSSTAT3Request req = new FSSTAT3Request(handle);
  req.serialize(xdr_req);
  
  // Attempt by an unpriviledged user should fail.
  FSSTAT3Response response1 = nfsd.fsstat(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  FSSTAT3Response response2 = nfsd.fsstat(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java

示例15: testPathconf

import org.apache.hadoop.oncrpc.XDR; //导入依赖的package包/类
@Test(timeout = 60000)
public void testPathconf() throws Exception {
  HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
  long dirId = status.getFileId();
  FileHandle handle = new FileHandle(dirId);
  XDR xdr_req = new XDR();
  PATHCONF3Request req = new PATHCONF3Request(handle);
  req.serialize(xdr_req);
  
  // Attempt by an unpriviledged user should fail.
  PATHCONF3Response response1 = nfsd.pathconf(xdr_req.asReadOnlyWrap(),
      securityHandlerUnpriviledged,
      new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
      response1.getStatus());

  // Attempt by a priviledged user should pass.
  PATHCONF3Response response2 = nfsd.pathconf(xdr_req.asReadOnlyWrap(),
      securityHandler, new InetSocketAddress("localhost", 1234));
  assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
      response2.getStatus());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRpcProgramNfs3.java


注:本文中的org.apache.hadoop.oncrpc.XDR类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。