示例#1
0
        public void Should_NotBeEqual_WhenCustomMetricEqualsNodeMetric()
        {
            var     nodeMetric      = new NodeMetric(NodeMetric.Counters.AuthenticationErrors.Name);
            IMetric nodeMetricBase  = nodeMetric;
            IMetric nodeMetricBase2 = nodeMetric;

            var testMetric = new TestMetric {
                Name = NodeMetric.Counters.AuthenticationErrors.Name
            };
            IMetric testMetricBase  = testMetric;
            IMetric testMetricBase2 = testMetric;

            Assert.IsFalse(testMetric.Equals(nodeMetric));
            Assert.IsFalse(nodeMetric.Equals(testMetric));

            Assert.IsFalse(testMetric.Equals(nodeMetricBase));
            Assert.IsFalse(nodeMetricBase.Equals(testMetric));

            Assert.IsFalse(testMetric.Equals(nodeMetricBase2));
            Assert.IsFalse(nodeMetricBase2.Equals(testMetric));

            Assert.IsFalse(testMetricBase.Equals(nodeMetric));
            Assert.IsFalse(nodeMetric.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase.Equals(nodeMetricBase));
            Assert.IsFalse(nodeMetricBase.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase.Equals(nodeMetricBase2));
            Assert.IsFalse(nodeMetricBase2.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase2.Equals(nodeMetric));
            Assert.IsFalse(nodeMetric.Equals(testMetricBase2));

            Assert.IsFalse(testMetricBase2.Equals(nodeMetricBase));
            Assert.IsFalse(nodeMetricBase.Equals(testMetricBase2));

            Assert.IsFalse(testMetricBase2.Equals(nodeMetricBase2));
            Assert.IsFalse(nodeMetricBase2.Equals(testMetricBase2));
        }
示例#2
0
        /// <inheritdoc />
        public TMetricType GetNodeMetric <TMetricType>(Host host, NodeMetric nodeMetric) where TMetricType : class, IDriverMetric
        {
            if (!_nodeMetricsCollection.TryGetValue(host, out var nodeMetrics))
            {
                throw new ArgumentException("Could not retrieve metrics for this host: " + host.Address);
            }

            var metric = nodeMetrics.MetricsRegistry.GetMetric(nodeMetric);

            if (metric == null)
            {
                throw new ArgumentException("Could not find the provided metric: ", nodeMetric.Name);
            }

            if (!(metric is TMetricType typedMetric))
            {
                throw new ArgumentException(
                          $"Node Metric {nodeMetric.Name} is not of type {typeof(TMetricType).Name}. Its type is {metric.GetType().Name}.");
            }

            return(typedMetric);
        }
示例#3
0
 /// <summary>
 /// Utility method that wraps a call to <see cref="IDriverMetrics.GetNodeMetric{TMetricType}"/> with the appropriate AppMetrics based timer type
 /// as the type parameter. For more information see the API docs of <see cref="IDriverMetrics.GetNodeMetric{TMetricType}"/>.
 /// </summary>
 public static IAppMetricsTimer GetNodeTimer(this IDriverMetrics driverMetrics, Host host, NodeMetric nodeMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, host, nodeMetric);
     return(driverMetrics.GetNodeMetric <IAppMetricsTimer>(host, nodeMetric));
 }
示例#4
0
 private static void ThrowIfNull(IDriverMetrics driverMetrics, Host host, NodeMetric nodeMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, nameof(driverMetrics));
     MetricsExtensions.ThrowIfNull(host, nameof(host));
     MetricsExtensions.ThrowIfNull(nodeMetric, nameof(nodeMetric));
 }
示例#5
0
        protected virtual void Setup(SukiSchemaInfo info)
        {
            _id        = info._id;
            name       = info.SchemaName;
            resolution = info.SchemaResolution;
            device     = info.SchemaDevice;
            metric     = info.SchemaMetric;

            if (null != info.CalculationInfo)
            {
                SetCalculationFunction(info.CalculationInfo.calculationOperator, info.CalculationInfo.vectorOperand);
            }
            if (null != info.ReductionInfo)
            {
                SetReductionFunction(info.ReductionInfo.reductionOperator, info.ReductionInfo.vectorOperand);
            }
            if (null != info.ConditionInfo)
            {
                SetConditionFunction(info.ConditionInfo.conditionOperator, info.ConditionInfo.scalarOperand, info.ConditionInfo.extentPercentage);
            }
            if (null != info.FloatBoundsInfo)
            {
                SetFloatBoundsFunction(info.FloatBoundsInfo.lowBounds, info.FloatBoundsInfo.highBounds, info.FloatBoundsInfo.useExtents, info.FloatBoundsInfo.reverse);
            }
            if (null != info.Vector2BoundsInfo)
            {
                SetVector2BoundsFunction(info.Vector2BoundsInfo.lowBounds, info.Vector2BoundsInfo.highBounds, info.Vector2BoundsInfo.useExtents, info.Vector2BoundsInfo.reverse);
            }
            if (null != info.Vector3BoundsInfo)
            {
                SetVector3BoundsFunction(info.Vector3BoundsInfo.lowBounds, info.Vector3BoundsInfo.highBounds);
            }

            switch (info.SchemaResolution)
            {
            case InputResolution.Trigger:
                data.CreateTrigger(name, false);
                break;

            case InputResolution.Signal:
                data.CreateSignal(name, false);
                break;

            case InputResolution.Range:
                data.CreateRange(name, 0.5f);
                break;

            case InputResolution.Location2D:
                data.CreateLocation2D(name, Vector2.zero);
                break;

            case InputResolution.Location3D:
                data.CreateLocation3D(name, Vector3.zero);
                break;

            default:
                throw new System.Exception("Invalid Schema Resolution");
            }

            GetSchemaExtentsFromServer();
        }