コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReportPeriod()
        public virtual void MustReportPeriod()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            Log          log          = logProvider.GetLog(typeof(IndexPopulationJob));
            PhaseTracker phaseTracker = GetPhaseTracker(1, log);

            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);

            // when
            Sleep(1000);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);

            // then
            AssertableLogProvider.LogMatcher firstEntry = AssertableLogProvider.inLog(typeof(IndexPopulationJob)).debug("TIME/PHASE Total: SCAN[totalTime=1s], Last 1 sec: SCAN[totalTime=1s]");
            logProvider.AssertExactly(firstEntry);

            // when
            Sleep(1000);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);

            // then
            AssertableLogProvider.LogMatcher secondEntry = AssertableLogProvider.inLog(typeof(IndexPopulationJob)).debug("TIME/PHASE Total: SCAN[totalTime=1s], WRITE[totalTime=1s], Last 1 sec: WRITE[totalTime=1s]");
            logProvider.AssertExactly(firstEntry, secondEntry);

            // when
            Sleep(1000);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);

            // then
            AssertableLogProvider.LogMatcher thirdEntry = AssertableLogProvider.inLog(typeof(IndexPopulationJob)).debug("TIME/PHASE Total: " + "SCAN[totalTime=2s, avgTime=1s, minTime=0ns, maxTime=1s, nbrOfReports=2], " + "WRITE[totalTime=1s], " + "Last 1 sec: SCAN[totalTime=1s]");
            logProvider.AssertExactly(firstEntry, secondEntry, thirdEntry);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReportMain()
        public virtual void MustReportMain()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            Log          log          = logProvider.GetLog(typeof(IndexPopulationJob));
            PhaseTracker phaseTracker = GetPhaseTracker(log);

            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Merge);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Build);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.ApplyExternal);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Flip);
            Sleep(100);

            // when
            phaseTracker.Stop();

            // then
            AssertableLogProvider.LogMatcher logMatcher = AssertableLogProvider.inLog(typeof(IndexPopulationJob)).info("TIME/PHASE Final: " + "SCAN[totalTime=200ms, avgTime=100ms, minTime=0ns, maxTime=100ms, nbrOfReports=2], " + "WRITE[totalTime=200ms, avgTime=100ms, minTime=0ns, maxTime=100ms, nbrOfReports=2], " + "MERGE[totalTime=100ms], BUILD[totalTime=100ms], APPLY_EXTERNAL[totalTime=100ms], FLIP[totalTime=100ms]");
            logProvider.AssertAtLeastOnce(logMatcher);
        }
コード例 #3
0
 public MultipleIndexPopulator(IndexStoreView storeView, LogProvider logProvider, EntityType type, SchemaState schemaState)
 {
     this._storeView    = storeView;
     this._logProvider  = logProvider;
     this.Log           = logProvider.GetLog(typeof(IndexPopulationJob));
     this._type         = type;
     this._schemaState  = schemaState;
     this._phaseTracker = new LoggingPhaseTracker(logProvider.GetLog(typeof(IndexPopulationJob)));
 }
コード例 #4
0
 protected internal PropertyAwareEntityStoreScan(StorageReader storageReader, long totalEntityCount, System.Func <int, bool> propertyKeyIdFilter, System.Func <long, Lock> lockFunction)
 {
     this._storageReader       = storageReader;
     this.EntityCursor         = AllocateCursor(storageReader);
     this._propertyCursor      = storageReader.AllocatePropertyCursor();
     this._propertyKeyIdFilter = propertyKeyIdFilter;
     this._lockFunction        = lockFunction;
     this._totalCount          = totalEntityCount;
     this._phaseTracker        = Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Fields.NullInstance;
 }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwIfEnterAfterStop()
        public virtual void ThrowIfEnterAfterStop()
        {
            PhaseTracker phaseTracker = PhaseTracker;

            phaseTracker.Stop();
            try
            {
                phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException e)
            {
                assertThat(e.Message, containsString("Trying to report a new phase after phase tracker has been stopped."));
            }
        }
コード例 #6
0
 public override void ScanCompleted(PhaseTracker phaseTracker)
 {
 }
