Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of ReferenceCountedACLCache in zk

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces what is the role of ReferenceCountedACLCache in zk, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Function: complete the conversion between LIst and Long. Acl in DataNode is a long value, not an ACL list.

Spatial complexity: inner class AtomicLongWithEquals

Attributes:

/ / log information private static final Logger LOG = LoggerFactory.getLogger (ReferenceCountedACLCache.class); / / long ACL list correspondence final Map longKeyMap = new HashMap (); / / ACL list long correspondence final Map aclKeyMap = new HashMap (); final Map referenceCounter = new HashMap (); private static final long OPEN_UNSAFE_ACL_ID =-1L * * these are the number of acls that we have in the datatree * / long aclIndex = 0

Methods:

Record the number of references

Private static class AtomicLongWithEquals extends AtomicLong {private static final long serialVersionUID = 3355155896813725462L; public AtomicLongWithEquals (long I) {super (I);} @ Override public boolean equals (Object o) {if (this = = o) {return true;} if (o = = null | | getClass ()! = o.getClass ()) {return false;} return equals ((AtomicLongWithEquals) o) } public boolean equals (AtomicLongWithEquals that) {return get () = = that.get ();} @ Override public int hashCode () {return 31 * Long.valueOf (get ()). HashCode ();}} add use public synchronized void addUsage (Long acl) {if (acl = = OPEN_UNSAFE_ACL_ID) {return } if (! longKeyMap.containsKey (acl)) {LOG.info ("Ignoring acl" + acl + "as it does not exist in the cache"); return;} AtomicLong count = referenceCounter.get (acl); if (count = = null) {referenceCounter.put (acl, new AtomicLongWithEquals (1));} else {count.incrementAndGet () }} / / remove reference public synchronized void removeUsage (Long acl) {if (acl = = OPEN_UNSAFE_ACL_ID) {return;} if (! longKeyMap.containsKey (acl)) {LOG.info ("Ignoring acl" + acl + "as it does not exist in the cache"); return;} long newCount = referenceCounter.get (acl). DecrementAndGet (); if (newCount)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report