Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long commit(final org.neo4j.kernel.impl.api.TransactionToApply tx, final org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public override long Commit(TransactionToApply tx, CommitEvent commitEvent, TransactionApplicationMode mode)
        {
            TransactionRepresentationReplicatedTransaction transaction = ReplicatedTransaction.from(tx.TransactionRepresentation());
            Future <object> futureTxId;

            try
            {
                futureTxId = _replicator.replicate(transaction, true);
            }
            catch (ReplicationFailureException e)
            {
                throw new TransactionFailureException(ReplicationFailure, e);
            }

            try
            {
                return(( long )futureTxId.get());
            }
            catch (ExecutionException e)
            {
                if (e.InnerException is TransactionFailureException)
                {
                    throw ( TransactionFailureException )e.InnerException;
                }
                // TODO: Panic?
                throw new Exception(e);
            }
            catch (InterruptedException e)
            {
                // TODO Wait for the transaction to possibly finish within a user configurable time, before aborting.
                throw new TransactionFailureException("Interrupted while waiting for txId", e);
            }
        }
Ejemplo n.º 2
0
 private bool ReplicateIdAllocationRequest(IdType idType, ReplicatedIdAllocationRequest idAllocationRequest)
 {
     try
     {
         return(( bool? )_replicator.replicate(idAllocationRequest, true).get().Value);
     }
     catch (Exception e)
     {
         _log.warn(format("Failed to acquire id range for idType %s", idType), e);
         throw new IdGenerationException(e);
     }
 }
Ejemplo n.º 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);
            }
        }