public AbstractLatencyScoreStrategyImpl(String name, int updateInterval, int resetInterval, int blockedThreshold, double keepRatio, double scoreThreshold, ScheduledExecutorService executor) { this.updateInterval = updateInterval; this.resetInterval = resetInterval; this.name = name; this.scoreThreshold = scoreThreshold; this.blockedThreshold = blockedThreshold; this.keepRatio = keepRatio; this.executor = executor; this.instances = new NonBlockingHashSet<Instance>(); }
/** * Register an un-named dependency provider * * @param providers the providers to register */ public static void register(DependencyProvider... providers) { for (DependencyProvider o : providers) { Injector.providers.add(o); } }
/** * de-register an un-named provider * * @param provider the provider to remove * @return false if the provider was either not in the set or the parameter is null, true if it was removed */ public static boolean deRegister(DependencyProvider provider) { return provider != null && providers.remove(provider); }
/** * Sets all pools for this partition. Removes old partitions and adds new * one. * * @param newPools */ public synchronized boolean setPools(Collection<HostConnectionPool<CL>> newPools) { Set<HostConnectionPool<CL>> toRemove = Sets.newHashSet(this.pools); // Add new pools not previously seen boolean didChange = false; for (HostConnectionPool<CL> pool : newPools) { if (this.pools.add(pool)) didChange = true; toRemove.remove(pool); } // Remove pools for hosts that no longer exist for (HostConnectionPool<CL> pool : toRemove) { if (this.pools.remove(pool)) didChange = true; } if (didChange) refresh(); return didChange; }
/** * Returns true if a pool is contained in this partition * @param pool */ public boolean hasPool(HostConnectionPool<CL> pool) { return pools.contains(pool); }
/** * Sets all pools for this partition. Removes old partitions and adds new * one. * * @param newPools */ public synchronized boolean setPools(Collection<HostConnectionPool<CL>> newPools) { Set<HostConnectionPool<CL>> toRemove = Sets.newHashSet(this.pools); // Add new pools not previously seen boolean didChange = false; for (HostConnectionPool<CL> pool : newPools) { if (this.pools.add(pool)) didChange = true; toRemove.remove(pool); } // Remove pools for hosts that no longer exist for (HostConnectionPool<CL> pool : toRemove) { if (this.pools.remove(pool)) didChange = true; } if (didChange) refresh(); return didChange; }
/** * Returns true if a pool is contained in this partition * @param pool */ public boolean hasPool(HostConnectionPool<CL> pool) { return pools.contains(pool); }
public AbstractLatencyScoreStrategyImpl(String name, int updateInterval, int resetInterval, int blockedThreshold, double keepRatio, double scoreThreshold, ScheduledExecutorService executor) { this.updateInterval = updateInterval; this.resetInterval = resetInterval; this.name = name; this.scoreThreshold = scoreThreshold; this.blockedThreshold = blockedThreshold; this.keepRatio = keepRatio; this.executor = executor; this.instances = new NonBlockingHashSet<Instance>(); }
/** * de-register an un-named provider * * @param provider the provider to remove * @return false if the provider was either not in the set or the parameter is null, true if it was removed */ public static boolean deRegister(DependencyProvider provider) { return provider != null && providers.remove(provider); }
/** * Register an un-named dependency provider * * @param providers the providers to register */ public static void register(DependencyProvider... providers) { for (DependencyProvider o : providers) { Injector.providers.add(o); } }
CommitLogReplayer(CommitLog commitLog, CommitLogPosition globalPosition, Map<UUID, IntervalSet<CommitLogPosition>> cfPersisted, ReplayFilter replayFilter) { this.keyspacesReplayed = new NonBlockingHashSet<Keyspace>(); this.futures = new ArrayDeque<Future<Integer>>(); // count the number of replayed mutation. We don't really care about atomicity, but we need it to be a reference. this.replayedCount = new AtomicInteger(); this.cfPersisted = cfPersisted; this.globalPosition = globalPosition; this.replayFilter = replayFilter; this.archiver = commitLog.archiver; this.commitLogReader = new CommitLogReader(); }
public synchronized boolean removePool(HostConnectionPool<CL> pool) { if (this.pools.remove(pool)) { refresh(); return true; } return false; }
public void scheduleHintDelivery(final InetAddress to, final boolean precompact) { // We should not deliver hints to the same host in 2 different threads if (!queuedDeliveries.add(to)) return; logger.debug("Scheduling delivery of Hints to {}", to); hintDeliveryExecutor.execute(new Runnable() { public void run() { try { // If it's an individual node hint replay (triggered by Gossip or via JMX), and not the global scheduled replay // (every 10 minutes), force a major compaction to get rid of the tombstones and expired hints. if (precompact) compact(); deliverHintsToEndpoint(to); } finally { queuedDeliveries.remove(to); } } }); }
CommitLogReplayer(CommitLog commitLog, CommitLogPosition globalPosition, Map<UUID, IntervalSet<CommitLogPosition>> cfPersisted, ReplayFilter replayFilter) { this.keyspacesReplayed = new NonBlockingHashSet<Keyspace>(); this.futures = new ArrayDeque<Future<Integer>>(); // count the number of replayed mutation. We don't really care about atomicity, but we need it to be a reference. this.replayedCount = new AtomicInteger(); this.cfPersisted = cfPersisted; this.globalPosition = globalPosition; this.replayFilter = replayFilter; this.archiver = commitLog.archiver; this.commitLogReader = new CommitLogReader(); }
public synchronized boolean removePool(HostConnectionPool<CL> pool) { if (this.pools.remove(pool)) { refresh(); return true; } return false; }
/** * Add a new pool to the partition. Checks to see if the pool already * existed. If so then there is no need to refresh the pool. * @param pool * @return True if anything changed */ public synchronized boolean addPool(HostConnectionPool<CL> pool) { if (this.pools.add(pool)) { refresh(); return true; } return false; }
CommitLogReplayer(CommitLog commitLog, CommitLogPosition globalPosition, Map<UUID, IntervalSet<CommitLogPosition>> cfPersisted, ReplayFilter replayFilter) { this.keyspacesReplayed = new NonBlockingHashSet<Keyspace>(); this.futures = new ArrayDeque<Future<Integer>>(); // count the number of replayed mutation. We don't really care about atomicity, but we need it to be a reference. this.replayedCount = new AtomicInteger(); this.cfPersisted = cfPersisted; this.globalPosition = globalPosition; this.replayFilter = replayFilter; this.archiver = commitLog.archiver; this.commitLogReader = new CommitLogReader(); }
public void run() { try { // If it's an individual node hint replay (triggered by Gossip or via JMX), and not the global scheduled replay // (every 10 minutes), force a major compaction to get rid of the tombstones and expired hints. if (precompact) compact(); deliverHintsToEndpoint(to); } finally { queuedDeliveries.remove(to); } } });
/** * Add a new pool to the partition. Checks to see if the pool already * existed. If so then there is no need to refresh the pool. * @param pool * @return True if anything changed */ public synchronized boolean addPool(HostConnectionPool<CL> pool) { if (this.pools.add(pool)) { refresh(); return true; } return false; }
/** * {@inheritDoc} * <p> * <strong>NOTE:</strong> This method deviates from the original * {@link Multimap} interface in that changes to the returned collection * WILL NOT update the underlying multimap and vice-versa. */ @Override public Collection<Entry<K, V>> entries() { Set<Entry<K, V>> entries = new NonBlockingHashSet<Entry<K, V>>(); for (K key : keySet()) { for (V value : get(key)) { entries.add(Maps.immutableEntry(key, value)); } } return entries; }