下面列出了怎么用org.apache.hadoop.fs.swift.util.JSONUtil的API类实例代码及写法,或者点击链接到github查看源代码。
private String[] getRawObjectNames() throws Exception {
SwiftRestClient client;
client = SwiftRestClient.getInstance(fs.getUri(), fs.getConf());
SwiftObjectPath path = SwiftObjectPath.fromPath(fs.getUri(), new Path("/"));
byte[] bytes = client.listDeepObjectsInDirectory(path, true, true);
final CollectionType collectionType = JSONUtil.getJsonMapper().
getTypeFactory().constructCollectionType(List.class,
SwiftObjectFileStatus.class);
final List<SwiftObjectFileStatus> fileStatusList =
JSONUtil.toObject(new String(bytes), collectionType);
final ArrayList<String> objects = new ArrayList();
for (SwiftObjectFileStatus status : fileStatusList) {
if (status.getName() != null) {
objects.add(status.getName());
} else if (status.getSubdir() != null) {
objects.add(status.getSubdir());
}
}
return objects.toArray(new String[objects.size()]);
}
private StringRequestEntity getAuthenticationRequst(AuthenticationRequest authenticationRequest)
throws IOException {
final String data = JSONUtil.toJSON(new AuthenticationRequestWrapper(
authenticationRequest));
if (LOG.isDebugEnabled()) {
LOG.debug("Authenticating with " + authenticationRequest);
}
return toJsonEntity(data);
}
private StringRequestEntity getAuthenticationRequst(AuthenticationRequest authenticationRequest)
throws IOException {
final String data = JSONUtil.toJSON(new AuthenticationRequestWrapper(
authenticationRequest));
if (LOG.isDebugEnabled()) {
LOG.debug("Authenticating with " + authenticationRequest);
}
return toJsonEntity(data);
}
private StringRequestEntity getAuthenticationRequst(AuthenticationRequest authenticationRequest)
throws IOException {
final String data = JSONUtil.toJSON(new AuthenticationRequestWrapper(
authenticationRequest));
if (LOG.isDebugEnabled()) {
LOG.debug("Authenticating with " + authenticationRequest);
}
return toJsonEntity(data);
}