use of com.bonree.brfs.client.StorageNameStick in project BRFS by zhangnianli.
the class DefaultBRFileSystem method openStorageName.
@Override
public StorageNameStick openStorageName(String storageName) {
StorageNameStick stick = null;
try {
Service[] serviceList = regionNodeSelector.select(regionNodeSelector.serviceNum());
if (serviceList.length == 0) {
throw new BRFSException("none disknode!!!");
}
for (Service service : serviceList) {
URI uri = new URIBuilder().setScheme(config.getUrlSchema()).setHost(service.getHost()).setPort(service.getPort()).setPath(config.getStorageUrlRoot() + "/" + storageName).build();
HttpResponse response = null;
try {
response = httpClient.executeGet(uri, defaultHeaders);
} catch (Exception e) {
LOG.warn("openStorageName http request failed", e);
continue;
}
if (response == null) {
throw new Exception("can not get response for deleteStorageName!");
}
if (response.isReponseOK()) {
int storageId = Ints.fromByteArray(response.getResponseBody());
stick = new DefaultStorageNameStick(storageName, storageId, httpClient, serviceSelectorManager.useDiskSelector(storageId), regionNodeSelector, config);
return stick;
}
}
} catch (Exception e) {
LOG.error("openStorageName error", e);
}
return stick;
}
Aggregations