Browse Source

possibly fix concurrent access to entry object in SeaweedOutputStream

pull/1371/head
Chris Lu 5 years ago
parent
commit
222f93e816
  1. 2
      LICENSE
  2. 10
      other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java
  3. 3
      other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedOutputStream.java
  4. 3
      other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

2
LICENSE

@ -1,4 +1,4 @@
Apache License
g Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

10
other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java

@ -45,9 +45,7 @@ public class SeaweedWrite {
String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey);
// cache fileId ~ bytes
SeaweedRead.chunkCache.setChunk(fileId, bytes);
synchronized (entry) {
entry.addChunks(FilerProto.FileChunk.newBuilder()
.setFileId(fileId)
.setOffset(offset)
@ -56,11 +54,16 @@ public class SeaweedWrite {
.setETag(etag)
.setCipherKey(cipherKeyString)
);
}
// cache fileId ~ bytes
SeaweedRead.chunkCache.setChunk(fileId, bytes);
}
public static void writeMeta(final FilerGrpcClient filerGrpcClient,
final String parentDirectory, final FilerProto.Entry.Builder entry) {
synchronized (entry){
filerGrpcClient.getBlockingStub().createEntry(
FilerProto.CreateEntryRequest.newBuilder()
.setDirectory(parentDirectory)
@ -68,6 +71,7 @@ public class SeaweedWrite {
.build()
);
}
}
private static String multipartUpload(String targetUrl,
String auth,

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

@ -69,9 +69,6 @@ public class SeaweedOutputStream extends OutputStream {
}
private synchronized void flushWrittenBytesToServiceInternal(final long offset) throws IOException {
LOG.debug("SeaweedWrite.writeMeta path: {} entry:{}", path, entry);
try {
SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);
} catch (Exception ex) {

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

@ -78,9 +78,6 @@ public class SeaweedOutputStream extends OutputStream implements Syncable, Strea
}
private synchronized void flushWrittenBytesToServiceInternal(final long offset) throws IOException {
LOG.debug("SeaweedWrite.writeMeta path: {} entry:{}", path, entry);
try {
SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);
} catch (Exception ex) {

Loading…
Cancel
Save