Search in sources :

Example 6 with ConstraintItemBuilder

use of org.apache.helix.model.builder.ConstraintItemBuilder in project helix by apache.

the class TestPreferenceListAsQueue method testReprioritizedWithConstraint.

/**
 * This test ensures successful creation when the state model has OFFLINE --> deprioritized and
 * a partition-level constraint enforces parallelism
 * @throws Exception
 */
@Test
public void testReprioritizedWithConstraint() throws Exception {
    _stateModel = "OnlineOfflineReprioritized";
    // Add a state model with the transition to ONLINE deprioritized
    _clusterSetup.addStateModelDef(_clusterName, _stateModel, createReprioritizedStateModelDef(_stateModel));
    // Add a constraint of one transition per partition
    ConstraintItemBuilder constraintItemBuilder = new ConstraintItemBuilder();
    constraintItemBuilder.addConstraintAttribute(ConstraintAttribute.MESSAGE_TYPE.toString(), "STATE_TRANSITION").addConstraintAttribute(ConstraintAttribute.PARTITION.toString(), ".*").addConstraintAttribute(ConstraintAttribute.CONSTRAINT_VALUE.toString(), String.valueOf(PARALLELISM));
    _admin.setConstraint(_clusterName, ConstraintType.MESSAGE_CONSTRAINT, "constraint_1", constraintItemBuilder.build());
    runTest();
}
Also used : ConstraintItemBuilder(org.apache.helix.model.builder.ConstraintItemBuilder) Test(org.testng.annotations.Test)

Aggregations

ConstraintItemBuilder (org.apache.helix.model.builder.ConstraintItemBuilder)6 HelixAdmin (org.apache.helix.HelixAdmin)4 ZNRecord (org.apache.helix.ZNRecord)4 Test (org.testng.annotations.Test)4 Date (java.util.Date)3 ZKHelixAdmin (org.apache.helix.manager.zk.ZKHelixAdmin)3 HelixDataAccessor (org.apache.helix.HelixDataAccessor)2 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)2 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)2 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)2 ConstraintItem (org.apache.helix.model.ConstraintItem)2 IdealState (org.apache.helix.model.IdealState)2 Message (org.apache.helix.model.Message)2 StateModelDefinition (org.apache.helix.model.StateModelDefinition)2 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IZkChildListener (org.I0Itec.zkclient.IZkChildListener)1 HelixException (org.apache.helix.HelixException)1 PropertyKey (org.apache.helix.PropertyKey)1 PropertyPathBuilder (org.apache.helix.PropertyPathBuilder)1