@Override public ResourceClaim newResourceClaim(final String container, final String section, final String id, final boolean lossTolerant, final boolean writable) { final StandardResourceClaim claim = new StandardResourceClaim(this, container, section, id, lossTolerant); if (!writable) { claim.freeze(); } return claim; }
@Override public boolean isInUse() { // Note that it is critical here that we always check isWritable() BEFORE checking // the claimant count. This is due to the fact that if the claim is in fact writable, the claimant count // could increase. So if we first check claimant count and that is 0, and then we check isWritable, it may be // that the claimant count has changed to 1 before checking isWritable. // However, if isWritable() is false, then the only way that the claimant count can increase is if a FlowFile referencing // the Resource Claim is cloned. In this case, though, the claimant count has not become 0. // Said another way, if isWritable() == false, then the claimant count can never increase from 0. return isWritable() || claimManager.getClaimantCount(this) > 0; } }
@Override public ResourceClaim getResourceClaim(final String container, final String section, final String id) { final ResourceClaim tempClaim = new StandardResourceClaim(this, container, section, id, false); final ClaimCount count = claimantCounts.get(tempClaim); return (count == null) ? null : count.getClaim(); }
@Override public void freeze(final ResourceClaim claim) { if (claim == null) { return; } if (!(claim instanceof StandardResourceClaim)) { throw new IllegalArgumentException("The given resource claim is not managed by this Resource Claim Manager"); } ((StandardResourceClaim) claim).freeze(); synchronized (claim) { if (getClaimantCount(claim) == 0) { claimantCounts.remove(claim); } } }
@Override public ResourceClaim getResourceClaim(final String container, final String section, final String id) { final ResourceClaim tempClaim = new StandardResourceClaim(this, container, section, id, false); final ClaimCount count = claimantCounts.get(tempClaim); return (count == null) ? null : count.getClaim(); }
@Override public void freeze(final ResourceClaim claim) { if (claim == null) { return; } if (!(claim instanceof StandardResourceClaim)) { throw new IllegalArgumentException("The given resource claim is not managed by this Resource Claim Manager"); } ((StandardResourceClaim) claim).freeze(); synchronized (claim) { if (getClaimantCount(claim) == 0) { claimantCounts.remove(claim); } } }
@Override public ResourceClaim newResourceClaim(final String container, final String section, final String id, final boolean lossTolerant, final boolean writable) { final StandardResourceClaim claim = new StandardResourceClaim(this, container, section, id, lossTolerant); if (!writable) { claim.freeze(); } return claim; }
@Override public boolean isInUse() { // Note that it is critical here that we always check isWritable() BEFORE checking // the claimant count. This is due to the fact that if the claim is in fact writable, the claimant count // could increase. So if we first check claimant count and that is 0, and then we check isWritable, it may be // that the claimant count has changed to 1 before checking isWritable. // However, if isWritable() is false, then the only way that the claimant count can increase is if a FlowFile referencing // the Resource Claim is cloned. In this case, though, the claimant count has not become 0. // Said another way, if isWritable() == false, then the claimant count can never increase from 0. return isWritable() || claimManager.getClaimantCount(this) > 0; } }