use of org.apache.hadoop.oncrpc.security.CredentialsNone in project hadoop by apache.
the class PortmapRequest method create.
public static XDR create(PortmapMapping mapping, boolean set) {
XDR request = new XDR();
int procedure = set ? RpcProgramPortmap.PMAPPROC_SET : RpcProgramPortmap.PMAPPROC_UNSET;
RpcCall call = RpcCall.getInstance(RpcUtil.getNewXid(String.valueOf(RpcProgramPortmap.PROGRAM)), RpcProgramPortmap.PROGRAM, RpcProgramPortmap.VERSION, procedure, new CredentialsNone(), new VerifierNone());
call.write(request);
return mapping.serialize(request);
}
use of org.apache.hadoop.oncrpc.security.CredentialsNone in project hadoop by apache.
the class TestPortmap method testRegistration.
@Test(timeout = 1000)
public void testRegistration() throws IOException, InterruptedException {
XDR req = new XDR();
RpcCall.getInstance(++xid, RpcProgramPortmap.PROGRAM, RpcProgramPortmap.VERSION, RpcProgramPortmap.PMAPPROC_SET, new CredentialsNone(), new VerifierNone()).write(req);
PortmapMapping sent = new PortmapMapping(90000, 1, PortmapMapping.TRANSPORT_TCP, 1234);
sent.serialize(req);
byte[] reqBuf = req.getBytes();
DatagramSocket s = new DatagramSocket();
DatagramPacket p = new DatagramPacket(reqBuf, reqBuf.length, pm.getUdpServerLoAddress());
try {
s.send(p);
} finally {
s.close();
}
// Give the server a chance to process the request
Thread.sleep(100);
boolean found = false;
@SuppressWarnings("unchecked") Map<String, PortmapMapping> map = (Map<String, PortmapMapping>) Whitebox.getInternalState(pm.getHandler(), "map");
for (PortmapMapping m : map.values()) {
if (m.getPort() == sent.getPort() && PortmapMapping.key(m).equals(PortmapMapping.key(sent))) {
found = true;
break;
}
}
Assert.assertTrue("Registration failed", found);
}
use of org.apache.hadoop.oncrpc.security.CredentialsNone in project hadoop by apache.
the class TestRpcCall method testConstructor.
@Test
public void testConstructor() {
Credentials credential = new CredentialsNone();
Verifier verifier = new VerifierNone();
int rpcVersion = RpcCall.RPC_VERSION;
int program = 2;
int version = 3;
int procedure = 4;
RpcCall call = new RpcCall(0, RpcMessage.Type.RPC_CALL, rpcVersion, program, version, procedure, credential, verifier);
assertEquals(0, call.getXid());
assertEquals(RpcMessage.Type.RPC_CALL, call.getMessageType());
assertEquals(rpcVersion, call.getRpcVersion());
assertEquals(program, call.getProgram());
assertEquals(version, call.getVersion());
assertEquals(procedure, call.getProcedure());
assertEquals(credential, call.getCredential());
assertEquals(verifier, call.getVerifier());
}
use of org.apache.hadoop.oncrpc.security.CredentialsNone in project hadoop by apache.
the class TestOutOfOrderWrite method create.
static XDR create() {
XDR request = new XDR();
RpcCall.getInstance(0x8000004c, Nfs3Constant.PROGRAM, Nfs3Constant.VERSION, Nfs3Constant.NFSPROC3.CREATE.getValue(), new CredentialsNone(), new VerifierNone()).write(request);
SetAttr3 objAttr = new SetAttr3();
CREATE3Request createReq = new CREATE3Request(new FileHandle("/"), "out-of-order-write" + System.currentTimeMillis(), 0, objAttr, 0);
createReq.serialize(request);
return request;
}
use of org.apache.hadoop.oncrpc.security.CredentialsNone in project hadoop by apache.
the class TestOutOfOrderWrite method write.
static XDR write(FileHandle handle, int xid, long offset, int count, byte[] data) {
XDR request = new XDR();
RpcCall.getInstance(xid, Nfs3Constant.PROGRAM, Nfs3Constant.VERSION, Nfs3Constant.NFSPROC3.CREATE.getValue(), new CredentialsNone(), new VerifierNone()).write(request);
WRITE3Request write1 = new WRITE3Request(handle, offset, count, WriteStableHow.UNSTABLE, ByteBuffer.wrap(data));
write1.serialize(request);
return request;
}
Aggregations