pkuwm commented on a change in pull request #845: Async write operation should
not throw Exception for serializing error
URL: https://github.com/apache/helix/pull/845#discussion_r386744545
##########
File path:
helix-core/src/test/java/org/apache/helix/manager/zk/TestRawZkClient.java
##########
@@ -745,4 +749,65 @@ public void testWaitForEstablishedSession() {
// Recover zk server for later tests.
_zkServer.start();
}
+
+ @Test
+ public void testAsyncWriteOperations() {
+ ZkClient zkClient = new ZkClient(ZK_ADDR);
+ String originSizeLimit =
+
System.getProperty(ZkSystemPropertyKeys.ZK_SERIALIZER_ZNRECORD_WRITE_SIZE_LIMIT_BYTES);
+
System.setProperty(ZkSystemPropertyKeys.ZK_SERIALIZER_ZNRECORD_WRITE_SIZE_LIMIT_BYTES,
"2000");
+ try {
+ zkClient.setZkSerializer(new ZNRecordSerializer());
+
+ ZNRecord oversizeZNRecord = new ZNRecord("Oversize");
+ StringBuilder sb = new StringBuilder(1204);
+ Random ran = new Random();
+ for (int i = 0; i < 1024; i++) {
+ sb.append(ran.nextInt(26) + 'a');
+ }
+ String buf = sb.toString();
+ for (int i = 0; i < 1024; i++) {
+ oversizeZNRecord.setSimpleField(Integer.toString(i), buf);
+ }
+
+ // ensure /tmp exists for the test
+ if (!zkClient.exists("/tmp")) {
+ zkClient.create("/tmp", null, CreateMode.PERSISTENT);
+ }
+
+
org.apache.helix.zookeeper.zkclient.callback.ZkAsyncCallbacks.CreateCallbackHandler
+ createCallback = new
org.apache.helix.zookeeper.zkclient.callback.ZkAsyncCallbacks.CreateCallbackHandler();
+ zkClient.asyncCreate("/tmp/async", null, CreateMode.PERSISTENT,
createCallback);
+ createCallback.waitForSuccess();
+ Assert.assertEquals(createCallback.getRc(), 0);
+
+ // try to create oversize node, should fail
+ zkClient.asyncCreate("/tmp/asyncOversize", oversizeZNRecord,
CreateMode.PERSISTENT,
+ createCallback);
+ createCallback.waitForSuccess();
+ Assert.assertEquals(createCallback.getRc(),
KeeperException.Code.MarshallingError);
Review comment:
Nit: Do you also want to check before and after: if the node exists or not
to double check the node is not created?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]