public TopicImpl(int domain, string name, string type, QosPolicy[] qos) { Domain = domain; Name = name; Type = type; QoS = qos; }
private void CheckForInconsistencies(QosPolicy policy) { #if TODO if (policy instanceof QosDeadline) { // --- DEADLINE --- QosTimeBasedFilter tbf = (QosTimeBasedFilter) policies.get(typeof(QosTimeBasedFilter)); if (tbf == null) { tbf = QosTimeBasedFilter.defaultTimeBasedFilter(); } QosDeadline dl = (QosDeadline) policy; if (dl.getPeriod().asMillis() < tbf.getMinimumSeparation().asMillis()) { throw new InconsistentPolicy("DEADLINE.period(" + dl.getPeriod() + ") must be >= TIME_BASED_FILTER.minimum_separation(" + tbf.getMinimumSeparation() + ")"); } } else if (policy instanceof QosTimeBasedFilter) { // --- TIME_BASED_FILTER --- QosDeadline dl = (QosDeadline) policies.get(typeof(QosDeadline)); if (dl == null) { dl = QosDeadline.defaultDeadline(); } QosTimeBasedFilter tbf = (QosTimeBasedFilter) policy; if (dl.getPeriod().asMillis() < tbf.getMinimumSeparation().asMillis()) { throw new InconsistentPolicy("DEADLINE.period(" + dl.getPeriod() + ") must be >= TIME_BASED_FILTER.minimum_separation(" + tbf.getMinimumSeparation() + ")"); } } else if (policy instanceof QosHistory) { // --- HISTORY --- QosResourceLimits rl = (QosResourceLimits) policies.get(typeof(QosResourceLimits)); if (rl == null) { rl = QosResourceLimits.defaultResourceLimits(); } QosHistory h = (QosHistory) policy; if (rl.getMaxSamplesPerInstance() != -1 && rl.getMaxSamplesPerInstance() < h.getDepth()) { throw new InconsistentPolicy("HISTORY.depth must be <= RESOURCE_LIMITS.max_samples_per_instance"); } } else if (policy instanceof QosResourceLimits) { // --- RESOURCE_LIMITS --- QosResourceLimits rl = (QosResourceLimits) policy; if (rl.getMaxSamples() < rl.getMaxSamplesPerInstance()) { throw new InconsistentPolicy( "RESOURCE_LIMITS.max_samples must be >= RESOURCE_LIMITS.max_samples_per_instance"); } QosHistory h = (QosHistory) policies.get(typeof(QosHistory)); if (h == null) { h = QosHistory.defaultHistory(); } if (rl.getMaxSamplesPerInstance() != -1 && rl.getMaxSamplesPerInstance() < h.getDepth()) { throw new InconsistentPolicy("HISTORY.depth must be <= RESOURCE_LIMITS.max_samples_per_instance"); } #endif } }
public void TryUrlMatching_Fail(QosUrlTemplate urlTemplate, string httpMethod, string url) { var policy = new QosPolicy("Foo") { UrlTemplates = new[] { urlTemplate } }; var description = new PolicyDescription(policy); var success = description.TryUrlMatching(httpMethod, new PathString(url), new RouteValueDictionary(), out var routeTemplate); Assert.False(success); Assert.Null(routeTemplate); }
private IEnumerable <QosPolicy> BuildPolicies( QosQuotaOptions options, IEnumerable <IQosPolicyKeyEvaluatorProvider> keyEvaluatorProviders, IServiceProvider serviceProvider) { if (options?.Policies != null) { foreach (var option in options.Policies) { var policy = new QosPolicy(option.Key) { Order = -1100, UrlTemplates = option.Value.UrlTemplates?.Select(u => QosUrlTemplate.Parse(u)), Key = keyEvaluatorProviders.Create(option.Value.Key), Gate = CreateGate(option.Value.Period, option.Value.MaxCount * 1024, option.Value.Distributed, serviceProvider) }; yield return(policy); } } }
public PolicyDescription(QosPolicy policy) { Policy = policy; _templates = BuilderTemplates().ToArray(); }
/* * Sets a given QosPolicy. Old value will be overridden. * * @param policy * QosPolicy to set. * @throws InconsistentPolicy * is thrown if there is some inconsistent value with the policy */ public void SetPolicy(QosPolicy policy) { CheckForInconsistencies(policy); policies.Add(policy.GetType(), policy); }
/// <summary> /// Adds a QosPolicy. /// </summary> /// <param name="policy"></param> protected void addQosPolicy(QosPolicy policy) { try { qos.SetPolicy(policy); } catch (InconsistentPolicy e) { inconsistenPolicies.Add(policy); } }