コード例 #1
0
        public static IActionResult QueryByIdFromQueryString(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest request,
            [RethinkDb(
                 databaseName: "Demo_AspNetCore_Changefeed_RethinkDB",
                 tableName: "ThreadStats",
                 HostnameSetting = "RethinkDbHostname",
                 Id = "{Query.id}")] ThreadStats threadStats,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            if (threadStats == null)
            {
                log.LogInformation($"Thread stats not found (Query['id']: {request.Query["id"]}).");
                return(new NotFoundResult());
            }

            log.LogInformation($"Thread stats found (Query['id']: {request.Query["id"]}).");
            return(new ObjectResult(threadStats));
        }
コード例 #2
0
ファイル: NativeMemory.cs プロジェクト: syrjgc11006/ravendb
        internal static void UpdateMemoryStatsForThread(ThreadStats stats, long size)
        {
            var currentThreadValue = ThreadAllocations.Value;

            if (currentThreadValue == stats)
            {
                currentThreadValue.Allocations -= size;

                // fix allocations with releases from other threads
                var released = currentThreadValue.ReleasesFromOtherThreads;
                if (released > 0)
                {
                    currentThreadValue.Allocations -= released;
                    Interlocked.Add(ref currentThreadValue.ReleasesFromOtherThreads, -released);
                }
            }
            else
            {
                Interlocked.Add(ref stats.ReleasesFromOtherThreads, size);
            }
        }
コード例 #3
0
        public static byte *AllocateMemory(long size, out ThreadStats thread)
        {
            thread = ThreadAllocations.Value;

            // Allocating when there isn't enough commit charge available is dangerous, on Linux, the OOM
            // will try to kill us. On Windows, we might get into memory allocation failures that are not
            // fun, so let's try to avoid it explicitly.
            // This is not expected to be called frequently, since we are caching the memory used here

            MemoryInformation.AssertNotAboutToRunOutOfMemory(_minimumFreeCommittedMemory);

            try
            {
                var ptr = (byte *)Marshal.AllocHGlobal((IntPtr)size).ToPointer();
                thread.Allocations += size;
                return(ptr);
            }
            catch (OutOfMemoryException e)
            {
                return(ThrowFailedToAllocate(size, thread, e));
            }
        }
コード例 #4
0
        public ThreadStats GetSummary()
        {
            ThreadStats returnValue = new ThreadStats();

            try
            {
                foreach (var stat in _stats.Values)
                {
                    returnValue.Http100Responses += stat.Http100Responses;
                    returnValue.Http200Responses += stat.Http200Responses;
                    returnValue.Http300Responses += stat.Http300Responses;
                    returnValue.Http400Responses += stat.Http400Responses;
                    returnValue.Http500Responses += stat.Http500Responses;
                }
            }
            catch (Exception ex)
            {
                _logger?.LogWarning(new EventId(), ex, "Exception while calculating the health summary");
            }
            returnValue.UpTime = DateTime.UtcNow - _startedTime;
            return(returnValue);
        }
コード例 #5
0
        public ThreadCallbackManager(int threadCount)
        {
            if (threadCount <= 0)
            {
                throw new System.ArgumentOutOfRangeException(nameof(threadCount), $"Invalid thread count '{threadCount}'. Must be at least 1.");
            }

            ThreadCount = threadCount;
            threads     = new Thread[threadCount];
            processors  = new IThreadProcessor <In, Out> [threadCount];
            Statistics  = new ThreadStats[threadCount];

            const int HISTORY_COUNT = 20;

            for (int i = 0; i < threadCount; i++)
            {
                Thread t = new Thread(RunThread);
                t.Name        = $"Worker Thread {i}";
                threads[i]    = t;
                Statistics[i] = new ThreadStats(HISTORY_COUNT);

                processors[i] = this.CreateProcessor(i);
            }
        }
コード例 #6
0
 private static byte *ThrowFailedToAllocate(long size, ThreadStats thread, OutOfMemoryException e)
 {
     throw new OutOfMemoryException($"Failed to allocate additional {new Size(size, SizeUnit.Bytes)} to already allocated {new Size(thread.Allocations, SizeUnit.Bytes)}", e);
 }
コード例 #7
0
ファイル: NativeMemory.cs プロジェクト: otgoo0603/ravendb
 public static byte *AllocateMemory(long size, out ThreadStats thread)
 {
     thread              = ThreadAllocations.Value;
     thread.Allocations += size;
     return((byte *)Marshal.AllocHGlobal((IntPtr)size).ToPointer());
 }
コード例 #8
0
        public Task InsertThreadStatsAsync(ThreadStats threadStats)
        {
            _rethinkDbSingleton.Db(DATABASE_NAME).Table(THREAD_STATS_TABLE_NAME).Insert(threadStats).Run(_rethinkDbConnection);

            return(Task.CompletedTask);
        }
 public Task InsertThreadStatsAsync(ThreadStats threadStats)
 {
     return(ThreadStatsContainer.CreateItemAsync <ThreadStatsItem>(new ThreadStatsItem(threadStats), _partitionKey));
 }
コード例 #10
0
 public Task InsertThreadStatsAsync(ThreadStats threadStats)
 {
     return(_threadStatsCollection.InsertOneAsync(new MongoDbThreadStats(threadStats)));
 }
コード例 #11
0
 public MongoDbThreadStats(ThreadStats threadStats)
 {
     WorkerThreads = threadStats.WorkerThreads;
     MinThreads    = threadStats.MinThreads;
     MaxThreads    = threadStats.MaxThreads;
 }
コード例 #12
0
 public Task InsertThreadStatsAsync(ThreadStats threadStats)
 {
     return _documentClientSingleton.CreateDocumentAsync(_threadStatsCollectionUri, threadStats);
 }