use of java.io.IOError in project flink by apache.
the class CliClient method getAndExecuteStatements.
private boolean getAndExecuteStatements(LineReader lineReader, ExecutionMode mode) {
// begin reading loop
boolean exitOnFailure = !mode.equals(ExecutionMode.INTERACTIVE_EXECUTION);
isRunning = true;
while (isRunning) {
// make some space to previous command
terminal.writer().append("\n");
terminal.flush();
Optional<Operation> parsedOperation = Optional.empty();
try {
// read a statement from terminal and parse it
String line = lineReader.readLine(prompt, null, inputTransformer, null);
if (line.trim().isEmpty()) {
continue;
}
// get the parsed operation.
// if the command is invalid, the exception caught from parser would be thrown.
parsedOperation = parser.getParsedOperation();
Preconditions.checkArgument(line.equals(parser.getCommand()), String.format("This is a bug, please report to the flink community. Statement read[%s] isn't the same as statement parsed[%s]", line, parser.getCommand()));
} catch (SqlExecutionException e) {
// print the detailed information on about the parse errors in the terminal.
printExecutionException(e);
if (exitOnFailure) {
return false;
}
} catch (UserInterruptException e) {
// user cancelled line with Ctrl+C
continue;
} catch (EndOfFileException | IOError e) {
// user cancelled application with Ctrl+D or kill
break;
} catch (Throwable t) {
throw new SqlClientException("Could not read from command line.", t);
}
// no operation available, read next command
if (!parsedOperation.isPresent()) {
continue;
}
// execute the operation
boolean success = executeOperation(parsedOperation.get(), mode);
if (exitOnFailure && !success) {
return false;
}
}
// finish all statements.
return true;
}
use of java.io.IOError in project eiger by wlloyd.
the class BufferedSegmentedFile method getSegment.
public FileDataInput getSegment(long position) {
try {
RandomAccessReader file = RandomAccessReader.open(new File(path));
file.seek(position);
return file;
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project eiger by wlloyd.
the class Gossiper method sendGossip.
/**
* Returns true if the chosen target was also a seed. False otherwise
*
* @param prod produces a message to send
* @param epSet a set of endpoint from which a random endpoint is chosen.
* @return true if the chosen endpoint is also a seed.
*/
private boolean sendGossip(MessageProducer prod, Set<InetAddress> epSet) {
int size = epSet.size();
if (size < 1)
return false;
/* Generate a random number from 0 -> size */
List<InetAddress> liveEndpoints = new ArrayList<InetAddress>(epSet);
int index = (size == 1) ? 0 : random.nextInt(size);
InetAddress to = liveEndpoints.get(index);
if (logger.isTraceEnabled())
logger.trace("Sending a GossipDigestSynMessage to {} ...", to);
try {
MessagingService.instance().sendOneWay(prod.getMessage(getVersion(to)), to);
} catch (IOException ex) {
throw new IOError(ex);
}
return seeds.contains(to);
}
use of java.io.IOError in project eiger by wlloyd.
the class KeyIterator method computeNext.
protected DecoratedKey<?> computeNext() {
try {
if (in.isEOF())
return endOfData();
DecoratedKey<?> key = SSTableReader.decodeKey(StorageService.getPartitioner(), desc, ByteBufferUtil.readWithShortLength(in));
// skip data position
in.readLong();
return key;
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project eiger by wlloyd.
the class ReadRepairVerbHandler method doVerb.
@Override
public void doVerb(Message message, String id) {
byte[] body = message.getMessageBody();
FastByteArrayInputStream buffer = new FastByteArrayInputStream(body);
try {
RowMutation rm = RowMutation.serializer().deserialize(new DataInputStream(buffer), message.getVersion());
// WL TODO: Might need to check dependencies here, if we implement on top of quorums
rm.apply();
WriteResponse response = new WriteResponse(rm.getTable(), rm.key(), true);
Message responseMessage = WriteResponse.makeWriteResponseMessage(message, response);
MessagingService.instance().sendReply(responseMessage, id, message.getFrom());
} catch (IOException e) {
throw new IOError(e);
}
}
Aggregations