-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-22618 Provide a way to have Heterogeneous deployment #439
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.hadoop.hbase.master.balancer; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
|
||
public class DummyCostFunction extends StochasticLoadBalancer.CostFunction { | ||
public DummyCostFunction(Configuration c) { | ||
super(c); | ||
} | ||
|
||
@Override | ||
protected double cost() { | ||
return 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,8 @@ | |
*/ | ||
package org.apache.hadoop.hbase.master.balancer; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
|
@@ -53,6 +47,10 @@ | |
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
@Category({ MasterTests.class, MediumTests.class }) | ||
public class TestStochasticLoadBalancer extends BalancerTestBase { | ||
|
||
|
@@ -121,7 +119,8 @@ public class TestStochasticLoadBalancer extends BalancerTestBase { | |
}; | ||
|
||
private ServerMetrics mockServerMetricsWithCpRequests(ServerName server, | ||
List<RegionInfo> regionsOnServer, long cpRequestCount) { | ||
List<RegionInfo> regionsOnServer, | ||
long cpRequestCount) { | ||
ServerMetrics serverMetrics = mock(ServerMetrics.class); | ||
Map<byte[], RegionMetrics> regionLoadMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); | ||
for(RegionInfo info : regionsOnServer){ | ||
|
@@ -457,6 +456,17 @@ public void testLosingRs() throws Exception { | |
assertNull(plans); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about test that, upon StochasticLoadBalancer.balanceCluster() call, verify that DummyCostFunctions.cost() get indeed called? That would validate custom cost functions are indeed used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about adding tests with the real cost function I want to implement, is that OK for you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should keep this jira concerned only with the implementation to allow additional cost functions to be added. Then you could propose another jira with the real implementation of your cost functions, which then would also define those functions specific tests. What would you say? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! |
||
@Test | ||
public void testAdditionalCostFunction() { | ||
conf.set(StochasticLoadBalancer.COST_FUNCTIONS_COST_FUNCTIONS_KEY, | ||
DummyCostFunction.class.getName()); | ||
|
||
loadBalancer.setConf(conf); | ||
assertTrue(Arrays. | ||
asList(loadBalancer.getCostFunctionNames()). | ||
contains(DummyCostFunction.class.getSimpleName())); | ||
} | ||
|
||
// This mock allows us to test the LocalityCostFunction | ||
private class MockCluster extends BaseLoadBalancer.Cluster { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am getting the following checkstyle issues, when running checkstyle locally:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for the trouble, I must admit that I was trusting the import style of my IDE 😄
Will fix it in another commit that will be checked locally this time