예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void applyUpTo(long applyUpToIndex) throws Exception
        private void ApplyUpTo(long applyUpToIndex)
        {
            using (InFlightLogEntryReader logEntrySupplier = new InFlightLogEntryReader(_raftLog, _inFlightCache, true))
            {
                for (long logIndex = _applierState.lastApplied + 1; _applierState.keepRunning && logIndex <= applyUpToIndex; logIndex++)
                {
                    RaftLogEntry entry = logEntrySupplier.Get(logIndex);
                    if (entry == null)
                    {
                        throw new System.InvalidOperationException(format("Committed log entry at index %d must exist.", logIndex));
                    }

                    if (entry.Content() is DistributedOperation)
                    {
                        DistributedOperation distributedOperation = ( DistributedOperation )entry.Content();
                        _progressTracker.trackReplication(distributedOperation);
                        _batcher.add(logIndex, distributedOperation);
                    }
                    else
                    {
                        _batcher.flush();
                        // since this last entry didn't get in the batcher we need to update the lastApplied:
                        _applierState.lastApplied = logIndex;
                    }
                }
                _batcher.flush();
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private ContentBuilder<org.neo4j.causalclustering.core.replication.ReplicatedContent> unmarshal(byte contentType, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException, org.neo4j.causalclustering.messaging.EndOfStreamException
        private ContentBuilder <ReplicatedContent> Unmarshal(sbyte contentType, ReadableChannel channel)
        {
            switch (contentType)
            {
            case TX_CONTENT_TYPE:
                return(ContentBuilder.Finished(ReplicatedTransactionSerializer.unmarshal(channel)));

            case RAFT_MEMBER_SET_TYPE:
                return(ContentBuilder.Finished(MemberIdSetSerializer.unmarshal(channel)));

            case ID_RANGE_REQUEST_TYPE:
                return(ContentBuilder.Finished(ReplicatedIdAllocationRequestSerializer.unmarshal(channel)));

            case TOKEN_REQUEST_TYPE:
                return(ContentBuilder.Finished(ReplicatedTokenRequestSerializer.unmarshal(channel)));

            case NEW_LEADER_BARRIER_TYPE:
                return(ContentBuilder.Finished(new NewLeaderBarrier()));

            case LOCK_TOKEN_REQUEST:
                return(ContentBuilder.Finished(ReplicatedLockTokenSerializer.unmarshal(channel)));

            case DISTRIBUTED_OPERATION:
            {
                return(DistributedOperation.deserialize(channel));
            }

            case DUMMY_REQUEST:
                return(ContentBuilder.Finished(DummyRequest.Marshal.INSTANCE.unmarshal(channel)));

            default:
                throw new System.InvalidOperationException("Not a recognized content type: " + contentType);
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void add(long index, org.neo4j.causalclustering.core.replication.DistributedOperation operation) throws Exception
        internal virtual void Add(long index, DistributedOperation operation)
        {
            Debug.Assert(_batch.Count <= 0 || index == (_lastIndex + 1));

            _batch.Add(operation);
            _lastIndex = index;

            if (_batch.Count == _maxBatchSize)
            {
                Flush();
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void handle(org.neo4j.causalclustering.core.replication.DistributedOperation distributedOperation) throws java.io.IOException
            public override void Handle(DistributedOperation distributedOperation)
            {
                WritableChannel.put(DISTRIBUTED_OPERATION);
                distributedOperation.MarshalMetaData(WritableChannel);
            }
예제 #5
0
 public override void Handle(DistributedOperation distributedOperation)
 {
     Output.Add(ChunkedReplicatedContent.Single(DISTRIBUTED_OPERATION, distributedOperation.marshalMetaData));
 }