-
Notifications
You must be signed in to change notification settings - Fork 902
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
Support set local region for RegionAwareEnsemblePlacementPolicy #3248
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -63,6 +63,7 @@ public class RegionAwareEnsemblePlacementPolicy extends RackawareEnsemblePlaceme | |
public static final String REPP_DISABLE_DURABILITY_ENFORCEMENT_FEATURE = "reppDisableDurabilityEnforcementFeature"; | ||
public static final String REPP_ENABLE_VALIDATION = "reppEnableValidation"; | ||
public static final String REGION_AWARE_ANOMALOUS_ENSEMBLE = "region_aware_anomalous_ensemble"; | ||
public static final String REPP_LOCAL_REGION = "reppLocalRegion"; | ||
static final int MINIMUM_REGIONS_FOR_DURABILITY_DEFAULT = 2; | ||
static final int REGIONID_DISTANCE_FROM_LEAVES = 2; | ||
static final String UNKNOWN_REGION = "UnknownRegion"; | ||
|
@@ -79,7 +80,7 @@ public class RegionAwareEnsemblePlacementPolicy extends RackawareEnsemblePlaceme | |
protected Feature disableDurabilityFeature; | ||
private int lastRegionIndex = 0; | ||
|
||
RegionAwareEnsemblePlacementPolicy() { | ||
protected RegionAwareEnsemblePlacementPolicy() { | ||
super(); | ||
perRegionPlacement = new HashMap<String, TopologyAwareEnsemblePlacementPolicy>(); | ||
address2Region = new ConcurrentHashMap<BookieId, String>(); | ||
|
@@ -173,6 +174,10 @@ public RegionAwareEnsemblePlacementPolicy initialize(ClientConfiguration conf, | |
super.initialize(conf, optionalDnsResolver, timer, featureProvider, statsLogger, bookieAddressResolver) | ||
.withDefaultRack(NetworkTopology.DEFAULT_REGION_AND_RACK); | ||
myRegion = getLocalRegion(localNode); | ||
String localRegion = conf.getString(REPP_LOCAL_REGION, null); | ||
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. 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'm not sure whether |
||
if (null != localRegion) { | ||
myRegion = localRegion; | ||
} | ||
enableValidation = conf.getBoolean(REPP_ENABLE_VALIDATION, true); | ||
// We have to statically provide regions we want the writes to go through and how many regions | ||
// are required for durability. This decision cannot be driven by the active bookies as the | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1208,16 +1208,31 @@ private void prepareNetworkTopologyForReorderTests(String myRegion) throws Excep | |||
|
||||
@Test | ||||
public void testBasicReorderReadSequenceWithLocalRegion() throws Exception { | ||||
prepareNetworkTopologyForReorderTests("region2"); | ||||
basicReorderReadSequenceWithLocalRegionTest("region2", false); | ||||
} | ||||
|
||||
@Test | ||||
public void testBasicReorderReadLACSequenceWithLocalRegion() throws Exception { | ||||
prepareNetworkTopologyForReorderTests("region2"); | ||||
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. We should both test read and write. 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.
As current policy, read sequence is as follows Line 810 in 4debbbf
This motivation just add a configuration to set the local region as myRegion for client, bookies in the same region will be orderd as 1. available (local) bookies , when these bookies become unavailable or slow, they will be orderd as 3. R* remaining (local) bookies or 6. slow bookies .
This motivation just add a configuration related to the read order of bookies in a writeSet. IMO we do not need test write. |
||||
basicReorderReadSequenceWithLocalRegionTest("region2", true); | ||||
} | ||||
|
||||
@Test | ||||
public void testBasicReorderReadSequenceWithLocalRegionConfig() throws Exception { | ||||
conf.setProperty("reppLocalRegion", "region2"); | ||||
prepareNetworkTopologyForReorderTests("dummyRegion"); | ||||
basicReorderReadSequenceWithLocalRegionTest("region2", false); | ||||
} | ||||
|
||||
@Test | ||||
public void testBasicReorderReadLACSequenceWithLocalRegionConfig() throws Exception { | ||||
conf.setProperty("reppLocalRegion", "region2"); | ||||
prepareNetworkTopologyForReorderTests("dummyRegion"); | ||||
basicReorderReadSequenceWithLocalRegionTest("region2", true); | ||||
} | ||||
|
||||
private void basicReorderReadSequenceWithLocalRegionTest(String myRegion, boolean isReadLAC) throws Exception { | ||||
prepareNetworkTopologyForReorderTests(myRegion); | ||||
List<BookieId> ensemble = repp.newEnsemble(9, 9, 5, null, | ||||
new HashSet<BookieId>()).getResult(); | ||||
assertEquals(9, getNumCoveredRegionsInWriteQuorum(ensemble, 9)); | ||||
|
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.
why not change it to public?
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.
Change to protected so that we could extends
RegionAwareEnsemblePlacementPolicy
and implement some addtion policy in broker side in future.IMO no need change to public.