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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
};
}
Aggregations