Search in sources :

Example 1 with ReplicationThrottler

use of io.druid.server.coordinator.ReplicationThrottler in project druid by druid-io.

the class LoadRule method drop.

private CoordinatorStats drop(final Map<String, Integer> loadStatus, final DataSegment segment, final DruidCoordinatorRuntimeParams params) {
    CoordinatorStats stats = new CoordinatorStats();
    // Make sure we have enough loaded replicants in the correct tiers in the cluster before doing anything
    for (Integer leftToLoad : loadStatus.values()) {
        if (leftToLoad > 0) {
            return stats;
        }
    }
    final ReplicationThrottler replicationManager = params.getReplicationManager();
    // Find all instances of this segment across tiers
    Map<String, Integer> replicantsByTier = params.getSegmentReplicantLookup().getClusterTiers(segment.getIdentifier());
    for (Map.Entry<String, Integer> entry : replicantsByTier.entrySet()) {
        final String tier = entry.getKey();
        int loadedNumReplicantsForTier = entry.getValue();
        int expectedNumReplicantsForTier = getNumReplicants(tier);
        stats.addToTieredStat(droppedCount, tier, 0);
        MinMaxPriorityQueue<ServerHolder> serverQueue = params.getDruidCluster().get(tier);
        if (serverQueue == null) {
            log.makeAlert("No holders found for tier[%s]", entry.getKey()).emit();
            continue;
        }
        List<ServerHolder> droppedServers = Lists.newArrayList();
        while (loadedNumReplicantsForTier > expectedNumReplicantsForTier) {
            final ServerHolder holder = serverQueue.pollLast();
            if (holder == null) {
                log.warn("Wtf, holder was null?  I have no servers serving [%s]?", segment.getIdentifier());
                break;
            }
            if (holder.isServingSegment(segment)) {
                holder.getPeon().dropSegment(segment, null);
                --loadedNumReplicantsForTier;
                stats.addToTieredStat(droppedCount, tier, 1);
            }
            droppedServers.add(holder);
        }
        serverQueue.addAll(droppedServers);
    }
    return stats;
}
Also used : CoordinatorStats(io.druid.server.coordinator.CoordinatorStats) ReplicationThrottler(io.druid.server.coordinator.ReplicationThrottler) ServerHolder(io.druid.server.coordinator.ServerHolder) Map(java.util.Map)

Example 2 with ReplicationThrottler

use of io.druid.server.coordinator.ReplicationThrottler in project druid by druid-io.

the class LoadRuleTest method setUp.

@Before
public void setUp() throws Exception {
    EmittingLogger.registerEmitter(emitter);
    emitter.start();
    mockPeon = EasyMock.createMock(LoadQueuePeon.class);
    throttler = new ReplicationThrottler(2, 1);
    for (String tier : Arrays.asList("hot", DruidServer.DEFAULT_TIER)) {
        throttler.updateReplicationState(tier);
    }
    segment = new DataSegment("foo", new Interval("0/3000"), new DateTime().toString(), Maps.<String, Object>newHashMap(), Lists.<String>newArrayList(), Lists.<String>newArrayList(), NoneShardSpec.instance(), 0, 0);
}
Also used : ReplicationThrottler(io.druid.server.coordinator.ReplicationThrottler) LoadQueuePeon(io.druid.server.coordinator.LoadQueuePeon) DataSegment(io.druid.timeline.DataSegment) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Before(org.junit.Before)

Aggregations

ReplicationThrottler (io.druid.server.coordinator.ReplicationThrottler)2 CoordinatorStats (io.druid.server.coordinator.CoordinatorStats)1 LoadQueuePeon (io.druid.server.coordinator.LoadQueuePeon)1 ServerHolder (io.druid.server.coordinator.ServerHolder)1 DataSegment (io.druid.timeline.DataSegment)1 Map (java.util.Map)1 DateTime (org.joda.time.DateTime)1 Interval (org.joda.time.Interval)1 Before (org.junit.Before)1