コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void marshal(ReplicatedTokenRequest content, org.neo4j.storageengine.api.WritableChannel channel) throws java.io.IOException
        public static void Marshal(ReplicatedTokenRequest content, WritableChannel channel)
        {
            channel.PutInt(content.Type().ordinal());
            StringMarshal.marshal(channel, content.TokenName());

            channel.PutInt(content.CommandBytes().Length);
            channel.Put(content.CommandBytes(), content.CommandBytes().Length);
        }
コード例 #2
0
        public static void Marshal(ReplicatedTokenRequest content, ByteBuf buffer)
        {
            buffer.writeInt(content.Type().ordinal());
            StringMarshal.marshal(buffer, content.TokenName());

            buffer.writeInt(content.CommandBytes().Length);
            buffer.writeBytes(content.CommandBytes());
        }
コード例 #3
0
        protected internal override int CreateToken(string tokenName)
        {
            ReplicatedTokenRequest tokenRequest = new ReplicatedTokenRequest(_type, tokenName, CreateCommands(tokenName));

            try
            {
                Future <object> future = _replicator.replicate(tokenRequest, true);
                return(( int )future.get());
            }
            catch (Exception e) when(e is ReplicationFailureException || e is InterruptedException)
            {
                throw new Org.Neo4j.Graphdb.TransactionFailureException("Could not create token", e);
            }
            catch (ExecutionException e)
            {
                throw new System.InvalidOperationException(e);
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllocateTokenIdToFirstReplicateRequest()
        public virtual void ShouldAllocateTokenIdToFirstReplicateRequest()
        {
            // given
            TokenRegistry registry = new TokenRegistry("Label");
            ReplicatedTokenStateMachine stateMachine = new ReplicatedTokenStateMachine(registry, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            stateMachine.InstallCommitProcess(mock(typeof(TransactionCommitProcess)), -1);

            ReplicatedTokenRequest winningRequest = new ReplicatedTokenRequest(LABEL, "Person", commandBytes(TokenCommands(_expectedTokenId)));
            ReplicatedTokenRequest losingRequest  = new ReplicatedTokenRequest(LABEL, "Person", commandBytes(TokenCommands(_unexpectedTokenId)));

            // when
            stateMachine.ApplyCommand(winningRequest, 1, r =>
            {
            });
            stateMachine.ApplyCommand(losingRequest, 2, r =>
            {
            });

            // then
            assertEquals(_expectedTokenId, ( int )registry.GetId("Person"));
        }
コード例 #5
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }

            ReplicatedTokenRequest that = ( ReplicatedTokenRequest )o;

            if (_type != that._type)
            {
                return(false);
            }
            if (!_tokenName.Equals(that._tokenName))
            {
                return(false);
            }
            return(Arrays.Equals(_commandBytes, that._commandBytes));
        }