diff --git a/src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFileOutputStream.java b/src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFileOutputStream.java
index 4469fee..b958964 100644
--- a/src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFileOutputStream.java
+++ b/src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFileOutputStream.java
@@ -1,5 +1,5 @@
-/**
- * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
+package com.emc.ecs.nfsclient.nfs.io; /**
+ * Copyright 2016 EMC Corporation. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
@@ -12,12 +12,13 @@
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
-package com.emc.ecs.nfsclient.nfs.io;
import com.emc.ecs.nfsclient.nfs.NfsCreateMode;
import com.emc.ecs.nfsclient.nfs.NfsSetAttributes;
import com.emc.ecs.nfsclient.nfs.NfsWriteRequest;
import com.emc.ecs.nfsclient.nfs.NfsWriteResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.OutputStream;
@@ -25,9 +26,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* The NFS equivalent of java.io.FileOutputStream.
*
@@ -81,6 +79,13 @@ public class NfsFileOutputStream extends OutputStream {
*/
private boolean _closed = false;
+ /**
+ * The buffer size specified by the user when calling the write()
+ * 8K is enough for all metadata and A send operation can be avoided to
+ * the maximum extent when the user does not specify the bufferSize parameter.
+ */
+ private static final int bufferSize = 8 * 1024;
+
/**
* Creates a file output stream to write to the file represented by the
* specified NfsFile object, starting at
@@ -97,7 +102,7 @@ public class NfsFileOutputStream extends OutputStream {
* opened for any other reason
*/
public NfsFileOutputStream(NfsFile, ?> nfsFile) throws IOException {
- this(nfsFile, 0, NfsWriteRequest.FILE_SYNC);
+ this(nfsFile, 0, NfsWriteRequest.FILE_SYNC, bufferSize);
}
/**
@@ -124,7 +129,36 @@ public NfsFileOutputStream(NfsFile, ?> nfsFile) throws IOException {
* opened for any other reason
*/
public NfsFileOutputStream(NfsFile, ?> nfsFile, int syncType) throws IOException {
- this(nfsFile, 0, syncType);
+ this(nfsFile, syncType, bufferSize);
+ }
+
+ /**
+ * Creates a file output stream to write to the file represented by the
+ * specified NfsFile object, starting at
+ * offset = 0 and using syncType behavior.
+ *
+ * If the file does not exist, it will first be created. + * + * @param nfsFile + * The file to be opened for writing. + * @param syncType + * One of the values below. + *