| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ReBucket |
|
| 1.0;1 | ||||
| ReBucket$1 |
|
| 1.0;1 | ||||
| ReBucket$1$1 |
|
| 1.0;1 | ||||
| ReBucket$1$1$AjcClosure1 |
|
| 1.0;1 | ||||
| ReBucket$1$1$AjcClosure3 |
|
| 1.0;1 | ||||
| ReBucket$1$1$AjcClosure5 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure1 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure11 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure13 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure15 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure17 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure3 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure5 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure7 |
|
| 1.0;1 | ||||
| ReBucket$AjcClosure9 |
|
| 1.0;1 |
| 1 | 0 | /** |
| 2 | * Copyright (c) 2012-2015, jcabi.com | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: 1) Redistributions of source code must retain the above | |
| 8 | * copyright notice, this list of conditions and the following | |
| 9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
| 10 | * copyright notice, this list of conditions and the following | |
| 11 | * disclaimer in the documentation and/or other materials provided | |
| 12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
| 13 | * the names of its contributors may be used to endorse or promote | |
| 14 | * products derived from this software without specific prior written | |
| 15 | * permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | */ | |
| 30 | package com.jcabi.s3.retry; | |
| 31 | ||
| 32 | import com.jcabi.aspects.Immutable; | |
| 33 | import com.jcabi.aspects.Loggable; | |
| 34 | import com.jcabi.aspects.RetryOnFailure; | |
| 35 | import com.jcabi.s3.Bucket; | |
| 36 | import com.jcabi.s3.Ocket; | |
| 37 | import com.jcabi.s3.Region; | |
| 38 | import java.io.IOException; | |
| 39 | import java.util.Iterator; | |
| 40 | import lombok.EqualsAndHashCode; | |
| 41 | ||
| 42 | /** | |
| 43 | * Region that retries a few times before giving up. | |
| 44 | * | |
| 45 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
| 46 | * @version $Id: f62c247a2810c69226d14c9be23945fba931e94c $ | |
| 47 | * @since 0.5 | |
| 48 | */ | |
| 49 | 0 | @Immutable |
| 50 | 0 | @EqualsAndHashCode(of = "origin") |
| 51 | @Loggable(Loggable.DEBUG) | |
| 52 | @SuppressWarnings("PMD.TooManyMethods") | |
| 53 | public final class ReBucket implements Bucket { | |
| 54 | ||
| 55 | /** | |
| 56 | * Original bucket. | |
| 57 | */ | |
| 58 | private final transient Bucket origin; | |
| 59 | ||
| 60 | /** | |
| 61 | * Public ctor. | |
| 62 | * @param bkt Bucket we're in | |
| 63 | */ | |
| 64 | 0 | public ReBucket(final Bucket bkt) { |
| 65 | 0 | this.origin = bkt; |
| 66 | 0 | } |
| 67 | ||
| 68 | @Override | |
| 69 | public Region region() { | |
| 70 | 0 | return new ReRegion(this.origin.region()); |
| 71 | } | |
| 72 | ||
| 73 | @Override | |
| 74 | public String name() { | |
| 75 | 0 | return this.origin.name(); |
| 76 | } | |
| 77 | ||
| 78 | @Override | |
| 79 | public Ocket ocket(final String key) { | |
| 80 | 0 | return new ReOcket(this.origin.ocket(key)); |
| 81 | } | |
| 82 | ||
| 83 | @Override | |
| 84 | public boolean exists() throws IOException { | |
| 85 | 0 | return this.origin.exists(); |
| 86 | } | |
| 87 | ||
| 88 | @Override | |
| 89 | @RetryOnFailure(verbose = false) | |
| 90 | public void remove(final String key) throws IOException { | |
| 91 | 0 | this.origin.remove(key); |
| 92 | 0 | } |
| 93 | ||
| 94 | @Override | |
| 95 | @RetryOnFailure(verbose = false) | |
| 96 | public Iterable<String> list(final String pfx) throws IOException { | |
| 97 | 0 | final Iterable<String> list = this.origin.list(pfx); |
| 98 | // @checkstyle AnonInnerLengthCheck (50 lines) | |
| 99 | 0 | return new Iterable<String>() { |
| 100 | @Override | |
| 101 | public Iterator<String> iterator() { | |
| 102 | 0 | final Iterator<String> iterator = list.iterator(); |
| 103 | 0 | return new Iterator<String>() { |
| 104 | @Override | |
| 105 | @RetryOnFailure(verbose = false) | |
| 106 | public boolean hasNext() { | |
| 107 | 0 | return iterator.hasNext(); |
| 108 | } | |
| 109 | @Override | |
| 110 | @RetryOnFailure(verbose = false) | |
| 111 | public String next() { | |
| 112 | 0 | return iterator.next(); |
| 113 | } | |
| 114 | @Override | |
| 115 | @RetryOnFailure(verbose = false) | |
| 116 | public void remove() { | |
| 117 | 0 | iterator.remove(); |
| 118 | 0 | } |
| 119 | }; | |
| 120 | } | |
| 121 | }; | |
| 122 | } | |
| 123 | ||
| 124 | @Override | |
| 125 | public int compareTo(final Bucket bkt) { | |
| 126 | 0 | return this.origin.name().compareTo(bkt.name()); |
| 127 | } | |
| 128 | } |