/// <summary>Waits for a rescan to complete.</summary>
 /// <remarks>
 /// Waits for a rescan to complete. This doesn't guarantee consistency with
 /// pending operations, only relative recency, since it will not force a new
 /// rescan if a rescan is already underway.
 /// <p>
 /// Note that this call will release the FSN lock, so operations before and
 /// after are not atomic.
 /// </remarks>
 public virtual void WaitForRescanIfNeeded()
 {
     Preconditions.CheckArgument(!namesystem.HasWriteLock(), "Must not hold the FSN write lock when waiting for a rescan."
                                 );
     Preconditions.CheckArgument(Lock.IsHeldByCurrentThread(), "Must hold the CRM lock when waiting for a rescan."
                                 );
     if (neededScanCount <= completedScanCount)
     {
         return;
     }
     // If no scan is already ongoing, mark the CRM as dirty and kick
     if (curScanCount < 0)
     {
         doRescan.Signal();
     }
     // Wait until the scan finishes and the count advances
     while ((!shutdown) && (completedScanCount < neededScanCount))
     {
         try
         {
             scanFinished.Await();
         }
         catch (Exception e)
         {
             Log.Warn("Interrupted while waiting for CacheReplicationMonitor" + " rescan", e);
             break;
         }
     }
 }
예제 #2
0
파일: Transports.cs 프로젝트: zlorb/agnos
        //
        // write interface
        //
        public virtual void BeginWrite(int seq)
        {
            if (wlock.IsHeldByCurrentThread())
            {
                throw new IOException("BeginWrite is not reentrant");
            }
#if AGNOS_TRANSPORT_DEBUG
            System.Console.WriteLine("Transport.BeginWrite");
#endif
            wlock.Acquire();
            wseq             = seq;
            wbuffer.Position = 0;
            wbuffer.SetLength(0);
#if AGNOS_TRANSPORT_DEBUG
            System.Console.WriteLine(">> okay");
#endif
        }
예제 #3
0
파일: Transports.cs 프로젝트: zlorb/agnos
        //
        // read interface
        //
        public virtual int BeginRead()
        {
            if (rlock.IsHeldByCurrentThread())
            {
                throw new IOException("BeginRead is not reentrant");
            }

#if AGNOS_TRANSPORT_DEBUG
            System.Console.WriteLine("TransportBegin.BeginRead");
#endif
            rlock.Acquire();

            try {
                int seq                = readSInt32(inStream);
                int packetLength       = readSInt32(inStream);
                int uncompressedLength = readSInt32(inStream);

#if AGNOS_TRANSPORT_DEBUG
                System.Console.WriteLine(">> seq={0}, len={1}, uncomp={2}", seq, packetLength, uncompressedLength);
#endif
                if (readStream != null)
                {
                    throw new InvalidOperationException("readStream must be null at this point");
                }

                readStream = new BoundInputStream(inStream, packetLength, true, false);
                if (uncompressedLength > 0)
                {
                    readStream = new BoundInputStream(new DeflateStream(readStream, CompressionMode.Decompress, false), packetLength, false, true);
                }
                return(seq);
            } catch (Exception) {
                readStream = null;
                rlock.Release();
                throw;
            }
        }
예제 #4
0
 /// <summary>Wake up the DomainSocketWatcher thread.</summary>
 private void Kick()
 {
     System.Diagnostics.Debug.Assert((Lock.IsHeldByCurrentThread()));
     if (kicked)
     {
         return;
     }
     try
     {
         notificationSockets[0].GetOutputStream().Write(0);
         kicked = true;
     }
     catch (IOException e)
     {
         if (!closed)
         {
             Log.Error(this + ": error writing to notificationSockets[0]", e);
         }
     }
 }