use of org.apache.geode.pdx.internal.PdxType in project geode by apache.
the class GFSnapshot method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.println("Usage: GFSnapshot <file>");
System.exit(1);
}
GFSnapshotImporter imp = new GFSnapshotImporter(new File(args[0]));
try {
System.out.println("Snapshot format is version " + imp.getVersion());
System.out.println("Snapshot region is " + imp.getRegionName());
ExportedRegistry reg = imp.getPdxTypes();
Map<Integer, PdxType> types = reg.types();
System.out.println("Found " + types.size() + " PDX types:");
for (Entry<Integer, PdxType> entry : types.entrySet()) {
System.out.println("\t" + entry.getKey() + " = " + entry.getValue());
}
Map<Integer, EnumInfo> enums = reg.enums();
System.out.println("Found " + enums.size() + " PDX enums: ");
for (Entry<Integer, EnumInfo> entry : enums.entrySet()) {
System.out.println("\t" + entry.getKey() + " = " + entry.getValue());
}
System.out.println();
SnapshotRecord record;
while ((record = imp.readSnapshotRecord()) != null) {
System.out.println(record.getKeyObject() + " = " + record.getValueObject());
}
} finally {
imp.close();
}
}
use of org.apache.geode.pdx.internal.PdxType in project geode by apache.
the class PdxRenameJUnitTest method testPdxRename.
@Test
public void testPdxRename() throws Exception {
String DS_NAME = "PdxRenameJUnitTestDiskStore";
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
File f = new File(DS_NAME);
f.mkdir();
try {
final Cache cache = (new CacheFactory(props)).setPdxPersistent(true).setPdxDiskStore(DS_NAME).create();
try {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(new File[] { f });
dsf.create(DS_NAME);
RegionFactory<String, PdxValue> rf1 = cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT);
rf1.setDiskStoreName(DS_NAME);
Region<String, PdxValue> region1 = rf1.create("region1");
region1.put("key1", new PdxValue(1));
cache.close();
Collection<Object> renameResults = DiskStoreImpl.pdxRename(DS_NAME, new File[] { f }, "apache", "pivotal");
assertEquals(2, renameResults.size());
for (Object o : renameResults) {
if (o instanceof PdxType) {
PdxType t = (PdxType) o;
assertEquals("org.pivotal.geode.internal.PdxRenameJUnitTest$PdxValue", t.getClassName());
} else {
EnumInfo ei = (EnumInfo) o;
assertEquals("org.pivotal.geode.internal.PdxRenameJUnitTest$Day", ei.getClassName());
}
}
Collection<PdxType> types = DiskStoreImpl.getPdxTypes(DS_NAME, new File[] { f });
assertEquals(1, types.size());
assertEquals("org.pivotal.geode.internal.PdxRenameJUnitTest$PdxValue", types.iterator().next().getClassName());
} finally {
if (!cache.isClosed()) {
cache.close();
}
}
} finally {
FileUtils.deleteDirectory(f);
}
}
Aggregations