|
3 | 3 | import org.tarantool.TarantoolClient;
|
4 | 4 | import org.tarantool.TarantoolClientOps;
|
5 | 5 | import org.tarantool.TarantoolClusterClientConfig;
|
| 6 | +import org.tarantool.logging.Logger; |
| 7 | +import org.tarantool.logging.LoggerFactory; |
6 | 8 | import org.tarantool.util.StringUtils;
|
7 | 9 |
|
8 | 10 | import java.util.LinkedHashSet;
|
9 | 11 | import java.util.List;
|
10 | 12 | import java.util.Set;
|
11 |
| -import java.util.stream.Collectors; |
12 | 13 |
|
13 | 14 | /**
|
14 | 15 | * A cluster nodes discoverer based on calling a predefined function
|
|
19 | 20 | */
|
20 | 21 | public class TarantoolClusterStoredFunctionDiscoverer implements TarantoolClusterDiscoverer {
|
21 | 22 |
|
| 23 | + private static final Logger LOGGER = LoggerFactory.getLogger(TarantoolClusterStoredFunctionDiscoverer.class); |
| 24 | + |
22 | 25 | private TarantoolClient client;
|
23 | 26 | private String entryFunction;
|
24 | 27 |
|
@@ -57,12 +60,24 @@ private Set<String> checkAndFilterAddresses(List<?> result) {
|
57 | 60 | throw new IllegalDiscoveryFunctionResult("The first value must be an array of strings");
|
58 | 61 | }
|
59 | 62 |
|
60 |
| - return ((List<Object>) result.get(0)).stream() |
61 |
| - .filter(item -> item instanceof String) |
62 |
| - .map(Object::toString) |
63 |
| - .filter(s -> !StringUtils.isBlank(s)) |
64 |
| - .filter(this::isAddress) |
65 |
| - .collect(Collectors.toCollection(LinkedHashSet::new)); |
| 63 | + LinkedHashSet<String> passed = new LinkedHashSet<>(); |
| 64 | + LinkedHashSet<String> skipped = new LinkedHashSet<>(); |
| 65 | + for (Object item : ((List<Object>) result.get(0))) { |
| 66 | + if (!(item instanceof String)) { |
| 67 | + skipped.add(item.toString()); |
| 68 | + continue; |
| 69 | + } |
| 70 | + String s = item.toString(); |
| 71 | + if (!StringUtils.isBlank(s) && isAddress(s)) { |
| 72 | + passed.add(s); |
| 73 | + } else { |
| 74 | + skipped.add(s); |
| 75 | + } |
| 76 | + } |
| 77 | + if (!skipped.isEmpty()) { |
| 78 | + LOGGER.warn("Some of the addresses were skipped because of unsupported format: {0}", skipped); |
| 79 | + } |
| 80 | + return passed; |
66 | 81 | }
|
67 | 82 |
|
68 | 83 | /**
|
|
0 commit comments