review-followup Wave 3 라운드 3(P19): 3-D 공통 유틸 — Sha256·HmacSha256·Backoff·MdcKeys·TenantId, caller 트랜잭션 guard 하나
- shared-contract `Sha256`(약 65벌 흡수, notification `MessageDigestPort` 삭제), `HmacSha256`(서명 헬퍼), `Backoff`("full jitter" 뜻 하나),
`MdcKeys`(gRPC·STOMP에도 상관관계), registry edge application-notification → shared-contract
- application-core `TenantId` 하나로 web·GraphQL tenant 문법 통일, web operation 경로에 tenant 해석(JWT `tenant_id`)
- persistence-jpa `CallerTransaction` 하나(복사본 4벌 + `JpaStreamScope` 흡수), 범위 없는 멱등성·outbox 리포지토리 메서드 제거(E-6b)
- 주입된 `Clock` 우회 제거(objectstorage·websocket·mongo·web stream), GraphQL 오류가 HTTP request id 사용, notification UUIDv7은 uuid-creator
- 호출처 없는 `WebRequestContext`·argument resolver 삭제
- 결함 수정: `WebStreamRegistry` 상한 경합(ORCH-new-3 — bin 하나만 잠그는 lock 안에서 크기 확인, 원자 카운터로 슬롯 예약)
- 현황표: 소유자 결정 33(persistence-notification·fileserver → persistence-jpa edge), 34(id 포트 domain 전환 보류), 35(X2-P2-6b 나머지 보류)
검증: ./gradlew check architectureCheck verifyDependencyLocks verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys configContractCheck
:app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest graphql·websocket systemTest
persistence-jpa jpaPlatformContractTest·postgresql{Idempotency,Outbox*}IntegrationTest --continue 통과(695 task)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4f4bd1fd34
commit
09e2dd63d6
+2
-11
@@ -1,10 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.objectstorage.codec;
|
||||
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
|
||||
/** Canonical lowercase Crockford Base32 and bounded namespace support. */
|
||||
public final class CrockfordBase32 {
|
||||
@@ -46,12 +43,6 @@ public final class CrockfordBase32 {
|
||||
}
|
||||
|
||||
static String sha256Hex(String value) {
|
||||
try {
|
||||
return HexFormat.of()
|
||||
.formatHex(
|
||||
MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
return Sha256.ofUtf8(value).hex();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -2,9 +2,7 @@ package dev.caskeleton.adapter.outbound.objectstorage.codec;
|
||||
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectId;
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectOperationKey;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -31,13 +29,8 @@ public final class ObjectIdentityCodec {
|
||||
+ operationKey.operationId().value()
|
||||
+ "\n"
|
||||
+ requestFingerprint;
|
||||
try {
|
||||
byte[] digest =
|
||||
MessageDigest.getInstance("SHA-256").digest(seed.getBytes(StandardCharsets.UTF_8));
|
||||
return ObjectId.parse(CrockfordBase32.encode(Arrays.copyOf(digest, 16), 26));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
byte[] digest = Sha256.ofUtf8(seed).bytes();
|
||||
return ObjectId.parse(CrockfordBase32.encode(Arrays.copyOf(digest, 16), 26));
|
||||
}
|
||||
|
||||
/** Lower-case hex SHA-256 of the UTF-8 bytes of {@code value}. */
|
||||
|
||||
+25
-8
@@ -6,6 +6,7 @@ import dev.caskeleton.adapter.outbound.objectstorage.routing.RoutingObjectMutati
|
||||
import dev.caskeleton.adapter.outbound.objectstorage.routing.RoutingObjectReadAdapter;
|
||||
import dev.caskeleton.adapter.outbound.objectstorage.s3.S3ObjectStorageProviderContribution;
|
||||
import dev.caskeleton.application.outbound.SecretSourcePort;
|
||||
import java.time.Clock;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -41,10 +42,11 @@ public class ObjectStorageCapabilityConfig {
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(name = "s3ObjectStorageProviderContribution")
|
||||
public ObjectStorageProviderContribution s3ObjectStorageProviderContribution(
|
||||
ObjectProvider<SecretSourcePort> secretSources) {
|
||||
ObjectProvider<SecretSourcePort> secretSources, ObjectProvider<Clock> clocks) {
|
||||
// Looked up when an S3 binding actually resolves a credential, so a local-only composition
|
||||
// without a secret backend still starts; an S3 credential without one fails at that point.
|
||||
return new S3ObjectStorageProviderContribution(key -> secretSources.getObject().resolve(key));
|
||||
return new S3ObjectStorageProviderContribution(
|
||||
key -> secretSources.getObject().resolve(key), clock(clocks));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -54,7 +56,9 @@ public class ObjectStorageCapabilityConfig {
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public ObjectStorageBindingCompiler objectStorageBindingCompiler(
|
||||
List<ObjectStorageProviderContribution> contributions, Environment environment) {
|
||||
List<ObjectStorageProviderContribution> contributions,
|
||||
Environment environment,
|
||||
ObjectProvider<Clock> clocks) {
|
||||
Set<String> profiles =
|
||||
Set.copyOf(
|
||||
Arrays.asList(
|
||||
@@ -64,7 +68,8 @@ public class ObjectStorageCapabilityConfig {
|
||||
boolean scannerWorkflowEnabled =
|
||||
environment.getProperty(
|
||||
"app.object-storage.scan-maintenance.enabled", Boolean.class, false);
|
||||
return new ObjectStorageBindingCompiler(contributions, profiles, scannerWorkflowEnabled);
|
||||
return new ObjectStorageBindingCompiler(
|
||||
contributions, profiles, scannerWorkflowEnabled, clock(clocks));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -97,8 +102,9 @@ public class ObjectStorageCapabilityConfig {
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public RoutingObjectMutationAdapter routingObjectMutationAdapter(
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability) {
|
||||
return new RoutingObjectMutationAdapter(capability);
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability,
|
||||
ObjectProvider<Clock> clocks) {
|
||||
return new RoutingObjectMutationAdapter(capability, clock(clocks));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -108,8 +114,9 @@ public class ObjectStorageCapabilityConfig {
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public ObjectPublicationHandoffService objectPublicationHandoffService(
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability) {
|
||||
return new ObjectPublicationHandoffService(capability, java.time.Clock.systemUTC());
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability,
|
||||
ObjectProvider<Clock> clocks) {
|
||||
return new ObjectPublicationHandoffService(capability, clock(clocks));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -122,4 +129,14 @@ public class ObjectStorageCapabilityConfig {
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability) {
|
||||
return new RoutingObjectReadAdapter(capability);
|
||||
}
|
||||
|
||||
/**
|
||||
* The application's {@link Clock} bean, or the system UTC clock when the composition has none.
|
||||
*
|
||||
* <p>One clock for the whole capability: a component that read {@code Instant.now()} beside an
|
||||
* injected clock recorded times a test (or a deployment with a controlled clock) could not see.
|
||||
*/
|
||||
static Clock clock(ObjectProvider<Clock> clocks) {
|
||||
return clocks.getIfAvailable(Clock::systemUTC);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -1,6 +1,8 @@
|
||||
package dev.caskeleton.adapter.outbound.objectstorage.config;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.objectstorage.routing.RoutingObjectScanMaintenanceAdapter;
|
||||
import java.time.Clock;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -20,7 +22,9 @@ public class ObjectStorageScanMaintenanceConfig {
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
public RoutingObjectScanMaintenanceAdapter routingObjectScanMaintenanceAdapter(
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability) {
|
||||
return new RoutingObjectScanMaintenanceAdapter(capability, java.time.Clock.systemUTC());
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability,
|
||||
ObjectProvider<Clock> clocks) {
|
||||
return new RoutingObjectScanMaintenanceAdapter(
|
||||
capability, ObjectStorageCapabilityConfig.clock(clocks));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-7
@@ -24,14 +24,13 @@ import dev.caskeleton.application.objectstorage.model.ObjectMediaType;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectPublicationRequirement;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectRetentionRequirement;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectScanState;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.Base64;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -104,11 +103,7 @@ public final class CanonicalJsonObjectControlRecordCodec implements ObjectContro
|
||||
}
|
||||
|
||||
public String sha256Hex(byte[] value) {
|
||||
try {
|
||||
return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
return Sha256.of(value).hex();
|
||||
}
|
||||
|
||||
private static byte[] payload(ObjectControlRecord record) {
|
||||
|
||||
+2
-12
@@ -3,12 +3,9 @@ package dev.caskeleton.adapter.outbound.objectstorage.control;
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectOperationKey;
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectStageHandle;
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectVersionToken;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Durable monotonically fenced application-to-publication handoff lease. */
|
||||
@@ -191,13 +188,6 @@ public record ObjectPublicationHandoffRecord(
|
||||
if (claimant == null || claimant.isBlank() || claimant.length() > 128) {
|
||||
throw new IllegalArgumentException("handoff claimant is invalid");
|
||||
}
|
||||
try {
|
||||
return HexFormat.of()
|
||||
.formatHex(
|
||||
MessageDigest.getInstance("SHA-256")
|
||||
.digest(claimant.getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
return Sha256.ofUtf8(claimant).hex();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-10
@@ -11,6 +11,7 @@ import dev.caskeleton.application.objectstorage.identity.ObjectId;
|
||||
import dev.caskeleton.application.objectstorage.identity.ObjectVersionToken;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectContentIdentity;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectDigest;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
@@ -20,7 +21,6 @@ import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class LocalDevObjectDataStore {
|
||||
return Optional.empty();
|
||||
}
|
||||
try {
|
||||
MessageDigest digest = sha256();
|
||||
MessageDigest digest = Sha256.newMessageDigest();
|
||||
long size = 0;
|
||||
ByteBuffer buffer = ByteBuffer.allocate(64 * 1024);
|
||||
try (FileChannel channel = FileChannel.open(source, StandardOpenOption.READ)) {
|
||||
@@ -173,14 +173,6 @@ public final class LocalDevObjectDataStore {
|
||||
ObjectRouteToken.parse(segments[2]), ObjectId.parse(segments[4]));
|
||||
}
|
||||
|
||||
private static MessageDigest sha256() {
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static ObjectStorageProviderException conflict() {
|
||||
return new ObjectStorageProviderException(
|
||||
ObjectStorageProviderException.Failure.CONFLICT, "local immutable object already exists");
|
||||
|
||||
+2
-10
@@ -15,13 +15,13 @@ import dev.caskeleton.application.objectstorage.content.ObjectContentProductionE
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentReadContext;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectContentIdentity;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectDigest;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class LocalObjectStreamTransfer {
|
||||
throws IOException {
|
||||
Objects.requireNonNull(producer, "producer must be non-null");
|
||||
requireActive(operation.budget(), operation.cancellation().isCancelled());
|
||||
MessageDigest digest = sha256();
|
||||
MessageDigest digest = Sha256.newMessageDigest();
|
||||
long[] written = {0};
|
||||
ObjectContentProductionContext context =
|
||||
ObjectContentProductionContext.open(
|
||||
@@ -160,14 +160,6 @@ public final class LocalObjectStreamTransfer {
|
||||
}
|
||||
}
|
||||
|
||||
private static MessageDigest sha256() {
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireActive(
|
||||
dev.caskeleton.application.outbound.CallBudget budget, boolean cancelled) {
|
||||
if (cancelled) {
|
||||
|
||||
+13
-11
@@ -19,7 +19,7 @@ import dev.caskeleton.application.objectstorage.model.ObjectMutationOutcome;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectPublicationRequirement;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectPublishReceipt;
|
||||
import dev.caskeleton.application.objectstorage.request.ObjectPublishRequest;
|
||||
import java.time.Instant;
|
||||
import java.time.Clock;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -33,12 +33,14 @@ import java.util.Optional;
|
||||
public final class ManagedObjectPublicationKernel {
|
||||
|
||||
private final ObjectStorageCapabilityAssembler.DestinationRuntime runtime;
|
||||
private final Clock clock;
|
||||
private final ObjectReferencePublicationService references =
|
||||
new ObjectReferencePublicationService();
|
||||
|
||||
public ManagedObjectPublicationKernel(
|
||||
ObjectStorageCapabilityAssembler.DestinationRuntime runtime) {
|
||||
ObjectStorageCapabilityAssembler.DestinationRuntime runtime, Clock clock) {
|
||||
this.runtime = Objects.requireNonNull(runtime, "runtime must be non-null");
|
||||
this.clock = Objects.requireNonNull(clock, "clock must be non-null");
|
||||
}
|
||||
|
||||
public ObjectPublishReceipt publish(
|
||||
@@ -69,7 +71,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
runtime.destination().route(),
|
||||
runtime.destination().policySnapshot(),
|
||||
request.contentIdentity(),
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
if (reserved.decision() == ObjectOperationKernelResult.Decision.CONFLICT) {
|
||||
throw new IllegalArgumentException("operation identity conflicts with a different intent");
|
||||
}
|
||||
@@ -100,7 +102,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
operation,
|
||||
PublicationOperationState.PUBLISHED,
|
||||
stored.contentIdentity(),
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
}
|
||||
ObjectOperationRecord terminal = requireOperation(request);
|
||||
@@ -118,7 +120,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
runtime.destination().policySnapshot().policyRevision().value());
|
||||
}
|
||||
|
||||
private static ObjectStorageProvider.StoredData continueDataPublication(
|
||||
private ObjectStorageProvider.StoredData continueDataPublication(
|
||||
ObjectOperationKernel kernel,
|
||||
ObjectOperationRecord initial,
|
||||
ObjectStorageProviderOperation providerOperation,
|
||||
@@ -128,7 +130,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
if (operation.stablePhase() == PublicationOperationState.RESERVED) {
|
||||
operation =
|
||||
kernel.advancePublication(
|
||||
operation, PublicationOperationState.DATA_UPLOAD_IN_PROGRESS, null, Instant.now());
|
||||
operation, PublicationOperationState.DATA_UPLOAD_IN_PROGRESS, null, clock.instant());
|
||||
}
|
||||
if (operation.stablePhase() != PublicationOperationState.DATA_UPLOAD_IN_PROGRESS) {
|
||||
return provider
|
||||
@@ -160,17 +162,17 @@ public final class ManagedObjectPublicationKernel {
|
||||
throw new IllegalStateException("provider create cannot be resolved safely");
|
||||
}
|
||||
if (operation.effectCertainty() != ObjectEffectCertainty.CONFIRMED) {
|
||||
operation = kernel.confirmEffect(operation, Instant.now());
|
||||
operation = kernel.confirmEffect(operation, clock.instant());
|
||||
}
|
||||
kernel.advancePublication(
|
||||
operation,
|
||||
PublicationOperationState.DATA_UPLOADED,
|
||||
stored.contentIdentity(),
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
return stored;
|
||||
}
|
||||
|
||||
private static ObjectOperationRecord advanceToReferencePublication(
|
||||
private ObjectOperationRecord advanceToReferencePublication(
|
||||
ObjectOperationKernel kernel, ObjectOperationRecord initial) {
|
||||
ObjectOperationRecord operation = initial;
|
||||
if (operation.stablePhase() == PublicationOperationState.DATA_UPLOADED) {
|
||||
@@ -179,7 +181,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
operation,
|
||||
PublicationOperationState.INTEGRITY_VERIFIED,
|
||||
operation.observedContentIdentity(),
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
if (operation.stablePhase() == PublicationOperationState.INTEGRITY_VERIFIED) {
|
||||
operation =
|
||||
@@ -187,7 +189,7 @@ public final class ManagedObjectPublicationKernel {
|
||||
operation,
|
||||
PublicationOperationState.REFERENCE_PUBLISH_IN_PROGRESS,
|
||||
operation.observedContentIdentity(),
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
+6
-12
@@ -30,7 +30,6 @@ import dev.caskeleton.application.objectstorage.request.ObjectRetireRequest;
|
||||
import dev.caskeleton.application.objectstorage.request.ObjectStageRequest;
|
||||
import dev.caskeleton.application.objectstorage.request.ObjectVerifyRequest;
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Normal mutation router. It never implements privileged purge or scanner-maintenance ports. */
|
||||
@@ -43,11 +42,6 @@ public final class RoutingObjectMutationAdapter
|
||||
private final ObjectStorageCapabilityAssembler.AssembledCapability capability;
|
||||
private final Clock clock;
|
||||
|
||||
public RoutingObjectMutationAdapter(
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability) {
|
||||
this(capability, Clock.systemUTC());
|
||||
}
|
||||
|
||||
public RoutingObjectMutationAdapter(
|
||||
ObjectStorageCapabilityAssembler.AssembledCapability capability, Clock clock) {
|
||||
this.capability = java.util.Objects.requireNonNull(capability);
|
||||
@@ -80,7 +74,7 @@ public final class RoutingObjectMutationAdapter
|
||||
public ObjectPublishReceipt publish(
|
||||
ObjectPublishRequest request, ObjectContentProducer producer) {
|
||||
return new ManagedObjectPublicationKernel(
|
||||
capability.destination(request.operationKey().destination()))
|
||||
capability.destination(request.operationKey().destination()), clock)
|
||||
.publish(request, producer);
|
||||
}
|
||||
|
||||
@@ -106,7 +100,7 @@ public final class RoutingObjectMutationAdapter
|
||||
request.operationKey(),
|
||||
ObjectMutationOutcome.REJECTED,
|
||||
ObjectOperationError.CONFLICT,
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
if (record.state() == PublishedReferenceState.RETIRED
|
||||
|| record.state() == PublishedReferenceState.PURGE_ELIGIBLE
|
||||
@@ -115,7 +109,7 @@ public final class RoutingObjectMutationAdapter
|
||||
request.operationKey(),
|
||||
ObjectMutationOutcome.REPLAYED,
|
||||
ObjectOperationError.NONE,
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
ObjectReferenceRecord pending =
|
||||
new ObjectReferenceRecord(
|
||||
@@ -126,7 +120,7 @@ public final class RoutingObjectMutationAdapter
|
||||
record.objectId(),
|
||||
record.immutableDataVersion(),
|
||||
PublishedReferenceState.RETIREMENT_PENDING,
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
current = store.compareAndSet(key, new ObjectControlMutation(current.version(), pending));
|
||||
ObjectReferenceRecord retired =
|
||||
new ObjectReferenceRecord(
|
||||
@@ -137,13 +131,13 @@ public final class RoutingObjectMutationAdapter
|
||||
record.objectId(),
|
||||
record.immutableDataVersion(),
|
||||
PublishedReferenceState.RETIRED,
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
store.compareAndSet(key, new ObjectControlMutation(current.version(), retired));
|
||||
return new ObjectMutationReceipt(
|
||||
request.operationKey(),
|
||||
ObjectMutationOutcome.APPLIED,
|
||||
ObjectOperationError.NONE,
|
||||
Instant.now());
|
||||
clock.instant());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-10
@@ -9,9 +9,9 @@ import dev.caskeleton.application.objectstorage.content.ObjectContentProducer;
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentProductionContext;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectContentIdentity;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectDigest;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -113,7 +113,7 @@ public final class S3AsyncRequestBodyBridge implements AsyncRequestBody {
|
||||
}
|
||||
|
||||
private void produce() {
|
||||
MessageDigest digest = sha256();
|
||||
MessageDigest digest = Sha256.newMessageDigest();
|
||||
long[] written = {0};
|
||||
CancellationView cancellation = () -> operation.cancellation().isCancelled() || isCancelled();
|
||||
ObjectContentProductionContext context =
|
||||
@@ -243,14 +243,6 @@ public final class S3AsyncRequestBodyBridge implements AsyncRequestBody {
|
||||
}
|
||||
}
|
||||
|
||||
private static MessageDigest sha256() {
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static ObjectStorageProviderException providerFailure(
|
||||
ObjectStorageProviderException.Failure failure, String message, Throwable cause) {
|
||||
return cause == null
|
||||
|
||||
+2
-10
@@ -6,9 +6,9 @@ import dev.caskeleton.application.objectstorage.content.ObjectChunkReadException
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectChunkSource;
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentConsumer;
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentReadContext;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
@@ -109,7 +109,7 @@ public final class S3AsyncResponseBodyBridge<R> implements AsyncResponseTransfor
|
||||
operation.contentIdentity(),
|
||||
operation.exactVersion(),
|
||||
operation.range());
|
||||
MessageDigest digest = sha256();
|
||||
MessageDigest digest = Sha256.newMessageDigest();
|
||||
ChunkCursor cursor = new ChunkCursor(subscriber, digest);
|
||||
ObjectChunkSource source = ObjectChunkSource.scoped(context, cursor::read);
|
||||
Throwable failure = null;
|
||||
@@ -323,14 +323,6 @@ public final class S3AsyncResponseBodyBridge<R> implements AsyncResponseTransfor
|
||||
}
|
||||
}
|
||||
|
||||
private static MessageDigest sha256() {
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Chunk {
|
||||
|
||||
private final byte[] bytes;
|
||||
|
||||
+3
-3
@@ -35,11 +35,11 @@ public final class S3ObjectStorageProviderContribution
|
||||
* Production contribution. Credential references resolve through the deployment's configured
|
||||
* secret backend, never straight from the process environment.
|
||||
*/
|
||||
public S3ObjectStorageProviderContribution(SecretSourcePort secretSource) {
|
||||
public S3ObjectStorageProviderContribution(SecretSourcePort secretSource, Clock clock) {
|
||||
this(
|
||||
Clock.systemUTC(),
|
||||
clock,
|
||||
new S3ProviderQualifier(
|
||||
Clock.systemUTC(),
|
||||
clock,
|
||||
(binding, plan) -> {
|
||||
throw new IllegalStateException("startup S3 probing is not configured");
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user