internal AnalyticsPageViewRequest(IAnalyticsClient analyticsClient, string page, string title)
 {
     m_analyticsClient = analyticsClient;
     m_page            = page;
     m_title           = title;
     m_customVariables = new CustomVariableBag();
 }
Example #2
0
 internal AnalyticsPageViewRequest(IAnalyticsClient analyticsClient, string page, string title)
 {
     _analyticsClient = analyticsClient;
     _page            = page;
     _title           = title;
     _customVariables = new VariableBucket();
 }
Example #3
0
        protected async override Task OnStartAsync(IAnalyticsClient client, DateTime now)
        {
            await base.OnStartAsync(client, now);

            _lastGeoLocationMsgSent = now + TimeSpan.Zero.WithRandomDeviation(3);
            _geoRoute = _geoRouteProvider.GetGeoRoute();
        }
Example #4
0
        public Task <IAnalyticsResult <T> > AnalyticsQueryAsync <T>(string statement, AnalyticsOptions options = default)
        {
            if (options == default)
            {
                options = new AnalyticsOptions();
            }

            var query = new AnalyticsRequest(statement);

            query.ClientContextId(options.ClientContextId);
            query.Pretty(options.Pretty);
            query.IncludeMetrics(options.IncludeMetrics);
            query.NamedParameters     = options.NamedParameters;
            query.PositionalArguments = options.PositionalParameters;

            if (options.Timeout.HasValue)
            {
                query.Timeout(options.Timeout.Value);
            }

            query.Priority(options.Priority);
            query.Deferred(options.Deferred);

            query.ConfigureLifespan(30); //TODO: use configuration.AnalyticsTimeout

            if (_analyticsClient == null)
            {
                _analyticsClient = new AnalyticsClient(_configuration);
            }
            return(_analyticsClient.QueryAsync <T>(query, options.CancellationToken));
        }
 internal AnalyticsPageViewRequest(IAnalyticsClient analyticsClient, string page, string title)
 {
    m_analyticsClient = analyticsClient;
    m_page = page;
    m_title = title;
    m_customVariables = new CustomVariableBag();
 }
 internal AnalyticsPageViewRequest(IAnalyticsClient analyticsClient, string page, string title)
 {
     _analyticsClient = analyticsClient;
     _page = page;
     _title = title;
     _customVariables = new VariableBucket();
 }
Example #7
0
        protected async override Task OnTickAsync(IAnalyticsClient client, DateTime now, TimeSpan timeAlive, TimeSpan sinceLastTick, long tickNo)
        {
            await base.OnTickAsync(client, now, timeAlive, sinceLastTick, tickNo);

            if (_geoOptions.GeoLocationMsgInterval > TimeSpan.Zero && now - _lastGeoLocationMsgSent >= _geoOptions.GeoLocationMsgInterval.WithRandomDeviation(1))
            {
                var currentPosition = _geoRoute.GetPosition(timeAlive);

                if (currentPosition == null)
                {
                    // We've reached the end of the route for the bot
                    _endOfRoute = true;
                    return;
                }

                var msg = new GeoLocation
                {
                    GameSession = GameSession,
                    Lat         = currentPosition.Latitude,
                    Lon         = currentPosition.Longitude
                };

                await client.SendMessageAsync(msg, now);

                _lastGeoLocationMsgSent = now;
            }
        }
Example #8
0
 public NetherBot(IAnalyticsClient client, IGamerTagProvider gamerTagProvider, IGameSessionProvider gameSessionProvider, NetherBotOptions options = null)
 {
     _client              = client;
     _gamerTagProvider    = gamerTagProvider;
     _gameSessionProvider = gameSessionProvider;
     _options             = options ?? new NetherBotOptions();
 }
        public SendSampleMessageMenu(IAnalyticsClient client)
        {
            _client = client;

            Title = "Send Sample Message";

            LoadMenuItems();
        }
Example #10
0
        /// <summary>
        /// Shuts down the client. Application life cycle end is tracked.
        /// </summary>
        internal static void ShutDown()
        {
            if (client != null) client.ShutDown();

            IDisposable disposable = client as IDisposable;
            if (disposable != null) disposable.Dispose();
            client = null;
        }
Example #11
0
        public SimulateMovementMenu(IAnalyticsClient client)
        {
            _client = client;

            Title = "Nether Analytics Test Client - Simulate moving game client";

            MenuItems.Add('1', new ConsoleMenuItem("Generate random walking routes to files", GenerateRoutes));
            MenuItems.Add('2', new ConsoleMenuItem("Simulate walkers", SimulateWalkers));
        }
