Search in sources :

Example 16 with IOError

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

Example 17 with IOError

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

Example 18 with IOError

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

Example 19 with IOError

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);
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) IOError(java.io.IOError) IOException(java.io.IOException)

Example 20 with IOError

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);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) IOError(java.io.IOError) JsonFactory(org.codehaus.jackson.JsonFactory) JsonGenerator(org.codehaus.jackson.JsonGenerator) IOException(java.io.IOException) File(java.io.File)

Aggregations

IOError (java.io.IOError)50 IOException (java.io.IOException)43 File (java.io.File)8 DataInputStream (java.io.DataInputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Console (java.io.Console)4 IPartitioner (org.apache.cassandra.dht.IPartitioner)4 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)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