Browse Source

reset volume id cache if not found

pull/2321/head
Chris Lu 3 years ago
parent
commit
268de45aa5
  1. 5
      other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
  2. 7
      other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java

5
other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java

@ -64,10 +64,11 @@ public class SeaweedRead {
startOffset += gap; startOffset += gap;
} }
FilerProto.Locations locations = knownLocations.get(parseVolumeId(chunkView.fileId));
String volumeId = parseVolumeId(chunkView.fileId);
FilerProto.Locations locations = knownLocations.get(volumeId);
if (locations == null || locations.getLocationsCount() == 0) { if (locations == null || locations.getLocationsCount() == 0) {
LOG.error("failed to locate {}", chunkView.fileId); LOG.error("failed to locate {}", chunkView.fileId);
// log here!
volumeIdCache.clearLocations(volumeId);
return 0; return 0;
} }

7
other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java

@ -26,6 +26,13 @@ public class VolumeIdCache {
return this.cache.getIfPresent(volumeId); return this.cache.getIfPresent(volumeId);
} }
public void clearLocations(String volumeId) {
if (this.cache == null) {
return;
}
this.cache.invalidate(volumeId);
}
public void setLocations(String volumeId, FilerProto.Locations locations) { public void setLocations(String volumeId, FilerProto.Locations locations) {
if (this.cache == null) { if (this.cache == null) {
return; return;

Loading…
Cancel
Save