Ejemplo n.º 1
0
 protected internal EntryUpdater <Key> Updater()
 {
     using (LockWrapper @lock = readLock(_updateLock, _logger))
     {
         return(State.unsafeUpdater(@lock.Get()));
     }
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: protected final java.util.Optional<EntryUpdater<Key>> updater(final long version)
        protected internal Optional <EntryUpdater <Key> > Updater(long version)
        {
            using (LockWrapper @lock = readLock(_updateLock, _logger))
            {
                return(State.optionalUpdater(version, @lock.Get()));
            }
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public final void start() throws java.io.IOException
        public override void Start()
        {
            using (LockWrapper ignored = writeLock(_updateLock, _logger))
            {
                State = State.start(_stateInitializer);
            }
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public final void init() throws java.io.IOException
        public override void Init()
        {
            using (LockWrapper ignored = writeLock(_updateLock, _logger))
            {
                State = State.initialize(RotationStrategy);
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public final void shutdown() throws java.io.IOException
        public override void Shutdown()
        {
            using (LockWrapper ignored = writeLock(_updateLock, _logger))
            {
                _stopped = true;
                State    = State.stop();
            }
        }
Ejemplo n.º 6
0
 protected internal EntryUpdater <Key> Resetter(long version)
 {
     using (LockWrapper @lock = writeLock(_updateLock, _logger))
     {
         ProgressiveState <Key> current = State;
         return(current.Resetter(@lock.Get(), new RotationTask(this, version)));
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Prepare for rotation. Sets up the internal structures to ensure that all changes up to and including the changes
        /// of the specified version are applied before rotation takes place. This method does not block, however if all
        /// required changes have not been applied <seealso cref="PreparedRotation.rotate() the rotate method"/> will block
        /// waiting for all changes to be applied. Invoking <seealso cref="PreparedRotation.rotate() the rotate method"/> some
        /// time after all requested transactions have been applied is ok, since setting the store up for rotation does
        /// not block updates, it just sorts them into updates that apply before rotation and updates that apply after.
        /// </summary>
        /// <param name="version"> the smallest version to include in the rotation. Note that the actual rotated version might be a
        /// later version than this version. The actual rotated version is returned by
        /// <seealso cref="PreparedRotation.rotate()"/>. </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: protected final PreparedRotation prepareRotation(final long version)
        protected internal PreparedRotation PrepareRotation(long version)
        {
            using (LockWrapper ignored = writeLock(_updateLock, _logger))
            {
                ProgressiveState <Key> prior = State;
                if (prior.StoredVersion() == version && !prior.HasChanges())
                {
                    return(() => version);
                }
                return(new RotationTask(this, version));
            }
        }
Ejemplo n.º 8
0
 public override void Run()
 {
     try
     {
         using (LockWrapper ignored = writeLock(outerInstance.updateLock, outerInstance.logger))
         {
             Rotate(true);
         }
     }
     catch (IOException e)
     {
         throw new UnderlyingStorageException(e);
     }
 }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long rotate(boolean force) throws java.io.IOException
            internal virtual long Rotate(bool force)
            {
                using (RotationState <Key> rotation = this.Rotation)
                {
                    try
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long version = rotation.rotationVersion();
                        long version = rotation.RotationVersion();
                        ProgressiveState <Key> next = rotation.Rotate(force, outerInstance.RotationStrategy, outerInstance.rotationTimerFactory, value => updateHeaders(value, version));
                        using (LockWrapper ignored = writeLock(outerInstance.updateLock, outerInstance.logger))
                        {
                            outerInstance.State = next;
                        }
                        return(version);
                    }
                    catch (Exception t)
                    {
                        // Rotation failed. Here we assume that rotation state remembers this so that closing it
                        // won't close the state as it was before rotation began, which we're reverting to right here.
                        using (LockWrapper ignored = writeLock(outerInstance.updateLock, outerInstance.logger))
                        {
                            // Only mark as failed if we're still running.
                            // If shutdown has been called while being in rotation state then shutdown will fail
                            // without closing the store. This means that rotation takes over that responsibility.
                            // Therefore avoid marking rotation state as failed in this case and let the store
                            // be naturally closed before leaving this method.
                            if (!outerInstance.stopped)
                            {
                                outerInstance.State = rotation.MarkAsFailed();
                            }
                        }
                        throw t;
                    }
                }
            }