Browse Source

simplify

pull/1402/head
Chris Lu 4 years ago
parent
commit
6839f96c0c
  1. 2
      other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java
  2. 1
      other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java
  3. 1
      other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

2
other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java

@ -18,6 +18,7 @@ public class ByteBufferPool {
if (bufferSize < MIN_BUFFER_SIZE) { if (bufferSize < MIN_BUFFER_SIZE) {
bufferSize = MIN_BUFFER_SIZE; bufferSize = MIN_BUFFER_SIZE;
} }
LOG.debug("requested new buffer {}", bufferSize);
if (bufferList.isEmpty()) { if (bufferList.isEmpty()) {
return ByteBuffer.allocate(bufferSize); return ByteBuffer.allocate(bufferSize);
} }
@ -33,6 +34,7 @@ public class ByteBufferPool {
} }
public static synchronized void release(ByteBuffer obj) { public static synchronized void release(ByteBuffer obj) {
obj.clear();
bufferList.add(0, obj); bufferList.add(0, obj);
} }

1
other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

@ -187,7 +187,6 @@ public class SeaweedOutputStream extends OutputStream {
// System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")"); // System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit()); SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit());
// System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")"); // System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
bufferToWrite.clear();
ByteBufferPool.release(bufferToWrite); ByteBufferPool.release(bufferToWrite);
return null; return null;
}); });

1
other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

@ -234,7 +234,6 @@ public class SeaweedOutputStream extends OutputStream implements Syncable, Strea
// System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")"); // System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit()); SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit());
// System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")"); // System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
bufferToWrite.clear();
ByteBufferPool.release(bufferToWrite); ByteBufferPool.release(bufferToWrite);
return null; return null;
}); });

Loading…
Cancel
Save