【发布时间】:2018-07-02 12:42:18
【问题描述】:
我已经在 3 个节点上部署了一个 Ceph 集群,并创建了 msd 和 rgw。我有 3 台机器,分别命名为 ceph1、ceph2 和 ceph3。
- ceph1 运行 osd、mon、mds 和 rwg
- ceph2 运行 osd
- ceph3 运行 osd
我用radosgw-admin user create 命令创建了一个用户。
现在我想使用 swift api 访问 ceph 集群并创建一个容器。为此,我编写了以下 java 代码:
import org.javaswift.joss.client.factory.AccountConfig;
import org.javaswift.joss.client.factory.AccountFactory;
import org.javaswift.joss.client.factory.AuthenticationMethod;
import org.javaswift.joss.model.Account;
import org.javaswift.joss.model.Container;
import org.javaswift.joss.model.StoredObject;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class Example {
public static void main(String[] args) {
String username = "sahoo";
String password = "IM8K5GAQIXHFRAKYS761";
String authUrl = "http://ceph1:7480/";
AccountConfig config = new AccountConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthUrl(authUrl);
config.setAuthenticationMethod(AuthenticationMethod.BASIC);
Account account = new AccountFactory(config).createAccount();
Container container = account.getContainer("container-name");
container.create();
}
}
但是在运行代码时出现以下异常:
Exception in thread "main" java.lang.NullPointerException
at org.javaswift.joss.command.impl.identity.BasicAuthenticationCommandImpl.getReturnObject(BasicAuthenticationCommandImpl.java:35)
at org.javaswift.joss.command.impl.identity.BasicAuthenticationCommandImpl.getReturnObject(BasicAuthenticationCommandImpl.java:18)
at org.javaswift.joss.command.impl.core.AbstractCommand.call(AbstractCommand.java:51)
at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:97)
at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:27)
at org.javaswift.joss.client.core.AbstractClient.authenticate(AbstractClient.java:35)
at org.javaswift.joss.client.factory.AccountFactory.createAccount(AccountFactory.java:30)
at Example.main(Example.java:24)
谁能帮我解释为什么我会收到异常以及我们需要传递给config.setAuthUrl()的确切内容。
【问题讨论】: