Skip to content

Commit

Permalink
add a option to provide customized bucket endpoint (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Nov 18, 2021
1 parent 96e8c01 commit 30c8220
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ func (g *GateWay) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, er
}
chunkConf.CacheDir = strings.Join(ds, string(os.PathListSeparator))
}
if c.IsSet("bucket") {
format.Bucket = c.String("bucket")
}
blob, err := createStorage(format)
if err != nil {
logger.Fatalf("object storage: %s", err)
Expand Down
7 changes: 7 additions & 0 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func mount(c *cli.Context) error {
}
chunkConf.CacheDir = strings.Join(ds, string(os.PathListSeparator))
}
if c.IsSet("bucket") {
format.Bucket = c.String("bucket")
}
blob, err := createStorage(format)
if err != nil {
logger.Fatalf("object storage: %s", err)
Expand Down Expand Up @@ -257,6 +260,10 @@ func clientFlags() []cli.Flag {
defaultCacheDir = path.Join(homeDir, ".juicefs", "cache")
}
return []cli.Flag{
&cli.StringFlag{
Name: "bucket",
Usage: "customized endpoint to access object store",
},
&cli.IntFlag{
Name: "get-timeout",
Value: 60,
Expand Down
4 changes: 4 additions & 0 deletions sdk/java/libjfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func freeHandle(fd int) {

type javaConf struct {
MetaURL string `json:"meta"`
Bucket string `json:"bucket"`
ReadOnly bool `json:"readOnly"`
OpenCache float64 `json:"openCache"`
CacheDir string `json:"cacheDir"`
Expand Down Expand Up @@ -359,6 +360,9 @@ func jfs_init(cname, jsonConf, user, group, superuser, supergroup *C.char) uintp
go metric.UpdateMetrics(m)
}

if jConf.Bucket != "" {
format.Bucket = jConf.Bucket
}
blob, err := createStorage(format)
if err != nil {
logger.Fatalf("object storage: %s", err)
Expand Down
5 changes: 3 additions & 2 deletions sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public void initialize(URI uri, Configuration conf) throws IOException {
for (String key : bkeys) {
obj.put(key, Boolean.valueOf(getConf(conf, key, "false")));
}
obj.put("bucket", getConf(conf, "bucket", ""));
obj.put("readOnly", Boolean.valueOf(getConf(conf, "read-only", "false")));
obj.put("cacheDir", getConf(conf, "cache-dir", "memory"));
obj.put("cacheSize", Integer.valueOf(getConf(conf, "cache-size", "100")));
Expand Down Expand Up @@ -501,11 +502,11 @@ public static Libjfs loadLibrary() throws IOException {

LibraryLoader<Libjfs> libjfsLibraryLoader = LibraryLoader.create(Libjfs.class);
libjfsLibraryLoader.failImmediately();
String name = "libjfs.3.so";
String name = "libjfs.4.so";
File dir = new File("/tmp");
String os = System.getProperty("os.name");
if (os.toLowerCase().contains("windows")) {
name = "libjfs2.dll";
name = "libjfs3.dll";
dir = new File(System.getProperty("java.io.tmpdir"));
}
File libFile = new File(dir, name);
Expand Down

0 comments on commit 30c8220

Please sign in to comment.