protected void SetHostname(VizqlServerSession session) { if (!session.Worker.HasValue) { session.Hostname = "Unknown"; } else { session.Hostname = GetHostnameForWorkerId(session.Worker.Value); } }
protected void SetHostname(VizqlServerSession session) { if (session.Worker == null) { session.Hostname = "Unknown"; } else { session.Hostname = GetHostnameForWorkerId(session.Worker); } }
protected VizqlServerSession SetHostname(VizqlServerSession session, IDictionary <int, string> workerHostnameMap) { if (session.Worker == null) { session.Hostname = "Unknown"; } else { session.Hostname = GetHostnameForWorkerId(session.Worker, workerHostnameMap); } return(session); }
protected virtual VizqlServerSession ProcessSession(string sessionId, IMongoCollection <BsonDocument> collection, IDictionary <int, string> workerHostnameMap) { try { VizqlServerSession session = Queries.GetServerSession(sessionId, collection); session = Queries.AppendErrorEvents(session, collection) as VizqlServerSession; return(SetHostname(session, workerHostnameMap)); } catch (Exception ex) { Log.ErrorFormat("Failed to process session {0} in {1}: {2}", sessionId, collection.CollectionNamespace.CollectionName, ex.Message); return(null); } }
protected override VizqlServerSession ProcessSession(string sessionId, IMongoCollection <BsonDocument> collection) { try { VizqlServerSession session = MongoQueryHelper.GetServerSession(sessionId, collection, logsetHash); session = MongoQueryHelper.AppendAllSessionEvents(session, collection) as VizqlServerSession; SetHostname(session); return(session); } catch (Exception ex) { string errorMessage = String.Format("Failed to process session {0} in {1}: {2}", sessionId, collection.CollectionNamespace.CollectionName, ex.Message); Log.Error(errorMessage); pluginResponse.AppendError(errorMessage); return(null); } }
public static VizqlServerSession GetServerSession(string sessionId, IMongoCollection <BsonDocument> collection, Guid logsetHash) { var sessionQuery = Query.Eq("sess", sessionId); // Only include fields which we actually need to new up the session. var projection = Builders <BsonDocument> .Projection.Include("ts") .Include("sess") .Include("site") .Include("file") .Include("user") .Include("worker"); BsonDocument firstEvent = collection.Find(sessionQuery).Project(projection).Sort(Builders <BsonDocument> .Sort.Ascending("ts")).Limit(1).First(); BsonDocument lastEvent = collection.Find(sessionQuery).Project(projection).Sort(Builders <BsonDocument> .Sort.Descending("ts")).Limit(1).First(); string processName = collection.CollectionNamespace.CollectionName.Split('_')[0]; VizqlSession session = new VizqlServerSession(firstEvent, lastEvent, GetWorkbookForSession(sessionId, collection), processName, GetBootstrapRequestIdForSession(sessionId, collection), logsetHash); return(session as VizqlServerSession); }
public static InsertionResult PersistSession(IDbConnection database, VizqlServerSession currentSession) { try { try { database.Insert(currentSession); database.InsertAll(currentSession.ErrorEvents); } catch (PostgresException ex) { // We now use these tables in both VizqlServer and VizqlServerPerformance. // If someone runs both we need to swallow any duplicates exceptions that may arise. if (!ex.SqlState.Equals(PluginLibConstants.POSTGRES_ERROR_CODE_UNIQUE_VIOLATION)) { throw; } } Log.DebugFormat("Persisted session {0}", currentSession.VizqlSessionId); return(new InsertionResult { SuccessfulInserts = 1, FailedInserts = 0 }); } catch (Exception ex) { Log.ErrorFormat("Failed to persist session '{0}': {1}", currentSession.VizqlSessionId, ex.Message); return(new InsertionResult { SuccessfulInserts = 0, FailedInserts = 1 }); } }
public static InsertionResult PersistSession(IPluginRequest pluginRequest, IDbConnection database, VizqlServerSession currentSession) { try { try { database.Insert(currentSession); database.InsertAll(currentSession.ErrorEvents); } catch (PostgresException ex) { // We now use these tables in both VizqlServer and VizqlServerPerformance. // If someone runs both we need to swallow any duplicates exceptions that may arise. if (!ex.SqlState.Equals(PluginLibConstants.POSTGRES_ERROR_CODE_UNIQUE_VIOLATION)) { throw; } } // Performance database.InsertAll(currentSession.PerformanceEvents); // Query int maxQueryLength = VizqlPluginArgumentHelper.GetMaxQueryLength(pluginRequest, MaxQueryLengthArgumentKey, DefaultMaxQueryLength); database.InsertAll(currentSession.EndQueryEvents.Select(queryEvent => queryEvent.WithTruncatedQueryText(maxQueryLength))); database.InsertAll(currentSession.QpQueryEndEvents); Log.DebugFormat("Persisted session {0}", currentSession.VizqlSessionId); return(new InsertionResult { SuccessfulInserts = 1, FailedInserts = 0 }); } catch (Exception ex) { Log.ErrorFormat("Failed to persist session '{0}': {1}", currentSession.VizqlSessionId, ex.Message); return(new InsertionResult { SuccessfulInserts = 0, FailedInserts = 1 }); } }
public static InsertionResult PersistSession(IPluginRequest pluginRequest, IDbConnection database, VizqlServerSession currentSession) { try { try { database.Insert(currentSession); database.InsertAll(currentSession.ErrorEvents); } catch (PostgresException ex) { // We now use these tables in both VizqlServer and VizqlServerPerformance. // If someone runs both we need to swallow any duplicates exceptions that may arise. if (!ex.SqlState.Equals(PluginLibConstants.POSTGRES_ERROR_CODE_UNIQUE_VIOLATION)) { throw; } } // Performance database.InsertAll(currentSession.PerformanceEvents); // Connection database.InsertAll(currentSession.ConstructProtocolEvents); database.InsertAll(currentSession.ConstructProtocolGroupEvents); // Compute database.InsertAll(currentSession.EndComputeQuickFilterStateEvents); // Render database.InsertAll(currentSession.EndUpdateSheetEvents); // Caching database.InsertAll(currentSession.EcDropEvents); database.InsertAll(currentSession.EcStoreEvents); database.InsertAll(currentSession.EcLoadEvents); database.InsertAll(currentSession.EqcStoreEvents); database.InsertAll(currentSession.EqcLoadEvents); // Query int maxQueryLength = VizqlPluginArgumentHelper.GetMaxQueryLength(pluginRequest, MaxQueryLengthArgumentKey, DefaultMaxQueryLength); database.InsertAll(currentSession.EndQueryEvents.Select(queryEvent => queryEvent.WithTruncatedQueryText(maxQueryLength))); database.InsertAll(currentSession.QpQueryEndEvents); database.InsertAll(currentSession.EndPrepareQuickFilterQueriesEvents); database.InsertAll(currentSession.EndSqlTempTableTuplesCreateEvents); foreach (VizqlQpBatchSummary qpBatchSummaryEvent in currentSession.QpBatchSummaryEvents) { database.Insert(qpBatchSummaryEvent); database.InsertAll(qpBatchSummaryEvent.QpBatchSummaryJobs.Select(queryEvent => queryEvent.WithTruncatedQueryText(maxQueryLength))); } Log.DebugFormat("Persisted session {0}", currentSession.VizqlSessionId); return(new InsertionResult { SuccessfulInserts = 1, FailedInserts = 0 }); } catch (Exception ex) { Log.ErrorFormat("Failed to persist session '{0}': {1}", currentSession.VizqlSessionId, ex.Message); return(new InsertionResult { SuccessfulInserts = 0, FailedInserts = 1 }); } }