-
-
Save akki/1d80c97463198275b3abe39350688bda to your computer and use it in GitHub Desktop.
Helix OnlineOffline state model
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
package my.package; | |
import org.apache.helix.HelixDefinedState; | |
import org.apache.helix.model.StateModelDefinition; | |
public final class OnlineOfflineStateModel { | |
public static final String name = "OnlineOffline"; | |
public enum States { | |
ONLINE, | |
OFFLINE | |
} | |
/** | |
* Build OnlineOffline state model definition | |
*/ | |
public static StateModelDefinition build() { | |
StateModelDefinition.Builder builder = new StateModelDefinition.Builder(name); | |
// add states | |
builder.addState(States.ONLINE.name(), 1); | |
builder.addState(States.OFFLINE.name(), 2); | |
for (HelixDefinedState state : HelixDefinedState.values()) { | |
builder.addState(state.name()); | |
} | |
// Set the initial state when the node starts | |
builder.initialState(States.OFFLINE.name()); | |
// Add transitions between the states. | |
builder.addTransition(States.ONLINE.name(), States.OFFLINE.name()); | |
builder.addTransition(States.OFFLINE.name(), States.ONLINE.name()); | |
builder.addTransition(States.OFFLINE.name(), HelixDefinedState.DROPPED.name()); | |
// bounds | |
builder.upperBound(States.ONLINE.name(), 1); | |
builder.dynamicUpperBound(States.ONLINE.name(), "R"); | |
return builder.build(); | |
} | |
} |
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
############################################ | |
# INITIAL STATE # | |
############################################ | |
get /helixClustername/IDEALSTATES/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"IDEAL_STATE_MODE" : "CUSTOMIZED", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "CUSTOMIZED", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { | |
"0" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"1" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"2" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"3" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"4" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"5" : { | |
"hadin-worker-1001" : "ONLINE" | |
} | |
}, | |
"listFields" : { } | |
} | |
############################################ | |
# AFTER ADDING A NODE # | |
############################################ | |
get /helixClustername/EXTERNALVIEW/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"BUCKET_SIZE" : "0", | |
"IDEAL_STATE_MODE" : "CUSTOMIZED", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "CUSTOMIZED", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { | |
"0" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"1" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"2" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"3" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"4" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"5" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
} | |
}, | |
"listFields" : { } | |
} | |
get /helixClustername/IDEALSTATES/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"IDEAL_STATE_MODE" : "CUSTOMIZED", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "CUSTOMIZED", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { | |
"0" : { | |
"hadin-worker-1002" : "ONLINE" | |
}, | |
"1" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"2" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"3" : { | |
"hadin-worker-1002" : "ONLINE" | |
}, | |
"4" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"5" : { | |
"hadin-worker-1002" : "ONLINE" | |
} | |
}, | |
"listFields" : { } | |
} |
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
get /helixClustername/EXTERNALVIEW/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"BUCKET_SIZE" : "0", | |
"IDEAL_STATE_MODE" : "AUTO", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "SEMI_AUTO", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { | |
"0" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"1" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"2" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"3" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"4" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"5" : { | |
"hadin-worker-1001" : "ONLINE" | |
} | |
}, | |
"listFields" : { } | |
} | |
get /helixClustername/IDEALSTATES/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"IDEAL_STATE_MODE" : "AUTO", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "SEMI_AUTO", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { }, | |
"listFields" : { | |
"0" : [ "hadin-worker-1002" ], | |
"1" : [ "hadin-worker-1001" ], | |
"2" : [ "hadin-worker-1001" ], | |
"3" : [ "hadin-worker-1002" ], | |
"4" : [ "hadin-worker-1002" ], | |
"5" : [ "hadin-worker-1001" ] | |
} | |
} |
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
get /helixClustername/EXTERNALVIEW/ResourceName | |
{ | |
"id" : "ResourceName", | |
"simpleFields" : { | |
"BUCKET_SIZE" : "0", | |
"IDEAL_STATE_MODE" : "CUSTOMIZED", | |
"MAX_PARTITIONS_PER_INSTANCE" : "6", | |
"NUM_PARTITIONS" : "6", | |
"REBALANCE_MODE" : "CUSTOMIZED", | |
"REPLICAS" : "1", | |
"STATE_MODEL_DEF_REF" : "OnlineOffline", | |
"STATE_MODEL_FACTORY_NAME" : "DEFAULT" | |
}, | |
"mapFields" : { | |
"0" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"1" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"2" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"3" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"4" : { | |
"hadin-worker-1001" : "ONLINE" | |
}, | |
"5" : { | |
"hadin-worker-1002" : "ONLINE", | |
"hadin-worker-1001" : "ONLINE" | |
} | |
}, | |
"listFields" : { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment