All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentracing.contrib.redis.redisson.TracingRSortedSet Maven / Gradle / Ivy

There is a newer version: 0.1.16
Show newest version
/*
 * Copyright 2017-2019 The OpenTracing Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package io.opentracing.contrib.redis.redisson;

import static io.opentracing.contrib.redis.common.TracingHelper.nullable;

import io.opentracing.Span;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.redisson.api.RFuture;
import org.redisson.api.RSortedSet;
import org.redisson.api.mapreduce.RCollectionMapReduce;

public class TracingRSortedSet extends TracingRObject implements RSortedSet {
  private final RSortedSet set;
  private final TracingRedissonHelper tracingRedissonHelper;

  public TracingRSortedSet(RSortedSet set, TracingRedissonHelper tracingRedissonHelper) {
    super(set, tracingRedissonHelper);
    this.set = set;
    this.tracingRedissonHelper = tracingRedissonHelper;
  }

  @Override
  public  RCollectionMapReduce mapReduce() {
    return new TracingRCollectionMapReduce<>(set.mapReduce(), tracingRedissonHelper);
  }

  @Override
  public Collection readAll() {
    Span span = tracingRedissonHelper.buildSpan("readAll", set);
    return tracingRedissonHelper.decorate(span, set::readAll);
  }

  @Override
  public RFuture> readAllAsync() {
    Span span = tracingRedissonHelper.buildSpan("readAllAsync", set);
    return tracingRedissonHelper.prepareRFuture(span, set::readAllAsync);
  }

  @Override
  public RFuture addAsync(V value) {
    Span span = tracingRedissonHelper.buildSpan("addAsync", set);
    span.setTag("value", nullable(value));
    return tracingRedissonHelper.prepareRFuture(span, () -> set.addAsync(value));
  }

  @Override
  public RFuture removeAsync(Object value) {
    Span span = tracingRedissonHelper.buildSpan("removeAsync", set);
    span.setTag("value", nullable(value));
    return tracingRedissonHelper.prepareRFuture(span, () -> set.removeAsync(value));
  }

  @Override
  public boolean trySetComparator(Comparator comparator) {
    Span span = tracingRedissonHelper.buildSpan("trySetComparator", set);
    span.setTag("comparator", nullable(comparator));
    return tracingRedissonHelper.decorate(span, () -> set.trySetComparator(comparator));
  }

  @Override
  public Comparator comparator() {
    return set.comparator();
  }

  @Override
  public SortedSet subSet(V fromElement, V toElement) {
    Span span = tracingRedissonHelper.buildSpan("subSet", set);
    span.setTag("fromElement", nullable(fromElement));
    span.setTag("toElement", nullable(toElement));
    return tracingRedissonHelper.decorate(span, () -> set.subSet(fromElement, toElement));
  }

  @Override
  public SortedSet headSet(V toElement) {
    Span span = tracingRedissonHelper.buildSpan("headSet", set);
    span.setTag("toElement", nullable(toElement));
    return tracingRedissonHelper.decorate(span, () -> set.headSet(toElement));
  }

  @Override
  public SortedSet tailSet(V fromElement) {
    Span span = tracingRedissonHelper.buildSpan("tailSet", set);
    span.setTag("fromElement", nullable(fromElement));
    return tracingRedissonHelper.decorate(span, () -> set.tailSet(fromElement));
  }

  @Override
  public V first() {
    Span span = tracingRedissonHelper.buildSpan("first", set);
    return tracingRedissonHelper.decorate(span, set::first);
  }

  @Override
  public V last() {
    Span span = tracingRedissonHelper.buildSpan("last", set);
    return tracingRedissonHelper.decorate(span, set::last);
  }

  @Override
  public Spliterator spliterator() {
    return set.spliterator();
  }

  @Override
  public int size() {
    Span span = tracingRedissonHelper.buildSpan("size", set);
    return tracingRedissonHelper.decorate(span, set::size);
  }

  @Override
  public boolean isEmpty() {
    Span span = tracingRedissonHelper.buildSpan("isEmpty", set);
    return tracingRedissonHelper.decorate(span, set::isEmpty);
  }

  @Override
  public boolean contains(Object o) {
    Span span = tracingRedissonHelper.buildSpan("contains", set);
    span.setTag("object", nullable(o));
    return tracingRedissonHelper.decorate(span, () -> set.contains(o));
  }

  @Override
  public Iterator iterator() {
    return set.iterator();
  }

  @Override
  public Object[] toArray() {
    Span span = tracingRedissonHelper.buildSpan("toArray", set);
    return tracingRedissonHelper.decorate(span, () -> set.toArray());
  }

  @Override
  public  T[] toArray(T[] a) {
    Span span = tracingRedissonHelper.buildSpan("toArray", set);
    return tracingRedissonHelper.decorate(span, () -> set.toArray(a));
  }

  @Override
  public boolean add(V v) {
    Span span = tracingRedissonHelper.buildSpan("add", set);
    span.setTag("element", nullable(v));
    return tracingRedissonHelper.decorate(span, () -> set.add(v));
  }

  @Override
  public boolean remove(Object o) {
    Span span = tracingRedissonHelper.buildSpan("remove", set);
    span.setTag("object", nullable(o));
    return tracingRedissonHelper.decorate(span, () -> set.remove(o));
  }

  @Override
  public boolean containsAll(Collection c) {
    Span span = tracingRedissonHelper.buildSpan("containsAll", set);
    return tracingRedissonHelper.decorate(span, () -> set.containsAll(c));
  }

  @Override
  public boolean addAll(Collection c) {
    Span span = tracingRedissonHelper.buildSpan("addAll", set);
    return tracingRedissonHelper.decorate(span, () -> set.addAll(c));
  }

  @Override
  public boolean retainAll(Collection c) {
    Span span = tracingRedissonHelper.buildSpan("retainAll", set);
    return tracingRedissonHelper.decorate(span, () -> set.retainAll(c));
  }

  @Override
  public boolean removeAll(Collection c) {
    Span span = tracingRedissonHelper.buildSpan("removeAll", set);
    return tracingRedissonHelper.decorate(span, () -> set.removeAll(c));
  }

  @Override
  public void clear() {
    Span span = tracingRedissonHelper.buildSpan("clear", set);
    tracingRedissonHelper.decorate(span, set::clear);
  }

  @Override
  public boolean removeIf(Predicate filter) {
    Span span = tracingRedissonHelper.buildSpan("removeIf", set);
    span.setTag("filter", nullable(filter));
    return tracingRedissonHelper.decorate(span, () -> set.removeIf(filter));
  }

  @Override
  public Stream stream() {
    return set.stream();
  }

  @Override
  public Stream parallelStream() {
    return set.parallelStream();
  }

  @Override
  public void forEach(Consumer action) {
    Span span = tracingRedissonHelper.buildSpan("forEach", set);
    span.setTag("action", nullable(action));
    tracingRedissonHelper.decorate(span, () -> set.forEach(action));
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy