Example #1
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;
                    }
                }
            }
Example #2
0
 internal RotationTask(AbstractKeyValueStore <Key> outerInstance, long version)
 {
     this._outerInstance = outerInstance;
     outerInstance.State = this.Rotation = outerInstance.State.prepareRotation(version);
 }