예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void relationshipIdReusableOnlyAfterTransactionFinish()
        public virtual void RelationshipIdReusableOnlyAfterTransactionFinish()
        {
            Label testLabel      = Label.label("testLabel");
            long  relationshipId = CreateRelationship(testLabel);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController idMaintenanceController = getIdMaintenanceController();
            IdController idMaintenanceController = IdMaintenanceController;

            using (Transaction transaction = DbRule.beginTx(), ResourceIterator <Node> nodes = DbRule.findNodes(testLabel))
            {
                IList <Node> nodeList = Iterators.asList(nodes);
                foreach (Node node in nodeList)
                {
                    IEnumerable <Relationship> relationships = node.GetRelationships(TestRelationshipType.Marker);
                    foreach (Relationship relationship in relationships)
                    {
                        relationship.Delete();
                    }
                }

                idMaintenanceController.Maintenance();

                Node node1 = DbRule.createNode(testLabel);
                Node node2 = DbRule.createNode(testLabel);

                Relationship relationshipTo = node1.CreateRelationshipTo(node2, TestRelationshipType.Marker);

                assertNotEquals("Relationships should have different ids.", relationshipId, relationshipTo.Id);
                transaction.Success();
            }
        }
예제 #2
0
 private void ViewIncrementIdentifier(object sender, EventArgs e)
 {
     try
     {
         IdController.Increment(_view.IncrementValue);
         ShowMessage($"ID инкрементирован на {_view.IncrementValue} и ID = {IdController.Identifier}");
     }
     catch (Exception exception)
     {
         ShowError($"ќшибка: {exception.Message}");
     }
 }
예제 #3
0
 private void ViewInitAlphaNumericIdentifier(object sender, EventArgs e)
 {
     try
     {
         IdController.InitAlphaNumericIdentifier(_view.AlphaNumericIdentifier);
         ShowMessage($"ID изменен на {IdController.Identifier}");
     }
     catch (Exception exception)
     {
         ShowError($"ќшибка: {exception.Message}");
     }
 }
예제 #4
0
        public void Get()
        {
            // inicializa o controlador
            AmigosController controller = new AmigosController();

            //retorna o id do amigo
            int id = new IdController().Post(token, -23.9916395m, -46.2615829m);

            // retorna o amigo
            AmigoData amigo = controller.Post(token, id);

            Assert.IsTrue((amigo != null));
        }
예제 #5
0
        private void Increment(CancellationToken token)
        {
            //var stringA = TestHelper.LoadStringNumber("stringA.txt");
            //var stringB = TestHelper.LoadStringNumber("stringB.txt");

            string stringA;
            string stringB;

            TestHelper.GetRandomStringNumber((long)(1024 * 1024 * 1024 / 2), out stringA, out stringB);

            IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier);
            IdController.Increment(stringA, () => token.IsCancellationRequested);
            IdController.Increment(stringB, () => token.IsCancellationRequested);
        }
