private ContentClaim createClaim(final String container, final String section, final String identifier, final Long offset) { if (container == null || section == null || identifier == null) { return null; } final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(container, section, identifier, false, false); return new StandardContentClaim(resourceClaim, offset == null ? 0L : offset.longValue()); }
private ContentClaim createLossTolerant() { final long id = idGenerator.getAndIncrement(); final ResourceClaim resourceClaim = claimManager.newResourceClaim(CONTAINER_NAME, "section", String.valueOf(id), true, false); final ContentClaim claim = new StandardContentClaim(resourceClaim, 0L); final ContentBlock contentBlock = new ContentBlock(claim, repoSize); claimManager.incrementClaimantCount(resourceClaim, true); claimMap.put(claim, contentBlock); logger.debug("Created {} and mapped to {}", claim, contentBlock); return claim; }
private void removeIncompleteContent(final String containerName, final Path containerPath, final Path fileToRemove) { if (Files.isDirectory(fileToRemove)) { final Path lastPathName = fileToRemove.subpath(1, fileToRemove.getNameCount()); final String fileName = lastPathName.toFile().getName(); if (fileName.equals(ARCHIVE_DIR_NAME)) { return; } final File[] children = fileToRemove.toFile().listFiles(); if (children != null) { for (final File child : children) { removeIncompleteContent(containerName, containerPath, child.toPath()); } } return; } final Path relativePath = containerPath.relativize(fileToRemove); final Path sectionPath = relativePath.subpath(0, 1); if (relativePath.getNameCount() < 2) { return; } final Path idPath = relativePath.subpath(1, relativePath.getNameCount()); final String id = idPath.toFile().getName(); final String sectionName = sectionPath.toFile().getName(); final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(containerName, sectionName, id, false, false); if (resourceClaimManager.getClaimantCount(resourceClaim) == 0) { removeIncompleteContent(fileToRemove); } }
final String claimId = System.currentTimeMillis() + "-" + currentIndex; resourceClaim = resourceClaimManager.newResourceClaim(containerName, section, claimId, lossTolerant, true); resourceOffset = 0L; LOG.debug("Creating new Resource Claim {}", resourceClaim);
final ResourceClaim resourceClaim = claimManager.newResourceClaim(container, section, claimId, lossTolerant, false); final StandardContentClaim contentClaim = new StandardContentClaim(resourceClaim, resourceOffset); contentClaim.setLength(resourceLength);
public static ResourceClaim getResourceClaim(final Record record, final ResourceClaimManager claimManager) { final String container = (String) record.getFieldValue(ContentClaimSchema.CLAIM_CONTAINER); final String section = (String) record.getFieldValue(ContentClaimSchema.CLAIM_SECTION); final String identifier = (String) record.getFieldValue(ContentClaimSchema.CLAIM_IDENTIFIER); final Boolean lossTolerant = (Boolean) record.getFieldValue(ContentClaimSchema.LOSS_TOLERANT); // Make sure that we preserve the existing ResourceClaim, if there is already one held by the Resource Claim Manager // because we need to honor its determination of whether or not the claim is writable. If the Resource Claim Manager // does not have a copy of this Resource Claim, then we can go ahead and just create one and assume that it is not // writable (because if it were writable, then the Resource Claim Manager would know about it). ResourceClaim resourceClaim = claimManager.getResourceClaim(container, section, identifier); if (resourceClaim == null) { resourceClaim = claimManager.newResourceClaim(container, section, identifier, lossTolerant, false); } return resourceClaim; }
+ "but this Resource Claim cannot be found! Will create a temporary Resource Claim, but this may affect the framework's " + "ability to properly clean up this resource", container, section, claimId); resourceClaim = claimManager.newResourceClaim(container, section, claimId, lossTolerant, true);
public static ContentClaim getContentClaim(final Record claimRecord, final ResourceClaimManager resourceClaimManager) { final Record resourceClaimRecord = (Record) claimRecord.getFieldValue(ContentClaimSchema.RESOURCE_CLAIM); final String container = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_CONTAINER); final String section = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_SECTION); final String identifier = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_IDENTIFIER); final Boolean lossTolerant = (Boolean) resourceClaimRecord.getFieldValue(ContentClaimSchema.LOSS_TOLERANT); final Long length = (Long) claimRecord.getFieldValue(ContentClaimSchema.CONTENT_CLAIM_LENGTH); final Long resourceOffset = (Long) claimRecord.getFieldValue(ContentClaimSchema.RESOURCE_CLAIM_OFFSET); // Make sure that we preserve the existing ResourceClaim, if there is already one held by the Resource Claim Manager // because we need to honor its determination of whether or not the claim is writable. If the Resource Claim Manager // does not have a copy of this Resource Claim, then we can go ahead and just create one and assume that it is not // writable (because if it were writable, then the Resource Claim Manager would know about it). ResourceClaim resourceClaim = resourceClaimManager.getResourceClaim(container, section, identifier); if (resourceClaim == null) { resourceClaim = resourceClaimManager.newResourceClaim(container, section, identifier, lossTolerant, false); } final StandardContentClaim contentClaim = new StandardContentClaim(resourceClaim, resourceOffset); contentClaim.setLength(length); return contentClaim; }
final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(contentClaimContainer, contentClaimSection, contentClaimId, false, false); final ContentClaim contentClaim = new StandardContentClaim(resourceClaim, event.getPreviousContentClaimOffset());
final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(provEvent.getPreviousContentClaimContainer(), provEvent.getPreviousContentClaimSection(), provEvent.getPreviousContentClaimIdentifier(), false, false); claim = new StandardContentClaim(resourceClaim, provEvent.getPreviousContentClaimOffset()); final ResourceClaim resourceClaim = resourceClaimManager.newResourceClaim(provEvent.getContentClaimContainer(), provEvent.getContentClaimSection(), provEvent.getContentClaimIdentifier(), false, false);
event.getPreviousContentClaimSection(), event.getPreviousContentClaimIdentifier()); if (resourceClaim == null) { resourceClaim = resourceClaimManager.newResourceClaim(event.getPreviousContentClaimContainer(), event.getPreviousContentClaimSection(), event.getPreviousContentClaimIdentifier(), false, false);
final ResourceClaim resourceClaim = claimManager.newResourceClaim(container, section, claimId, lossTolerant, false); final StandardContentClaim contentClaim = new StandardContentClaim(resourceClaim, resourceOffset); contentClaim.setLength(resourceLength);
public static ResourceClaim getResourceClaim(final Record record, final ResourceClaimManager claimManager) { final String container = (String) record.getFieldValue(ContentClaimSchema.CLAIM_CONTAINER); final String section = (String) record.getFieldValue(ContentClaimSchema.CLAIM_SECTION); final String identifier = (String) record.getFieldValue(ContentClaimSchema.CLAIM_IDENTIFIER); final Boolean lossTolerant = (Boolean) record.getFieldValue(ContentClaimSchema.LOSS_TOLERANT); // Make sure that we preserve the existing ResourceClaim, if there is already one held by the Resource Claim Manager // because we need to honor its determination of whether or not the claim is writable. If the Resource Claim Manager // does not have a copy of this Resource Claim, then we can go ahead and just create one and assume that it is not // writable (because if it were writable, then the Resource Claim Manager would know about it). ResourceClaim resourceClaim = claimManager.getResourceClaim(container, section, identifier); if (resourceClaim == null) { resourceClaim = claimManager.newResourceClaim(container, section, identifier, lossTolerant, false); } return resourceClaim; }
public static ContentClaim getContentClaim(final Record claimRecord, final ResourceClaimManager resourceClaimManager) { final Record resourceClaimRecord = (Record) claimRecord.getFieldValue(ContentClaimSchema.RESOURCE_CLAIM); final String container = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_CONTAINER); final String section = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_SECTION); final String identifier = (String) resourceClaimRecord.getFieldValue(ContentClaimSchema.CLAIM_IDENTIFIER); final Boolean lossTolerant = (Boolean) resourceClaimRecord.getFieldValue(ContentClaimSchema.LOSS_TOLERANT); final Long length = (Long) claimRecord.getFieldValue(ContentClaimSchema.CONTENT_CLAIM_LENGTH); final Long resourceOffset = (Long) claimRecord.getFieldValue(ContentClaimSchema.RESOURCE_CLAIM_OFFSET); // Make sure that we preserve the existing ResourceClaim, if there is already one held by the Resource Claim Manager // because we need to honor its determination of whether or not the claim is writable. If the Resource Claim Manager // does not have a copy of this Resource Claim, then we can go ahead and just create one and assume that it is not // writable (because if it were writable, then the Resource Claim Manager would know about it). ResourceClaim resourceClaim = resourceClaimManager.getResourceClaim(container, section, identifier); if (resourceClaim == null) { resourceClaim = resourceClaimManager.newResourceClaim(container, section, identifier, lossTolerant, false); } final StandardContentClaim contentClaim = new StandardContentClaim(resourceClaim, resourceOffset); contentClaim.setLength(length); return contentClaim; }