コード例 #7
0
        public Duel(Game game, GameState gameState) : base(game)
        {
            this.gameState = gameState;
            this.gameState.ActionResolved += GameState_ActionResolved;
            Vector2 cardSize = new Vector2(100, 126);
            Vector2 zoneSize = new Vector2(854, 126);

            /* PLAYER ONE */
            playerOneHero          = new Single(this, gameState.PlayerOne.PlayerCard);
            playerOneHero.Position = new Vector2(196, 584);
            playerOneHero.Size     = cardSize;

            playerOneHealthDisplay             = new Display(playerOneHero);
            playerOneHealthDisplay.Text        = "HP: 20";
            playerOneHealthDisplay.Alignment   = System.Drawing.ContentAlignment.BottomRight;
            gameState.PlayerOne.HealthChanged += (e) => playerOneHealthDisplay.SetText(string.Format("HP: {0}", e));

            playerOneDeck               = new CardStack(this, gameState.PlayerOne.Deck, new Vector2(1170, 584), cardSize);
            playerOneGraveyard          = new CardStack(this, gameState.PlayerOne.Graveyard, new Vector2(1170, 448), cardSize);
            playerOneGraveyard.IsFaceUp = true;

            playerOneHand        = new CardGroup(this, new Vector2(306, 584), zoneSize, gameState.PlayerOne.Hand);
            playerOneElysium     = new CardGroup(this, new Vector2(306, 448), zoneSize, gameState.PlayerOne.Elysium);
            playerOneBattlefield = new CardGroup(this, new Vector2(306, 312), zoneSize, gameState.PlayerOne.Field);

            playerOneHero.Clicked                    += PlayerOneHero_Clicked;
            playerOneHand.CardSelected               += PlayerOneHand_CardSelected;
            playerOneHand.CardContextSelected        += PlayerOneHand_CardContextSelected;
            playerOneHand.CardHovered                += CardHovered;
            playerOneElysium.CardSelected            += PlayerOneElysium_CardSelected;
            playerOneElysium.CardContextSelected     += PlayerOneElysium_CardContextSelected;
            playerOneElysium.CardHovered             += CardHovered;
            playerOneBattlefield.CardSelected        += PlayerOneBattlefield_CardSelected;
            playerOneBattlefield.CardHovered         += CardHovered;
            playerOneBattlefield.CardContextSelected += PlayerOneBattlefield_CardContextSelected;

            /* PLAYER TWO */
            playerTwoHero          = new Single(this, gameState.PlayerTwo.PlayerCard);
            playerTwoHero.Position = new Vector2(196, 10);
            playerTwoHero.Size     = cardSize;
            playerTwoHero.Clicked += PlayerTwoHero_Clicked;

            playerTwoHealthDisplay             = new Display(playerTwoHero);
            playerTwoHealthDisplay.Text        = "HP: 20";
            playerTwoHealthDisplay.Alignment   = System.Drawing.ContentAlignment.BottomRight;
            gameState.PlayerTwo.HealthChanged += (e) => playerTwoHealthDisplay.SetText(string.Format("HP: {0}", e));

            playerTwoDeck               = new CardStack(this, gameState.PlayerTwo.Deck, new Vector2(1170, 10), cardSize);
            playerTwoGraveyard          = new CardStack(this, gameState.PlayerTwo.Graveyard, new Vector2(1170, 146), cardSize);
            playerTwoGraveyard.IsFaceUp = true;

            playerTwoElysium     = new CardGroup(this, new Vector2(306, 10), zoneSize, gameState.PlayerTwo.Elysium);
            playerTwoBattlefield = new CardGroup(this, new Vector2(306, 146), zoneSize, gameState.PlayerTwo.Field);

            playerTwoBattlefield.CardSelected += PlayerTwoBattlefield_CardSelected;

            playerTwoHandCounter = new HandCounter(this, "Content/Art/Assets/hand_count_symbol.png", new Vector2(206f, 12f));
            gameState.PlayerTwo.Hand.CollectionChanged += () =>
            {
                playerTwoHandCounter.Text = gameState.PlayerTwo.Hand.Count.ToString();
            };

            /* OTHER */
            gameStackControl          = new GameStack(this, new Vector2(10f, 10f), new Vector2(175f, 470f));
            gameState.NewStateAction += (e) => gameStackControl.AddGameStack(e);

            phaseTracker = new PhaseTracker(this, new Vector2(304f, 280f), gameState);

            previewCard                  = new Single(this, null);
            previewCard.Position         = new Vector2(10f, 490f);
            previewCard.Size             = new Vector2(175f, 220f);
            previewCard.IgnoreCardStates = true;

            promptBox                   = new TextBox(this, string.Empty, 12f);
            promptBox.Position          = new Vector2(1175f, 287f);
            gameState.PlayerOne.Prompt += (e) => promptBox.SetText(e);

            continueButton          = new Button(this, "Continue", 12f);
            continueButton.Position = new Vector2(1170, 388);
            continueButton.OnClick += ContinueButton_Click;

            endTurnButton          = new Button(this, "End Turn", 12f);
            endTurnButton.Position = new Vector2(1170, 418);
            endTurnButton.OnClick += EndTurnButton_Click;

            Menu.ItemSelected += Menu_ItemSelected;

            castingController           = new CastingController(gameState, gameState.PlayerOne);
            castingController.CostPaid += CastingController_CostPaid;
            castingController.Canceled += CastingController_Canceled;
        }
