public void Initialize(String directoryProviderName, IDictionary <string, string> properties, ISearchFactoryImplementor searchFactory) { this.properties = properties; this.directoryProviderName = directoryProviderName; // source guessing source = DirectoryProviderHelper.GetSourceDirectory(Environment.SourceBase, Environment.Source, directoryProviderName, (IDictionary)properties); if (source == null) { throw new ArgumentException("FSSlaveDirectoryProvider requires a viable source directory"); } if (!File.Exists(Path.Combine(source, "current1")) && !File.Exists(Path.Combine(source, "current2"))) { log.Warn("No current marker in source directory: " + source); } log.Debug("Source directory: " + source); indexDir = DirectoryProviderHelper.DetermineIndexDir(directoryProviderName, (IDictionary)properties); log.Debug("Index directory: " + indexDir.FullName); try { bool create = !indexDir.Exists; if (create) { log.DebugFormat("Index directory not found, creating '{0}'", indexDir.FullName); indexDir.Create(); } indexName = indexDir.FullName; } catch (IOException e) { throw new HibernateException("Unable to initialize index: " + directoryProviderName, e); } }
public void CreateViaRoot() { var properties = new Dictionary <string, string>(); properties["sourceBase"] = root; DirectoryProviderHelper.GetSourceDirectory("sourceBase", "relativeBase", "Test", properties); DirectoryInfo info = new DirectoryInfo(root + "/Test"); Assert.IsTrue(info.Exists); }
public void Initialize(string directoryProviderName, IDictionary <string, string> properties, ISearchFactoryImplementor searchFactory) { this.properties = properties; this.directoryProviderName = directoryProviderName; // source guessing source = DirectoryProviderHelper.GetSourceDirectory(Environment.SourceBase, Environment.Source, directoryProviderName, (IDictionary)properties); if (source == null) { throw new ArgumentException("FSMasterDirectoryProvider requires a viable source directory"); } log.Debug("Source directory: " + source); indexDir = DirectoryProviderHelper.DetermineIndexDir(directoryProviderName, (IDictionary)properties); log.Debug("Index directory: " + indexDir); try { // NB Do we need to do this since we are passing the create flag to Lucene? bool create = !IndexReader.IndexExists(indexDir.FullName); if (create) { log.DebugFormat("Index directory not found, creating '{0}'", indexDir.FullName); indexDir.Create(); } indexName = indexDir.FullName; directory = FSDirectory.GetDirectory(indexName, create); if (create) { indexName = indexDir.FullName; IndexWriter iw = new IndexWriter(directory, new StandardAnalyzer(), create); iw.Close(); } } catch (IOException e) { throw new HibernateException("Unable to initialize index: " + directoryProviderName, e); } this.searchFactory = searchFactory; }
public override void Initialize(string directoryProviderName, IDictionary <string, string> properties, ISearchFactoryImplementor searchFactory) { this.properties = properties; this.directoryProviderName = directoryProviderName; // source guessing source = DirectoryProviderHelper.GetSourceDirectory(Environment.SourceBase, Environment.Source, directoryProviderName, (IDictionary)properties); if (source == null) { throw new ArgumentException("FSMasterDirectoryProvider requires a viable source directory"); } log.Debug("Source directory: " + source); indexDir = DirectoryProviderHelper.DetermineIndexDir(directoryProviderName, (IDictionary)properties); log.Debug("Index directory: " + indexDir); this.indexName = directoryProviderName; this.directory = InitializeIndex(indexDir, indexDir.FullName); this.searchFactory = searchFactory; }