Search in sources :

Example 71 with IOError

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

the class LazilyCompactedRow method update.

public void update(MessageDigest digest) {
    assert !closed;
    // no special-case for rows.size == 1, we're actually skipping some bytes here so just
    // blindly updating everything wouldn't be correct
    DataOutputBuffer out = new DataOutputBuffer();
    try {
        ColumnFamily.serializer().serializeCFInfo(emptyColumnFamily, out);
        out.writeInt(columnCount);
        digest.update(out.getData(), 0, out.getLength());
    } catch (IOException e) {
        throw new IOError(e);
    }
    Iterator<IColumn> iter = iterator();
    while (iter.hasNext()) {
        iter.next().updateDigest(digest);
    }
    close();
}
Also used : IOError(java.io.IOError) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) IOException(java.io.IOException)

Example 72 with IOError

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

the class CommitLogSegment method close.

/**
 * Close the segment file.
 */
public void close() {
    if (closed)
        return;
    try {
        logFileAccessor.close();
        closed = true;
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException)

Example 73 with IOError

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

the class Directories method migrateFile.

private static void migrateFile(File file, File ksDir, String additionalPath) {
    try {
        if (file.isDirectory())
            return;
        String name = file.getName();
        boolean isManifest = name.endsWith(LeveledManifest.EXTENSION);
        String cfname = isManifest ? name.substring(0, name.length() - LeveledManifest.EXTENSION.length()) : name.substring(0, name.indexOf(Component.separator));
        // idx > 0 => secondary index
        int idx = cfname.indexOf(SECONDARY_INDEX_NAME_SEPARATOR);
        String dirname = idx > 0 ? cfname.substring(0, idx) : cfname;
        File destDir = getOrCreate(ksDir, dirname, additionalPath);
        File destFile = new File(destDir, isManifest ? name : ksDir.getName() + Component.separator + name);
        logger.debug(String.format("[upgrade to 1.1] Moving %s to %s", file, destFile));
        FileUtils.renameWithConfirm(file, destFile);
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException) MmappedSegmentedFile(org.apache.cassandra.io.util.MmappedSegmentedFile) File(java.io.File)

Example 74 with IOError

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

the class Directories method sstablesNeedsMigration.

/**
 * To check if sstables needs migration, we look at the System directory.
 * If it contains a directory for the status cf, we'll attempt a sstable
 * migration.
 * Note that it is mostly harmless to try a migration uselessly, except
 * maybe for some wasted cpu cycles.
 */
public static boolean sstablesNeedsMigration() {
    if (StorageService.instance.isClientMode())
        return false;
    boolean hasSystemKeyspace = false;
    for (File location : dataFileLocations) {
        File systemDir = new File(location, Table.SYSTEM_TABLE);
        hasSystemKeyspace |= (systemDir.exists() && systemDir.isDirectory());
        File statusCFDir = new File(systemDir, SystemTable.STATUS_CF);
        if (statusCFDir.exists())
            return false;
    }
    if (!hasSystemKeyspace)
        // This is a brand new node.
        return false;
    // Check whether the migration migth create too long a filename
    int longestLocation = -1;
    try {
        for (File loc : dataFileLocations) longestLocation = Math.max(longestLocation, loc.getCanonicalPath().length());
    } catch (IOException e) {
        throw new IOError(e);
    }
    for (KSMetaData ksm : Schema.instance.getTableDefinitions()) {
        String ksname = ksm.name;
        for (Map.Entry<String, CFMetaData> entry : ksm.cfMetaData().entrySet()) {
            String cfname = entry.getKey();
            // max path is roughly (guess-estimate) <location>/ksname/cfname/snapshots/1324314347102-somename/ksname-cfname-tmp-hb-1024-Statistics.db
            if (longestLocation + (ksname.length() + cfname.length()) * 2 + 62 > 256)
                throw new RuntimeException("Starting with 1.1, keyspace names and column family names must be less than 32 characters long. " + ksname + "/" + cfname + " doesn't respect that restriction. Please rename your keyspace/column families to respect that restriction before updating.");
        }
    }
    return true;
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException) MmappedSegmentedFile(org.apache.cassandra.io.util.MmappedSegmentedFile) File(java.io.File) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 75 with IOError

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

the class MessagingService method shutdown.

/**
 * Wait for callbacks and don't allow any more to be created (since they could require writing hints)
 */
public void shutdown() {
    logger_.info("Waiting for messaging service to quiesce");
    // We may need to schedule hints on the mutation stage, so it's erroneous to shut down the mutation stage first
    assert !StageManager.getStage(Stage.MUTATION).isShutdown();
    // the important part
    callbacks.shutdown();
    // attempt to humor tests that try to stop and restart MS
    try {
        for (SocketThread th : socketThreads) th.close();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException)

Aggregations

IOError (java.io.IOError)78 IOException (java.io.IOException)58 File (java.io.File)11 ArrayList (java.util.ArrayList)8 Path (java.nio.file.Path)5 Status (ch.qos.logback.core.status.Status)4 BufferedReader (java.io.BufferedReader)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Console (java.io.Console)4 DataInputStream (java.io.DataInputStream)4 IPartitioner (org.apache.cassandra.dht.IPartitioner)4 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)4 Test (org.junit.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 ByteBuffer (java.nio.ByteBuffer)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 QueryPath (org.apache.cassandra.db.filter.QueryPath)3 CorruptSSTableException (org.apache.cassandra.io.sstable.CorruptSSTableException)3 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)3