use of com.ibm.j9ddr.tools.store.StructureKey in project openj9 by eclipse.
the class J9DDRStructureStoreTest method add.
@Test
public void add() {
// Test
J9DDRStructureStore store = null;
try {
store = new J9DDRStructureStore("newDir", "superset.dat");
} catch (IOException e) {
e.printStackTrace();
fail("Could not open store");
}
String original = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\j9ddr.dat";
String newOne = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\newj9ddr.dat";
StructureKey keyOne = new StructureKey("windows", "foo");
StructureKey keyTwo = new StructureKey("windows", "bar");
// String structureFileName = original;
// StructureKey key = keyOne;
String structureFileName = newOne;
StructureKey key = keyTwo;
try {
store.add(key, structureFileName, true);
store.close();
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (StructureMismatchError e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
try {
store.close();
} catch (IOException e) {
fail("Could not close store");
}
}
// TODO: Open file and make sure it is good.
try {
store.close();
store = null;
store = new J9DDRStructureStore("newDir", "superset.dat");
ImageInputStream is = store.get(key);
FileInputStream fis = new FileInputStream(structureFileName);
assertTrue("Files where not the same", compare(is, fis));
} catch (IOException e) {
fail();
}
}
use of com.ibm.j9ddr.tools.store.StructureKey in project openj9 by eclipse.
the class AddStructureBlob method addFromPropertiesFile.
// the order in which files are added is controlled by a properties file, it expects the -f parameter to point to a directory containg
// either blobs or supersets
private void addFromPropertiesFile(J9DDRStructureStore store) throws IOException, StructureMismatchError {
String directoryName = opts.get("-d");
String keyString = opts.get("-k");
File structurePath = new File(opts.get("-f"));
// load the spec order (if specified on the command line)
String[] specs = loadSpecNames();
File[] structureFiles = new File[specs.length];
for (int i = 0; i < specs.length; i++) {
structureFiles[i] = new File(structurePath, specs[i]);
}
for (File file : structureFiles) {
if (file.exists()) {
StructureKey key = new StructureKey(file.getName() + "." + keyString);
store.add(key, file.getPath(), false);
store.updateSuperset();
System.out.println(String.format("Added %s to %s/%s as %s", file.getAbsolutePath(), directoryName, store.getSuperSetFileName(), key));
} else {
System.out.println("WARNING : The specified structure file " + file.getName() + " does not exist and was ignored");
}
}
}
use of com.ibm.j9ddr.tools.store.StructureKey in project openj9 by eclipse.
the class AddStructureBlob method addFromFile.
// add a structure from a specified path
private void addFromFile(J9DDRStructureStore store) throws IOException, StructureMismatchError {
String directoryName = opts.get("-d");
String structureName = opts.get("-f");
String keyString = opts.get("-k");
String supersetName = opts.get("-s");
if (keyString == null) {
File structurePath = new File(structureName);
File[] structureFiles;
if (structurePath.isDirectory()) {
structureFiles = structurePath.listFiles();
} else {
structureFiles = new File[] { structurePath };
structurePath = structurePath.getParentFile();
}
for (File file : structureFiles) {
if (file.exists()) {
store.add(null, file.getPath(), false);
store.updateSuperset();
System.out.println("Added " + file.getName() + " to superset " + supersetName + " in " + directoryName);
} else {
System.out.println("WARNING : The specified structure file " + file.getName() + " does not exist and was ignored");
}
}
} else {
StructureKey key = new StructureKey(keyString);
store.add(key, structureName, true);
store.updateSuperset();
System.out.println(String.format("Added %s to %s/%s as %s", structureName, directoryName, store.getSuperSetFileName(), keyString));
}
}
Aggregations