private string SyncDoWork()
        {
            if (Session["work"] == null)
            {
                w = new WorkSync();
                Session["work"] = w;
            }
            else
            {
                w = (WorkSync)Session["work"];
            }
            try
            {
                switch (w.State)
                {
                case SeatManage.ISystemTerminal.IStuLibSync.SyncState.None:
                    w.runwork();
                    return("1:开始同步");

                case SeatManage.ISystemTerminal.IStuLibSync.SyncState.Syncing:
                    return("1:已完成:" + w.Percent + " %,已耗时:" + ((TimeSpan)(DateTime.Now - w.StartTime)).TotalSeconds.ToString("0") + "秒");

                case SeatManage.ISystemTerminal.IStuLibSync.SyncState.Success:
                    string r = string.Format("2:任务结束,新增{0}条,更新{1}条,错误{2}条,用时{3}秒", w.AddAmount, w.UpdateAmount, w.ErrorAmount, (int)(((TimeSpan)(w.FinishTime - w.StartTime)).TotalSeconds));
                    //  Abort();
                    return(r);
                }
                return("3:执行错误");
            }
            catch (Exception ex)
            {
                return(string.Format("3:执行出错:{0}", ex.Message));
            }
        }
Example #2
0
 public AsyncApplyAnonymousInnerClass(WorkSync <Material, W> outerInstance, Org.Neo4j.Util.concurrent.WorkSync.WorkUnit <Material, W> unit, Exception initialThrowable)
 {
     this.outerInstance     = outerInstance;
     this._unit             = unit;
     this._initialThrowable = initialThrowable;
     throwable = initialThrowable;
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideLabelScanStoreUpdatesSortedByNodeId()
        {
            // GIVEN
            IndexingService indexing = mock(typeof(IndexingService));

            when(indexing.ConvertToIndexUpdates(any(), eq(EntityType.NODE))).thenAnswer(o => Iterables.empty());
            LabelScanWriter writer = new OrderVerifyingLabelScanWriter(10, 15, 20);
            WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork> labelScanSync    = spy(new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(SingletonProvider(writer)));
            WorkSync <IndexingUpdateService, IndexUpdatesWork>        indexUpdatesSync = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(indexing);
            TransactionToApply tx            = mock(typeof(TransactionToApply));
            PropertyStore      propertyStore = mock(typeof(PropertyStore));

            using (IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier(indexing, labelScanSync, indexUpdatesSync, mock(typeof(NodeStore)), mock(typeof(RelationshipStore)), propertyStore, new IndexActivator(indexing)))
            {
                using (TransactionApplier txApplier = applier.StartTx(tx))
                {
                    // WHEN
                    txApplier.VisitNodeCommand(Node(15));
                    txApplier.VisitNodeCommand(Node(20));
                    txApplier.VisitNodeCommand(Node(10));
                }
            }
            // THEN all assertions happen inside the LabelScanWriter#write and #close
            verify(labelScanSync).applyAsync(any());
        }
Example #4
0
 private void InitializeInstanceFields()
 {
     _storeApplier = new NeoStoreBatchTransactionApplier(_neoStores, mock(typeof(CacheAccessBackDoor)), LockService.NO_LOCK_SERVICE);
     _labelScanStoreSynchronizer = new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(_labelScanStore);
     _indexUpdatesSync           = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexes);
     _indexApplier = new IndexBatchTransactionApplier(_indexes, _labelScanStoreSynchronizer, _indexUpdatesSync, mock(typeof(NodeStore)), _neoStores.RelationshipStore, _propertyStore, new IndexActivator(_indexes));
     _rule         = TestIndexDescriptorFactory.forLabel(_labelId, _propertyKey).withId(_id);
 }
Example #5
0
 public IndexBatchTransactionApplier(IndexingService indexingService, WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork> labelScanStoreSync, WorkSync <IndexingUpdateService, IndexUpdatesWork> indexUpdatesSync, NodeStore nodeStore, RelationshipStore relationshipStore, PropertyStore propertyStore, IndexActivator indexActivator)
 {
     this._indexingService    = indexingService;
     this._labelScanStoreSync = labelScanStoreSync;
     this._indexUpdatesSync   = indexUpdatesSync;
     this._propertyStore      = propertyStore;
     this._transactionApplier = new SingleTransactionApplier(this, nodeStore, relationshipStore);
     this._indexActivator     = indexActivator;
 }
Example #6
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;
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRegisterIndexesToActivateIntoTheActivator() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRegisterIndexesToActivateIntoTheActivator()
        {
            // given
            IndexingService indexing = mock(typeof(IndexingService));
            LabelScanWriter writer   = new OrderVerifyingLabelScanWriter(10, 15, 20);
            WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork> labelScanSync    = spy(new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(SingletonProvider(writer)));
            WorkSync <IndexingUpdateService, IndexUpdatesWork>        indexUpdatesSync = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(indexing);
            PropertyStore      propertyStore  = mock(typeof(PropertyStore));
            TransactionToApply tx             = mock(typeof(TransactionToApply));
            IndexActivator     indexActivator = new IndexActivator(indexing);
            long indexId1      = 1;
            long indexId2      = 2;
            long indexId3      = 3;
            long constraintId1 = 10;
            long constraintId2 = 11;
            long constraintId3 = 12;
            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("index-key", "v1");
            StoreIndexDescriptor    rule1 = uniqueForSchema(forLabel(1, 1), providerDescriptor).withIds(indexId1, constraintId1);
            StoreIndexDescriptor    rule2 = uniqueForSchema(forLabel(2, 1), providerDescriptor).withIds(indexId2, constraintId2);
            StoreIndexDescriptor    rule3 = uniqueForSchema(forLabel(3, 1), providerDescriptor).withIds(indexId3, constraintId3);

            using (IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier(indexing, labelScanSync, indexUpdatesSync, mock(typeof(NodeStore)), mock(typeof(RelationshipStore)), propertyStore, indexActivator))
            {
                using (TransactionApplier txApplier = applier.StartTx(tx))
                {
                    // WHEN
                    // activate index 1
                    txApplier.VisitSchemaRuleCommand(new Command.SchemaRuleCommand(Collections.emptyList(), AsRecords(rule1, true), rule1));

                    // activate index 2
                    txApplier.VisitSchemaRuleCommand(new Command.SchemaRuleCommand(Collections.emptyList(), AsRecords(rule2, true), rule2));

                    // activate index 3
                    txApplier.VisitSchemaRuleCommand(new Command.SchemaRuleCommand(Collections.emptyList(), AsRecords(rule3, true), rule3));

                    // drop index 2
                    txApplier.VisitSchemaRuleCommand(new Command.SchemaRuleCommand(AsRecords(rule2, true), AsRecords(rule2, false), rule2));
                }
            }

            verify(indexing).dropIndex(rule2);
            indexActivator.Close();
            verify(indexing).activateIndex(indexId1);
            verify(indexing).activateIndex(indexId3);
            verifyNoMoreInteractions(indexing);
        }
 public void Abort()
 {
     w = (WorkSync)Session["work"];
     w.Dispose();
     Session["work"] = null;
 }
 private void InitializeInstanceFields()
 {
     _workSync = new WorkSync <IndexUpdateApply, IndexUpdateWork>(new IndexUpdateApply(this));
 }
Example #10
0
 private void InitializeInstanceFields()
 {
     _labelScanStoreSynchronizer = new WorkSync <System.Func <LabelScanWriter>, LabelUpdateWork>(_labelScanStore);
     _indexUpdatesSync           = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexingService);
 }