Resolves the metric and tags (if set) to their UIDs, setting the local arrays. @return A deferred to wait on or catch exceptions in @throws IllegalArgumentException if the metric is empty || null or the tag list is null.
()
| 678 | * tag list is null. |
| 679 | */ |
| 680 | private Deferred<Object> resolveMetric() { |
| 681 | if (metric == null || metric.isEmpty()) { |
| 682 | throw new IllegalArgumentException("The metric cannot be empty"); |
| 683 | } |
| 684 | if (tags == null) { |
| 685 | throw new IllegalArgumentException("Tags cannot be null or empty " |
| 686 | + "when getting a TSUID"); |
| 687 | } |
| 688 | |
| 689 | class TagsCB implements Callback<Object, ArrayList<byte[]>> { |
| 690 | @Override |
| 691 | public Object call(final ArrayList<byte[]> tag_list) throws Exception { |
| 692 | setTagUIDs(tag_list); |
| 693 | return null; |
| 694 | } |
| 695 | @Override |
| 696 | public String toString() { |
| 697 | return "Tag resolution callback"; |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | class MetricCB implements Callback<Deferred<Object>, byte[]> { |
| 702 | @Override |
| 703 | public Deferred<Object> call(final byte[] uid) |
| 704 | throws Exception { |
| 705 | setMetricUID(uid); |
| 706 | if (tags.isEmpty()) { |
| 707 | setTagUIDs(new ArrayList<byte[]>(0)); |
| 708 | return null; |
| 709 | } |
| 710 | return Tags.resolveAllAsync(tsdb, tags).addCallback(new TagsCB()); |
| 711 | } |
| 712 | @Override |
| 713 | public String toString() { |
| 714 | return "Metric resolution callback"; |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | return tsdb.getUIDAsync(UniqueIdType.METRIC, metric) |
| 719 | .addCallbackDeferring(new MetricCB()); |
| 720 | } |
| 721 | |
| 722 | /** @param tsuid The TSUID to store */ |
| 723 | private void setTSUID(final byte[] tsuid) { |
no test coverage detected