コード例 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void scanCompleted(org.neo4j.kernel.impl.api.index.PhaseTracker phaseTracker) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void ScanCompleted(PhaseTracker phaseTracker)
        {
            _actual.scanCompleted(phaseTracker);
        }
コード例 #9
0
 public override void ScanCompleted(PhaseTracker phaseTracker)
 {
     throw new System.NotSupportedException("Not supposed to be called");
 }
コード例 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void scanCompleted(org.neo4j.kernel.impl.api.index.PhaseTracker phaseTracker) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void ScanCompleted(PhaseTracker phaseTracker)
        {
            if (!MarkMergeStarted())
            {
                // This populator has already been closed, either from an external cancel or drop call.
                // Either way we're not supposed to do this merge.
                return;
            }

            try
            {
                phaseTracker.EnterPhase(Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Phase.Merge);
                if (_allScanUpdates.Count > 0)
                {
                    MergeScanUpdates();
                }

                _externalUpdates.doneAdding();
                // don't merge and sort the external updates

                // Build the tree from the scan updates
                if (_cancellation.cancelled())
                {
                    // Do one additional check before starting to write to the tree
                    return;
                }
                phaseTracker.EnterPhase(Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Phase.Build);
                File duplicatesFile = new File(storeFile.ParentFile, storeFile.Name + ".dup");
                int  readBufferSize = SmallerBufferSize();
                using (Allocator allocator = _bufferFactory.newLocalAllocator(), IndexKeyStorage <KEY> indexKeyStorage = new IndexKeyStorage <KEY>(fileSystem, duplicatesFile, allocator, readBufferSize, layout))
                {
                    RecordingConflictDetector <KEY, VALUE> recordingConflictDetector = new RecordingConflictDetector <KEY, VALUE>(!descriptor.Unique, indexKeyStorage);
                    WriteScanUpdatesToTree(recordingConflictDetector, allocator, readBufferSize);

                    // Apply the external updates
                    phaseTracker.EnterPhase(Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Phase.ApplyExternal);
                    WriteExternalUpdatesToTree(recordingConflictDetector);

                    // Verify uniqueness
                    if (descriptor.Unique)
                    {
                        using (IndexKeyStorage.KeyEntryCursor <KEY> allConflictingKeys = recordingConflictDetector.AllConflicts())
                        {
                            VerifyUniqueKeys(allConflictingKeys);
                        }
                    }
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
            catch (InterruptedException e)
            {
                Thread.CurrentThread.Interrupt();
                throw new Exception("Got interrupted, so merge not completed", e);
            }
            catch (ExecutionException e)
            {
                // Propagating merge exception from other thread
                Exception executionException = e.InnerException;
                if (executionException is Exception)
                {
                    throw ( Exception )executionException;
                }
                throw new Exception(executionException);
            }
            finally
            {
                _mergeOngoingLatch.Signal();
            }
        }