Search in sources :

Example 66 with IOError

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;
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) EndOfFileException(org.jline.reader.EndOfFileException) IOError(java.io.IOError) SqlClientException(org.apache.flink.table.client.SqlClientException) ModifyOperation(org.apache.flink.table.operations.ModifyOperation) AlterOperation(org.apache.flink.table.operations.ddl.AlterOperation) SetOperation(org.apache.flink.table.operations.command.SetOperation) SinkModifyOperation(org.apache.flink.table.operations.SinkModifyOperation) LoadModuleOperation(org.apache.flink.table.operations.LoadModuleOperation) Operation(org.apache.flink.table.operations.Operation) DropOperation(org.apache.flink.table.operations.ddl.DropOperation) ShowCreateViewOperation(org.apache.flink.table.operations.ShowCreateViewOperation) UnloadModuleOperation(org.apache.flink.table.operations.UnloadModuleOperation) ShowJarsOperation(org.apache.flink.table.operations.command.ShowJarsOperation) RemoveJarOperation(org.apache.flink.table.operations.command.RemoveJarOperation) QueryOperation(org.apache.flink.table.operations.QueryOperation) HelpOperation(org.apache.flink.table.operations.command.HelpOperation) QuitOperation(org.apache.flink.table.operations.command.QuitOperation) BeginStatementSetOperation(org.apache.flink.table.operations.BeginStatementSetOperation) CreateOperation(org.apache.flink.table.operations.ddl.CreateOperation) AddJarOperation(org.apache.flink.table.operations.command.AddJarOperation) EndStatementSetOperation(org.apache.flink.table.operations.EndStatementSetOperation) ExplainOperation(org.apache.flink.table.operations.ExplainOperation) ClearOperation(org.apache.flink.table.operations.command.ClearOperation) ResetOperation(org.apache.flink.table.operations.command.ResetOperation) StatementSetOperation(org.apache.flink.table.operations.StatementSetOperation) ShowCreateTableOperation(org.apache.flink.table.operations.ShowCreateTableOperation) UseOperation(org.apache.flink.table.operations.UseOperation) UserInterruptException(org.jline.reader.UserInterruptException)

Example 67 with IOError

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);
    }
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException) File(java.io.File)

Example 68 with IOError

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);
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException) InetAddress(java.net.InetAddress)

Example 69 with IOError

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);
    }
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException)

Example 70 with IOError

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);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) Message(org.apache.cassandra.net.Message) IOError(java.io.IOError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Aggregations

IOError (java.io.IOError)78 IOException (java.io.IOException)58 File (java.io.File)11 ArrayList (java.util.ArrayList)8 Path (java.nio.file.Path)5 Status (ch.qos.logback.core.status.Status)4 BufferedReader (java.io.BufferedReader)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Console (java.io.Console)4 DataInputStream (java.io.DataInputStream)4 IPartitioner (org.apache.cassandra.dht.IPartitioner)4 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)4 Test (org.junit.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 ByteBuffer (java.nio.ByteBuffer)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 QueryPath (org.apache.cassandra.db.filter.QueryPath)3 CorruptSSTableException (org.apache.cassandra.io.sstable.CorruptSSTableException)3 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)3