Example #12
0
        public Server(IIOService ioService, IViewClient viewClient, IViewClient streamingViewClient, IQueryClient queryClient, IQueryClient streamingQueryClient, ISearchClient searchClient,
                      IAnalyticsClient analyticsClient, INodeAdapter nodeAdapter,
                      ClientConfiguration clientConfiguration, ITypeTranscoder transcoder, IBucketConfig bucketConfig)
        {
            if (ioService != null)
            {
                _ioService = ioService;
                _ioService.ConnectionPool.Owner = this;
            }
            _nodeAdapter         = nodeAdapter;
            _clientConfiguration = clientConfiguration;
            _bucketConfiguration = clientConfiguration.BucketConfigs[bucketConfig.Name];
            _timingEnabled       = _clientConfiguration.EnableOperationTiming;
            _typeTranscoder      = transcoder;
            _bucketConfig        = bucketConfig;

            //services that this node is responsible for
            IsMgmtNode      = _nodeAdapter.MgmtApi > 0;
            IsDataNode      = _nodeAdapter.KeyValue > 0;
            IsQueryNode     = _nodeAdapter.N1QL > 0;
            IsIndexNode     = _nodeAdapter.IndexAdmin > 0;
            IsViewNode      = _nodeAdapter.Views > 0;
            IsSearchNode    = _nodeAdapter.IsSearchNode;
            IsAnalyticsNode = _nodeAdapter.IsAnalyticsNode;

            //View and query clients
            ViewClient            = viewClient;
            _streamingViewClient  = streamingViewClient;
            QueryClient           = queryClient;
            SearchClient          = searchClient;
            _streamingQueryClient = streamingQueryClient;
            AnalyticsClient       = analyticsClient;

            CachedViewBaseUri  = UrlUtil.GetViewBaseUri(_nodeAdapter, _bucketConfiguration);
            CachedQueryBaseUri = UrlUtil.GetN1QLBaseUri(_nodeAdapter, _bucketConfiguration);

            if (IsDataNode || IsQueryNode)
            {
                _lastIOErrorCheckedTime = DateTime.Now;

                //On initialization, data nodes are authenticated, so they can start in a down state.
                //If the node is down immediately start the timer, otherwise disable it.
                if (IsDataNode)
                {
                    _isDown = _ioService.ConnectionPool.InitializationFailed;
                }

                Log.Info("Initialization {0} for node {1}", _isDown ? "failed" : "succeeded", EndPoint);

                //timer and node status
                _heartBeatTimer = new Timer(_heartBeatTimer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
                if (_isDown)
                {
                    StartHeartbeatTimer();
                }
            }
        }
 public AnalyticsIndexManager(ILogger <AnalyticsIndexManager> logger, IAnalyticsClient client, IRedactor redactor,
                              IServiceUriProvider serviceUriProvider, ICouchbaseHttpClientFactory httpClientFactory)
 {
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _client             = client ?? throw new ArgumentNullException(nameof(client));
     _redactor           = redactor ?? throw new ArgumentNullException(nameof(redactor));
     _serviceUriProvider = serviceUriProvider ?? throw new ArgumentNullException(nameof(serviceUriProvider));
     _httpClientFactory  = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
 }
Example #14
0
 /// <summary>
 /// Loads the data.
 /// </summary>
 /// <param name="fromDate">From date.</param>
 /// <param name="toDate">To date.</param>
 public void LoadData(DateTime fromDate, DateTime toDate)
 {
     this.TryExecute(
         () =>
     {
         IAnalyticsClient client = this.factory.Create <IAnalyticsClient>();
         this.View.SetPerformanceData(client.GetAllAppPerformances(fromDate, toDate));
     },
         null,
         true);
 }
Example #15
0
 /// <summary>
 /// Calls the server to immediately refresh the performance graphs
 /// </summary>
 public void SendGraphRefresh()
 {
     this.TryExecute(
         () =>
     {
         IAnalyticsClient client = this.factory.Create <IAnalyticsClient>();
         client.RequestPerformanceRefresh();
     },
         null,
         true);
 }
Example #16
0
        public MainMenu(IAnalyticsClient client)
        {
            _client = client;

            Title = "Nether Analytics Test Client - Main Menu";

            MenuItems.Add('1', new ConsoleMenuItem("Send Typed Game Messages ...", () => { new SendTypedGameEventMenu(_client).Show(); }));
            MenuItems.Add('2', new ConsoleMenuItem("Send Custom Game Message", SendCustomGameEvent));
            MenuItems.Add('3', new ConsoleMenuItem("Simulate moving game client ...", () => { new SimulateMovementMenu(_client).Show(); }));
            MenuItems.Add('4', new ConsoleMenuItem("USQL Script ...", () => new USQLJobMenu().Show()));
            MenuItems.Add('5', new ConsoleMenuItem("Results API Consumer ...", () => { new ResultsApiConsumerMenu().Show(); }));
            MenuItems.Add('6', new ConsoleMenuItem("Scheduler ...", () => { new SchedulerJobMenu().Show(); }));
        }
Example #17
0
        /// <summary>
        /// Shuts down the client. Application life cycle end is tracked.
        /// </summary>
        internal static void ShutDown()
        {
            if (client != null)
            {
                client.ShutDown();
            }

            IDisposable disposable = client as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
            client = null;
        }
Example #18
0
        protected async virtual Task OnTickAsync(IAnalyticsClient client, DateTime now, TimeSpan timeAlive, TimeSpan sinceLastTick, long tickNo)
        {
            if (_options.HeartBeatMessageInterval > TimeSpan.Zero && now - _lastHeartBeatMsgSent >= _options.HeartBeatMessageInterval.WithRandomDeviation())
            {
                // Send HeartBeat msg if enough time has passed since
                var msg = new HeartBeat
                {
                    GameSession = GameSession
                };

                await client.SendMessageAsync(msg, now);

                _lastHeartBeatMsgSent = now;
            }
        }
Example #19
0
        protected async virtual Task OnStartAsync(IAnalyticsClient client, DateTime now)
        {
            _lastHeartBeatMsgSent = now + TimeSpan.Zero.WithRandomDeviation(3);

            if (_options.SessionStartMessage)
            {
                var msg = new SessionStart
                {
                    GamerTag    = GamerTag,
                    GameSession = GameSession
                };

                await client.SendMessageAsync(msg, now);
            }
        }
        public AnalyticsAgent(RecognitionTaskQueue queue,
                              IAnalyticsClient analyticsClient,
                              ILoggerFactory loggerFactory,
                              IPhotoRepository photoRepository,
                              IRecognitionResultsRepository recognitionRepository,
                              IConfiguration configuration)
        {
            this.queue                 = queue;
            this.analyticsClient       = analyticsClient;
            this.photoRepository       = photoRepository;
            this.configuration         = configuration;
            this.recognitionRepository = recognitionRepository;
            logger = loggerFactory.CreateLogger <AnalyticsAgent>();

            PollingTask();
        }
        public Server(IIOService ioService, IViewClient viewClient, IViewClient streamingViewClient, IQueryClient queryClient, IQueryClient streamingQueryClient, ISearchClient searchClient,
                      IAnalyticsClient analyticsClient, INodeAdapter nodeAdapter, ITypeTranscoder transcoder, ConfigContextBase context)
        {
            if (ioService != null)
            {
                _ioService = ioService;
                _ioService.ConnectionPool.Owner = this;
            }

            _clientConfiguration = context.ClientConfig;
            _bucketConfiguration = context.ClientConfig.BucketConfigs[context.BucketConfig.Name];
            _timingEnabled       = _clientConfiguration.EnableOperationTiming;
            _typeTranscoder      = transcoder;
            _bucketConfig        = context.BucketConfig;

            //set all properties based off the nodes and nodeExt adapter
            LoadNodeAdapter(nodeAdapter);

            //View and query clients
            ViewClient            = viewClient;
            _streamingViewClient  = streamingViewClient;
            QueryClient           = queryClient;
            SearchClient          = searchClient;
            _streamingQueryClient = streamingQueryClient;
            AnalyticsClient       = analyticsClient;

            if (IsDataNode || IsQueryNode)
            {
                _lastIOErrorCheckedTime = DateTime.Now;

                //On initialization, data nodes are authenticated, so they can start in a down state.
                //If the node is down immediately start the timer, otherwise disable it.
                if (IsDataNode)
                {
                    _isDown = _ioService.ConnectionPool.InitializationFailed;
                }

                Log.Info("Initialization {0} for node {1}", _isDown ? "failed" : "succeeded", EndPoint);

                //timer and node status
                _heartBeatTimer = new Timer(_heartBeatTimer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
                if (_isDown)
                {
                    StartHeartbeatTimer();
                }
            }
        }
Example #22
0
        public SendTypedGameEventMenu(IAnalyticsClient client)
        {
            _client = client;

            Title = "Nether Analytics Test Client - Send Static Game Messages";

            var msgTypes = GetMessageTypes();
            var menuKey  = 'a';

            foreach (var msgType in msgTypes)
            {
                var msg = (ITypeVersionMessage)Activator.CreateInstance(msgType);
                MenuItems.Add(menuKey++,
                              new ConsoleMenuItem(
                                  $"{msg.Type}, {msg.Version}",
                                  () => TypedMessageSelected(msg)));
            }

            MenuItems.Add('1', new ConsoleMenuItem("Loop and send random messages", LoopAndSendRandom));
        }
Example #23
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        /// <param name="fromDate">From date.</param>
        /// <param name="toDate">To date.</param>
        public void LoadData(DateTime fromDate, DateTime toDate)
        {
            this.TryExecute(
                () =>
            {
                IAnalyticsClient client = this.factory.Create <IAnalyticsClient>();
                this.View.SetCpuPerformanceData(client.GetSystemCpuPerformance(fromDate, toDate));
            },
                null,
                true);

            this.TryExecute(
                () =>
            {
                IAnalyticsClient client = this.factory.Create <IAnalyticsClient>();
                this.View.SetMemoryPerformanceData(client.GetSystemMemoryPerformance(fromDate, toDate));
            },
                null,
                true);
        }
Example #24
0
 public static void Init(IAnalyticsClient client, DynamoModel model)
 {
     Analytics.Start(client);
 }
Example #25
0
 /// <summary>
 /// Starts the client when DynamoModel is created. This method initializes
 /// the Analytics service and application life cycle start is tracked.
 /// </summary>
 /// <param name="model">DynamoModel</param>
 internal static void Start(DynamoModel model)
 {
     client = new DynamoAnalyticsClient();
     client.Start(model);
     model.WorkspaceAdded += OnWorkspaceAdded;
 }
Example #26
0
 /// <summary>
 /// Starts analytics client
 /// </summary>
 /// <param name="client"></param>
 internal static void Start(IAnalyticsClient client)
 {
     Analytics.client = client;
     client.Start();
 }
Example #27
0
 /// <summary>
 /// Starts analytics client
 /// </summary>
 /// <param name="client"></param>
 internal static void Start(IAnalyticsClient client)
 {
     Analytics.client = client;
     client.Start();
 }
Example #28
0
 public GeoBot(IAnalyticsClient client, IGamerTagProvider gamerTagProvider, IGameSessionProvider gameSessionProvider, IGeoRouteProvider geoRouteProvider,
               NetherBotOptions options = null, GeoBotOptions geoOptions = null) : base(client, gamerTagProvider, gameSessionProvider, options)
 {
     _geoOptions       = geoOptions ?? new GeoBotOptions();
     _geoRouteProvider = geoRouteProvider;
 }
Example #29
0
 public static void Init(IAnalyticsClient client, DynamoModel model)
 {
     Analytics.client = client;
     client.Start(model);
 }
Example #30
0
 /// <summary>
 /// Starts the client when DynamoModel is created. This method initializes
 /// the Analytics service and application life cycle start is tracked.
 /// </summary>
 /// <param name="model">DynamoModel</param>
 internal static void Start(DynamoModel model)
 {
     client = new DynamoAnalyticsClient();
     client.Start(model);
     model.WorkspaceAdded += OnWorkspaceAdded;
 }
 internal static EndpointDiagnostics CreateEndpointHealth(string bucketName, DateTime createdAt, IAnalyticsClient client, EndPoint endPoint)
 {
     return(new EndpointDiagnostics
     {
         Type = ServiceType.Analytics,
         LastActivity = CalculateLastActivity(createdAt, client.LastActivity),
         Remote = endPoint?.ToString() ?? UnknownEndpointValue,
         State = client.LastActivity.HasValue ? ServiceState.Connected : ServiceState.New,
         Scope = bucketName
     });
 }
Example #32
0
        protected virtual Task OnStopAsync(IAnalyticsClient client, DateTime now, TimeSpan timeAlive)
        {
            _gamerTagProvider.ReturnGamerTag(GamerTag);

            return(Task.CompletedTask);
        }