예제 #6
0
        internal ModularDatabaseCreationContext(string databaseName, PlatformModule platformModule, DatabaseEditionContext editionContext, Procedures procedures, GraphDatabaseFacade facade)
        {
            this._databaseName = databaseName;
            this._config       = platformModule.Config;
            DatabaseIdContext idContext = editionContext.IdContext;

            this._idGeneratorFactory = idContext.IdGeneratorFactory;
            this._idController       = idContext.IdController;
            this._databaseLayout     = platformModule.StoreLayout.databaseLayout(databaseName);
            this._logService         = platformModule.Logging;
            this._scheduler          = platformModule.JobScheduler;
            this._globalDependencies = platformModule.Dependencies;
            this._tokenHolders       = editionContext.CreateTokenHolders();
            this._tokenNameLookup    = new NonTransactionalTokenNameLookup(_tokenHolders);
            this._locks = editionContext.CreateLocks();
            this._statementLocksFactory    = editionContext.CreateStatementLocksFactory();
            this._schemaWriteGuard         = editionContext.SchemaWriteGuard;
            this._transactionEventHandlers = new TransactionEventHandlers(facade);
            this._monitors = new Monitors(platformModule.Monitors);
            this._indexingServiceMonitor = _monitors.newMonitor(typeof(IndexingService.Monitor));
            this._physicalLogMonitor     = _monitors.newMonitor(typeof(LogFileCreationMonitor));
            this._fs = platformModule.FileSystem;
            this._transactionStats = editionContext.CreateTransactionMonitor();
            this._databaseHealth   = new DatabaseHealth(platformModule.PanicEventGenerator, _logService.getInternalLog(typeof(DatabaseHealth)));
            this._transactionHeaderInformationFactory = editionContext.HeaderInformationFactory;
            this._commitProcessFactory  = editionContext.CommitProcessFactory;
            this._autoIndexing          = new InternalAutoIndexing(platformModule.Config, _tokenHolders.propertyKeyTokens());
            this._indexConfigStore      = new IndexConfigStore(_databaseLayout, _fs);
            this._explicitIndexProvider = new DefaultExplicitIndexProvider();
            this._pageCache             = platformModule.PageCache;
            this._constraintSemantics   = editionContext.ConstraintSemantics;
            this._tracers    = platformModule.Tracers;
            this._procedures = procedures;
            this._ioLimiter  = editionContext.IoLimiter;
            this._clock      = platformModule.Clock;
            this._databaseAvailabilityGuard    = editionContext.CreateDatabaseAvailabilityGuard(_clock, _logService, _config);
            this._databaseAvailability         = new DatabaseAvailability(_databaseAvailabilityGuard, _transactionStats, platformModule.Clock, AwaitActiveTransactionDeadlineMillis);
            this._coreAPIAvailabilityGuard     = new CoreAPIAvailabilityGuard(_databaseAvailabilityGuard, editionContext.TransactionStartTimeout);
            this._accessCapability             = editionContext.AccessCapability;
            this._storeCopyCheckPointMutex     = new StoreCopyCheckPointMutex();
            this._recoveryCleanupWorkCollector = platformModule.RecoveryCleanupWorkCollector;
            this._databaseInfo               = platformModule.DatabaseInfo;
            this._versionContextSupplier     = platformModule.VersionContextSupplier;
            this._collectionsFactorySupplier = platformModule.CollectionsFactorySupplier;
            this._kernelExtensionFactories   = platformModule.KernelExtensionFactories;
            this._watcherServiceFactory      = editionContext.WatcherServiceFactory;
            this._facade          = facade;
            this._engineProviders = platformModule.EngineProviders;
        }
예제 #7
0
        public RecordStorageEngine(DatabaseLayout databaseLayout, Config config, PageCache pageCache, FileSystemAbstraction fs, LogProvider logProvider, LogProvider userLogProvider, TokenHolders tokenHolders, SchemaState schemaState, ConstraintSemantics constraintSemantics, JobScheduler scheduler, TokenNameLookup tokenNameLookup, LockService lockService, IndexProviderMap indexProviderMap, IndexingService.Monitor indexingServiceMonitor, DatabaseHealth databaseHealth, ExplicitIndexProvider explicitIndexProvider, IndexConfigStore indexConfigStore, IdOrderingQueue explicitIndexTransactionOrdering, IdGeneratorFactory idGeneratorFactory, IdController idController, Monitors monitors, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, OperationalMode operationalMode, VersionContextSupplier versionContextSupplier)
        {
            this._tokenHolders   = tokenHolders;
            this._schemaState    = schemaState;
            this._lockService    = lockService;
            this._databaseHealth = databaseHealth;
            this._explicitIndexProviderLookup      = explicitIndexProvider;
            this._indexConfigStore                 = indexConfigStore;
            this._constraintSemantics              = constraintSemantics;
            this._explicitIndexTransactionOrdering = explicitIndexTransactionOrdering;

            this._idController = idController;
            StoreFactory factory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, logProvider, versionContextSupplier);

            _neoStores = factory.OpenAllNeoStores(true);

            try
            {
                _schemaCache   = new SchemaCache(constraintSemantics, Collections.emptyList(), indexProviderMap);
                _schemaStorage = new SchemaStorage(_neoStores.SchemaStore);

                NeoStoreIndexStoreView neoStoreIndexStoreView = new NeoStoreIndexStoreView(lockService, _neoStores);
                bool readOnly = config.Get(GraphDatabaseSettings.read_only) && operationalMode == OperationalMode.single;
                monitors.AddMonitorListener(new LoggingMonitor(logProvider.GetLog(typeof(NativeLabelScanStore))));
                _labelScanStore = new NativeLabelScanStore(pageCache, databaseLayout, fs, new FullLabelStream(neoStoreIndexStoreView), readOnly, monitors, recoveryCleanupWorkCollector);

                _indexStoreView        = new DynamicIndexStoreView(neoStoreIndexStoreView, _labelScanStore, lockService, _neoStores, logProvider);
                this._indexProviderMap = indexProviderMap;
                _indexingService       = IndexingServiceFactory.createIndexingService(config, scheduler, indexProviderMap, _indexStoreView, tokenNameLookup, Iterators.asList(_schemaStorage.loadAllSchemaRules()), logProvider, userLogProvider, indexingServiceMonitor, schemaState, readOnly);

                _integrityValidator = new IntegrityValidator(_neoStores, _indexingService);
                _cacheAccess        = new BridgingCacheAccess(_schemaCache, schemaState, tokenHolders);

                _explicitIndexApplierLookup = new Org.Neo4j.Kernel.Impl.Api.ExplicitIndexApplierLookup_Direct(explicitIndexProvider);

                _labelScanStoreSync = new WorkSync <Supplier <LabelScanWriter>, LabelUpdateWork>(_labelScanStore.newWriter);

                _commandReaderFactory = new RecordStorageCommandReaderFactory();
                _indexUpdatesSync     = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexingService);

                _denseNodeThreshold = config.Get(GraphDatabaseSettings.dense_node_threshold);
                _recordIdBatchSize  = config.Get(GraphDatabaseSettings.record_id_batch_size);
            }
            catch (Exception failure)
            {
                _neoStores.close();
                throw failure;
            }
        }
