| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Queue; |
| | |
| | | private WritabilityMode writabilityMode = WritabilityMode.ENABLED; |
| | | |
| | | /** The set of persistent searches registered with this backend. */ |
| | | private final ConcurrentLinkedQueue<PersistentSearch> persistentSearches = |
| | | new ConcurrentLinkedQueue<PersistentSearch>(); |
| | | private final ConcurrentLinkedQueue<PersistentSearch> persistentSearches = new ConcurrentLinkedQueue<>(); |
| | | |
| | | /** |
| | | * Configure this backend based on the information in the provided configuration. |
| | |
| | | */ |
| | | public final synchronized void addSubordinateBackend(Backend<?> subordinateBackend) |
| | | { |
| | | LinkedHashSet<Backend<?>> backendSet = new LinkedHashSet<Backend<?>>(); |
| | | |
| | | for (Backend<?> b : subordinateBackends) |
| | | { |
| | | backendSet.add(b); |
| | | } |
| | | LinkedHashSet<Backend<?>> backendSet = new LinkedHashSet<>(); |
| | | Collections.addAll(backendSet, subordinateBackends); |
| | | |
| | | if (backendSet.add(subordinateBackend)) |
| | | { |
| | | Backend<?>[] newSubordinateBackends = new Backend[backendSet.size()]; |
| | | backendSet.toArray(newSubordinateBackends); |
| | | subordinateBackends = newSubordinateBackends; |
| | | subordinateBackends = backendSet.toArray(new Backend[backendSet.size()]); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public final synchronized void removeSubordinateBackend(Backend<?> subordinateBackend) |
| | | { |
| | | ArrayList<Backend<?>> backendList = new ArrayList<Backend<?>>(subordinateBackends.length); |
| | | ArrayList<Backend<?>> backendList = new ArrayList<>(subordinateBackends.length); |
| | | |
| | | boolean found = false; |
| | | for (Backend<?> b : subordinateBackends) |
| | |
| | | |
| | | if (found) |
| | | { |
| | | Backend<?>[] newSubordinateBackends = new Backend[backendList.size()]; |
| | | backendList.toArray(newSubordinateBackends); |
| | | subordinateBackends = newSubordinateBackends; |
| | | subordinateBackends = backendList.toArray(new Backend[backendList.size()]); |
| | | } |
| | | } |
| | | |