use of java.io.IOError in project eiger by wlloyd.
the class LeveledManifest method serialize.
public synchronized void serialize() {
File manifestFile = cfs.directories.getOrCreateLeveledManifest();
File oldFile = new File(manifestFile.getPath().replace(EXTENSION, "-old.json"));
File tmpFile = new File(manifestFile.getPath().replace(EXTENSION, "-tmp.json"));
JsonFactory f = new JsonFactory();
try {
JsonGenerator g = f.createJsonGenerator(tmpFile, JsonEncoding.UTF8);
g.useDefaultPrettyPrinter();
g.writeStartObject();
g.writeArrayFieldStart("generations");
for (int level = 0; level < generations.length; level++) {
g.writeStartObject();
g.writeNumberField("generation", level);
g.writeArrayFieldStart("members");
for (SSTableReader ssTableReader : generations[level]) g.writeNumber(ssTableReader.descriptor.generation);
// members
g.writeEndArray();
// generation
g.writeEndObject();
}
// for field generations
g.writeEndArray();
// write global object
g.writeEndObject();
g.close();
if (oldFile.exists() && manifestFile.exists())
FileUtils.deleteWithConfirm(oldFile);
if (manifestFile.exists())
FileUtils.renameWithConfirm(manifestFile, oldFile);
assert tmpFile.exists();
FileUtils.renameWithConfirm(tmpFile, manifestFile);
logger.debug("Saved manifest {}", manifestFile);
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project eiger by wlloyd.
the class AbstractRowResolver method preprocess.
public void preprocess(Message message) {
byte[] body = message.getMessageBody();
FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
try {
ReadResponse result = ReadResponse.serializer().deserialize(new DataInputStream(bufIn), message.getVersion());
if (logger.isDebugEnabled())
logger.debug("Preprocessed {} response", result.isDigestQuery() ? "digest" : "data");
replies.put(message, result);
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project eiger by wlloyd.
the class CompressedSegmentedFile method getSegment.
public FileDataInput getSegment(long position) {
try {
RandomAccessReader file = CompressedRandomAccessReader.open(path, metadata);
file.seek(position);
return file;
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project eiger by wlloyd.
the class MmappedSegmentedFile method getSegment.
/**
* @return The segment containing the given position: must be closed after use.
*/
public FileDataInput getSegment(long position) {
Segment segment = floor(position);
if (segment.right != null) {
// segment is mmap'd
return new MappedFileDataInput(segment.right, path, (int) (position - segment.left));
}
// not mmap'd: open a braf covering the segment
try {
// FIXME: brafs are unbounded, so this segment will cover the rest of the file, rather than just the row
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 RowRepairResolver method scheduleRepairs.
/**
* For each row version, compare with resolved (the superset of all row versions);
* if it is missing anything, send a mutation to the endpoint it come from.
*/
public static List<IAsyncResult> scheduleRepairs(ColumnFamily resolved, String table, DecoratedKey<?> key, List<ColumnFamily> versions, List<InetAddress> endpoints) {
List<IAsyncResult> results = new ArrayList<IAsyncResult>(versions.size());
for (int i = 0; i < versions.size(); i++) {
ColumnFamily diffCf = ColumnFamily.diff(versions.get(i), resolved);
if (// no repair needs to happen
diffCf == null)
continue;
// create and send the row mutation message based on the diff
RowMutation rowMutation = new RowMutation(table, key.key);
rowMutation.add(diffCf);
Message repairMessage;
try {
// use a separate verb here because we don't want these to be get the white glove hint-
// on-timeout behavior that a "real" mutation gets
repairMessage = rowMutation.getMessage(StorageService.Verb.READ_REPAIR, Gossiper.instance.getVersion(endpoints.get(i)));
} catch (IOException e) {
throw new IOError(e);
}
results.add(MessagingService.instance().sendRR(repairMessage, endpoints.get(i)));
}
return results;
}
Aggregations