use of com.bonree.brfs.common.net.http.client.HttpResponse in project BRFS by zhangnianli.
the class HttpDiskNodeClient method recover.
@Override
public boolean recover(String path, long fileLength, List<String> fullSates) {
URI uri = new URIBuilder().setScheme(DEFAULT_SCHEME).setHost(host).setPort(port).setPath(DiskContext.URI_RECOVER_NODE_ROOT + path).addParameter("length", String.valueOf(fileLength)).addParameter("fulls", Joiner.on(',').join(fullSates)).build();
try {
LOG.info("recover file[{}] response[{}] to {}:{}", path, host, port);
HttpResponse response = client.executePost(uri);
LOG.debug("recover file[{}] response[{}]", path, response.getStatusCode());
return response.isReponseOK();
} catch (Exception e) {
LOG.error("recover file[{}] at {}:{} error", path, host, port, e);
}
return false;
}
use of com.bonree.brfs.common.net.http.client.HttpResponse in project BRFS by zhangnianli.
the class HttpDiskNodeClient method flush.
@Override
public boolean flush(String path) {
URI uri = new URIBuilder().setScheme(DEFAULT_SCHEME).setHost(host).setPort(port).setPath(DiskContext.URI_FLUSH_NODE_ROOT + path).build();
try {
LOG.info("flush file[{}] to {}:{}", path, host, port);
HttpResponse response = client.executePost(uri);
LOG.debug("flush file[{}] response[{}]", path, response.getStatusCode());
return response.isReponseOK();
} catch (Exception e) {
LOG.error("write file[{}] to {}:{} error", path, host, port, e);
}
return false;
}
use of com.bonree.brfs.common.net.http.client.HttpResponse in project BRFS by zhangnianli.
the class HttpDiskNodeClient method openFile.
@Override
public long openFile(String path, long capacity) {
URI uri = new URIBuilder().setScheme(DEFAULT_SCHEME).setHost(host).setPort(port).setPath(DiskContext.URI_DISK_NODE_ROOT + path).addParameter("capacity", String.valueOf(capacity)).build();
try {
LOG.info("open file[{}] @ {}:{}", path, host, port);
HttpResponse response = client.executePut(uri);
LOG.debug("open file[{}] response[{}]", path, response.getStatusCode());
if (response != null && response.isReponseOK()) {
return Longs.fromByteArray(response.getResponseBody());
}
} catch (Exception e) {
LOG.error("open file[{}] at {}:{} error", path, host, port, e);
}
return -1l;
}
use of com.bonree.brfs.common.net.http.client.HttpResponse in project BRFS by zhangnianli.
the class HttpDiskNodeClient method deleteFile.
@Override
public boolean deleteFile(String path, boolean force) {
URIBuilder builder = new URIBuilder();
builder.setScheme(DEFAULT_SCHEME).setHost(host).setPort(port).setPath(DiskContext.URI_DISK_NODE_ROOT + path);
if (force) {
builder.addParameter("force");
}
try {
LOG.info("delete file[{}] force[{}] to {}:{}", path, force, host, port);
HttpResponse response = client.executeDelete(builder.build());
LOG.debug("delete file[{}] response[{}]", path, response.getStatusCode());
return response.isReponseOK();
} catch (Exception e) {
LOG.error("delete file[{}] at {}:{} error", path, host, port, e);
}
return false;
}
use of com.bonree.brfs.common.net.http.client.HttpResponse in project BRFS by zhangnianli.
the class DefaultBRFileSystem method deleteStorageName.
@Override
public boolean deleteStorageName(String storageName) {
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.executeDelete(uri, defaultHeaders);
} catch (Exception e) {
LOG.warn("deleteStorageName http request failed", e);
continue;
}
if (response == null) {
throw new Exception("can not get response for deleteStorageName!");
}
if (response.isReponseOK()) {
return true;
}
}
} catch (Exception e) {
LOG.error("deleteStorageName error", e);
}
return false;
}
Aggregations