예제 #8
0
        public void Test_Inrement(string id, string baseValue, string incrementValue, string resultId)
        {
            var sw = new Stopwatch();

            sw.Start();

            IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier);
            IdController.Increment(baseValue);
            IdController.Increment(incrementValue);

            sw.Stop();

            Assert.AreEqual(resultId, IdController.Identifier);

            Console.WriteLine($"Numbers sum was done, Time: {sw.Elapsed}");
        }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void relationshipIdReused() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RelationshipIdReused()
        {
            Label cityLabel = Label.label("city");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Label bandLabel = org.neo4j.graphdb.Label.label("band");
            Label bandLabel = Label.label("band");

            CreateBands(bandLabel);
            CreateCities(cityLabel);

            AtomicBoolean        stopFlag             = new AtomicBoolean(false);
            RelationshipsCreator relationshipsCreator = new RelationshipsCreator(this, stopFlag, bandLabel, cityLabel);
            RelationshipRemover  relationshipRemover  = new RelationshipRemover(this, bandLabel, cityLabel, stopFlag);
            IdController         idController         = EmbeddedDatabase.DependencyResolver.resolveDependency(typeof(IdController));

            assertNotNull("idController was null for some reason", idController);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<java.util.concurrent.Future<?>> futures = new java.util.ArrayList<>();
            IList <Future <object> > futures = new List <Future <object> >();

            futures.Add(_executorService.submit(relationshipRemover));
            futures.Add(_executorService.submit(relationshipsCreator));
            futures.Add(StartRelationshipTypesCalculator(bandLabel, stopFlag));
            futures.Add(StartRelationshipCalculator(bandLabel, stopFlag));

            long startTime = currentTimeMillis();
            long currentTime;
            long createdRelationships;
            long removedRelationships;

            do
            {
                TimeUnit.MILLISECONDS.sleep(500);
                idController.Maintenance();                         // just to make sure maintenance happens
                currentTime          = currentTimeMillis();
                createdRelationships = relationshipsCreator.CreatedRelationships;
                removedRelationships = relationshipRemover.RemovedRelationships;
            } while ((currentTime - startTime) < 5_000 || createdRelationships < 1_000 || removedRelationships < 100);
            stopFlag.set(true);
            _executorService.shutdown();
            CompleteFutures(futures);

            long highestPossibleIdInUse = HighestUsedIdForRelationships;

            assertThat("Number of created relationships should be higher then highest possible id, since those are " + "reused.", relationshipsCreator.CreatedRelationships, Matchers.greaterThan(highestPossibleIdInUse));
        }
예제 #10
0
 private static void MaybeRunIdMaintenance(GraphDatabaseService db, int iteration)
 {
     if (iteration % 100 == 0 && ThreadLocalRandom.current().nextBoolean())
     {
         DependencyResolver resolver     = DependencyResolver(db);
         IdController       idController = resolver.ResolveDependency(typeof(IdController));
         if (idController != null)
         {
             idController.Maintenance();
         }
         else
         {
             Console.WriteLine("Id controller is null. Dumping resolver content.");
             Console.WriteLine("Resolver: " + ReflectionToStringBuilder.ToString(resolver));
             throw new System.InvalidOperationException("Id controller not found");
         }
     }
 }
