use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class IndexSamplingIntegrationTest method fetchIndexSamplingValues.
private DoubleLongRegister fetchIndexSamplingValues(GraphDatabaseService db) throws IndexNotFoundKernelException {
try {
// Then
db = new TestGraphDatabaseFactory().newEmbeddedDatabase(testDirectory.graphDbDir());
@SuppressWarnings("deprecation") GraphDatabaseAPI api = (GraphDatabaseAPI) db;
CountsTracker countsTracker = api.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getCounts();
IndexSampleKey key = CountsKeyFactory.indexSampleKey(indexId(api));
return countsTracker.get(key, Registers.newDoubleLongRegister());
} finally {
if (db != null) {
db.shutdown();
}
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class FileWatchIT method doNotNotifyAboutLuceneIndexFilesDeletion.
@Test(timeout = TEST_TIMEOUT)
public void doNotNotifyAboutLuceneIndexFilesDeletion() throws InterruptedException, IOException {
DependencyResolver dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
FileWatcher fileWatcher = getFileWatcher(database);
CheckPointer checkPointer = dependencyResolver.resolveDependency(CheckPointer.class);
String propertyStoreName = MetaDataStore.DEFAULT_NAME + StoreFactory.PROPERTY_STORE_NAME;
AccumulativeDeletionEventListener accumulativeListener = new AccumulativeDeletionEventListener();
ModificationEventListener modificationListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(modificationListener);
fileWatcher.addFileWatchEventListener(accumulativeListener);
String labelName = "labelName";
String propertyName = "propertyName";
Label testLabel = Label.label(labelName);
createIndexes(database, propertyName, testLabel);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!modificationListener.awaitModificationNotification());
fileWatcher.removeFileWatchEventListener(modificationListener);
ModificationEventListener afterRemovalListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(afterRemovalListener);
dropAllIndexes(database);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!afterRemovalListener.awaitModificationNotification());
accumulativeListener.assertDoesNotHaveAnyDeletions();
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TestRecoveryMultipleDataSources method main.
public static void main(String[] args) throws IOException {
if (args.length != 1) {
exit(1);
}
File storeDir = new File(args[0]);
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
try (Transaction tx = db.beginTx()) {
db.createNode().createRelationshipTo(db.createNode(), MyRelTypes.TEST);
tx.success();
}
((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(CheckPointer.class).forceCheckPoint(new SimpleTriggerInfo("test"));
try (Transaction tx = db.beginTx()) {
db.index().forNodes("index").add(db.createNode(), storeDir.getAbsolutePath(), db.createNode());
tx.success();
}
exit(0);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class IndexStatisticsTest method before.
@Before
public void before() {
GraphDatabaseAPI graphDatabaseAPI = dbRule.getGraphDatabaseAPI();
this.db = graphDatabaseAPI;
DependencyResolver dependencyResolver = graphDatabaseAPI.getDependencyResolver();
this.bridge = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class);
graphDatabaseAPI.getDependencyResolver().resolveDependency(Monitors.class).addMonitorListener(indexOnlineMonitor);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TestReferenceDangling method testPropertyStoreReferencesOnRead.
@Test
public void testPropertyStoreReferencesOnRead() throws Throwable {
// Given
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
// and Given the cache contains a LazyProperty
long nId = ensurePropertyIsCachedLazyProperty(db, "some");
// When
restartNeoDataSource(db);
// Then reading the property is still possible
try (Transaction tx = db.beginTx()) {
db.getNodeById(nId).getProperty("some");
tx.success();
}
}
Aggregations