This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BookKeeper Client: Allow using a decider to dynamically disable durab…
…ility enforcement in region aware placement policy - Introduce Features that are dynamic configuration options - Allow specifying Features as configuration parameters - Use a configuration parameter so that the client can specify the Feature to be used to determine if the region aware ensemble placement policy should enforce durability - Make each call to newEnsemble or replaceBookie independently enforce durability based on the dynamic feature regardless of how the region aware ensemble placement policy was configured RB_ID=588200
- Loading branch information
Showing
11 changed files
with
182 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
bookkeeper-server/src/main/java/org/apache/bookkeeper/feature/Feature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.apache.bookkeeper.feature; | ||
|
||
/** | ||
* This interface represents a feature. | ||
*/ | ||
public interface Feature { | ||
public static int FEATURE_AVAILABILITY_MAX_VALUE = 100; | ||
|
||
/** | ||
* Returns a textual representation of the feature. | ||
* | ||
* @return name of the feature. | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* Returns the availability of this feature, an integer between 0 and 100. | ||
* | ||
* @return the availability of this feature. | ||
*/ | ||
int availability(); | ||
|
||
/** | ||
* Whether this feature is available or not. | ||
* | ||
* @return true if this feature is available, otherwise false. | ||
*/ | ||
boolean isAvailable(); | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
bookkeeper-server/src/main/java/org/apache/bookkeeper/feature/FeatureProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.apache.bookkeeper.feature; | ||
|
||
/** | ||
* Provider to provide features. | ||
*/ | ||
public interface FeatureProvider { | ||
/** | ||
* Return the feature with given name. | ||
* | ||
* @param name feature name | ||
* @return feature instance | ||
*/ | ||
Feature getFeature(String name); | ||
} |
28 changes: 28 additions & 0 deletions
28
bookkeeper-server/src/main/java/org/apache/bookkeeper/feature/FixedValueFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.apache.bookkeeper.feature; | ||
|
||
public class FixedValueFeature implements Feature { | ||
protected int availability; | ||
|
||
public FixedValueFeature(int availability) { | ||
this.availability = availability; | ||
} | ||
|
||
public FixedValueFeature(boolean isAvailabile) { | ||
this.availability = isAvailabile ? FEATURE_AVAILABILITY_MAX_VALUE : 0; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int availability() { | ||
return availability; | ||
} | ||
|
||
@Override | ||
public boolean isAvailable() { | ||
return availability() > 0; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
bookkeeper-server/src/main/java/org/apache/bookkeeper/feature/SettableFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.apache.bookkeeper.feature; | ||
|
||
public class SettableFeature extends FixedValueFeature { | ||
public SettableFeature(int initialAvailability) { | ||
super(initialAvailability); | ||
} | ||
|
||
public SettableFeature(boolean isAvailabile) { | ||
super(isAvailabile); | ||
} | ||
|
||
public void set(int availability) { | ||
this.availability = availability; | ||
} | ||
|
||
public void set(boolean isAvailabile) { | ||
this.availability = isAvailabile ? FEATURE_AVAILABILITY_MAX_VALUE : 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.