@return A TSMeta object loaded with UIDMetas if successful @throws HBaseException if there was a storage issue @throws JSONException if the data was corrupted @throws NoSuchUniqueName if one of the UIDMeta objects does not exist
(final TSMeta meta)
| 897 | * @throws NoSuchUniqueName if one of the UIDMeta objects does not exist |
| 898 | */ |
| 899 | @Override |
| 900 | public Deferred<TSMeta> call(final TSMeta meta) throws Exception { |
| 901 | if (meta == null) { |
| 902 | return Deferred.fromResult(null); |
| 903 | } |
| 904 | |
| 905 | // split up the tags |
| 906 | final List<byte[]> tags = UniqueId.getTagsFromTSUID(tsuid); |
| 907 | meta.tags = new ArrayList<UIDMeta>(tags.size()); |
| 908 | |
| 909 | // initialize with empty objects, otherwise the "set" operations in |
| 910 | // the callback won't work. Each UIDMeta will be given an index so that |
| 911 | // the callback can store it in the proper location |
| 912 | for (int i = 0; i < tags.size(); i++) { |
| 913 | meta.tags.add(new UIDMeta()); |
| 914 | } |
| 915 | |
| 916 | // list of fetch calls that we can wait on for completion |
| 917 | ArrayList<Deferred<Object>> uid_group = |
| 918 | new ArrayList<Deferred<Object>>(tags.size() + 1); |
| 919 | |
| 920 | /** |
| 921 | * Callback for each getUIDMeta request that will place the resulting |
| 922 | * meta data in the proper location. The meta should always be either an |
| 923 | * actual stored value or a default. On creation, this callback will have |
| 924 | * an index to associate the UIDMeta with the proper location. |
| 925 | */ |
| 926 | final class UIDMetaCB implements Callback<Object, UIDMeta> { |
| 927 | |
| 928 | final int index; |
| 929 | |
| 930 | public UIDMetaCB(final int index) { |
| 931 | this.index = index; |
| 932 | } |
| 933 | |
| 934 | /** |
| 935 | * @return null always since we don't care about the result, just that |
| 936 | * the callback has completed. |
| 937 | */ |
| 938 | @Override |
| 939 | public Object call(final UIDMeta uid_meta) throws Exception { |
| 940 | if (index < 0) { |
| 941 | meta.metric = uid_meta; |
| 942 | } else { |
| 943 | meta.tags.set(index, uid_meta); |
| 944 | } |
| 945 | return null; |
| 946 | } |
| 947 | |
| 948 | } |
| 949 | |
| 950 | // for the UIDMeta indexes: -1 means metric, >= 0 means tag. Each |
| 951 | // getUIDMeta request must be added to the uid_group array so that we |
| 952 | // can wait for them to complete before returning the TSMeta object, |
| 953 | // otherwise the caller may get a TSMeta with missing UIDMetas |
| 954 | uid_group.add(UIDMeta.getUIDMeta(tsdb, UniqueIdType.METRIC, |
| 955 | tsuid.substring(0, TSDB.metrics_width() * 2)).addCallback( |
| 956 | new UIDMetaCB(-1))); |
nothing calls this directly
no test coverage detected