jiajunwang commented on a change in pull request #671: Add ZooKeeperAccessor to
helix-rest
URL: https://github.com/apache/helix/pull/671#discussion_r366723464
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/server/ServerContext.java
##########
@@ -122,27 +122,34 @@ public HelixDataAccessor getDataAccssor(String
clusterName) {
}
}
- public ZkBaseDataAccessor<byte[]> getByteArrayBaseDataAccessor() {
- if (_byteArrayBaseDataAccessor == null) {
- synchronized (this) {
- if (_byteArrayBaseDataAccessor == null) {
- _byteArrayBaseDataAccessor = new ZkBaseDataAccessor<>(_zkAddr, new
ZkSerializer() {
- @Override
- public byte[] serialize(Object o)
- throws ZkMarshallingError {
- throw new UnsupportedOperationException("Serialize is not
supported yet!");
- }
-
- @Override
- public Object deserialize(byte[] bytes)
- throws ZkMarshallingError {
- return bytes;
- }
- });
- }
+ /**
+ * Returns a lazily-instantiated ZkBaseDataAccessor for the byte array type.
+ * @return
+ */
+ public ZkBaseDataAccessor<byte[]> getByteArrayZkBaseDataAccessor() {
+ ZkBaseDataAccessor<byte[]> byteArrayZkBaseDataAccessor =
_byteArrayZkBaseDataAccessor;
+ if (byteArrayZkBaseDataAccessor != null) { // First check (no locking)
+ return byteArrayZkBaseDataAccessor;
+ }
+
+ synchronized (this) {
+ if (_byteArrayZkBaseDataAccessor == null) { // Second check (with
locking)
+ _byteArrayZkBaseDataAccessor = new ZkBaseDataAccessor<>(_zkAddr, new
ZkSerializer() {
+ @Override
+ public byte[] serialize(Object o)
+ throws ZkMarshallingError {
+ throw new UnsupportedOperationException("serialize() is not
supported yet!");
Review comment:
nit, I think "yet" is not necessary. Just say "serialize() is not
supported!" or "write is not supported!"?
----------------------------------------------------------------
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]