aboutsummaryrefslogtreecommitdiff
path: root/other/java/client/src
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2020-11-16 16:30:19 +0800
committerGitHub <noreply@github.com>2020-11-16 16:30:19 +0800
commit218561c206943d179740a80d8bb21e1f42b35daa (patch)
treeefabb31545c495648d99d4b2eb7ea7536d17d8e3 /other/java/client/src
parente0d5207ed9ff6350e83497586ac9859d841a711a (diff)
parentc0d279c54e56882bc0ecdf496ecfcbcfa1c6d6e3 (diff)
downloadseaweedfs-218561c206943d179740a80d8bb21e1f42b35daa.tar.xz
seaweedfs-218561c206943d179740a80d8bb21e1f42b35daa.zip
Merge pull request #37 from chrislusf/master
sync
Diffstat (limited to 'other/java/client/src')
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/FilerClient.java15
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java14
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java2
-rw-r--r--other/java/client/src/main/proto/filer.proto1
4 files changed, 24 insertions, 8 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
index 035b2c852..7338d5bee 100644
--- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
+++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
@@ -275,9 +275,9 @@ public class FilerClient {
try {
FilerProto.CreateEntryResponse createEntryResponse =
filerGrpcClient.getBlockingStub().createEntry(FilerProto.CreateEntryRequest.newBuilder()
- .setDirectory(parent)
- .setEntry(entry)
- .build());
+ .setDirectory(parent)
+ .setEntry(entry)
+ .build());
if (Strings.isNullOrEmpty(createEntryResponse.getError())) {
return true;
}
@@ -333,4 +333,13 @@ public class FilerClient {
return true;
}
+ public Iterator<FilerProto.SubscribeMetadataResponse> watch(String prefix, String clientName, long sinceNs) {
+ return filerGrpcClient.getBlockingStub().subscribeMetadata(FilerProto.SubscribeMetadataRequest.newBuilder()
+ .setPathPrefix(prefix)
+ .setClientName(clientName)
+ .setSinceNs(sinceNs)
+ .build()
+ );
+ }
+
}
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
index a9ddd51db..2b530d2dd 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
@@ -28,20 +28,26 @@ public class SeaweedRead {
List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, bufferLength);
+ Map<String, FilerProto.Locations> knownLocations = new HashMap<>();
+
FilerProto.LookupVolumeRequest.Builder lookupRequest = FilerProto.LookupVolumeRequest.newBuilder();
for (ChunkView chunkView : chunkViews) {
String vid = parseVolumeId(chunkView.fileId);
- if (volumeIdCache.getLocations(vid)==null){
+ FilerProto.Locations locations = volumeIdCache.getLocations(vid);
+ if (locations == null) {
lookupRequest.addVolumeIds(vid);
+ } else {
+ knownLocations.put(vid, locations);
}
}
- if (lookupRequest.getVolumeIdsCount()>0){
+ if (lookupRequest.getVolumeIdsCount() > 0) {
FilerProto.LookupVolumeResponse lookupResponse = filerGrpcClient
.getBlockingStub().lookupVolume(lookupRequest.build());
Map<String, FilerProto.Locations> vid2Locations = lookupResponse.getLocationsMapMap();
- for (Map.Entry<String,FilerProto.Locations> entry : vid2Locations.entrySet()) {
+ for (Map.Entry<String, FilerProto.Locations> entry : vid2Locations.entrySet()) {
volumeIdCache.setLocations(entry.getKey(), entry.getValue());
+ knownLocations.put(entry.getKey(), entry.getValue());
}
}
@@ -57,7 +63,7 @@ public class SeaweedRead {
startOffset += gap;
}
- FilerProto.Locations locations = volumeIdCache.getLocations(parseVolumeId(chunkView.fileId));
+ FilerProto.Locations locations = knownLocations.get(parseVolumeId(chunkView.fileId));
if (locations == null || locations.getLocationsCount() == 0) {
LOG.error("failed to locate {}", chunkView.fileId);
// log here!
diff --git a/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java b/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
index 38daa14ac..fd2649cc2 100644
--- a/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
+++ b/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
@@ -15,7 +15,7 @@ public class VolumeIdCache {
}
this.cache = CacheBuilder.newBuilder()
.maximumSize(maxEntries)
- .expireAfterAccess(1, TimeUnit.HOURS)
+ .expireAfterAccess(5, TimeUnit.MINUTES)
.build();
}
diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto
index f75caec4e..4d9398897 100644
--- a/other/java/client/src/main/proto/filer.proto
+++ b/other/java/client/src/main/proto/filer.proto
@@ -362,6 +362,7 @@ message FilerConf {
SSD = 1;
}
DiskType disk_type = 5;
+ bool fsync = 6;
}
repeated PathConf locations = 2;
}