Search in sources :

Example 26 with IOError

use of java.io.IOError in project eiger by wlloyd.

the class StorageService method initClient.

public synchronized void initClient(int delay) throws IOException, ConfigurationException {
    if (initialized) {
        if (!isClientMode)
            throw new UnsupportedOperationException("StorageService does not support switching modes.");
        return;
    }
    initialized = true;
    isClientMode = true;
    logger_.info("Starting up client gossip");
    setMode(Mode.CLIENT, false);
    Gossiper.instance.register(this);
    // needed for node-ring gathering.
    Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
    MessagingService.instance().listen(FBUtilities.getLocalAddress());
    // sleep a while to allow gossip to warm up (the other nodes need to know about this one before they can reply).
    try {
        Thread.sleep(delay);
    } catch (Exception ex) {
        throw new IOError(ex);
    }
    MigrationManager.passiveAnnounce(Schema.instance.getVersion());
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 27 with IOError

use of java.io.IOError in project eiger by wlloyd.

the class StreamOut method transferRanges.

/**
     * Stream the given ranges to the target endpoint from each of the given CFs.
    */
public static void transferRanges(StreamOutSession session, Iterable<ColumnFamilyStore> cfses, Collection<Range<Token>> ranges, OperationType type) {
    assert ranges.size() > 0;
    logger.info("Beginning transfer to {}", session.getHost());
    logger.debug("Ranges are {}", StringUtils.join(ranges, ","));
    try {
        flushSSTables(cfses);
        Iterable<SSTableReader> sstables = Collections.emptyList();
        for (ColumnFamilyStore cfStore : cfses) sstables = Iterables.concat(sstables, cfStore.markCurrentSSTablesReferenced());
        transferSSTables(session, sstables, ranges, type);
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) IOError(java.io.IOError) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) IOException(java.io.IOException)

Example 28 with IOError

use of java.io.IOError in project eiger by wlloyd.

the class StreamReplyVerbHandler method doVerb.

public void doVerb(Message message, String id) {
    byte[] body = message.getMessageBody();
    FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
    try {
        StreamReply reply = StreamReply.serializer.deserialize(new DataInputStream(bufIn), message.getVersion());
        logger.debug("Received StreamReply {}", reply);
        StreamOutSession session = StreamOutSession.get(message.getFrom(), reply.sessionId);
        if (session == null) {
            logger.debug("Received stream action " + reply.action + " for an unknown session from " + message.getFrom());
            return;
        }
        switch(reply.action) {
            case FILE_FINISHED:
                logger.info("Successfully sent {} to {}", reply.file, message.getFrom());
                session.validateCurrentFile(reply.file);
                session.startNext();
                break;
            case FILE_RETRY:
                session.validateCurrentFile(reply.file);
                logger.info("Need to re-stream file {} to {}", reply.file, message.getFrom());
                session.retry();
                break;
            case SESSION_FINISHED:
                session.close();
                break;
            default:
                throw new RuntimeException("Cannot handle FileStatus.Action: " + reply.action);
        }
    } catch (IOException ex) {
        throw new IOError(ex);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) IOError(java.io.IOError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 29 with IOError

use of java.io.IOError in project eiger by wlloyd.

the class StreamRequestVerbHandler method doVerb.

public void doVerb(Message message, String id) {
    if (logger.isDebugEnabled())
        logger.debug("Received a StreamRequestMessage from {}", message.getFrom());
    byte[] body = message.getMessageBody();
    FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
    try {
        StreamRequestMessage srm = StreamRequestMessage.serializer().deserialize(new DataInputStream(bufIn), message.getVersion());
        if (logger.isDebugEnabled())
            logger.debug(srm.toString());
        StreamOutSession session = StreamOutSession.create(srm.table, message.getFrom(), srm.sessionId);
        StreamOut.transferRanges(session, srm.columnFamilies, srm.ranges, srm.type);
    } catch (IOException ex) {
        throw new IOError(ex);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) IOError(java.io.IOError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 30 with IOError

use of java.io.IOError in project cassandra by apache.

the class UnfilteredRowIteratorSerializer method deserialize.

public UnfilteredRowIterator deserialize(DataInputPlus in, int version, TableMetadata metadata, SerializationHelper.Flag flag, Header header) throws IOException {
    if (header.isEmpty)
        return EmptyIterators.unfilteredRow(metadata, header.key, header.isReversed);
    final SerializationHelper helper = new SerializationHelper(metadata, version, flag);
    final SerializationHeader sHeader = header.sHeader;
    return new AbstractUnfilteredRowIterator(metadata, header.key, header.partitionDeletion, sHeader.columns(), header.staticRow, header.isReversed, sHeader.stats()) {

        private final Row.Builder builder = BTreeRow.sortedBuilder();

        protected Unfiltered computeNext() {
            try {
                Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(in, sHeader, helper, builder);
                return unfiltered == null ? endOfData() : unfiltered;
            } catch (IOException e) {
                throw new IOError(e);
            }
        }
    };
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException)

Aggregations

IOError (java.io.IOError)49 IOException (java.io.IOException)42 File (java.io.File)8 DataInputStream (java.io.DataInputStream)5 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Console (java.io.Console)4 IPartitioner (org.apache.cassandra.dht.IPartitioner)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 QueryPath (org.apache.cassandra.db.filter.QueryPath)3 SshClient (org.apache.sshd.client.SshClient)3 UserInteraction (org.apache.sshd.client.auth.keyboard.UserInteraction)3 ClientChannel (org.apache.sshd.client.channel.ClientChannel)3 ClientSession (org.apache.sshd.client.session.ClientSession)3 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 PrintWriter (java.io.PrintWriter)2