@Override public Updater<Update, MetricType> update() { return new Updater<>((u) -> new MetricType(u.getName(), getPath(), getIdentityHash(), getContentHash(), getSyncHash(), valueOrDefault(u.unit, this.unit), metricDataType, u.getProperties(), valueOrDefault(u.getCollectionInterval(), collectionInterval))); }
/** * This will disappear in due time. * * @deprecated use {@link #getMetricDataType()} insteads * @return the metric data type */ @Deprecated @JsonSerialize(using = ToStringSerializer.class) public MetricDataType getType() { return getMetricDataType(); }
@Override public B visitMetricType(MetricType type, Void parameter) { return (B) fillCommon(type, MetricType.Blueprint.builder(type.getMetricDataType())) .withInterval(type.getCollectionInterval()).withUnit(type.getUnit()).build(); }
@Override protected EntityAndPendingNotifications<BE, MetricType> wireUpNewEntity(BE entity, MetricType.Blueprint blueprint, CanonicalPath parentPath, BE parent, Transaction<BE> tx) { tx.update(entity, MetricType.Update.builder().withUnit(blueprint.getUnit()).build()); MetricType metricType = new MetricType(blueprint.getName(), parentPath.extend(MetricType.SEGMENT_TYPE, tx.extractId(entity)).get(), null, null, null, blueprint.getUnit(), blueprint.getMetricDataType(), blueprint.getProperties(), blueprint.getCollectionInterval()); return new EntityAndPendingNotifications<>(entity, metricType, emptyList()); }
/** * Provides an access interface for inspecting given metric type. * * @param metricType the metric type to steer to. * @return the access interface to the metric type */ default MetricTypes.Single inspect(MetricType metricType) throws EntityNotFoundException { return inspect(metricType.getPath(), MetricTypes.Single.class); }
private static <BE> void preUpdate(TraversalContext<BE, ?> context, BE entity, MetricType.Update update, Transaction<BE> tx) { MetricType mt = tx.convert(entity, MetricType.class); if (mt.getUnit() == update.getUnit()) { //k, this is the only updatable thing that influences metadata packs, so if it is equal, we're ok. return; } if (isInMetadataPack(entity, tx)) { throw new IllegalArgumentException("Cannot update a metric type that is a part of metadata pack."); } }
break; case metricType: e = new MetricType(extractCanonicalPath(v), extractIdentityHash(v), extractContentHash(v), extractSyncHash(v), MetricUnit.fromDisplayName((String) v.property(Constants.Property.__unit.name()).value()),
@Override public B visitMetric(Metric metric, Void parameter) { //we don't want to have tenant ID and all that jazz influencing the hash, so always use //a relative path RelativePath metricTypePath = metric.getType().getPath().relativeTo(metric.getPath()); return (B) fillCommon(metric, Metric.Blueprint.builder()) .withInterval(metric.getCollectionInterval()) .withMetricTypePath(metricTypePath.toString()).build(); }
/** * This will disappear in due time. * * @deprecated use {@link #getMetricDataType()} insteads * @return the metric data type */ @Deprecated @JsonSerialize(using = ToStringSerializer.class) public MetricDataType getType() { return getMetricDataType(); }