use of java.io.InterruptedIOException in project hbase by apache.
the class RemoteAdmin method createTable.
/**
* Creates a new table.
* @param desc table descriptor for table
* @throws IOException if a remote or network exception occurs
*/
public void createTable(HTableDescriptor desc) throws IOException {
TableSchemaModel model = new TableSchemaModel(desc);
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append(desc.getTableName());
path.append('/');
path.append("schema");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(path.toString(), Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
code = response.getCode();
switch(code) {
case 201:
return;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("create request to " + path.toString() + " returned " + code);
}
}
throw new IOException("create request to " + path.toString() + " timed out");
}
use of java.io.InterruptedIOException in project hbase by apache.
the class RemoteHTable method put.
@Override
public void put(Put put) throws IOException {
CellSetModel model = buildModelFromPut(put);
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toString(name));
sb.append('/');
sb.append(toURLEncodedBytes(put.getRow()));
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(sb.toString(), Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
int code = response.getCode();
switch(code) {
case 200:
return;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("put request failed with " + code);
}
}
throw new IOException("put request timed out");
}
use of java.io.InterruptedIOException in project hbase by apache.
the class RemoteHTable method delete.
@Override
public void delete(Delete delete) throws IOException {
String spec = buildRowSpec(delete.getRow(), delete.getFamilyCellMap(), delete.getTimeStamp(), delete.getTimeStamp(), 1);
for (int i = 0; i < maxRetries; i++) {
Response response = client.delete(spec);
int code = response.getCode();
switch(code) {
case 200:
return;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("delete request failed with " + code);
}
}
throw new IOException("delete request timed out");
}
use of java.io.InterruptedIOException in project hbase by apache.
the class ZKProcedureCoordinator method sendGlobalBarrierReached.
@Override
public void sendGlobalBarrierReached(Procedure proc, List<String> nodeNames) throws IOException {
String procName = proc.getName();
String reachedNode = zkProc.getReachedBarrierNode(procName);
LOG.debug("Creating reached barrier zk node:" + reachedNode);
try {
// create the reached znode and watch for the reached znodes
ZKUtil.createWithParents(zkProc.getWatcher(), reachedNode);
// loop through all the children of the acquire phase and watch for them
for (String node : nodeNames) {
String znode = ZKUtil.joinZNode(reachedNode, node);
if (ZKUtil.watchAndCheckExists(zkProc.getWatcher(), znode)) {
byte[] dataFromMember = ZKUtil.getData(zkProc.getWatcher(), znode);
// ProtobufUtil.isPBMagicPrefix will check null
if (dataFromMember != null && dataFromMember.length > 0) {
if (!ProtobufUtil.isPBMagicPrefix(dataFromMember)) {
String msg = "Failed to get data from finished node or data is illegally formatted: " + znode;
LOG.error(msg);
throw new IOException(msg);
} else {
dataFromMember = Arrays.copyOfRange(dataFromMember, ProtobufUtil.lengthOfPBMagic(), dataFromMember.length);
coordinator.memberFinishedBarrier(procName, node, dataFromMember);
}
} else {
coordinator.memberFinishedBarrier(procName, node, dataFromMember);
}
}
}
} catch (KeeperException e) {
String msg = "Failed while creating reached node:" + reachedNode;
LOG.error(msg, e);
throw new IOException(msg, e);
} catch (InterruptedException e) {
String msg = "Interrupted while creating reached node:" + reachedNode;
LOG.error(msg, e);
throw new InterruptedIOException(msg);
}
}
use of java.io.InterruptedIOException in project hbase by apache.
the class ProcedureSyncWait method waitFor.
public static <T> T waitFor(MasterProcedureEnv env, long waitTime, long waitingTimeForEvents, String purpose, Predicate<T> predicate) throws IOException {
final long done = EnvironmentEdgeManager.currentTime() + waitTime;
do {
T result = predicate.evaluate();
if (result != null && !result.equals(Boolean.FALSE)) {
return result;
}
try {
Thread.sleep(waitingTimeForEvents);
} catch (InterruptedException e) {
LOG.warn("Interrupted while sleeping, waiting on " + purpose);
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
LOG.debug("Waiting on " + purpose);
} while (EnvironmentEdgeManager.currentTime() < done && env.isRunning());
throw new TimeoutIOException("Timed out while waiting on " + purpose);
}
Aggregations