Search in sources :

Example 1 with KernelExtensionFactory

use of org.neo4j.kernel.extension.KernelExtensionFactory in project neo4j by neo4j.

the class GraphDatabaseDependencies method newDependencies.

public static GraphDatabaseDependencies newDependencies() {
    List<KernelExtensionFactory<?>> kernelExtensions = new ArrayList<>();
    for (KernelExtensionFactory factory : Service.load(KernelExtensionFactory.class)) {
        kernelExtensions.add(factory);
    }
    Map<String, URLAccessRule> urlAccessRules = new HashMap<>();
    urlAccessRules.put("http", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("https", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("ftp", URLAccessRules.alwaysPermitted());
    urlAccessRules.put("file", URLAccessRules.fileAccess());
    List<QueryEngineProvider> queryEngineProviders = asList(Service.load(QueryEngineProvider.class));
    return new GraphDatabaseDependencies(null, null, new ArrayList<>(), kernelExtensions, urlAccessRules, queryEngineProviders);
}
Also used : QueryEngineProvider(org.neo4j.kernel.impl.query.QueryEngineProvider) URLAccessRule(org.neo4j.graphdb.security.URLAccessRule) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory)

Example 2 with KernelExtensionFactory

use of org.neo4j.kernel.extension.KernelExtensionFactory in project neo4j by neo4j.

the class LabelScanStoreHaIT method setUp.

@Before
public void setUp() {
    KernelExtensionFactory<?> testExtension = labelScanStoreExtension(monitor);
    TestHighlyAvailableGraphDatabaseFactory factory = new TestHighlyAvailableGraphDatabaseFactory();
    factory.removeKernelExtensions(extension -> extension.getClass().getName().contains("LabelScan"));
    factory.addKernelExtension(testExtension);
    ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("root")).withDbFactory(factory).withSharedSetting(GraphDatabaseSettings.label_index, labelIndexSettingName()).withStoreDirInitializer((serverId, storeDir) -> {
        if (serverId == 1) {
            GraphDatabaseService db = new TestGraphDatabaseFactory().addKernelExtension(testExtension).newEmbeddedDatabaseBuilder(storeDir.getAbsoluteFile()).setConfig(GraphDatabaseSettings.label_index, labelIndexSettingName()).newGraphDatabase();
            try {
                createSomeLabeledNodes(db, new Label[] { Labels.First }, new Label[] { Labels.First, Labels.Second }, new Label[] { Labels.Second });
            } finally {
                db.shutdown();
            }
        }
    }).build();
    life.add(clusterManager);
    life.start();
    cluster = clusterManager.getCluster();
    cluster.await(allSeesAllAsAvailable());
    cluster.await(allAvailabilityGuardsReleased());
}
Also used : Label(org.neo4j.graphdb.Label) TestDirectory(org.neo4j.test.rule.TestDirectory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Iterators.count(org.neo4j.helpers.collection.Iterators.count) TestHighlyAvailableGraphDatabaseFactory(org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory) Rule(org.junit.Rule) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) ClusterManager.allSeesAllAsAvailable(org.neo4j.kernel.impl.ha.ClusterManager.allSeesAllAsAvailable) After(org.junit.After) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) ClusterManager.allAvailabilityGuardsReleased(org.neo4j.kernel.impl.ha.ClusterManager.allAvailabilityGuardsReleased) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) Transaction(org.neo4j.graphdb.Transaction) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestHighlyAvailableGraphDatabaseFactory(org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Label(org.neo4j.graphdb.Label) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Before(org.junit.Before)

Example 3 with KernelExtensionFactory

use of org.neo4j.kernel.extension.KernelExtensionFactory in project neo4j by neo4j.

the class UniqueIndexRecoveryTests method before.

@Before
public void before() {
    List<KernelExtensionFactory<?>> extensionFactories = new ArrayList<>();
    extensionFactories.add(kernelExtensionFactory);
    extensionFactories.add(new LuceneLabelScanStoreExtension());
    factory.setKernelExtensions(extensionFactories);
    db = newDb();
}
Also used : LuceneLabelScanStoreExtension(org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStoreExtension) ArrayList(java.util.ArrayList) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) Before(org.junit.Before)

Example 4 with KernelExtensionFactory

use of org.neo4j.kernel.extension.KernelExtensionFactory in project neo4j by neo4j.

the class AbstractInProcessServerBuilder method newServer.

@Override
public ServerControls newServer() {
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        final OutputStream logOutputStream;
        try {
            logOutputStream = createOrOpenAsOuputStream(fileSystem, new File(serverFolder, "neo4j.log"), true);
        } catch (IOException e) {
            throw new RuntimeException("Unable to create log file", e);
        }
        config.put(ServerSettings.third_party_packages.name(), toStringForThirdPartyPackageProperty(extensions.toList()));
        final FormattedLogProvider userLogProvider = FormattedLogProvider.toOutputStream(logOutputStream);
        GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies();
        Iterable<KernelExtensionFactory<?>> kernelExtensions = append(new Neo4jHarnessExtensions(procedures), dependencies.kernelExtensions());
        dependencies = dependencies.kernelExtensions(kernelExtensions).userLogProvider(userLogProvider);
        AbstractNeoServer neoServer = createNeoServer(config, dependencies, userLogProvider);
        InProcessServerControls controls = new InProcessServerControls(serverFolder, neoServer, logOutputStream);
        controls.start();
        try {
            fixtures.applyTo(controls);
        } catch (Exception e) {
            controls.close();
            throw Exceptions.launderedException(e);
        }
        return controls;
    } catch (IOException e) {
        throw Exceptions.launderedException(e);
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) OutputStream(java.io.OutputStream) IOException(java.io.IOException) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) AbstractNeoServer(org.neo4j.server.AbstractNeoServer) IOException(java.io.IOException) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) File(java.io.File)

Aggregations

KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)4 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Label (org.neo4j.graphdb.Label)1 Transaction (org.neo4j.graphdb.Transaction)1 GraphDatabaseSettings (org.neo4j.graphdb.factory.GraphDatabaseSettings)1 TestHighlyAvailableGraphDatabaseFactory (org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory)1 URLAccessRule (org.neo4j.graphdb.security.URLAccessRule)1 Iterators.count (org.neo4j.helpers.collection.Iterators.count)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1