From 3d86db966ecd75f40eb8d5b03189216160410040 Mon Sep 17 00:00:00 2001 From: Christian Westgaard Date: Tue, 17 Sep 2024 16:41:48 +0200 Subject: [PATCH] Better usage control of node cache size #10782 --- .../xp/index/PatternIndexConfigDocument.java | 2 +- .../com/enonic/xp/util/ByteSizeParser.java | 85 +---------------- .../blobstore/cache/BlobRecordWeigher.java | 16 ---- .../blobstore/cache/CachedBlobStore.java | 2 +- .../xp/core/impl/image/ImageServiceImpl.java | 4 +- .../xp/core/internal/ByteSizeParser.java | 95 +++++++++++++++++++ .../xp/core/internal}/MemoryLimitParser.java | 11 ++- .../xp/core/internal}/ByteSizeParserTest.java | 2 +- .../core/internal}/MemoryLimitParserTest.java | 2 +- .../repo/impl/config/RepoConfiguration.java | 2 +- .../impl/config/RepoConfigurationImpl.java | 4 +- .../impl/node/dao/NodeVersionServiceImpl.java | 62 ++++++++---- .../impl/node/json/AccessControlJson.java | 4 +- .../node/json/NodeVersionAccessControl.java | 20 ---- .../node/json/NodeVersionJsonSerializer.java | 11 ++- .../xp/repo/impl/config/default.properties | 2 +- .../src/home/config/com.enonic.xp.repo.cfg | 2 +- 17 files changed, 168 insertions(+), 158 deletions(-) delete mode 100644 modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/BlobRecordWeigher.java create mode 100644 modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/ByteSizeParser.java rename modules/core/{core-image/src/main/java/com/enonic/xp/core/impl/image => core-internal/src/main/java/com/enonic/xp/core/internal}/MemoryLimitParser.java (73%) rename modules/core/{core-api/src/test/java/com/enonic/xp/util => core-internal/src/test/java/com/enonic/xp/core/internal}/ByteSizeParserTest.java (98%) rename modules/core/{core-image/src/test/java/com/enonic/xp/core/impl/image => core-internal/src/test/java/com/enonic/xp/core/internal}/MemoryLimitParserTest.java (94%) delete mode 100644 modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionAccessControl.java diff --git a/modules/core/core-api/src/main/java/com/enonic/xp/index/PatternIndexConfigDocument.java b/modules/core/core-api/src/main/java/com/enonic/xp/index/PatternIndexConfigDocument.java index a1b9d540b51..78ace6b3b45 100644 --- a/modules/core/core-api/src/main/java/com/enonic/xp/index/PatternIndexConfigDocument.java +++ b/modules/core/core-api/src/main/java/com/enonic/xp/index/PatternIndexConfigDocument.java @@ -21,7 +21,7 @@ public final class PatternIndexConfigDocument { private final ImmutableSortedSet pathIndexConfigs; - private final Map pathIndexConfigMap; + private final ImmutableMap pathIndexConfigMap; private final IndexConfig defaultConfig; diff --git a/modules/core/core-api/src/main/java/com/enonic/xp/util/ByteSizeParser.java b/modules/core/core-api/src/main/java/com/enonic/xp/util/ByteSizeParser.java index a6c8b8745d6..4a0fe0f0c53 100644 --- a/modules/core/core-api/src/main/java/com/enonic/xp/util/ByteSizeParser.java +++ b/modules/core/core-api/src/main/java/com/enonic/xp/util/ByteSizeParser.java @@ -1,91 +1,14 @@ package com.enonic.xp.util; -import java.util.Locale; - -public class ByteSizeParser +public final class ByteSizeParser { - private static final long BYTE_FACTOR = 1L; - - private static final long KB_FACTOR = BYTE_FACTOR * 1024L; - - private static final long MB_FACTOR = KB_FACTOR * 1024L; - - private static final long GB_FACTOR = MB_FACTOR * 1024L; - - private static final long TB_FACTOR = GB_FACTOR * 1024L; - - private static final long PB_FACTOR = TB_FACTOR * 1024L; - - public static long parse( final String sValue ) + private ByteSizeParser() { - String postFix = sValue. - substring( sValue.length() - Math.min( 2, sValue.length() ) ). - toLowerCase( Locale.ROOT ); - - long bytes; - - if ( postFix.endsWith( "k" ) ) - { - bytes = (long) parseByteValue( sValue, KB_FACTOR, 1 ); - } - else if ( postFix.endsWith( "kb" ) ) - { - bytes = (long) ( parseByteValue( sValue, KB_FACTOR, 2 ) ); - } - else if ( postFix.endsWith( "m" ) ) - { - bytes = (long) ( parseByteValue( sValue, MB_FACTOR, 1 ) ); - } - else if ( postFix.endsWith( "mb" ) ) - { - bytes = (long) ( parseByteValue( sValue, MB_FACTOR, 2 ) ); - } - else if ( postFix.endsWith( "g" ) ) - { - bytes = (long) ( parseByteValue( sValue, GB_FACTOR, 1 ) ); - } - else if ( postFix.endsWith( "gb" ) ) - { - bytes = (long) ( parseByteValue( sValue, GB_FACTOR, 2 ) ); - } - else if ( postFix.endsWith( "t" ) ) - { - bytes = (long) ( parseByteValue( sValue, TB_FACTOR, 1 ) ); - } - else if ( postFix.endsWith( "tb" ) ) - { - bytes = (long) ( parseByteValue( sValue, TB_FACTOR, 2 ) ); - } - else if ( postFix.endsWith( "p" ) ) - { - bytes = (long) ( parseByteValue( sValue, PB_FACTOR, 1 ) ); - } - else if ( postFix.endsWith( "pb" ) ) - { - bytes = (long) ( parseByteValue( sValue, PB_FACTOR, 2 ) ); - } - else if ( postFix.endsWith( "b" ) ) - { - bytes = Long.parseLong( sValue.substring( 0, sValue.length() - 1 ) ); - } - else - { - bytes = Long.parseLong( sValue ); - } - - return bytes; } - private static double parseByteValue( final String sValue, final long kbFactor, final int postfixLenght ) + public static long parse( final String sValue ) { - try - { - return Double.parseDouble( sValue.substring( 0, sValue.length() - postfixLenght ) ) * kbFactor; - } - catch ( NumberFormatException e ) - { - throw new IllegalArgumentException( "Wrong format of size-value [" + sValue + "]" ); - } + return com.enonic.xp.core.internal.ByteSizeParser.parse( sValue ); } } diff --git a/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/BlobRecordWeigher.java b/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/BlobRecordWeigher.java deleted file mode 100644 index 4a3415b3e52..00000000000 --- a/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/BlobRecordWeigher.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.enonic.xp.internal.blobstore.cache; - -import com.google.common.cache.Weigher; - -import com.enonic.xp.blob.BlobKey; -import com.enonic.xp.blob.BlobRecord; - -final class BlobRecordWeigher - implements Weigher -{ - @Override - public int weigh( final BlobKey key, final BlobRecord record ) - { - return (int) record.getLength(); - } -} diff --git a/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/CachedBlobStore.java b/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/CachedBlobStore.java index 8ca55ca5de9..b3c80474f7c 100644 --- a/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/CachedBlobStore.java +++ b/modules/core/core-blobstore/src/main/java/com/enonic/xp/internal/blobstore/cache/CachedBlobStore.java @@ -168,7 +168,7 @@ private enum BlobRecordWeigher @Override public int weigh( final BlobKey key, final BlobRecord record ) { - return (int) record.getLength(); + return (int) Math.min( record.getLength(), Integer.MAX_VALUE ); } } } diff --git a/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/ImageServiceImpl.java b/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/ImageServiceImpl.java index bf099f1b26f..ece4d4186b7 100644 --- a/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/ImageServiceImpl.java +++ b/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/ImageServiceImpl.java @@ -34,6 +34,7 @@ import com.enonic.xp.content.ContentService; import com.enonic.xp.core.impl.image.effect.ImageScaleFunction; +import com.enonic.xp.core.internal.MemoryLimitParser; import com.enonic.xp.core.internal.SimpleCsvParser; import com.enonic.xp.home.HomeDir; import com.enonic.xp.image.Cropping; @@ -70,8 +71,7 @@ public ImageServiceImpl( @Reference final ContentService contentService, this.imageScaleFunctionBuilder = imageScaleFunctionBuilder; this.imageFilterBuilder = imageFilterBuilder; - this.circuitBreaker = new MemoryCircuitBreaker( - toMegaBytes( new MemoryLimitParser( Runtime.getRuntime()::maxMemory ).parse( config.memoryLimit() ) ) ); + this.circuitBreaker = new MemoryCircuitBreaker( toMegaBytes( MemoryLimitParser.maxHeap().parse( config.memoryLimit() ) ) ); this.progressiveOnFormats = SimpleCsvParser.parseLine( config.progressive() ) .stream() diff --git a/modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/ByteSizeParser.java b/modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/ByteSizeParser.java new file mode 100644 index 00000000000..34bdedadf28 --- /dev/null +++ b/modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/ByteSizeParser.java @@ -0,0 +1,95 @@ +package com.enonic.xp.core.internal; + +import java.util.Locale; + +public final class ByteSizeParser +{ + + private ByteSizeParser() + { + } + + private static final long BYTE_FACTOR = 1L; + + private static final long KB_FACTOR = BYTE_FACTOR * 1024L; + + private static final long MB_FACTOR = KB_FACTOR * 1024L; + + private static final long GB_FACTOR = MB_FACTOR * 1024L; + + private static final long TB_FACTOR = GB_FACTOR * 1024L; + + private static final long PB_FACTOR = TB_FACTOR * 1024L; + + public static long parse( final String sValue ) + { + String postFix = sValue. + substring( sValue.length() - Math.min( 2, sValue.length() ) ). + toLowerCase( Locale.ROOT ); + + long bytes; + + if ( postFix.endsWith( "k" ) ) + { + bytes = (long) parseByteValue( sValue, KB_FACTOR, 1 ); + } + else if ( postFix.endsWith( "kb" ) ) + { + bytes = (long) ( parseByteValue( sValue, KB_FACTOR, 2 ) ); + } + else if ( postFix.endsWith( "m" ) ) + { + bytes = (long) ( parseByteValue( sValue, MB_FACTOR, 1 ) ); + } + else if ( postFix.endsWith( "mb" ) ) + { + bytes = (long) ( parseByteValue( sValue, MB_FACTOR, 2 ) ); + } + else if ( postFix.endsWith( "g" ) ) + { + bytes = (long) ( parseByteValue( sValue, GB_FACTOR, 1 ) ); + } + else if ( postFix.endsWith( "gb" ) ) + { + bytes = (long) ( parseByteValue( sValue, GB_FACTOR, 2 ) ); + } + else if ( postFix.endsWith( "t" ) ) + { + bytes = (long) ( parseByteValue( sValue, TB_FACTOR, 1 ) ); + } + else if ( postFix.endsWith( "tb" ) ) + { + bytes = (long) ( parseByteValue( sValue, TB_FACTOR, 2 ) ); + } + else if ( postFix.endsWith( "p" ) ) + { + bytes = (long) ( parseByteValue( sValue, PB_FACTOR, 1 ) ); + } + else if ( postFix.endsWith( "pb" ) ) + { + bytes = (long) ( parseByteValue( sValue, PB_FACTOR, 2 ) ); + } + else if ( postFix.endsWith( "b" ) ) + { + bytes = Long.parseLong( sValue.substring( 0, sValue.length() - 1 ) ); + } + else + { + bytes = Long.parseLong( sValue ); + } + + return bytes; + } + + private static double parseByteValue( final String sValue, final long kbFactor, final int postfixLenght ) + { + try + { + return Double.parseDouble( sValue.substring( 0, sValue.length() - postfixLenght ) ) * kbFactor; + } + catch ( NumberFormatException e ) + { + throw new IllegalArgumentException( "Wrong format of size-value [" + sValue + "]" ); + } + } +} diff --git a/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/MemoryLimitParser.java b/modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/MemoryLimitParser.java similarity index 73% rename from modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/MemoryLimitParser.java rename to modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/MemoryLimitParser.java index 6aeb8631b27..b399a4b8a51 100644 --- a/modules/core/core-image/src/main/java/com/enonic/xp/core/impl/image/MemoryLimitParser.java +++ b/modules/core/core-internal/src/main/java/com/enonic/xp/core/internal/MemoryLimitParser.java @@ -1,10 +1,8 @@ -package com.enonic.xp.core.impl.image; +package com.enonic.xp.core.internal; import java.util.function.LongSupplier; -import com.enonic.xp.util.ByteSizeParser; - -public class MemoryLimitParser +public final class MemoryLimitParser { private final LongSupplier baselineSupplier; @@ -24,4 +22,9 @@ public long parse( final String value ) return ByteSizeParser.parse( value ); } } + + public static MemoryLimitParser maxHeap() + { + return new MemoryLimitParser( Runtime.getRuntime()::maxMemory ); + } } diff --git a/modules/core/core-api/src/test/java/com/enonic/xp/util/ByteSizeParserTest.java b/modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/ByteSizeParserTest.java similarity index 98% rename from modules/core/core-api/src/test/java/com/enonic/xp/util/ByteSizeParserTest.java rename to modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/ByteSizeParserTest.java index 14b476c99db..578bee6e541 100644 --- a/modules/core/core-api/src/test/java/com/enonic/xp/util/ByteSizeParserTest.java +++ b/modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/ByteSizeParserTest.java @@ -1,4 +1,4 @@ -package com.enonic.xp.util; +package com.enonic.xp.core.internal; import org.junit.jupiter.api.Test; diff --git a/modules/core/core-image/src/test/java/com/enonic/xp/core/impl/image/MemoryLimitParserTest.java b/modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/MemoryLimitParserTest.java similarity index 94% rename from modules/core/core-image/src/test/java/com/enonic/xp/core/impl/image/MemoryLimitParserTest.java rename to modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/MemoryLimitParserTest.java index 13cca5c5705..95733ab6576 100644 --- a/modules/core/core-image/src/test/java/com/enonic/xp/core/impl/image/MemoryLimitParserTest.java +++ b/modules/core/core-internal/src/test/java/com/enonic/xp/core/internal/MemoryLimitParserTest.java @@ -1,4 +1,4 @@ -package com.enonic.xp.core.impl.image; +package com.enonic.xp.core.internal; import java.util.function.LongSupplier; diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfiguration.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfiguration.java index fb1fab6312a..5884cda37f4 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfiguration.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfiguration.java @@ -6,5 +6,5 @@ public interface RepoConfiguration { Path getSnapshotsDir(); - int cacheSize(); + String cacheCapacity(); } diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfigurationImpl.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfigurationImpl.java index defd7e12bc3..fa16e8688f0 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfigurationImpl.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/config/RepoConfigurationImpl.java @@ -32,8 +32,8 @@ public Path getSnapshotsDir() } @Override - public int cacheSize() + public String cacheCapacity() { - return Integer.parseInt( this.config.get( "cache.size" ) ); + return this.config.get( "cache.capacity" ); } } diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/dao/NodeVersionServiceImpl.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/dao/NodeVersionServiceImpl.java index 413bb2a4916..8de447cea08 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/dao/NodeVersionServiceImpl.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/dao/NodeVersionServiceImpl.java @@ -9,6 +9,7 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.common.cache.Weigher; import com.google.common.io.ByteSource; import com.google.common.util.concurrent.UncheckedExecutionException; @@ -19,8 +20,9 @@ import com.enonic.xp.blob.NodeVersionKey; import com.enonic.xp.blob.Segment; import com.enonic.xp.blob.SegmentLevel; +import com.enonic.xp.core.internal.MemoryLimitParser; import com.enonic.xp.data.PropertyTree; -import com.enonic.xp.index.IndexConfigDocument; +import com.enonic.xp.index.PatternIndexConfigDocument; import com.enonic.xp.node.NodeVersion; import com.enonic.xp.repo.impl.InternalContext; import com.enonic.xp.repo.impl.config.RepoConfiguration; @@ -28,10 +30,10 @@ import com.enonic.xp.repo.impl.node.json.ImmutableNodeVersion; import com.enonic.xp.repo.impl.node.json.ImmutableProperty; import com.enonic.xp.repo.impl.node.json.ImmutableVersionData; -import com.enonic.xp.repo.impl.node.json.NodeVersionAccessControl; import com.enonic.xp.repo.impl.node.json.NodeVersionJsonSerializer; import com.enonic.xp.repository.RepositoryId; import com.enonic.xp.repository.RepositorySegmentUtils; +import com.enonic.xp.security.acl.AccessControlList; @Component public class NodeVersionServiceImpl @@ -39,19 +41,24 @@ public class NodeVersionServiceImpl { private final BlobStore blobStore; - private final Cache nodeDataCache; + private final Cache> nodeDataCache; - private final Cache indexConfigCache; + private final Cache> indexConfigCache; - private final Cache accessControlCache; + private final Cache> accessControlCache; @Activate public NodeVersionServiceImpl( @Reference final BlobStore blobStore, @Reference final RepoConfiguration repoConfiguration ) { this.blobStore = blobStore; - this.nodeDataCache = CacheBuilder.newBuilder().maximumSize( repoConfiguration.cacheSize() ).build(); - this.indexConfigCache = CacheBuilder.newBuilder().maximumSize( repoConfiguration.cacheSize() ).build(); - this.accessControlCache = CacheBuilder.newBuilder().maximumSize( repoConfiguration.cacheSize() ).build(); + final long cacheCapacity = MemoryLimitParser.maxHeap().parse( repoConfiguration.cacheCapacity() ); + + final long nodeCacheCapacity = (long) ( cacheCapacity * 0.98D ); + final long otherCachesCapacity = (long) ( cacheCapacity * 0.01D ); + + this.nodeDataCache = CacheBuilder.newBuilder().maximumWeight( nodeCacheCapacity ).weigher( WithWeight.WEIGHTER ).build(); + this.indexConfigCache = CacheBuilder.newBuilder().maximumWeight( otherCachesCapacity ).weigher( WithWeight.WEIGHTER ).build(); + this.accessControlCache = CacheBuilder.newBuilder().maximumWeight( otherCachesCapacity ).weigher( WithWeight.WEIGHTER ).build(); } @Override @@ -85,24 +92,26 @@ public NodeVersion get( final NodeVersionKey nodeVersionKey, final InternalConte { final ImmutableNodeVersion immutableNodeVersion = nodeDataCache.get( nodeBlobKey, () -> { final BlobRecord nodeBlobRecord = getBlobRecord( NodeConstants.NODE_SEGMENT_LEVEL, context.getRepositoryId(), nodeBlobKey ); - - try (var is = nodeBlobRecord.getBytes().openBufferedStream()) + final ByteSource bytes = nodeBlobRecord.getBytes(); + try (var is = bytes.openBufferedStream()) { - return ImmutableVersionData.deserialize( is ); + return new WithWeight<>( ImmutableVersionData.deserialize( is ), bytes.size() ); } - } ); + } ).value; - final IndexConfigDocument indexConfigDocument = indexConfigCache.get( indexConfigBlobKey, () -> { + final PatternIndexConfigDocument indexConfigDocument = indexConfigCache.get( indexConfigBlobKey, () -> { final BlobRecord indexConfigBlobRecord = getBlobRecord( NodeConstants.INDEX_CONFIG_SEGMENT_LEVEL, context.getRepositoryId(), indexConfigBlobKey ); - return NodeVersionJsonSerializer.toIndexConfigDocument( indexConfigBlobRecord.getBytes() ); - } ); + final ByteSource bytes = indexConfigBlobRecord.getBytes(); + return new WithWeight<>( NodeVersionJsonSerializer.toIndexConfigDocument( bytes ), bytes.size() ); + } ).value; - final NodeVersionAccessControl accessControl = accessControlCache.get( accessControlBlobKey, () -> { + final AccessControlList accessControl = accessControlCache.get( accessControlBlobKey, () -> { final BlobRecord accessControlBlobRecord = getBlobRecord( NodeConstants.ACCESS_CONTROL_SEGMENT_LEVEL, context.getRepositoryId(), accessControlBlobKey ); - return NodeVersionJsonSerializer.toNodeVersionAccessControl( accessControlBlobRecord.getBytes() ); - } ); + final ByteSource bytes = accessControlBlobRecord.getBytes(); + return new WithWeight<>( NodeVersionJsonSerializer.toNodeVersionAccessControl( bytes ), bytes.size() ); + } ).value; return NodeVersion.create() .id( immutableNodeVersion.id ) @@ -112,7 +121,7 @@ public NodeVersion get( final NodeVersionKey nodeVersionKey, final InternalConte .manualOrderValue( immutableNodeVersion.manualOrderValue ) .attachedBinaries( immutableNodeVersion.attachedBinaries ) .indexConfigDocument( indexConfigDocument ) - .permissions( accessControl.getPermissions() ) + .permissions( accessControl ) .build(); } catch ( ExecutionException | UncheckedExecutionException e ) @@ -145,4 +154,19 @@ private BlobRecord getBlobRecord( SegmentLevel segmentLevel, RepositoryId reposi } return nodeBlobRecord; } + + private static class WithWeight + { + final T value; + + final int weight; + + WithWeight( final T value, final long weight ) + { + this.value = value; + this.weight = (int) Math.min( weight, Integer.MAX_VALUE ); + } + + static final Weigher> WEIGHTER = ( key, value ) -> value.weight; + } } diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/AccessControlJson.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/AccessControlJson.java index 3a9cefb6356..4a48489e7ac 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/AccessControlJson.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/AccessControlJson.java @@ -50,7 +50,7 @@ public static Builder create() return new Builder(); } - public static NodeVersionAccessControl fromJson( final AccessControlJson json ) + public static AccessControlList fromJson( final AccessControlJson json ) { final AccessControlList.Builder builder = AccessControlList.create(); for ( final AccessControlEntryJson entryJson : json.permissions ) @@ -58,7 +58,7 @@ public static NodeVersionAccessControl fromJson( final AccessControlJson json ) builder.add( entryJson.fromJson() ); } - return new NodeVersionAccessControl( builder.build() ); + return builder.build(); } public static final class Builder diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionAccessControl.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionAccessControl.java deleted file mode 100644 index 63f0dbeb02f..00000000000 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionAccessControl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.enonic.xp.repo.impl.node.json; - -import com.enonic.xp.security.acl.AccessControlList; - -public final class NodeVersionAccessControl -{ - private final AccessControlList permissions; - - - public NodeVersionAccessControl( final AccessControlList permissions ) - { - this.permissions = permissions; - } - - public AccessControlList getPermissions() - { - return permissions; - } - -} diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionJsonSerializer.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionJsonSerializer.java index 4a5a7e4d2cf..1a641a1de83 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionJsonSerializer.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/json/NodeVersionJsonSerializer.java @@ -12,6 +12,7 @@ import com.enonic.xp.index.PatternIndexConfigDocument; import com.enonic.xp.json.ObjectMapperHelper; import com.enonic.xp.node.NodeVersion; +import com.enonic.xp.security.acl.AccessControlList; public final class NodeVersionJsonSerializer { @@ -47,13 +48,13 @@ public static NodeVersion toNodeVersion( final ByteSource data, final ByteSource { final NodeVersion nodeVersion = toNodeVersionData( data ); - final IndexConfigDocument indexConfigDocument = toIndexConfigDocument( indexConfigDocumentData ); + final PatternIndexConfigDocument indexConfigDocument = toIndexConfigDocument( indexConfigDocumentData ); - final NodeVersionAccessControl accessControl = toNodeVersionAccessControl( accessControlData ); + final AccessControlList accessControl = toNodeVersionAccessControl( accessControlData ); return NodeVersion.create( nodeVersion ) .indexConfigDocument( indexConfigDocument ) - .permissions( accessControl.getPermissions() ) + .permissions( accessControl ) .build(); } @@ -63,13 +64,13 @@ public static NodeVersion toNodeVersionData( final ByteSource data ) return NodeVersionDataJson.fromJson( readValue( data, NodeVersionDataJson.class ) ); } - public static IndexConfigDocument toIndexConfigDocument( final ByteSource data ) + public static PatternIndexConfigDocument toIndexConfigDocument( final ByteSource data ) throws IOException { return IndexConfigDocumentJson.fromJson( readValue( data, IndexConfigDocumentJson.class ) ); } - public static NodeVersionAccessControl toNodeVersionAccessControl( final ByteSource data ) + public static AccessControlList toNodeVersionAccessControl( final ByteSource data ) throws IOException { return AccessControlJson.fromJson( readValue( data, AccessControlJson.class ) ); diff --git a/modules/core/core-repo/src/main/resources/com/enonic/xp/repo/impl/config/default.properties b/modules/core/core-repo/src/main/resources/com/enonic/xp/repo/impl/config/default.properties index aab693075b2..53c6fc5ab38 100644 --- a/modules/core/core-repo/src/main/resources/com/enonic/xp/repo/impl/config/default.properties +++ b/modules/core/core-repo/src/main/resources/com/enonic/xp/repo/impl/config/default.properties @@ -1,3 +1,3 @@ snapshots.dir = ${xp.home}/snapshots -cache.size = 100000 +cache.capacity = 10% diff --git a/modules/runtime/src/home/config/com.enonic.xp.repo.cfg b/modules/runtime/src/home/config/com.enonic.xp.repo.cfg index ddf493b0ed6..50f38e493ea 100644 --- a/modules/runtime/src/home/config/com.enonic.xp.repo.cfg +++ b/modules/runtime/src/home/config/com.enonic.xp.repo.cfg @@ -3,4 +3,4 @@ # # snapshots.dir = ${xp.home}/snapshots -# cache.size = 100000 +# cache.capacity = 10%