Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConvertListsAndMapsWhenPassingFromScalaToJava() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldConvertListsAndMapsWhenPassingFromScalaToJava()
        {
            GraphDatabaseQueryService graph    = new GraphDatabaseCypherService(this.Database.GraphDatabaseAPI);
            DependencyResolver        resolver = graph.DependencyResolver;
            Monitors monitors = resolver.ResolveDependency(typeof(Monitors));

            NullLogProvider nullLogProvider = NullLogProvider.Instance;

            Config config = resolver.ResolveDependency(typeof(Config));
            CypherConfiguration cypherConfig = CypherConfiguration.fromConfig(config);

            CommunityCompilerFactory compilerFactory = new CommunityCompilerFactory(graph, monitors, nullLogProvider, cypherConfig.toCypherPlannerConfiguration(config), cypherConfig.toCypherRuntimeConfiguration());
            ExecutionEngine          executionEngine = new ExecutionEngine(graph, nullLogProvider, compilerFactory);

            Result result;

            using (InternalTransaction tx = graph.BeginTransaction(KernelTransaction.Type.@implicit, LoginContext.AUTH_DISABLED))
            {
                string query            = "RETURN { key : 'Value' , collectionKey: [{ inner: 'Map1' }, { inner: 'Map2' }]}";
                TransactionalContext tc = CreateTransactionContext(graph, tx, query);
                result = executionEngine.ExecuteQuery(query, _noParams, tc);

                VerifyResult(result);

                result.Close();
                tx.Success();
            }
        }
Пример #2
0
        public override void Start()
        {
            DependencyResolver resolver = _database.Graph.DependencyResolver;

            this._executionEngine = ( ExecutionEngine )resolver.ResolveDependency(typeof(QueryExecutionEngine));
            this._service         = resolver.ResolveDependency(typeof(GraphDatabaseQueryService));
            this._contextFactory  = Neo4jTransactionalContextFactory.create(this._service, _locker);
        }
Пример #3
0
        public virtual long FindLastAppliedIndex()
        {
            DependencyResolver      dependencies       = _localDatabase.dataSource().DependencyResolver;
            TransactionIdStore      transactionIdStore = dependencies.ResolveDependency(typeof(TransactionIdStore), ONLY);
            LogicalTransactionStore transactionStore   = dependencies.ResolveDependency(typeof(LogicalTransactionStore), ONLY);

            return((new LastCommittedIndexFinder(transactionIdStore, transactionStore, _logProvider)).LastCommittedIndex);
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            DependencyResolver dependencyResolver = mock(typeof(DependencyResolver));

            when(_datasource.DependencyResolver).thenReturn(dependencyResolver);
            when(dependencyResolver.ResolveDependency(typeof(LogicalTransactionStore))).thenReturn(_logicalTransactionStore);
            when(dependencyResolver.ResolveDependency(typeof(TransactionIdStore))).thenReturn(_transactionIdStore);
            when(_transactionIdStore.LastCommittedTransactionId).thenReturn(15L);
            _txPullRequestHandler = new TxPullRequestHandler(new CatchupServerProtocol(), () => _storeId, () => true, () => _datasource, new Monitors(), _logProvider);
        }
Пример #5
0
        /// <summary>
        /// Creates an execution engine around the give graph database </summary>
        /// <param name="queryService"> The database to wrap </param>
        /// <param name="logProvider"> A <seealso cref="LogProvider"/> for cypher-statements </param>
        public ExecutionEngine(GraphDatabaseQueryService queryService, LogProvider logProvider, CompilerFactory compilerFactory)
        {
            DependencyResolver  resolver            = queryService.DependencyResolver;
            Monitors            monitors            = resolver.ResolveDependency(typeof(Monitors));
            CacheTracer         cacheTracer         = new MonitoringCacheTracer(monitors.NewMonitor(typeof(StringCacheMonitor)));
            Config              config              = resolver.ResolveDependency(typeof(Config));
            CypherConfiguration cypherConfiguration = CypherConfiguration.fromConfig(config);
            CompilationTracer   tracer              = new TimingCompilationTracer(monitors.NewMonitor(typeof(TimingCompilationTracer.EventListener)));

            _inner = new [email protected](queryService, monitors, tracer, cacheTracer, cypherConfiguration, compilerFactory, logProvider, Clock.systemUTC());
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault()
        public virtual void CreateBufferedIdComponentsByDefault()
        {
            ClusterManager.ManagedCluster managedCluster     = ClusterRule.startCluster();
            DependencyResolver            dependencyResolver = managedCluster.Master.DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreateBufferedIdComponentsByDefault()
        {
            Cluster            cluster            = ClusterRule.startCluster();
            CoreClusterMember  leader             = cluster.awaitLeader();
            DependencyResolver dependencyResolver = leader.Database().DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(FreeIdFilteredIdGeneratorFactory)));
        }
