Search in sources :

Example 1 with CredentialsNone

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);
}
Also used : RpcCall(org.apache.hadoop.oncrpc.RpcCall) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone)

Example 2 with CredentialsNone

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);
}
Also used : DatagramSocket(java.net.DatagramSocket) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) DatagramPacket(java.net.DatagramPacket) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone) Map(java.util.Map) Test(org.junit.Test)

Example 3 with CredentialsNone

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());
}
Also used : VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone) Verifier(org.apache.hadoop.oncrpc.security.Verifier) Credentials(org.apache.hadoop.oncrpc.security.Credentials) Test(org.junit.Test)

Example 4 with CredentialsNone

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;
}
Also used : SetAttr3(org.apache.hadoop.nfs.nfs3.request.SetAttr3) FileHandle(org.apache.hadoop.nfs.nfs3.FileHandle) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone) CREATE3Request(org.apache.hadoop.nfs.nfs3.request.CREATE3Request)

Example 5 with CredentialsNone

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;
}
Also used : XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) WRITE3Request(org.apache.hadoop.nfs.nfs3.request.WRITE3Request) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone)

Aggregations

CredentialsNone (org.apache.hadoop.oncrpc.security.CredentialsNone)5 VerifierNone (org.apache.hadoop.oncrpc.security.VerifierNone)5 XDR (org.apache.hadoop.oncrpc.XDR)4 Test (org.junit.Test)2 DatagramPacket (java.net.DatagramPacket)1 DatagramSocket (java.net.DatagramSocket)1 Map (java.util.Map)1 FileHandle (org.apache.hadoop.nfs.nfs3.FileHandle)1 CREATE3Request (org.apache.hadoop.nfs.nfs3.request.CREATE3Request)1 SetAttr3 (org.apache.hadoop.nfs.nfs3.request.SetAttr3)1 WRITE3Request (org.apache.hadoop.nfs.nfs3.request.WRITE3Request)1 RpcCall (org.apache.hadoop.oncrpc.RpcCall)1 Credentials (org.apache.hadoop.oncrpc.security.Credentials)1 Verifier (org.apache.hadoop.oncrpc.security.Verifier)1