diff options
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java index a7555307a59..ce5869af1a0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java @@ -17,6 +17,7 @@ import java.net.URI; import java.util.HashSet; import java.util.Map; import java.util.Optional; +import java.util.OptionalInt; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -29,14 +30,6 @@ import java.util.stream.Collectors; public class CuratorArchiveBucketDb { /** - * Due to policy limits, we can't put data for more than this many tenants in a bucket. - * Policy size limit is 20kb, about 550 bytes for non-tenant related policies. Each tenant - * needs about 500 + len(role_arn) bytes, we limit role_arn to 100 characters, so we can - * fit about (20k - 550) / 600 ~ 32 tenants per bucket. - */ - private final static int TENANTS_PER_BUCKET = 30; - - /** * Archive URIs are often requested because they are returned in /application/v4 API. Since they * never change, it's safe to cache them and only update on misses */ @@ -84,7 +77,7 @@ public class CuratorArchiveBucketDb { .orElseGet(() -> { // If not, find an existing bucket with space Optional<ArchiveBucket> unfilledBucket = zoneBuckets.stream() - .filter(bucket -> bucket.tenants().size() < TENANTS_PER_BUCKET) + .filter(bucket -> bucket.tenants().size() < tenantsPerBucket().orElse(Integer.MAX_VALUE)) .findAny(); // And place the tenant in that bucket. @@ -99,7 +92,8 @@ public class CuratorArchiveBucketDb { } // We'll have to create a new bucket - var newBucket = archiveService.createArchiveBucketFor(zoneId).withTenant(tenant); + var newBucket = archiveService.createArchiveBucketFor(zoneId, tenantsPerBucket().isPresent()) + .withTenant(tenant); zoneBuckets.add(newBucket); curatorDb.writeArchiveBuckets(zoneId, zoneBuckets); updateArchiveUriCache(zoneId, zoneBuckets); @@ -121,6 +115,23 @@ public class CuratorArchiveBucketDb { return bucketName; } + private OptionalInt tenantsPerBucket() { + if (system.isPublic()) { + /* + * Due to policy limits, we can't put data for more than this many tenants in a bucket. + * Policy size limit is 20kb, about 550 bytes for non-tenant related policies. Each tenant + * needs about 500 + len(role_arn) bytes, we limit role_arn to 100 characters, so we can + * fit about (20k - 550) / 600 ~ 32 tenants per bucket. + */ + return OptionalInt.of(30); + } else { + /* + * The S3 policies in main/cd have a fixed size. + */ + return OptionalInt.empty(); + } + } + private Optional<String> getBucketNameFromCache(ZoneId zoneId, TenantName tenantName) { return Optional.ofNullable(archiveUriCache.get(zoneId)).map(map -> map.get(tenantName)); } |