MCPcopy Create free account
hub / github.com/apache/solr / lock

Method lock

solr/core/src/java/org/apache/solr/cloud/LockTree.java:228–252  ·  view source on GitHub ↗
(LockLevel lockLevel, List<String> path, boolean reuseCurrentLock)

Source from the content-addressed store, hash-verified

226 }
227
228 Lock lock(LockLevel lockLevel, List<String> path, boolean reuseCurrentLock) {
229 if (myLock != null && !reuseCurrentLock) {
230 // I'm already locked. no need to go any further
231 return null;
232 }
233 if (lockLevel == level) {
234 // lock is supposed to be acquired at this level
235 if (myLock != null && reuseCurrentLock) {
236 // I am already locked, and I want to be re-used
237 refCount++;
238 return myLock;
239 }
240 // If I am locked or any of my children or grandchildren are locked
241 // it is not possible to acquire a lock
242 if (isLocked()) return null;
243 refCount++;
244 return myLock = new LockImpl(this);
245 } else {
246 String childName = path.get(level.getHeight());
247 Node child = children.get(childName);
248 if (child == null)
249 children.put(childName, child = new Node(childName, level.getChild(), this));
250 return child.lock(lockLevel, path, false);
251 }
252 }
253
254 boolean validateSubpath(int lockLevel, List<String> path) {
255 return level.getHeight() <= lockLevel

Callers 1

lockMethod · 0.95

Calls 5

isLockedMethod · 0.95
getHeightMethod · 0.80
getMethod · 0.65
putMethod · 0.65
getChildMethod · 0.45

Tested by

no test coverage detected