HADOOP-10990. Add missed NFSv3 request and response classes. Contributed by Brandon Li
This commit is contained in:
parent
e1109fb656
commit
bad5f38d47
@ -485,6 +485,8 @@ Release 2.6.0 - UNRELEASED
|
||||
HADOOP-11030. Define a variable jackson.version instead of using constant
|
||||
at multiple places. (Juan Yu via kasha)
|
||||
|
||||
HADOOP-10990. Add missed NFSv3 request and response classes (brandonli)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-10838. Byte array native checksumming. (James Thomas via todd)
|
||||
|
@ -53,8 +53,18 @@ public class Nfs3FileAttributes {
|
||||
* For Hadoop, currently this field is always zero.
|
||||
*/
|
||||
public static class Specdata3 {
|
||||
final static int specdata1 = 0;
|
||||
final static int specdata2 = 0;
|
||||
final int specdata1;
|
||||
final int specdata2;
|
||||
|
||||
public Specdata3() {
|
||||
specdata1 = 0;
|
||||
specdata2 = 0;
|
||||
}
|
||||
|
||||
public Specdata3(int specdata1, int specdata2) {
|
||||
this.specdata1 = specdata1;
|
||||
this.specdata2 = specdata2;
|
||||
}
|
||||
|
||||
public int getSpecdata1() {
|
||||
return specdata1;
|
||||
|
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
/**
|
||||
* LINK3 Request
|
||||
*/
|
||||
public class LINK3Request extends RequestWithHandle {
|
||||
private final FileHandle fromDirHandle;
|
||||
private final String fromName;
|
||||
|
||||
public LINK3Request(FileHandle handle, FileHandle fromDirHandle,
|
||||
String fromName) {
|
||||
super(handle);
|
||||
this.fromDirHandle = fromDirHandle;
|
||||
this.fromName = fromName;
|
||||
}
|
||||
|
||||
public static LINK3Request deserialize(XDR xdr) throws IOException {
|
||||
FileHandle handle = readHandle(xdr);
|
||||
FileHandle fromDirHandle = readHandle(xdr);
|
||||
String fromName = xdr.readString();
|
||||
return new LINK3Request(handle, fromDirHandle, fromName);
|
||||
}
|
||||
|
||||
public FileHandle getFromDirHandle() {
|
||||
return fromDirHandle;
|
||||
}
|
||||
|
||||
public String getFromName() {
|
||||
return fromName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
fromDirHandle.serialize(xdr);
|
||||
xdr.writeInt(fromName.length());
|
||||
xdr.writeFixedOpaque(fromName.getBytes(), fromName.length());
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.request;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.nfs.NfsFileType;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes.Specdata3;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
/**
|
||||
* MKNOD3 Request
|
||||
*/
|
||||
public class MKNOD3Request extends RequestWithHandle {
|
||||
private final String name;
|
||||
private int type;
|
||||
private SetAttr3 objAttr = null;
|
||||
private Specdata3 spec = null;
|
||||
|
||||
public MKNOD3Request(FileHandle handle, String name, int type,
|
||||
SetAttr3 objAttr, Specdata3 spec) {
|
||||
super(handle);
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.objAttr = objAttr;
|
||||
this.spec = spec;
|
||||
}
|
||||
|
||||
public static MKNOD3Request deserialize(XDR xdr) throws IOException {
|
||||
FileHandle handle = readHandle(xdr);
|
||||
String name = xdr.readString();
|
||||
int type = xdr.readInt();
|
||||
SetAttr3 objAttr = new SetAttr3();
|
||||
Specdata3 spec = null;
|
||||
if (type == NfsFileType.NFSCHR.toValue()
|
||||
|| type == NfsFileType.NFSBLK.toValue()) {
|
||||
objAttr.deserialize(xdr);
|
||||
spec = new Specdata3(xdr.readInt(), xdr.readInt());
|
||||
} else if (type == NfsFileType.NFSSOCK.toValue()
|
||||
|| type == NfsFileType.NFSFIFO.toValue()) {
|
||||
objAttr.deserialize(xdr);
|
||||
}
|
||||
return new MKNOD3Request(handle, name, type, objAttr, spec);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SetAttr3 getObjAttr() {
|
||||
return objAttr;
|
||||
}
|
||||
|
||||
public Specdata3 getSpec() {
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.length());
|
||||
xdr.writeFixedOpaque(name.getBytes(), name.length());
|
||||
objAttr.serialize(xdr);
|
||||
if (spec != null) {
|
||||
xdr.writeInt(spec.getSpecdata1());
|
||||
xdr.writeInt(spec.getSpecdata2());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
import org.apache.hadoop.oncrpc.security.Verifier;
|
||||
|
||||
public class LINK3Response extends NFS3Response {
|
||||
private final WccData fromDirWcc;
|
||||
private final WccData linkDirWcc;
|
||||
|
||||
public LINK3Response(int status) {
|
||||
this(status, new WccData(null, null), new WccData(null, null));
|
||||
}
|
||||
|
||||
public LINK3Response(int status, WccData fromDirWcc,
|
||||
WccData linkDirWcc) {
|
||||
super(status);
|
||||
this.fromDirWcc = fromDirWcc;
|
||||
this.linkDirWcc = linkDirWcc;
|
||||
}
|
||||
|
||||
public WccData getFromDirWcc() {
|
||||
return fromDirWcc;
|
||||
}
|
||||
|
||||
public WccData getLinkDirWcc() {
|
||||
return linkDirWcc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
fromDirWcc.serialize(out);
|
||||
linkDirWcc.serialize(out);
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
import org.apache.hadoop.oncrpc.security.Verifier;
|
||||
|
||||
public class MKNOD3Response extends NFS3Response {
|
||||
private final FileHandle objFileHandle;
|
||||
private final Nfs3FileAttributes objPostOpAttr;
|
||||
private final WccData dirWcc;
|
||||
|
||||
public MKNOD3Response(int status) {
|
||||
this(status, null, null, new WccData(null, null));
|
||||
}
|
||||
|
||||
public MKNOD3Response(int status, FileHandle handle,
|
||||
Nfs3FileAttributes attrs, WccData dirWcc) {
|
||||
super(status);
|
||||
this.objFileHandle = handle;
|
||||
this.objPostOpAttr = attrs;
|
||||
this.dirWcc = dirWcc;
|
||||
}
|
||||
|
||||
public FileHandle getObjFileHandle() {
|
||||
return objFileHandle;
|
||||
}
|
||||
|
||||
public Nfs3FileAttributes getObjPostOpAttr() {
|
||||
return objPostOpAttr;
|
||||
}
|
||||
|
||||
public WccData getDirWcc() {
|
||||
return dirWcc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
if (this.getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true);
|
||||
objFileHandle.serialize(out);
|
||||
out.writeBoolean(true);
|
||||
objPostOpAttr.serialize(out);
|
||||
}
|
||||
dirWcc.serialize(out);
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user