Пример #8
0
        public TxPullRequestHandler(CatchupServerProtocol protocol, System.Func <StoreId> storeIdSupplier, System.Func <bool> databaseAvailable, System.Func <NeoStoreDataSource> dataSourceSupplier, Monitors monitors, LogProvider logProvider)
        {
            this._protocol          = protocol;
            this._storeIdSupplier   = storeIdSupplier;
            this._databaseAvailable = databaseAvailable;
            DependencyResolver dependencies = dataSourceSupplier().DependencyResolver;

            this._transactionIdStore      = dependencies.ResolveDependency(typeof(TransactionIdStore));
            this._logicalTransactionStore = dependencies.ResolveDependency(typeof(LogicalTransactionStore));
            this._monitor = monitors.NewMonitor(typeof(TxPullRequestsMonitor));
            this._log     = logProvider.getLog(this.GetType());
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreateBufferedIdComponentsByDefault()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.startCluster();
            Cluster <object>   cluster            = ClusterRule.startCluster();
            CoreClusterMember  leader             = cluster.AwaitLeader();
            DependencyResolver dependencyResolver = leader.Database().DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(FreeIdFilteredIdGeneratorFactory)));
        }
Пример #10
0
        private HostnamePort AddressForConnector(string name)
        {
            DependencyResolver    resolver     = _server.database.Graph.DependencyResolver;
            ConnectorPortRegister portRegister = resolver.ResolveDependency(typeof(ConnectorPortRegister));

            return(portRegister.GetLocalAddress(name));
        }
Пример #11
0
            public override TransactionCommitProcess CommitProcess()
            {
                // We simply can't resolve the commit process here, since the commit process of a slave
                // is one that sends transactions to the master. We here, however would like to actually
                // commit transactions in this db.
                DependencyResolver databaseResolver = DatabaseResolver;

                return(new TransactionRepresentationCommitProcess(databaseResolver.ResolveDependency(typeof(TransactionAppender)), databaseResolver.ResolveDependency(typeof(StorageEngine))));
            }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            GraphDatabaseAPI api = DbRule.GraphDatabaseAPI;

            _graph = api;
            DependencyResolver dependencyResolver = api.DependencyResolver;

            this._bridge = dependencyResolver.ResolveDependency(typeof(ThreadToStatementContextBridge));
            this._tx     = _graph.beginTx();
        }
Пример #13
0
        private static BasicContext CreateContext(SecurityContext securityContext, DependencyResolver dependencyResolver, ProcedureCallContext procedureCallContext)
        {
            BasicContext ctx = new BasicContext();

            ctx.Put(SECURITY_CONTEXT, securityContext);
            ctx.Put(PROCEDURE_CALL_CONTEXT, procedureCallContext);
            ctx.Put(DEPENDENCY_RESOLVER, dependencyResolver);
            ctx.Put(DATABASE_API, dependencyResolver.ResolveDependency(typeof(GraphDatabaseAPI)));
            return(ctx);
        }
Пример #14
0
        protected internal override QueryExecutionEngine CreateEngine(Dependencies deps, GraphDatabaseAPI graphAPI)
        {
            GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graphAPI);

            deps.SatisfyDependency(queryService);

            DependencyResolver         resolver        = graphAPI.DependencyResolver;
            LogService                 logService      = resolver.ResolveDependency(typeof(LogService));
            Monitors                   monitors        = resolver.ResolveDependency(typeof(Monitors));
            Config                     config          = resolver.ResolveDependency(typeof(Config));
            CypherConfiguration        cypherConfig    = CypherConfiguration.fromConfig(config);
            CypherPlannerConfiguration plannerConfig   = cypherConfig.toCypherPlannerConfiguration(config);
            CypherRuntimeConfiguration runtimeConfig   = cypherConfig.toCypherRuntimeConfiguration();
            LogProvider                logProvider     = logService.InternalLogProvider;
            CommunityCompilerFactory   compilerFactory = new CommunityCompilerFactory(queryService, monitors, logProvider, plannerConfig, runtimeConfig);

            deps.SatisfyDependencies(compilerFactory);
            return(CreateEngine(queryService, config, logProvider, compilerFactory));
        }
