public CumulativeSum() { /* * We support both LongAdder and LongMaxUpdater in a bucket but don't want the memory allocation * of all types for each so we only allocate the objects if the HystrixRollingNumberEvent matches * the correct type - though we still have the allocation of empty arrays to the given length * as we want to keep using the type.ordinal() value for fast random access. */ // initialize the array of LongAdders _adderForCounterType = new LongAdder[HystrixRollingNumberEventHelper.Values.Count]; foreach (var type in HystrixRollingNumberEventHelper.Values) { if (HystrixRollingNumberEventHelper.IsCounter(type)) { _adderForCounterType[(int)type] = new LongAdder(); } } _updaterForCounterType = new LongMaxUpdater[HystrixRollingNumberEventHelper.Values.Count]; foreach (var type in HystrixRollingNumberEventHelper.Values) { if (HystrixRollingNumberEventHelper.IsMaxUpdater(type)) { _updaterForCounterType[(int)type] = new LongMaxUpdater(); // initialize to 0 otherwise it is Long.MIN_VALUE _updaterForCounterType[(int)type].Update(0); } } }
public async Task TestHandleResponseAsync() { using (MemoryStream blobContent = new MemoryStream(Encoding.UTF8.GetBytes("some BLOB content"))) { BlobDescriptor descriptor = await Digests.ComputeDigestAsync(blobContent).ConfigureAwait(false); DescriptorDigest testBlobDigest = descriptor.GetDigest(); blobContent.Position = 0; using (HttpResponseMessage mockResponse = new HttpResponseMessage() { Content = new StringContent("some BLOB content") }) { LongAdder byteCount = new LongAdder(); BlobPuller blobPuller = new BlobPuller( fakeRegistryEndpointRequestProperties, testBlobDigest, layerOutputStream, size => Assert.AreEqual("some BLOB content".Length, size), byteCount.Add); await blobPuller.HandleResponseAsync(mockResponse).ConfigureAwait(false); Assert.AreEqual( "some BLOB content", Encoding.UTF8.GetString(layerContentOutputStream.ToArray())); Assert.AreEqual(testBlobDigest, layerOutputStream.ComputeDigest().GetDigest()); Assert.AreEqual("some BLOB content".Length, byteCount.Sum()); } } }
internal HystrixCommandMetrics(string opName, string serviceName, string fullServiceName, string metricPrefix, IHystrixCommandProperties properties) { this.serviceName = serviceName; this.opName = opName; this.properties = properties; this.fullServiceName = fullServiceName; this.counter = new HystrixRollingNumber(properties.MetricsRollingStatisticalWindowInMilliseconds, properties.MetricsRollingStatisticalWindowBuckets); this.successCounter = new LongAdder(); this.frameworkErrorCounter = new LongAdder(); this.validationErrorCounter = new LongAdder(); this.serviceErrorCounter = new LongAdder(); this.shortCircuitCounter = new LongAdder(); this.threadPoolRejectedCounter = new LongAdder(); this.timeoutCounter = new LongAdder(); int timeWindowInSeconds = properties.MetricsIntegerBufferTimeWindowInSeconds.Get(); int bucketTimeWindowInSeconds = properties.MetricsIntegerBufferBucketTimeWindowInSeconds.Get(); int bucketSizeLimit = properties.MetricsIntegerBufferBucketSizeLimit.Get(); this.executionOperationLatencyBuffer = new HystrixIntegerCircularBuffer(timeWindowInSeconds, bucketTimeWindowInSeconds, bucketSizeLimit); this.requestLatencyBuffer = new HystrixIntegerCircularBuffer(timeWindowInSeconds, bucketTimeWindowInSeconds, bucketSizeLimit); MetricNameEventDistribution = metricPrefix + ".event.distribution"; MetricNameConcurrentExecutionCount = metricPrefix + ".execution.concurrency"; MetricNameRequestCount = metricPrefix + ".request.count"; MetricNameLatency = metricPrefix + ".request.latency"; MetricNameLatencyDistribution = metricPrefix + ".request.latency.distribution"; MetricNameLatencyPercentile = metricPrefix + ".request.latency.percentile"; }
internal ExhaustingEntityImporterRunnable(StageControl control, InputIterator data, EntityImporter visitor, LongAdder roughEntityCountProgress) { this._control = control; this._data = data; this._visitor = visitor; this._roughEntityCountProgress = roughEntityCountProgress; }
public async Task TestPullAsync() { // Pulls the busybox image. localRegistry.PullAndPushToLocal("busybox", "busybox"); RegistryClient registryClient = RegistryClient.CreateFactory(EventHandlers.NONE, "localhost:5000", "busybox") .SetAllowInsecureRegistries(true) .NewRegistryClient(); V21ManifestTemplate manifestTemplate = await registryClient.PullManifestAsync <V21ManifestTemplate>("latest").ConfigureAwait(false); DescriptorDigest realDigest = manifestTemplate.GetLayerDigests().First(); // Pulls a layer BLOB of the busybox image. LongAdder totalByteCount = new LongAdder(); LongAdder expectedSize = new LongAdder(); IBlob pulledBlob = registryClient.PullBlob( realDigest, size => { Assert.AreEqual(0, expectedSize.Sum()); expectedSize.Add(size); }, totalByteCount.Add); BlobDescriptor blobDescriptor = await pulledBlob.WriteToAsync(Stream.Null).ConfigureAwait(false); Assert.AreEqual(realDigest, blobDescriptor.GetDigest()); Assert.IsTrue(expectedSize.Sum() > 0); Assert.AreEqual(expectedSize.Sum(), totalByteCount.Sum()); }
internal SendDownstream(long ticket, object batch, LongAdder downstreamIdleTime) { this._downstreamIdleTime = downstreamIdleTime; TicketedBatch b = new TicketedBatch(ticket, batch); _head = b; _tail = b; }
internal ControllableStep(string name, LongAdder progress, Configuration config, params StatsProvider[] additionalStatsProviders) { this.NameConflict = name; this.Progress = progress; this.BatchSize = config.BatchSize(); // just to be able to report correctly StatsProviders.Add(this); StatsProviders.addAll(Arrays.asList(additionalStatsProviders)); }
private static void IncrementCounter(LongAdder readCount, LongAdder writeCount, bool write) { if (write) { writeCount.increment(); } else { readCount.increment(); } }
public async Task TestWriter_getContentAsync() { LongAdder byteCount = new LongAdder(); BlobHttpContent body = testBlobPusher.CreateWriter(mockURL, byteCount.Add).GetContent(); Assert.IsNotNull(body); Assert.AreEqual("application/octet-stream", body.Headers.ContentType.MediaType); using (MemoryStream byteArrayOutputStream = new MemoryStream()) { await body.CopyToAsync(byteArrayOutputStream).ConfigureAwait(false); Assert.AreEqual( TEST_BLOB_CONTENT, Encoding.UTF8.GetString(byteArrayOutputStream.ToArray())); Assert.AreEqual(TEST_BLOB_CONTENT.Length, byteCount.Sum()); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static long importData(String title, int numRunners, InputIterable data, org.neo4j.unsafe.impl.batchimport.store.BatchingNeoStores stores, System.Func<EntityImporter> visitors, org.neo4j.unsafe.impl.batchimport.staging.ExecutionMonitor executionMonitor, org.neo4j.unsafe.impl.batchimport.stats.StatsProvider memoryStatsProvider) throws java.io.IOException private static long ImportData(string title, int numRunners, InputIterable data, BatchingNeoStores stores, System.Func <EntityImporter> visitors, ExecutionMonitor executionMonitor, StatsProvider memoryStatsProvider) { LongAdder roughEntityCountProgress = new LongAdder(); ExecutorService pool = Executors.newFixedThreadPool(numRunners, new NamedThreadFactory(title + "Importer")); IoMonitor writeMonitor = new IoMonitor(stores.IoTracer); ControllableStep step = new ControllableStep(title, roughEntityCountProgress, Configuration.DEFAULT, writeMonitor, memoryStatsProvider); StageExecution execution = new StageExecution(title, null, Configuration.DEFAULT, Collections.singletonList(step), 0); long startTime = currentTimeMillis(); using (InputIterator dataIterator = data.GetEnumerator()) { executionMonitor.Start(execution); for (int i = 0; i < numRunners; i++) { pool.submit(new ExhaustingEntityImporterRunnable(execution, dataIterator, visitors(), roughEntityCountProgress)); } pool.shutdown(); long nextWait = 0; try { while (!pool.awaitTermination(nextWait, TimeUnit.MILLISECONDS)) { executionMonitor.Check(execution); nextWait = executionMonitor.NextCheckTime() - currentTimeMillis(); } } catch (InterruptedException e) { Thread.CurrentThread.Interrupt(); throw new IOException(e); } } execution.AssertHealthy(); step.MarkAsCompleted(); writeMonitor.Stop(); executionMonitor.End(execution, currentTimeMillis() - startTime); execution.AssertHealthy(); return(roughEntityCountProgress.sum()); }
internal MergeTask(MergeThread mergeThread, LongAdder taskCounter) { this.MergeThread = mergeThread; this.TaskCounter = taskCounter; }