use of java.io.IOError in project eiger by wlloyd.
the class SystemTable method updateToken.
/**
* This method is used to update the System Table with the new token for this node
*/
public static synchronized void updateToken(Token token) {
IPartitioner p = StorageService.getPartitioner();
ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, STATUS_CF);
cf.addColumn(new Column(SystemTable.TOKEN, p.getTokenFactory().toByteArray(token), LamportClock.getVersion()));
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, LOCATION_KEY);
rm.add(cf);
try {
rm.apply();
} catch (IOException e) {
throw new IOError(e);
}
forceBlockingFlush(STATUS_CF);
}
use of java.io.IOError in project eiger by wlloyd.
the class SystemTable method updateToken.
/**
* Record token being used by another node
*/
public static synchronized void updateToken(InetAddress ep, Token token) {
if (ep == FBUtilities.getLocalAddress())
return;
IPartitioner p = StorageService.getPartitioner();
ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, STATUS_CF);
cf.addColumn(new Column(p.getTokenFactory().toByteArray(token), ByteBuffer.wrap(ep.getAddress()), LamportClock.getVersion()));
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, RING_KEY);
rm.add(cf);
try {
rm.apply();
} catch (IOException e) {
throw new IOError(e);
}
forceBlockingFlush(STATUS_CF);
}
use of java.io.IOError in project eiger by wlloyd.
the class SystemTable method setIndexBuilt.
public static void setIndexBuilt(String table, String indexName) {
ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, INDEX_CF);
cf.addColumn(new Column(ByteBufferUtil.bytes(indexName), ByteBufferUtil.EMPTY_BYTE_BUFFER, LamportClock.getVersion()));
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(table));
rm.add(cf);
try {
rm.apply();
} catch (IOException e) {
throw new IOError(e);
}
forceBlockingFlush(INDEX_CF);
}
use of java.io.IOError in project eiger by wlloyd.
the class SystemTable method setIndexRemoved.
public static void setIndexRemoved(String table, String indexName) {
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes(table));
rm.delete(new QueryPath(INDEX_CF, null, ByteBufferUtil.bytes(indexName)), LamportClock.getVersion());
try {
rm.apply();
} catch (IOException e) {
throw new IOError(e);
}
forceBlockingFlush(INDEX_CF);
}
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);
}
}
Aggregations