// oversized data should not create any new data on zk
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(className, new ZkBaseDataAccessor(zkClient));
Builder keyBuilder = accessor.keyBuilder();
IdealState idealState = new IdealState("currentState");
idealState.setStateModelDefRef("MasterSlave");
idealState.setIdealStateMode("AUTO");
idealState.setNumPartitions(10);
for (int i = 0; i < 1024; i++)
{
idealState.getRecord().setSimpleField(i + "", bufStr);
}
boolean succeed = accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
Assert.assertFalse(succeed);
HelixProperty property =
accessor.getProperty(keyBuilder.stateTransitionStatus("localhost_12918",
"session_1",
"partition_1"));
Assert.assertNull(property);
// legal sized data gets written to zk
idealState.getRecord().getSimpleFields().clear();
idealState.setStateModelDefRef("MasterSlave");
idealState.setIdealStateMode("AUTO");
idealState.setNumPartitions(10);
for (int i = 0; i < 900; i++)
{
idealState.getRecord().setSimpleField(i + "", bufStr);
}
succeed = accessor.setProperty(keyBuilder.idealStates("TestDB1"), idealState);
Assert.assertTrue(succeed);
record =
accessor.getProperty(keyBuilder.idealStates("TestDB1")).getRecord();
Assert.assertTrue(serializer.serialize(record).length > 900 * 1024);
// oversized data should not update existing data on zk
idealState.getRecord().getSimpleFields().clear();
idealState.setStateModelDefRef("MasterSlave");
idealState.setIdealStateMode("AUTO");
idealState.setNumPartitions(10);
for (int i = 900; i < 1024; i++)
{
idealState.getRecord().setSimpleField(i + "", bufStr);
}
// System.out.println("record: " + idealState.getRecord());
succeed =
accessor.updateProperty(keyBuilder.idealStates("TestDB1"), idealState);
Assert.assertFalse(succeed);