pkuwm commented on a change in pull request #1066: URL: https://github.com/apache/helix/pull/1066#discussion_r436131950
########## File path: helix-core/src/main/java/org/apache/helix/controller/ControllerLeaderSession.java ########## @@ -0,0 +1,36 @@ +package org.apache.helix.controller; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * A thin wrapper to include a ZK session. This is created for controller leader to retrieve ZK + * session from Helix Manager in the mean time when checking leadership. + */ +public class ControllerLeaderSession { Review comment: `AtomicReference` would work, but it over qualifies. It guarantees the variable could be read and write **atomically**. It is designed for multi threading. Here in our case, we only need a way to get the value set out of scope as below: ``` var name; foo(name); // sets name = "helix" inside method print(name); // prints "helix" ``` We don't need atomicity. `AtomicReference` would be heavier than this light wrapper as internally it needs more memory work to guarantee atomicity. So I go with the thin wrapper which satisfies us better. ---------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
