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);
}
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));
}
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;
}
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);
}
}
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);
}
}
Aggregations