private InetAddress getIndexLocation(String subIndex) { ByteBuffer indexName = CassandraUtils.hashBytes(subIndex.getBytes()); List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(CassandraUtils.keySpace, indexName); if (endpoints.isEmpty()) throw new RuntimeException("Unable to find a live endpoint for: " + subIndex); DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getLocalAddress(), endpoints); if (endpoints.contains(FBUtilities.getLocalAddress())) return FBUtilities.getLocalAddress(); return endpoints.get(0); }
DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getLocalAddress(), endpoints);
private void sortByProximityWithBadness(final InetAddress address, List<InetAddress> addresses) { if (addresses.size() < 2) return; subsnitch.sortByProximity(address, addresses); HashMap<InetAddress, Double> scores = this.scores; // Make sure the score don't change in the middle of the loop below // (which wouldn't really matter here but its cleaner that way). ArrayList<Double> subsnitchOrderedScores = new ArrayList<>(addresses.size()); for (InetAddress inet : addresses) { Double score = scores.get(inet); if (score == null) continue; subsnitchOrderedScores.add(score); } // Sort the scores and then compare them (positionally) to the scores in the subsnitch order. // If any of the subsnitch-ordered scores exceed the optimal/sorted score by dynamicBadnessThreshold, use // the score-sorted ordering instead of the subsnitch ordering. ArrayList<Double> sortedScores = new ArrayList<>(subsnitchOrderedScores); Collections.sort(sortedScores); Iterator<Double> sortedScoreIterator = sortedScores.iterator(); for (Double subsnitchScore : subsnitchOrderedScores) { if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + dynamicBadnessThreshold))) { sortByProximityWithScore(address, addresses); return; } } }
private void sortByProximityWithBadness(final InetAddress address, List<InetAddress> addresses) { if (addresses.size() < 2) return; subsnitch.sortByProximity(address, addresses); HashMap<InetAddress, Double> scores = this.scores; // Make sure the score don't change in the middle of the loop below // (which wouldn't really matter here but its cleaner that way). ArrayList<Double> subsnitchOrderedScores = new ArrayList<>(addresses.size()); for (InetAddress inet : addresses) { Double score = scores.get(inet); if (score == null) continue; subsnitchOrderedScores.add(score); } // Sort the scores and then compare them (positionally) to the scores in the subsnitch order. // If any of the subsnitch-ordered scores exceed the optimal/sorted score by dynamicBadnessThreshold, use // the score-sorted ordering instead of the subsnitch ordering. ArrayList<Double> sortedScores = new ArrayList<>(subsnitchOrderedScores); Collections.sort(sortedScores); Iterator<Double> sortedScoreIterator = sortedScores.iterator(); for (Double subsnitchScore : subsnitchOrderedScores) { if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + dynamicBadnessThreshold))) { sortByProximityWithScore(address, addresses); return; } } }
private void sortByProximityWithBadness(final InetAddress address, List<InetAddress> addresses) { if (addresses.size() < 2) return; subsnitch.sortByProximity(address, addresses); HashMap<InetAddress, Double> scores = this.scores; // Make sure the score don't change in the middle of the loop below // (which wouldn't really matter here but its cleaner that way). ArrayList<Double> subsnitchOrderedScores = new ArrayList<>(addresses.size()); for (InetAddress inet : addresses) { Double score = scores.get(inet); if (score == null) continue; subsnitchOrderedScores.add(score); } // Sort the scores and then compare them (positionally) to the scores in the subsnitch order. // If any of the subsnitch-ordered scores exceed the optimal/sorted score by dynamicBadnessThreshold, use // the score-sorted ordering instead of the subsnitch ordering. ArrayList<Double> sortedScores = new ArrayList<>(subsnitchOrderedScores); Collections.sort(sortedScores); Iterator<Double> sortedScoreIterator = sortedScores.iterator(); for (Double subsnitchScore : subsnitchOrderedScores) { if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + dynamicBadnessThreshold))) { sortByProximityWithScore(address, addresses); return; } } }
private void sortByProximityWithBadness(final InetAddress address, List<InetAddress> addresses) { if (addresses.size() < 2) return; subsnitch.sortByProximity(address, addresses); HashMap<InetAddress, Double> scores = this.scores; // Make sure the score don't change in the middle of the loop below // (which wouldn't really matter here but its cleaner that way). ArrayList<Double> subsnitchOrderedScores = new ArrayList<>(addresses.size()); for (InetAddress inet : addresses) { Double score = scores.get(inet); if (score == null) return; subsnitchOrderedScores.add(score); } // Sort the scores and then compare them (positionally) to the scores in the subsnitch order. // If any of the subsnitch-ordered scores exceed the optimal/sorted score by BADNESS_THRESHOLD, use // the score-sorted ordering instead of the subsnitch ordering. ArrayList<Double> sortedScores = new ArrayList<>(subsnitchOrderedScores); Collections.sort(sortedScores); Iterator<Double> sortedScoreIterator = sortedScores.iterator(); for (Double subsnitchScore : subsnitchOrderedScores) { if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + BADNESS_THRESHOLD))) { sortByProximityWithScore(address, addresses); return; } } }
public static List<InetAddress> getLiveSortedEndpoints(Keyspace keyspace, RingPosition pos) { List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, pos); DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints); return liveEndpoints; }
public static List<InetAddress> getLiveSortedEndpoints(Keyspace keyspace, RingPosition pos) { List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, pos); DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints); return liveEndpoints; }
private static List<InetAddress> getLiveSortedEndpoints(Keyspace keyspace, RingPosition pos) { List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, pos); DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints); return liveEndpoints; }
public static List<InetAddress> getLiveSortedEndpoints(Keyspace keyspace, RingPosition pos) { List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, pos); DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints); return liveEndpoints; }
/** * Find the best target to stream hints to. Currently the closest peer according to the snitch */ private UUID getPreferredHintsStreamTarget() { List<InetAddress> candidates = new ArrayList<>(StorageService.instance.getTokenMetadata().cloneAfterAllLeft().getAllEndpoints()); candidates.remove(FBUtilities.getBroadcastAddress()); for (Iterator<InetAddress> iter = candidates.iterator(); iter.hasNext(); ) { InetAddress address = iter.next(); if (!FailureDetector.instance.isAlive(address)) iter.remove(); } if (candidates.isEmpty()) { logger.warn("Unable to stream hints since no live endpoints seen"); throw new RuntimeException("Unable to stream hints since no live endpoints seen"); } else { // stream to the closest peer as chosen by the snitch DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates); InetAddress hintsDestinationHost = candidates.get(0); return tokenMetadata.getHostId(hintsDestinationHost); } }
/** * Find the best target to stream hints to. Currently the closest peer according to the snitch */ private UUID getPreferredHintsStreamTarget() { List<InetAddress> candidates = new ArrayList<>(StorageService.instance.getTokenMetadata().cloneAfterAllLeft().getAllEndpoints()); candidates.remove(FBUtilities.getBroadcastAddress()); for (Iterator<InetAddress> iter = candidates.iterator(); iter.hasNext(); ) { InetAddress address = iter.next(); if (!FailureDetector.instance.isAlive(address)) iter.remove(); } if (candidates.isEmpty()) { logger.warn("Unable to stream hints since no live endpoints seen"); throw new RuntimeException("Unable to stream hints since no live endpoints seen"); } else { // stream to the closest peer as chosen by the snitch DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates); InetAddress hintsDestinationHost = candidates.get(0); return tokenMetadata.getHostId(hintsDestinationHost); } }
/** * Find the best target to stream hints to. Currently the closest peer according to the snitch */ private UUID getPreferredHintsStreamTarget() { List<InetAddress> candidates = new ArrayList<>(StorageService.instance.getTokenMetadata().cloneAfterAllLeft().getAllEndpoints()); candidates.remove(FBUtilities.getBroadcastAddress()); for (Iterator<InetAddress> iter = candidates.iterator(); iter.hasNext(); ) { InetAddress address = iter.next(); if (!FailureDetector.instance.isAlive(address)) iter.remove(); } if (candidates.isEmpty()) { logger.warn("Unable to stream hints since no live endpoints seen"); throw new RuntimeException("Unable to stream hints since no live endpoints seen"); } else { // stream to the closest peer as chosen by the snitch DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates); InetAddress hintsDestinationHost = candidates.get(0); return tokenMetadata.getHostId(hintsDestinationHost); } }
snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints); return endpoints.get(0);
snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints); return endpoints.get(0);
snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints); return endpoints.get(0);
snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints); return endpoints.get(0);
DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates); InetAddress hintsDestinationHost = candidates.get(0); InetAddress preferred = SystemKeyspace.getPreferredIP(hintsDestinationHost);