From 258063de2650699eef4488ff9096693737226fde Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Aug 2021 00:29:27 -0700 Subject: cloud drive: add google cloud storage --- other/java/client/src/main/proto/filer.proto | 1 + 1 file changed, 1 insertion(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 1c22276ae..eb329e6ae 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -393,6 +393,7 @@ message RemoteConf { string s3_secret_key = 5; string s3_region = 6; string s3_endpoint = 7; + string gcs_google_application_credentials = 10; } message RemoteStorageMapping { -- cgit v1.2.3 From 2836a58d878df03f7c60991a75105d16274fe0c1 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Aug 2021 02:18:56 -0700 Subject: cloud drive: S3 supports storage class --- other/java/client/src/main/proto/filer.proto | 1 + 1 file changed, 1 insertion(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index eb329e6ae..caef71933 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -393,6 +393,7 @@ message RemoteConf { string s3_secret_key = 5; string s3_region = 6; string s3_endpoint = 7; + string s3_storage_class = 8; string gcs_google_application_credentials = 10; } -- cgit v1.2.3 From 00c4e06caad6f5960c3acfdd07106e2d8e3577c5 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Aug 2021 03:30:41 -0700 Subject: cloud drive: s3 configurable force path style --- other/java/client/src/main/proto/filer.proto | 1 + 1 file changed, 1 insertion(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index caef71933..cef7e764c 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -394,6 +394,7 @@ message RemoteConf { string s3_region = 6; string s3_endpoint = 7; string s3_storage_class = 8; + bool s3_force_path_style = 9; string gcs_google_application_credentials = 10; } -- cgit v1.2.3 From 2ead7adaff5e4136df870e357ec1246b71f86f87 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Aug 2021 12:19:02 -0700 Subject: Java: FilerProto.Entry can read size via attributes --- .../main/java/seaweedfs/client/FilerClient.java | 49 +++++++++++++++------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'other/java') 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 0a8356258..dae7753a4 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -59,24 +59,43 @@ public class FilerClient extends FilerGrpcClient { public static FilerProto.Entry afterEntryDeserialization(FilerProto.Entry entry) { if (entry.getChunksList().size() <= 0) { + if (entry.getContent().isEmpty()) { + return entry; + } else { + if (entry.getAttributes().getFileSize() <= 0) { + FilerProto.Entry.Builder entryBuilder = entry.toBuilder(); + FilerProto.FuseAttributes.Builder attrBuilder = entry.getAttributes().toBuilder(); + attrBuilder.setFileSize(entry.getContent().size()); + entryBuilder.setAttributes(attrBuilder); + return entryBuilder.build(); + } + } 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(); - chunkBuilder.setFileId(toFileId(chunk.getFid())); - String sourceFileId = toFileId(chunk.getSourceFid()); - if (sourceFileId != null) { - chunkBuilder.setSourceFileId(sourceFileId); + } else { + String fileId = entry.getChunks(0).getFileId(); + if (fileId != null && fileId.length() != 0) { + return entry; + } + FilerProto.Entry.Builder entryBuilder = entry.toBuilder(); + entryBuilder.clearChunks(); + long fileSize = 0; + for (FilerProto.FileChunk chunk : entry.getChunksList()) { + fileSize = Math.max(fileSize, chunk.getOffset()+chunk.getSize()); + FilerProto.FileChunk.Builder chunkBuilder = chunk.toBuilder(); + chunkBuilder.setFileId(toFileId(chunk.getFid())); + String sourceFileId = toFileId(chunk.getSourceFid()); + if (sourceFileId != null) { + chunkBuilder.setSourceFileId(sourceFileId); + } + entryBuilder.addChunks(chunkBuilder); + } + if (entry.getAttributes().getFileSize() <= 0) { + FilerProto.FuseAttributes.Builder attrBuilder = entry.getAttributes().toBuilder(); + attrBuilder.setFileSize(fileSize); + entryBuilder.setAttributes(attrBuilder); } - entryBuilder.addChunks(chunkBuilder); + return entryBuilder.build(); } - return entryBuilder.build(); } public boolean mkdirs(String path, int mode) { -- cgit v1.2.3 From e9ebe24f2e0f8b30284ea9334d5924f54e970c95 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 24 Aug 2021 01:18:30 -0700 Subject: cloud drive: add support for Azure --- other/java/client/src/main/proto/filer.proto | 2 ++ 1 file changed, 2 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index cef7e764c..9d68182ef 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -396,6 +396,8 @@ message RemoteConf { string s3_storage_class = 8; bool s3_force_path_style = 9; string gcs_google_application_credentials = 10; + string azure_account_name = 15; + string azure_account_key = 16; } message RemoteStorageMapping { -- cgit v1.2.3 From 47d775cf68aed0cb342e9150b02509e0466541e6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 24 Aug 2021 22:30:06 -0700 Subject: cloud drive: add support for BackBlaze --- other/java/client/src/main/proto/filer.proto | 3 +++ 1 file changed, 3 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 9d68182ef..4c2f5e538 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -398,6 +398,9 @@ message RemoteConf { string gcs_google_application_credentials = 10; string azure_account_name = 15; string azure_account_key = 16; + string backblaze_key_id = 20; + string backblaze_application_key = 21; + string backblaze_endpoint = 22; } message RemoteStorageMapping { -- cgit v1.2.3 From 19a81d25af7224ac76816d11e740ecd79b7d7ab3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 24 Aug 2021 23:14:24 -0700 Subject: cloud drive: add support for Aliyun OSS --- other/java/client/src/main/proto/filer.proto | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 4c2f5e538..8895b607e 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -395,12 +395,19 @@ message RemoteConf { string s3_endpoint = 7; string s3_storage_class = 8; bool s3_force_path_style = 9; + string gcs_google_application_credentials = 10; + string azure_account_name = 15; string azure_account_key = 16; + string backblaze_key_id = 20; string backblaze_application_key = 21; string backblaze_endpoint = 22; + + string aliyun_access_key = 25; + string aliyun_secret_key = 26; + string aliyun_endpoint = 27; } message RemoteStorageMapping { -- cgit v1.2.3 From a19c728034839d893c0a73473520d9a4d558d984 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 24 Aug 2021 23:19:45 -0700 Subject: cloud drive: add support for Tencent COS --- other/java/client/src/main/proto/filer.proto | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 8895b607e..0dadda86a 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -408,6 +408,11 @@ message RemoteConf { string aliyun_access_key = 25; string aliyun_secret_key = 26; string aliyun_endpoint = 27; + + string tencent_secret_id = 30; + string tencent_secret_key = 31; + string tencent_endpoint = 32; + } message RemoteStorageMapping { -- cgit v1.2.3 From a7a914f120908f7204bf7310a86f401c05dce982 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 24 Aug 2021 23:46:33 -0700 Subject: cloud drive: add support for Baidu BOS --- other/java/client/src/main/proto/filer.proto | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 0dadda86a..2da575733 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -408,11 +408,17 @@ message RemoteConf { string aliyun_access_key = 25; string aliyun_secret_key = 26; string aliyun_endpoint = 27; + string aliyun_region = 28; string tencent_secret_id = 30; string tencent_secret_key = 31; string tencent_endpoint = 32; + string baidu_access_key = 35; + string baidu_secret_key = 36; + string baidu_endpoint = 37; + string baidu_region = 38; + } message RemoteStorageMapping { -- cgit v1.2.3 From c08ac536ed83ef2159a13ce826a249223272818f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 25 Aug 2021 17:34:29 -0700 Subject: cloud drive: add support for Wasabi * disable md5, sha256 checking to avoid reading one chunk twice * single threaded upload to avoid chunk swapping (to be enhanced later) --- other/java/client/src/main/proto/filer.proto | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index 2da575733..a5894a475 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -413,12 +413,17 @@ message RemoteConf { string tencent_secret_id = 30; string tencent_secret_key = 31; string tencent_endpoint = 32; + string tencent_region = 33; string baidu_access_key = 35; string baidu_secret_key = 36; string baidu_endpoint = 37; string baidu_region = 38; + string wasabi_access_key = 40; + string wasabi_secret_key = 41; + string wasabi_endpoint = 42; + string wasabi_region = 43; } message RemoteStorageMapping { -- cgit v1.2.3 From 05a648bb96df1be5a9261737d8f6fd01600c6a63 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 26 Aug 2021 15:18:34 -0700 Subject: refactor: separating out remote.proto --- other/java/client/src/main/proto/filer.proto | 49 +--------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index a5894a475..b7e4b0e6e 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -336,6 +336,7 @@ message KeepConnectedResponse { message LocateBrokerRequest { string resource = 1; } + message LocateBrokerResponse { bool found = 1; // if found, send the exact address @@ -386,54 +387,6 @@ message FilerConf { ///////////////////////// // Remote Storage related ///////////////////////// -message RemoteConf { - string type = 1; - string name = 2; - string s3_access_key = 4; - string s3_secret_key = 5; - string s3_region = 6; - string s3_endpoint = 7; - string s3_storage_class = 8; - bool s3_force_path_style = 9; - - string gcs_google_application_credentials = 10; - - string azure_account_name = 15; - string azure_account_key = 16; - - string backblaze_key_id = 20; - string backblaze_application_key = 21; - string backblaze_endpoint = 22; - - string aliyun_access_key = 25; - string aliyun_secret_key = 26; - string aliyun_endpoint = 27; - string aliyun_region = 28; - - string tencent_secret_id = 30; - string tencent_secret_key = 31; - string tencent_endpoint = 32; - string tencent_region = 33; - - string baidu_access_key = 35; - string baidu_secret_key = 36; - string baidu_endpoint = 37; - string baidu_region = 38; - - string wasabi_access_key = 40; - string wasabi_secret_key = 41; - string wasabi_endpoint = 42; - string wasabi_region = 43; -} - -message RemoteStorageMapping { - map mappings = 1; -} -message RemoteStorageLocation { - string name = 1; - string bucket = 2; - string path = 3; -} message DownloadToLocalRequest { string directory = 1; string name = 2; -- cgit v1.2.3 From dc936921aa027369d166467c9cb568b756957d1a Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 26 Aug 2021 18:20:14 -0700 Subject: ensure the following logic are executed --- other/java/client/src/main/java/seaweedfs/client/FilerClient.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'other/java') 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 dae7753a4..e70f6befa 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -72,10 +72,6 @@ public class FilerClient extends FilerGrpcClient { } return entry; } else { - String fileId = entry.getChunks(0).getFileId(); - if (fileId != null && fileId.length() != 0) { - return entry; - } FilerProto.Entry.Builder entryBuilder = entry.toBuilder(); entryBuilder.clearChunks(); long fileSize = 0; -- cgit v1.2.3 From 268de45aa521635a377950d7752d8f13316e4cad Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 29 Aug 2021 20:27:11 -0700 Subject: reset volume id cache if not found --- other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java | 5 +++-- .../java/client/src/main/java/seaweedfs/client/VolumeIdCache.java | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'other/java') 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 384636601..011462a17 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java @@ -64,10 +64,11 @@ public class SeaweedRead { 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) { LOG.error("failed to locate {}", chunkView.fileId); - // log here! + volumeIdCache.clearLocations(volumeId); return 0; } 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 fd2649cc2..86263fff9 100644 --- a/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java +++ b/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java @@ -26,6 +26,13 @@ public class VolumeIdCache { 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) { if (this.cache == null) { return; -- cgit v1.2.3 From 05f32376eb8e215fe69a5942ef741d406b6e93eb Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 29 Aug 2021 21:02:10 -0700 Subject: add cluster id in filer configuration response --- other/java/client/src/main/proto/filer.proto | 1 + 1 file changed, 1 insertion(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index b7e4b0e6e..bb461936c 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -305,6 +305,7 @@ message GetFilerConfigurationResponse { string metrics_address = 9; int32 metrics_interval_sec = 10; string version = 11; + string cluster_id = 12; } message SubscribeMetadataRequest { -- cgit v1.2.3 From 43fd11278ef811856551904b531bcc91821d0c9f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 31 Aug 2021 23:23:08 -0700 Subject: support follow additional path prefixes --- other/java/client/src/main/proto/filer.proto | 1 + 1 file changed, 1 insertion(+) (limited to 'other/java') diff --git a/other/java/client/src/main/proto/filer.proto b/other/java/client/src/main/proto/filer.proto index bb461936c..7b1838565 100644 --- a/other/java/client/src/main/proto/filer.proto +++ b/other/java/client/src/main/proto/filer.proto @@ -313,6 +313,7 @@ message SubscribeMetadataRequest { string path_prefix = 2; int64 since_ns = 3; int32 signature = 4; + repeated string path_prefixes = 6; } message SubscribeMetadataResponse { string directory = 1; -- cgit v1.2.3 From 9fb278c92c90e4d57e675f5b52ac2263dbd18f2b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 6 Sep 2021 11:33:56 -0700 Subject: Hadoop: avoid case insensitive on windows --- .../main/java/seaweedfs/client/FilerClient.java | 37 +++++++++++----------- .../main/java/seaweedfs/client/SeaweedUtil.java | 13 ++++++++ 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'other/java') 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 e70f6befa..12c6da631 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -4,7 +4,6 @@ import com.google.common.base.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -108,9 +107,9 @@ public class FilerClient extends FilerGrpcClient { if ("/".equals(path)) { return true; } - File pathFile = new File(path); - String parent = pathFile.getParent().replace('\\','/'); - String name = pathFile.getName(); + String[] dirAndName = SeaweedUtil.toDirAndName(path); + String parent = dirAndName[0]; + String name = dirAndName[1]; mkdirs(parent, mode, uid, gid, userName, groupNames); @@ -129,22 +128,22 @@ public class FilerClient extends FilerGrpcClient { public boolean mv(String oldPath, String newPath) { - File oldPathFile = new File(oldPath); - String oldParent = oldPathFile.getParent().replace('\\','/'); - String oldName = oldPathFile.getName(); + String[] oldDirAndName = SeaweedUtil.toDirAndName(oldPath); + String oldParent = oldDirAndName[0]; + String oldName = oldDirAndName[1]; - File newPathFile = new File(newPath); - String newParent = newPathFile.getParent().replace('\\','/'); - String newName = newPathFile.getName(); + String[] newDirAndName = SeaweedUtil.toDirAndName(newPath); + String newParent = newDirAndName[0]; + String newName = newDirAndName[1]; return atomicRenameEntry(oldParent, oldName, newParent, newName); } public boolean exists(String path){ - File pathFile = new File(path); - String parent = pathFile.getParent(); - String entryName = pathFile.getName(); + String[] dirAndName = SeaweedUtil.toDirAndName(path); + String parent = dirAndName[0]; + String entryName = dirAndName[1]; if(parent == null) { parent = path; entryName =""; @@ -155,9 +154,9 @@ public class FilerClient extends FilerGrpcClient { public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) { - File pathFile = new File(path); - String parent = pathFile.getParent().replace('\\','/'); - String name = pathFile.getName(); + String[] dirAndName = SeaweedUtil.toDirAndName(path); + String parent = dirAndName[0]; + String name = dirAndName[1]; return deleteEntry( parent, @@ -176,9 +175,9 @@ public class FilerClient extends FilerGrpcClient { public boolean touch(String path, long modifiedTimeSecond, int mode, int uid, int gid, String userName, String[] groupNames) { - File pathFile = new File(path); - String parent = pathFile.getParent().replace('\\','/'); - String name = pathFile.getName(); + String[] dirAndName = SeaweedUtil.toDirAndName(path); + String parent = dirAndName[0]; + String name = dirAndName[1]; FilerProto.Entry entry = lookupEntry(parent, name); if (entry == null) { diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java index c465d935f..6e1905370 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java @@ -27,4 +27,17 @@ public class SeaweedUtil { public static CloseableHttpClient getClosableHttpClient() { return httpClient; } + + public static String[] toDirAndName(String fullpath) { + if (fullpath.endsWith("/")) { + fullpath = fullpath.substring(0, fullpath.length() - 1); + } + if (fullpath.length() == 0) { + return new String[]{"/", ""}; + } + int sep = fullpath.lastIndexOf("/"); + String parent = sep == 0 ? "/" : fullpath.substring(0, sep); + String name = fullpath.substring(sep + 1); + return new String[]{parent, name}; + } } -- cgit v1.2.3 From 728ed21a80c815f3577d37e516655d171453590f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 6 Sep 2021 11:39:10 -0700 Subject: just in case --- other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'other/java') diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java index 6e1905370..66ea9a98d 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java @@ -29,6 +29,9 @@ public class SeaweedUtil { } public static String[] toDirAndName(String fullpath) { + if (fullpath == null) { + return new String[]{"/", ""}; + } if (fullpath.endsWith("/")) { fullpath = fullpath.substring(0, fullpath.length() - 1); } -- cgit v1.2.3 From fe4794fe9210073670fad8612a57bbbe4197d8f9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 6 Sep 2021 11:40:51 -0700 Subject: minor --- .../java/client/src/main/java/seaweedfs/client/FilerClient.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'other/java') 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 12c6da631..e962cbbcc 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -141,15 +141,12 @@ public class FilerClient extends FilerGrpcClient { } public boolean exists(String path){ + String[] dirAndName = SeaweedUtil.toDirAndName(path); String parent = dirAndName[0]; String entryName = dirAndName[1]; - if(parent == null) { - parent = path; - entryName =""; - } - return lookupEntry(parent, entryName) != null; + return lookupEntry(parent, entryName) != null; } public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) { @@ -167,10 +164,12 @@ public class FilerClient extends FilerGrpcClient { } public boolean touch(String path, int mode) { + String currentUser = System.getProperty("user.name"); long now = System.currentTimeMillis() / 1000L; return touch(path, now, mode, 0, 0, currentUser, new String[]{}); + } public boolean touch(String path, long modifiedTimeSecond, int mode, int uid, int gid, String userName, String[] groupNames) { -- cgit v1.2.3 From 0128239c0f8829bb20edd1df257840dcbfa37c0e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 7 Sep 2021 16:43:54 -0700 Subject: handle ipv6 addresses --- .../client/src/main/java/seaweedfs/client/FilerGrpcClient.java | 2 +- .../client/src/main/java/seaweedfs/client/SeaweedUtil.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'other/java') diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java index 6c57e2e0d..56aa35876 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java @@ -54,7 +54,7 @@ public class FilerGrpcClient { .negotiationType(NegotiationType.TLS) .sslContext(sslContext)); - filerAddress = String.format("%s:%d", host, grpcPort - 10000); + filerAddress = SeaweedUtil.joinHostPort(host, grpcPort - 10000); FilerProto.GetFilerConfigurationResponse filerConfigurationResponse = this.getBlockingStub().getFilerConfiguration( diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java index 66ea9a98d..027e49b96 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java @@ -43,4 +43,14 @@ public class SeaweedUtil { String name = fullpath.substring(sep + 1); return new String[]{parent, name}; } + + public static String joinHostPort(String host, int port) { + if (host.startsWith("[") && host.endsWith("]")) { + return host + ":" + port; + } + if (host.indexOf(':')>=0) { + return "[" + host + "]:" + port; + } + return host + ":" + port; + } } -- cgit v1.2.3