diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-05-18 11:16:07 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-05-18 11:16:07 -0700 |
| commit | 12dc6608f00811dd0a25e1d2563cc3f4b2c81c06 (patch) | |
| tree | 68fc0f1d5a52bb5d2989dd74781d175ee0f7cf1d /other/java | |
| parent | 8156958ee975e61e5ab53e5c3cab7613cd43bda1 (diff) | |
| parent | f2c4c888f6f26e632792b1c8db8541051ba02dcf (diff) | |
| download | seaweedfs-12dc6608f00811dd0a25e1d2563cc3f4b2c81c06.tar.xz seaweedfs-12dc6608f00811dd0a25e1d2563cc3f4b2c81c06.zip | |
Merge branch 'master' into erasure_coding
Diffstat (limited to 'other/java')
| -rw-r--r-- | other/java/client/pom.xml | 2 | ||||
| -rw-r--r-- | other/java/client/src/main/java/seaweedfs/client/FilerClient.java | 30 | ||||
| -rw-r--r-- | other/java/client/src/main/proto/filer.proto | 12 | ||||
| -rw-r--r-- | other/java/hdfs/pom.xml | 2 |
4 files changed, 40 insertions, 6 deletions
diff --git a/other/java/client/pom.xml b/other/java/client/pom.xml index 67b338c37..5882c726d 100644 --- a/other/java/client/pom.xml +++ b/other/java/client/pom.xml @@ -4,7 +4,7 @@ <groupId>com.github.chrislusf</groupId> <artifactId>seaweedfs-client</artifactId> - <version>1.0.9</version> + <version>1.1.0</version> <parent> <groupId>org.sonatype.oss</groupId> 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 562a36894..f4bd0944b 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -173,21 +173,27 @@ public class FilerClient { } public List<FilerProto.Entry> listEntries(String path, String entryPrefix, String lastEntryName, int limit) { - return filerGrpcClient.getBlockingStub().listEntries(FilerProto.ListEntriesRequest.newBuilder() + List<FilerProto.Entry> entries = filerGrpcClient.getBlockingStub().listEntries(FilerProto.ListEntriesRequest.newBuilder() .setDirectory(path) .setPrefix(entryPrefix) .setStartFromFileName(lastEntryName) .setLimit(limit) .build()).getEntriesList(); + List<FilerProto.Entry> fixedEntries = new ArrayList<>(entries.size()); + for (FilerProto.Entry entry : entries) { + fixedEntries.add(fixEntryAfterReading(entry)); + } + return fixedEntries; } public FilerProto.Entry lookupEntry(String directory, String entryName) { try { - return filerGrpcClient.getBlockingStub().lookupDirectoryEntry( + FilerProto.Entry entry = filerGrpcClient.getBlockingStub().lookupDirectoryEntry( FilerProto.LookupDirectoryEntryRequest.newBuilder() .setDirectory(directory) .setName(entryName) .build()).getEntry(); + return fixEntryAfterReading(entry); } catch (Exception e) { LOG.warn("lookupEntry {}/{}: {}", directory, entryName, e); return null; @@ -251,4 +257,24 @@ public class FilerClient { return true; } + private FilerProto.Entry fixEntryAfterReading(FilerProto.Entry entry) { + if (entry.getChunksList().size() <= 0) { + return entry; + } + String fileId = entry.getChunks(0).getFileId(); + if (fileId != null && fileId.length() != 0) { + return entry; + } + FilerProto.Entry.Builder entryBuilder = entry.toBuilder(); + entryBuilder.clearChunks(); + for (FilerProto.FileChunk chunk : entry.getChunksList()) { + FilerProto.FileChunk.Builder chunkBuilder = chunk.toBuilder(); + FilerProto.FileId fid = chunk.getFid(); + fileId = String.format("%d,%d%x", fid.getVolumeId(), fid.getFileKey(), fid.getCookie()); + chunkBuilder.setFileId(fileId); + entryBuilder.addChunks(chunkBuilder); + } + return entryBuilder.build(); + } + } diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 350288b53..56814c39a 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -85,12 +85,20 @@ message EventNotification { } message FileChunk { - string file_id = 1; + string file_id = 1; // to be deprecated int64 offset = 2; uint64 size = 3; int64 mtime = 4; string e_tag = 5; - string source_file_id = 6; + string source_file_id = 6; // to be deprecated + FileId fid = 7; + FileId source_fid = 8; +} + +message FileId { + uint32 volume_id = 1; + uint64 file_key = 2; + fixed32 cookie = 3; } message FuseAttributes { diff --git a/other/java/hdfs/pom.xml b/other/java/hdfs/pom.xml index 35911d463..6a1cd897f 100644 --- a/other/java/hdfs/pom.xml +++ b/other/java/hdfs/pom.xml @@ -5,7 +5,7 @@ <modelVersion>4.0.0</modelVersion> <properties> - <seaweedfs.client.version>1.0.9</seaweedfs.client.version> + <seaweedfs.client.version>1.1.0</seaweedfs.client.version> <hadoop.version>3.1.1</hadoop.version> </properties> |
