상속: Lucene.Net.Store.IndexInput
예제 #1
0
        public AzureIndexInput(AzureIndexInput cloneInput)
        {
            _fileMutex = BlobMutexManager.GrabMutex(cloneInput._name);
            _fileMutex.WaitOne();

            try
            {
#if FULLDEBUG
                Debug.WriteLine(String.Format("Creating clone for {0}", cloneInput._name));
#endif
                _azureDirectory = cloneInput._azureDirectory;
                _blobContainer  = cloneInput._blobContainer;
                _blob           = cloneInput._blob;
                _indexInput     = cloneInput._indexInput.Clone() as IndexInput;
            }
            catch (Exception)
            {
                // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet
                // but this covers our tail until I do
                Debug.WriteLine(String.Format("Dagnabbit, falling back to memory clone for {0}", cloneInput._name));
            }
            finally
            {
                _fileMutex.ReleaseMutex();
            }
        }
예제 #2
0
        public override Object Clone()
        {
            var clone = new AzureIndexInput(this._azureDirectory, this._name, this._blob);

            clone.Seek(this.GetFilePointer());
            return(clone);
        }
 /// <summary>Returns a stream reading an existing file. </summary>
 public override IndexInput OpenInput(System.String name)
 {
     try
     {
         CloudBlob blob = _blobContainer.GetBlobReference(name);
         blob.FetchAttributes();
         AzureIndexInput input = new AzureIndexInput(this, blob);
         return(input);
     }
     catch (Exception err)
     {
         throw new System.IO.FileNotFoundException(name, err);
     }
 }
예제 #4
0
 /// <summary>Returns a stream reading an existing file. </summary>
 public override IndexInput openInput(string name, IOContext ioc)
 {
     try
     {
         var blob = BlobContainer.GetBlockBlobReference(name);
         blob.FetchAttributes();
         var input = new AzureIndexInput(this, blob);
         return(input);
     }
     catch (StorageException)
     {
         throw new NoSuchFileException(name);
     }
 }
예제 #5
0
        public override object Clone()
        {
            IndexInput clone = null;

            try
            {
                _fileMutex.WaitOne();
                clone = new AzureIndexInput(this, "clone");
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.ToString());
            }
            finally
            {
                _fileMutex.ReleaseMutex();
            }
            Debug.Assert(clone != null);
            return(clone);
        }
예제 #6
0
        public AzureIndexInput(AzureIndexInput cloneInput)
            : base(cloneInput._blob.Name)
        {
            _fileMutex = BlobMutexManager.GrabMutex(cloneInput._name);
            _fileMutex.WaitOne();

            try
            {
                _azureDirectory = cloneInput._azureDirectory;
                _blobContainer = cloneInput._blobContainer;
                _blob = cloneInput._blob;
                _indexInput = cloneInput._indexInput.clone();
            }
            catch (Exception)
            {
                // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet
                // but this covers our tail until I do
                Debug.WriteLine(String.Format("Dagnabbit, falling back to memory clone for {0}", cloneInput._name));
            }
            finally
            {
                _fileMutex.ReleaseMutex();
            }
        }
예제 #7
0
 public override System.Object Clone()
 {
     IndexInput clone = null;
     try
     {
         _fileMutex.WaitOne();
         AzureIndexInput input = new AzureIndexInput(this);
         clone = (IndexInput)input;
     }
     catch (System.Exception err)
     {
         Debug.WriteLine(err.ToString());
     }
     finally
     {
         _fileMutex.ReleaseMutex();
     }
     Debug.Assert(clone != null);
     return clone;
 }
예제 #8
0
 /// <summary>Returns a stream reading an existing file. </summary>
 public override IndexInput OpenInput(System.String name)
 {
     try
     {
         CloudBlob blob = _blobContainer.GetBlobReference(name);
         blob.FetchAttributes();
         AzureIndexInput input = new AzureIndexInput(this, blob);
         return input;
     }
     catch (Exception err)
     {
         throw new System.IO.FileNotFoundException(name, err);
     }
 }
예제 #9
0
 /// <summary>Returns a stream reading an existing file. </summary>
 public override IndexInput openInput(string name, IOContext ioc)
 {
     try
     {
         var blob = BlobContainer.GetBlockBlobReference(name);
         blob.FetchAttributes();
         var input = new AzureIndexInput(this, blob);
         return input;
     }
     catch (StorageException)
     {
         throw new NoSuchFileException(name);
     }
 }
예제 #10
0
        public AzureIndexInput(AzureIndexInput cloneInput)
        {
            _fileMutex = new Mutex(false, cloneInput._name);
            _fileMutex.WaitOne();

            try
            {
            #if FULLDEBUG
                Debug.WriteLine(String.Format("Creating clone for {0}", cloneInput._name));
            #endif
                _azureDirectory = cloneInput._azureDirectory;
                _blobContainer = cloneInput._blobContainer;
                _blob = cloneInput._blob;
                _indexInput = cloneInput._indexInput.Clone() as IndexInput;
            }
            catch (Exception)
            {
                // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet
                // but this covers our tail until I do
                Debug.WriteLine(String.Format("Dagnabbit, falling back to memory clone for {0}", cloneInput._name));
            }
            finally
            {
                _fileMutex.ReleaseMutex();
            }
        }
예제 #11
0
 /// <summary>Returns a stream reading an existing file. </summary>
 public override IndexInput OpenInput(System.String name)
 {
     var cache = MemoryCache.Default;
     try
     {
         CloudBlockBlob blob;
         var key = string.Format(KeyPattern, name);
         if (cache.Contains(key)) {
             blob = cache.Get(key) as CloudBlockBlob;
         }
         else
         {
             blob = _blobContainer.GetBlockBlobReference(name);
             blob.FetchAttributes();
             cache.Set(key, blob, DateTime.Now.AddMinutes(5));
         }
         AzureIndexInput input = new AzureIndexInput(this, blob);
         return input;
     }
     catch (Exception err)
     {
         throw new System.IO.FileNotFoundException(name, err);
     }
 }