From 6839f96c0cd417a2f05d5ce999030c5e314dce84 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 22 Jul 2020 22:52:49 -0700 Subject: simplify --- other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'other/java/client/src/main') diff --git a/other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java b/other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java index 55f003a18..994bcaa2b 100644 --- a/other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java +++ b/other/java/client/src/main/java/seaweedfs/client/ByteBufferPool.java @@ -18,6 +18,7 @@ public class ByteBufferPool { if (bufferSize < MIN_BUFFER_SIZE) { bufferSize = MIN_BUFFER_SIZE; } + LOG.debug("requested new buffer {}", bufferSize); if (bufferList.isEmpty()) { return ByteBuffer.allocate(bufferSize); } @@ -33,6 +34,7 @@ public class ByteBufferPool { } public static synchronized void release(ByteBuffer obj) { + obj.clear(); bufferList.add(0, obj); } -- cgit v1.2.3 From 648ef566c42a90f961472a57efe4a1f1d4978b13 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 22 Jul 2020 22:54:06 -0700 Subject: HCFS: avoid lock bottleneck --- .../src/main/java/seaweedfs/client/SeaweedWrite.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'other/java/client/src/main') diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java index fd54453a1..5f4d888bd 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java @@ -6,6 +6,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -15,6 +17,8 @@ import java.util.List; public class SeaweedWrite { + private static final Logger LOG = LoggerFactory.getLogger(SeaweedWrite.class); + private static final SecureRandom random = new SecureRandom(); public static void writeData(FilerProto.Entry.Builder entry, @@ -23,8 +27,10 @@ public class SeaweedWrite { final long offset, final byte[] bytes, final long bytesOffset, final long bytesLength) throws IOException { + FilerProto.FileChunk.Builder chunkBuilder = writeChunk( + replication, filerGrpcClient, offset, bytes, bytesOffset, bytesLength); synchronized (entry) { - entry.addChunks(writeChunk(replication, filerGrpcClient, offset, bytes, bytesOffset, bytesLength)); + entry.addChunks(chunkBuilder); } } @@ -58,6 +64,8 @@ public class SeaweedWrite { // cache fileId ~ bytes SeaweedRead.chunkCache.setChunk(fileId, bytes); + LOG.debug("write file chunk {} size {}", targetUrl, bytesLength); + return FilerProto.FileChunk.newBuilder() .setFileId(fileId) .setOffset(offset) @@ -71,10 +79,8 @@ public class SeaweedWrite { final String parentDirectory, final FilerProto.Entry.Builder entry) throws IOException { - int chunkSize = entry.getChunksCount(); - List chunks = FileChunkManifest.maybeManifestize(filerGrpcClient, entry.getChunksList()); - synchronized (entry) { + List chunks = FileChunkManifest.maybeManifestize(filerGrpcClient, entry.getChunksList()); entry.clearChunks(); entry.addAllChunks(chunks); filerGrpcClient.getBlockingStub().createEntry( -- cgit v1.2.3