예제 #11
0
        public void Alter()
        {
            // inicializa o controlador
            AmigosController controller = new AmigosController();

            //retorna o id do amigo
            int id = new IdController().Post(token, -23.9862526m, -46.308403m);

            // altera o amigo
            controller.Put(token, new AmigoData()
            {
                IdAmigo   = id,
                Nome      = "Cláudio",
                Local     = "Guarujá",
                Latitude  = -23.9916395m,
                Longitude = -46.2615829m
            });

            Assert.IsTrue(this.ExisteAmigo(-23.9916395m, -46.2615829m));
        }
예제 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sequentialOperationRelationshipIdReuse()
        public virtual void SequentialOperationRelationshipIdReuse()
        {
            Label marker = Label.label("marker");

            long relationship1 = CreateRelationship(marker);
            long relationship2 = CreateRelationship(marker);
            long relationship3 = CreateRelationship(marker);

            assertEquals("Ids should be sequential", relationship1 + 1, relationship2);
            assertEquals("Ids should be sequential", relationship2 + 1, relationship3);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController idMaintenanceController = getIdMaintenanceController();
            IdController idMaintenanceController = IdMaintenanceController;

            DeleteRelationshipByLabelAndRelationshipType(marker);

            idMaintenanceController.Maintenance();

            assertEquals("Relationships have reused id", relationship1, CreateRelationship(marker));
            assertEquals("Relationships have reused id", relationship2, CreateRelationship(marker));
            assertEquals("Relationships have reused id", relationship3, CreateRelationship(marker));
        }
예제 #13
0
        private void IncrementAction(string name, string incrementValue, CancellationToken token)
        {
            for (int i = 0; i < 1000; i++)
            {
                try
                {
                    var sw = new Stopwatch();
                    sw.Start();
                    IdController.Increment(incrementValue, () => token.IsCancellationRequested);

                    token.ThrowIfCancellationRequested();

                    Console.WriteLine($"{name} #{i} was done, Time: {sw.Elapsed}");
                    sw.Stop();
                    Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Ошибка выполнения {name}");
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
예제 #14
0
        private void IdMaintenanceOnLeader(CoreClusterMember leader)
        {
            IdController idController = ResolveDependency(leader, typeof(IdController));

            idController.Maintenance();
        }
예제 #15
0
        public void Test_LoadAsyncTest()
        {
            var mre = new ManualResetEvent(false);

            Console.WriteLine("Test_LoadTest BEGIN");
            var sw = new Stopwatch();

            sw.Start();

            var incrementValue = "922337203685477";

            IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier);

            CancellationTokenSource cancelTokenSource = new CancellationTokenSource();

            var tf = new TaskFactory(cancelTokenSource.Token);

            tf.StartNew(() =>
            {
                try
                {
                    Console.WriteLine($"Begin load stringNumber, Time: {sw.Elapsed}");
                    sw.Restart();
                    //string stringA = TestHelper.LoadStringNumber("stringA.txt");
                    //string stringB = TestHelper.LoadStringNumber("stringB.txt");

                    string stringA;
                    string stringB;
                    TestHelper.GetRandomStringNumber((long)(1024 * 1024 * 100), out stringA, out stringB);

                    Console.WriteLine($"StringNumber loaded, Time: {sw.Elapsed}");
                    sw.Restart();
                    IdController.Increment(stringA);
                    Console.WriteLine($"Increment valueA was done, Time: {sw.Elapsed}");
                    sw.Restart();
                    IdController.Increment(stringB);
                    Console.WriteLine($"Increment valueB was done, Time: {sw.Elapsed}");
                    sw.Restart();
                    mre.Set();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    mre.Set();
                }
            }, cancelTokenSource.Token);

            tf.StartNew(() =>
            {
                IncrementAction("Increment1", incrementValue, cancelTokenSource.Token);
            }, cancelTokenSource.Token);

            tf.StartNew(() =>
            {
                IncrementAction("Increment2", incrementValue, cancelTokenSource.Token);
            }, cancelTokenSource.Token);

            mre.WaitOne();
            cancelTokenSource.Cancel();

            sw.Stop();
            Console.WriteLine($"Numbers sum was done, Time: {sw.Elapsed}");

            Console.WriteLine("Test_LoadTest END");
        }
예제 #16
0
 public Dictionary <int, SerializeableData> GetAll()
 {
     IdController.SetIdsTo(controller);
     return(IdController.GetAll().GetSerializeable().ToDictionary(k => k.Id, v => v));
 }