Search in sources :

Example 36 with IOError

use of java.io.IOError in project error-prone by google.

the class BaseErrorProneCompiler method run.

public Result run(String[] argv) {
    try {
        argv = CommandLine.parse(argv);
    } catch (IOException e) {
        throw new IOError(e);
    }
    List<String> javacOpts = new ArrayList<>();
    List<String> sources = new ArrayList<>();
    for (String arg : argv) {
        // TODO(cushon): is there a better way to categorize javacopts?
        if (!arg.startsWith("-") && arg.endsWith(".java")) {
            sources.add(arg);
        } else {
            javacOpts.add(arg);
        }
    }
    StandardJavaFileManager fileManager = new MaskedFileManager();
    return run(javacOpts.toArray(new String[0]), fileManager, ImmutableList.copyOf(fileManager.getJavaFileObjectsFromStrings(sources)), null);
}
Also used : MaskedFileManager(com.google.errorprone.MaskedClassLoader.MaskedFileManager) IOError(java.io.IOError) ArrayList(java.util.ArrayList) StandardJavaFileManager(javax.tools.StandardJavaFileManager) IOException(java.io.IOException)

Example 37 with IOError

use of java.io.IOError in project error-prone by google.

the class ErrorProneInMemoryFileManager method forResource.

/**
   * Loads a resource of the provided class into a {@link JavaFileObject}.
   */
public JavaFileObject forResource(Class<?> clazz, String fileName) {
    Path path = fileSystem.getPath("/", clazz.getPackage().getName().replace('.', '/'), fileName);
    try (InputStream is = findResource(clazz, fileName)) {
        Files.createDirectories(path.getParent());
        Files.copy(is, path);
    } catch (IOException e) {
        throw new IOError(e);
    }
    return Iterables.getOnlyElement(getJavaFileObjects(path));
}
Also used : Path(java.nio.file.Path) IOError(java.io.IOError) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 38 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 39 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 40 with IOError

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

the class ReadRepairVerbHandler method doVerb.

@Override
public void doVerb(Message message, String id) {
    byte[] body = message.getMessageBody();
    FastByteArrayInputStream buffer = new FastByteArrayInputStream(body);
    try {
        RowMutation rm = RowMutation.serializer().deserialize(new DataInputStream(buffer), message.getVersion());
        //WL TODO: Might need to check dependencies here, if we implement on top of quorums
        rm.apply();
        WriteResponse response = new WriteResponse(rm.getTable(), rm.key(), true);
        Message responseMessage = WriteResponse.makeWriteResponseMessage(message, response);
        MessagingService.instance().sendReply(responseMessage, id, message.getFrom());
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) Message(org.apache.cassandra.net.Message) IOError(java.io.IOError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

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