use of org.neo4j.kernel.impl.store.id.IdType in project neo4j by neo4j.
the class EnterpriseEditionSettingsTest method idTypesToReuseAllowedValues.
@Test
public void idTypesToReuseAllowedValues() {
for (IdType type : IdType.values()) {
if (type == IdType.NODE || type == IdType.RELATIONSHIP) {
assertIdTypesToReuseAllows(type);
} else {
assertIdTypesToReuseDisallows(type);
}
}
assertIdTypesToReuseAllows(IdType.NODE, IdType.RELATIONSHIP);
assertIdTypesToReuseAllows(IdType.RELATIONSHIP, IdType.NODE);
assertIdTypesToReuseDisallows(IdType.NODE, IdType.RELATIONSHIP, IdType.RELATIONSHIP_GROUP);
assertIdTypesToReuseDisallows(IdType.SCHEMA, IdType.NEOSTORE_BLOCK);
}
use of org.neo4j.kernel.impl.store.id.IdType in project neo4j by neo4j.
the class TestCrashWithRebuildSlow method crashAndRebuildSlowWithDynamicStringDeletions.
@Test
public void crashAndRebuildSlowWithDynamicStringDeletions() throws Exception {
File storeDir = new File("dir").getAbsoluteFile();
final GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(fs.get()).newImpermanentDatabase(storeDir);
List<Long> deletedNodeIds = produceNonCleanDefraggedStringStore(db);
Map<IdType, Long> highIdsBeforeCrash = getHighIds(db);
long checksumBefore = fs.get().checksum();
long checksumBefore2 = fs.get().checksum();
assertThat(checksumBefore, Matchers.equalTo(checksumBefore2));
EphemeralFileSystemAbstraction snapshot = fs.snapshot(() -> db.shutdown());
long snapshotChecksum = snapshot.checksum();
if (snapshotChecksum != checksumBefore) {
try (OutputStream out = new FileOutputStream(testDir.file("snapshot.zip"))) {
snapshot.dumpZip(out);
}
try (OutputStream out = new FileOutputStream(testDir.file("fs.zip"))) {
fs.get().dumpZip(out);
}
}
assertThat(snapshotChecksum, equalTo(checksumBefore));
// Recover with unsupported.dbms.id_generator_fast_rebuild_enabled=false
assertNumberOfFreeIdsEquals(storeDir, snapshot, 0);
GraphDatabaseAPI newDb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(snapshot).newImpermanentDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.rebuild_idgenerators_fast, FALSE).newGraphDatabase();
Map<IdType, Long> highIdsAfterCrash = getHighIds(newDb);
assertEquals(highIdsBeforeCrash, highIdsAfterCrash);
try (Transaction tx = newDb.beginTx()) {
// Verify that the data we didn't delete is still around
int nameCount = 0;
int relCount = 0;
for (Node node : newDb.getAllNodes()) {
nameCount++;
assertThat(node, inTx(newDb, hasProperty("name"), true));
relCount += Iterables.count(node.getRelationships(Direction.OUTGOING));
}
assertEquals(16, nameCount);
assertEquals(12, relCount);
// Verify that the ids of the nodes we deleted are reused
List<Long> newIds = new ArrayList<>();
newIds.add(newDb.createNode().getId());
newIds.add(newDb.createNode().getId());
newIds.add(newDb.createNode().getId());
newIds.add(newDb.createNode().getId());
assertThat(newIds, is(deletedNodeIds));
tx.success();
} finally {
newDb.shutdown();
snapshot.close();
}
}
use of org.neo4j.kernel.impl.store.id.IdType in project neo4j by neo4j.
the class TestCrashWithRebuildSlow method getHighIds.
private static Map<IdType, Long> getHighIds(GraphDatabaseAPI db) {
final Map<IdType, Long> highIds = new HashMap<>();
NeoStores neoStores = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
Visitor<CommonAbstractStore, RuntimeException> visitor = new Visitor<CommonAbstractStore, RuntimeException>() {
@Override
public boolean visit(CommonAbstractStore store) throws RuntimeException {
highIds.put(store.getIdType(), store.getHighId());
return true;
}
};
neoStores.visitStore(visitor);
return highIds;
}
Aggregations