Пример #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _dataSource = mock(typeof(NeoStoreDataSource));
            StorageEngine storageEngine = mock(typeof(StorageEngine));
            StorageReader storageReader = mock(typeof(StorageReader));

            when(storageEngine.NewReader()).thenReturn(storageReader);
            _indexingService = mock(typeof(IndexingService));
            TokenHolders tokenHolders = MockedTokenHolders();

            when(tokenHolders.LabelTokens().getIdByName(EXISTING_LABEL)).thenReturn(LABEL_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(EXISTING_PROPERTY)).thenReturn(PROPERTY_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(NON_EXISTING_PROPERTY)).thenReturn(-1);
            when(tokenHolders.LabelTokens().getIdByName(NON_EXISTING_LABEL)).thenReturn(NO_TOKEN);
            DependencyResolver resolver = mock(typeof(DependencyResolver));

            when(resolver.ResolveDependency(typeof(IndexingService))).thenReturn(_indexingService);
            when(resolver.ResolveDependency(typeof(StorageEngine))).thenReturn(storageEngine);
            when(resolver.ResolveDependency(typeof(TokenHolders))).thenReturn(tokenHolders);
            when(_dataSource.DependencyResolver).thenReturn(resolver);
        }
        private static DatabaseManager NewDbMock()
        {
            GraphDatabaseFacade db = mock(typeof(GraphDatabaseFacade));
            DependencyResolver  dependencyResolver = mock(typeof(DependencyResolver));

            when(Db.DependencyResolver).thenReturn(dependencyResolver);
            GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService));

            when(queryService.DependencyResolver).thenReturn(dependencyResolver);
            when(dependencyResolver.ResolveDependency(typeof(GraphDatabaseQueryService))).thenReturn(queryService);
            DatabaseManager databaseManager = mock(typeof(DatabaseManager));

            when(databaseManager.GetDatabaseFacade(CUSTOM_DB_NAME)).thenReturn(db);
            return(databaseManager);
        }
Пример #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shutdownWhileFinishingTransactionWithIndexUpdates()
        public virtual void ShutdownWhileFinishingTransactionWithIndexUpdates()
        {
            CreateConstraint(Database);
            WaitIndexesOnline(Database);

            using (Transaction transaction = Database.beginTx())
            {
                Node node = Database.createNode(_constraintIndexLabel);
                node.SetProperty(UNIQUE_PROPERTY_NAME, _indexProvider.AndIncrement);

                DependencyResolver       dependencyResolver = Database.DependencyResolver;
                NeoStoreDataSource       dataSource         = dependencyResolver.ResolveDependency(typeof(NeoStoreDataSource));
                LifeSupport              dataSourceLife     = dataSource.Life;
                TransactionCloseListener closeListener      = new TransactionCloseListener(transaction);
                dataSourceLife.AddLifecycleListener(closeListener);
                dataSource.Stop();

                assertTrue("Transaction should be closed and no exception should be thrown.", closeListener.TransactionClosed);
            }
        }
Пример #18
0
 public TransactionApplier(DependencyResolver resolver)
 {
     _commitProcess          = new TransactionRepresentationCommitProcess(resolver.ResolveDependency(typeof(TransactionAppender)), resolver.ResolveDependency(typeof(StorageEngine)));
     _versionContextSupplier = resolver.ResolveDependency(typeof(VersionContextSupplier));
 }
Пример #19
0
            public override void Registered(NeoStoreDataSource dataSource)
            {
                DependencyResolver dependencyResolver = dataSource.DependencyResolver;

                State = new State(dependencyResolver.ResolveDependency(typeof(StorageEngine)), dependencyResolver.ResolveDependency(typeof(IndexingService)), dependencyResolver.ResolveDependency(typeof(TokenHolders)));
            }
Пример #20
0
        public override Kernel KernelToTest()
        {
            DependencyResolver resolver = (( GraphDatabaseAPI )this._db).DependencyResolver;

            return(resolver.ResolveDependency(typeof(Kernel)));
        }
Пример #21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.Transaction transaction() throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        private Transaction Transaction()
        {
            DependencyResolver resolver = this.Db.DependencyResolver;

            return(resolver.ResolveDependency(typeof(Kernel)).beginTransaction(@implicit, LoginContext.AUTH_DISABLED));
        }