提交 99f7e21f 编写于 作者: R Rajan 提交者: Matteo Merli

Configure split-bundle task interval different than loadReportGenerationTask-interval (#183)

上级 de2a6110
...@@ -237,9 +237,6 @@ loadBalancerBrokerComfortLoadLevelPercentage=65 ...@@ -237,9 +237,6 @@ loadBalancerBrokerComfortLoadLevelPercentage=65
# enable/disable namespace bundle auto split # enable/disable namespace bundle auto split
loadBalancerAutoBundleSplitEnabled=false loadBalancerAutoBundleSplitEnabled=false
# interval to detect & split hot namespace bundle
loadBalancerNamespaceBundleSplitIntervalMinutes=15
# maximum topics in a bundle, otherwise bundle split will be triggered # maximum topics in a bundle, otherwise bundle split will be triggered
loadBalancerNamespaceBundleMaxTopics=1000 loadBalancerNamespaceBundleMaxTopics=1000
......
...@@ -210,9 +210,6 @@ loadBalancerBrokerComfortLoadLevelPercentage=65 ...@@ -210,9 +210,6 @@ loadBalancerBrokerComfortLoadLevelPercentage=65
# enable/disable namespace bundle auto split # enable/disable namespace bundle auto split
loadBalancerAutoBundleSplitEnabled=false loadBalancerAutoBundleSplitEnabled=false
# interval to detect & split hot namespace bundle
loadBalancerNamespaceBundleSplitIntervalMinutes=15
# maximum topics in a bundle, otherwise bundle split will be triggered # maximum topics in a bundle, otherwise bundle split will be triggered
loadBalancerNamespaceBundleMaxTopics=1000 loadBalancerNamespaceBundleMaxTopics=1000
......
...@@ -207,8 +207,6 @@ public class ServiceConfiguration implements PulsarConfiguration{ ...@@ -207,8 +207,6 @@ public class ServiceConfiguration implements PulsarConfiguration{
private int loadBalancerBrokerComfortLoadLevelPercentage = 65; private int loadBalancerBrokerComfortLoadLevelPercentage = 65;
// enable/disable automatic namespace bundle split // enable/disable automatic namespace bundle split
private boolean loadBalancerAutoBundleSplitEnabled = false; private boolean loadBalancerAutoBundleSplitEnabled = false;
// interval to detect & split hot namespace bundle
private int loadBalancerNamespaceBundleSplitIntervalMinutes = 15;
// maximum topics in a bundle, otherwise bundle split will be triggered // maximum topics in a bundle, otherwise bundle split will be triggered
private int loadBalancerNamespaceBundleMaxTopics = 1000; private int loadBalancerNamespaceBundleMaxTopics = 1000;
// maximum sessions (producers + consumers) in a bundle, otherwise bundle split will be triggered // maximum sessions (producers + consumers) in a bundle, otherwise bundle split will be triggered
...@@ -759,14 +757,6 @@ public class ServiceConfiguration implements PulsarConfiguration{ ...@@ -759,14 +757,6 @@ public class ServiceConfiguration implements PulsarConfiguration{
return loadBalancerBrokerOverloadedThresholdPercentage; return loadBalancerBrokerOverloadedThresholdPercentage;
} }
public void setLoadBalancerBundleSplitIntervalMinutes(int interval) {
this.loadBalancerNamespaceBundleSplitIntervalMinutes = interval;
}
public int getLoadBalancerBundleSplitIntervalMinutes() {
return this.loadBalancerNamespaceBundleSplitIntervalMinutes;
}
public void setLoadBalancerNamespaceBundleMaxTopics(int topics) { public void setLoadBalancerNamespaceBundleMaxTopics(int topics) {
this.loadBalancerNamespaceBundleMaxTopics = topics; this.loadBalancerNamespaceBundleMaxTopics = topics;
} }
......
...@@ -45,7 +45,6 @@ import com.yahoo.pulsar.broker.loadbalance.LoadManager; ...@@ -45,7 +45,6 @@ import com.yahoo.pulsar.broker.loadbalance.LoadManager;
import com.yahoo.pulsar.broker.loadbalance.LoadReportUpdaterTask; import com.yahoo.pulsar.broker.loadbalance.LoadReportUpdaterTask;
import com.yahoo.pulsar.broker.loadbalance.LoadResourceQuotaUpdaterTask; import com.yahoo.pulsar.broker.loadbalance.LoadResourceQuotaUpdaterTask;
import com.yahoo.pulsar.broker.loadbalance.LoadSheddingTask; import com.yahoo.pulsar.broker.loadbalance.LoadSheddingTask;
import com.yahoo.pulsar.broker.loadbalance.NamespaceBundleSplitTask;
import com.yahoo.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl; import com.yahoo.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl;
import com.yahoo.pulsar.broker.namespace.NamespaceService; import com.yahoo.pulsar.broker.namespace.NamespaceService;
import com.yahoo.pulsar.broker.service.BrokerService; import com.yahoo.pulsar.broker.service.BrokerService;
...@@ -92,7 +91,6 @@ public class PulsarService implements AutoCloseable { ...@@ -92,7 +91,6 @@ public class PulsarService implements AutoCloseable {
private final OrderedSafeExecutor orderedExecutor = new OrderedSafeExecutor(8, "pulsar-ordered"); private final OrderedSafeExecutor orderedExecutor = new OrderedSafeExecutor(8, "pulsar-ordered");
private ScheduledExecutorService loadManagerExecutor = null; private ScheduledExecutorService loadManagerExecutor = null;
private ScheduledFuture<?> loadReportTask = null; private ScheduledFuture<?> loadReportTask = null;
private ScheduledFuture<?> bundleSplitTask = null;
private ScheduledFuture<?> loadSheddingTask = null; private ScheduledFuture<?> loadSheddingTask = null;
private ScheduledFuture<?> loadResourceQuotaTask = null; private ScheduledFuture<?> loadResourceQuotaTask = null;
private LoadManager loadManager = null; private LoadManager loadManager = null;
...@@ -408,13 +406,6 @@ public class PulsarService implements AutoCloseable { ...@@ -408,13 +406,6 @@ public class PulsarService implements AutoCloseable {
new LoadReportUpdaterTask(loadManager), loadReportMinInterval, loadReportMinInterval, new LoadReportUpdaterTask(loadManager), loadReportMinInterval, loadReportMinInterval,
TimeUnit.MILLISECONDS); TimeUnit.MILLISECONDS);
} }
if (this.bundleSplitTask == null) {
long bundleSplitInterval = TimeUnit.MINUTES
.toMillis(getConfiguration().getLoadBalancerBundleSplitIntervalMinutes());
this.bundleSplitTask = this.loadManagerExecutor.scheduleAtFixedRate(
new NamespaceBundleSplitTask(loadManager), bundleSplitInterval, bundleSplitInterval,
TimeUnit.MILLISECONDS);
}
} }
} }
......
/**
* Copyright 2016 Yahoo Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yahoo.pulsar.broker.loadbalance;
import java.lang.Runnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents a task which detect hot namespace bundle to split
*/
public class NamespaceBundleSplitTask implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(NamespaceBundleSplitTask.class);
private final LoadManager loadManager;
public NamespaceBundleSplitTask(LoadManager manager) {
loadManager = manager;
}
@Override
public void run() {
try {
loadManager.doNamespaceBundleSplit();
} catch (Exception e) {
LOG.warn("Error while doing namespace bundle split.", e);
}
}
}
...@@ -1199,6 +1199,8 @@ public class SimpleLoadManagerImpl implements LoadManager, ZooKeeperCacheListene ...@@ -1199,6 +1199,8 @@ public class SimpleLoadManagerImpl implements LoadManager, ZooKeeperCacheListene
-1); -1);
this.lastLoadReport = lr; this.lastLoadReport = lr;
this.lastResourceUsageTimestamp = lr.getTimestamp(); this.lastResourceUsageTimestamp = lr.getTimestamp();
// split-bundle if requires
doNamespaceBundleSplit();
} }
} }
......
...@@ -459,10 +459,6 @@ public class SimpleLoadManagerImplTest { ...@@ -459,10 +459,6 @@ public class SimpleLoadManagerImplTest {
LoadSheddingTask task2 = new LoadSheddingTask(loadManager); LoadSheddingTask task2 = new LoadSheddingTask(loadManager);
task2.run(); task2.run();
verify(loadManager, times(1)).doLoadShedding(); verify(loadManager, times(1)).doLoadShedding();
NamespaceBundleSplitTask task3 = new NamespaceBundleSplitTask(loadManager);
task3.run();
verify(loadManager, times(1)).doNamespaceBundleSplit();
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册