admin.addInstance(className, instanceConfig);
// oversized data should not create any new data on zk
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(className, new ZkBaseDataAccessor(zkClient));
Builder keyBuilder = accessor.keyBuilder();
// ZNRecord statusUpdates = new ZNRecord("statusUpdates");
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("TestDB_1"),
idealState);
Assert.assertFalse(succeed);
HelixProperty property =
accessor.getProperty(keyBuilder.idealStates("TestDB_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("TestDB_2"),
idealState);
Assert.assertTrue(succeed);
record =
accessor.getProperty(keyBuilder.idealStates("TestDB_2")).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("TestDB_2"),
idealState);
Assert.assertFalse(succeed);
recordNew =
accessor.getProperty(keyBuilder.idealStates("TestDB_2")).getRecord();
arr = serializer.serialize(record);
arrNew = serializer.serialize(recordNew);
Assert.assertTrue(Arrays.equals(arr, arrNew));
System.out.println("END testZNRecordSizeLimitUseZNRecordStreamingSerializer at "