/// <summary> /// Creates all of the required MongoDB collections that this logset requires. /// </summary> private void CreateMongoDbCollections() { var collections = new Dictionary <string, HashSet <string> >(); ISet <IParser> parsers = parserFactory.GetAllParsers(); // Stuff collection names & indexes into the dictionary, deduping in the process. foreach (var parser in parsers) { var collectionName = parser.CollectionSchema.CollectionName.ToLowerInvariant(); IList <string> indexes = parser.CollectionSchema.Indexes; if (!collections.ContainsKey(collectionName)) { if (LogsetDependencyHelper.IsCollectionRequiredForRequest(collectionName, logsharkRequest)) { collections.Add(collectionName, new HashSet <string>()); } } // Add indexes. if (collections.ContainsKey(collectionName)) { foreach (var index in indexes) { if (collections.ContainsKey(collectionName)) { collections[collectionName].Add(index); } } } } // New up collections & indexes using the dictionary. foreach (var collection in collections) { var collectionName = collection.Key; ISet <string> indexes = collection.Value; var dbCollection = database.GetCollection <BsonDocument>(collectionName); logsharkRequest.RunContext.CollectionsGenerated.Add(collectionName); foreach (var index in indexes) { var indexKeysBuilder = new IndexKeysDefinitionBuilder <BsonDocument>(); CreateIndexOptions indexOptions = new CreateIndexOptions { Sparse = false }; dbCollection.Indexes.CreateOne(indexKeysBuilder.Ascending(index), indexOptions); } // If we are working against a sharded Mongo cluster, we need to explicitly shard each collection. MongoConnectionInfo mongoConnectionInfo = logsharkRequest.Configuration.MongoConnectionInfo; if (mongoConnectionInfo.ConnectionType == MongoConnectionType.ShardedCluster) { MongoAdminUtil.EnableShardingOnCollectionIfNotEnabled(mongoConnectionInfo.GetClient(), logsharkRequest.RunContext.MongoDatabaseName, collectionName); } } }
public PluginExecutor(LogsharkConfiguration config) { mongoConnectionInfo = config.MongoConnectionInfo; postgresConnectionInfo = config.PostgresConnectionInfo; tableauConnectionInfo = config.TableauConnectionInfo; applicationTempDirectory = config.ApplicationTempDirectory; applicationOutputDirectory = config.ApplicationOutputDirectory; }
public LogsharkConfiguration(LogsharkConfig config) { MongoConnectionInfo = new MongoConnectionInfo(config.MongoConnection); PostgresConnectionInfo = new PostgresConnectionInfo(config.PostgresConnection); TableauConnectionInfo = new TableauServerConnectionInfo(config.TableauConnection); LocalMongoOptions = new LogsharkLocalMongoOptions(config.RunOptions.LocalMongo); TuningOptions = new LogsharkTuningOptions(config.RunOptions.Tuning); ArtifactProcessorOptions = new LogsharkArtifactProcessorOptions(config.ArtifactProcessorOptions); }
void IModelDataGatewayInitializeable.Initialize<T>(ModelActionOption option, IContext context, T t, ICriterion criterion, ResolveDbKey<T> dbkeyResolver) { string key = ResolveConnectionStringKey(context); if (String.IsNullOrWhiteSpace(key)) { key = dbkeyResolver.Invoke(context); } if (String.IsNullOrEmpty(key)) { var message = Exceptions.ComposeDbConnectionStringKeyResolutionError<T>(option, t, context); context.SetError(500, message.ToPublish() ); EventWriter.WriteError(message.ToLog(), SeverityType.Error); } else { var cn = ConfigurationManager.ConnectionStrings[key]; if (cn != null) { MongoConnectionInfo info = new MongoConnectionInfo(); if (info.Initialize(cn)) { MongoDb = info.GetDatabase(); } if (MongoDb == null) { var message = Exceptions.ComposeDbConnectionCreationError<T>(option, t, context, key); context.SetError(500, message.ToPublish()); EventWriter.WriteError(message.ToLog(), SeverityType.Error); } else { Collection = GetCollection(); if (Collection == null) { context.SetError(500, "MongoDB.Collection is Null"); } else if (eXtensibleConfig.CaptureMetrics) { IRequestContext ctx = context as IRequestContext; ctx.SetMetric(XFConstants.Metrics.Scope.DataStore, XFConstants.Metrics.Database.Datasource, String.Format("server:{0};database:{1};", cn.ConnectionString, key)); ; } } } else { var message = Exceptions.ComposeDbConnectionCreationError<T>(option, t, context, key); context.SetError(500, message.ToPublish()); EventWriter.WriteError(message.ToLog(), SeverityType.Error); } } }
public LogsharkConfiguration(LogsharkConfig config) { MongoConnectionInfo = new MongoConnectionInfo(config.MongoConnection); PostgresConnectionInfo = new PostgresConnectionInfo(config.PostgresConnection); TableauConnectionInfo = new TableauConnectionInfo(config.TableauConnection); LocalMongoOptions = new LogsharkLocalMongoOptions(config.RunOptions.LocalMongo); TuningOptions = new LogsharkTuningOptions(config.RunOptions.Tuning); DefaultPlugins = new HashSet <string>(); foreach (Plugin plugin in config.PluginOptions.DefaultPlugins) { DefaultPlugins.Add(plugin.Name); } }
public LogsharkConfiguration(LogsharkConfig config) { MongoConnectionInfo = new MongoConnectionInfo(config.MongoConnection); if (!string.IsNullOrWhiteSpace(config.PostgresConnection.Server.Server) && !config.PostgresConnection.Server.Server.Equals("unspecified", StringComparison.OrdinalIgnoreCase)) { PostgresConnectionInfo = Option.Some(new PostgresConnectionInfo(config.PostgresConnection)); } TableauConnectionInfo = new TableauServerConnectionInfo(config.TableauConnection); DataRetentionOptions = new LogsharkDataRetentionOptions(config.RunOptions.DataRetention); LocalMongoOptions = new LogsharkLocalMongoOptions(config.RunOptions.LocalMongo); TuningOptions = new LogsharkTuningOptions(config.RunOptions.Tuning); ArtifactProcessorOptions = new LogsharkArtifactProcessorOptions(config.ArtifactProcessorOptions); ApplicationTempDirectory = GetApplicationTempDirectory(config); ApplicationOutputDirectory = GetApplicationOutputDirectory(); }
private void btnSave_Click(object sender, EventArgs e) { if (TestConnection()) { if (string.IsNullOrWhiteSpace(txtBoxName.Text)) { MessageBox.Show("Please enter a connection name"); return; } if (Settings.Instance.Connections.Exists(c => c.Name.Equals(txtBoxName.Text))) { MessageBox.Show("A connection with this name already exists"); return; } var newConnection = new MongoConnectionInfo { Id = Guid.NewGuid().ToString(), Name = txtBoxName.Text, ServerString = txtBoxServer.Text, Username = txtBoxUsername.Text, Password = txtBoxPassword.Text, Databases = txtBoxDatabase.Text.Split(new[] { ',' }).ToList().ConvertAll(db => new MongoDatabaseInfo { Name = db }) }; foreach (var database in newConnection.Databases) { database.Connection = newConnection; } Settings.Instance.Connections.Add(newConnection); Settings.Instance.Save(); Close(); if (OnAddConnection != null) { OnAddConnection(newConnection); } } }
public HashRunInitializer(MongoConnectionInfo mongoConnectionInfo) { this.mongoConnectionInfo = mongoConnectionInfo; }
public LogsetProcessingStatusChecker(MongoConnectionInfo mongoConnectionInfo) { this.mongoConnectionInfo = mongoConnectionInfo; }
public MongoParsedLogsetValidator(MongoConnectionInfo mongoConnectionInfo) { this.mongoConnectionInfo = mongoConnectionInfo; }
public PluginExecutor(LogsharkConfiguration config) { mongoConnectionInfo = config.MongoConnectionInfo; postgresConnectionInfo = config.PostgresConnectionInfo; tableauConnectionInfo = config.TableauConnectionInfo; }
public MongoLogsetParser(MongoConnectionInfo mongoConnectionInfo, LogsharkTuningOptions tuningOptions) : base(tuningOptions) { this.mongoConnectionInfo = mongoConnectionInfo; metadataWriter = new MongoLogProcessingMetadataWriter(mongoConnectionInfo); }
public MongoLogProcessingMetadataWriter(MongoConnectionInfo mongoConnectionInfo) { this.mongoConnectionInfo = mongoConnectionInfo; }
public ConnectionNodeTag(MongoConnectionInfo conn) { MongoConnectionInfo = conn; }
private string GenerateConnectionString(MongoConnectionInfo mongoConnectionInfo, MongoSettings settings) { return(string.Format(MongoConnectionStringPattern, settings.Login, settings.Password, mongoConnectionInfo.Address, mongoConnectionInfo.Port)); }