diff --git a/NOTICE b/NOTICE index 60d60ed3a6a3f2f3300f41c3fb13d1ef9f61fe63..126871c2640c3fa913e1f9420e76483f175d65bb 100644 --- a/NOTICE +++ b/NOTICE @@ -362,7 +362,7 @@ The following software have components provided under the terms of this license: - AssertJ Core (from ${project.organization.url}#${project.artifactId}) - Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) - Asynchronous Http Client Netty Utils (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client-netty-utils) -- AutoValue Annotations (from https://github.com/google/auto/tree/master/value, https://repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations) +- AutoValue Annotations (from https://github.com/google/auto/tree/main/value, https://github.com/google/auto/tree/master/value, https://repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations) - BSON (from http://bsonspec.org, https://bsonspec.org) - BSON Record Codec (from <https://www.mongodb.com/>, https://www.mongodb.com/) - Bean Validation API (from http://beanvalidation.org) diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/IRelatedObjectCache.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/IRelatedObjectCache.java index e33200e568cc575fc8d7f3ad1aeb9f24415a03e5..4ddad5e468c7ea554033207cb7216dd55db1c7e0 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/IRelatedObjectCache.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/IRelatedObjectCache.java @@ -18,7 +18,5 @@ package org.opengroup.osdu.indexer.cache; import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.storage.RecordData; -import java.util.Map; - public interface IRelatedObjectCache extends ICache<String, RecordData> { } diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RecordChangeInfoCacheVmImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RecordChangeInfoCacheVmImpl.java index 24a3467f8037d4d78b97f034684f31742ca149db..796d13186d5dfe61f97de41ba8a437c28ccbf0a0 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RecordChangeInfoCacheVmImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RecordChangeInfoCacheVmImpl.java @@ -25,7 +25,7 @@ public class RecordChangeInfoCacheVmImpl implements IRecordChangeInfoCache { private VmCache<String, RecordChangeInfo> cache; public RecordChangeInfoCacheVmImpl() { - cache = new VmCache<>(Constants.DATA_CACHE_EXPIRATION, Constants.DATA_MAX_CACHE_SIZE); + cache = new VmCache<>(Constants.DATA_CHANGE_INFO_CACHE_EXPIRATION, Constants.DATA_MAX_CACHE_SIZE); } @Override diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RelatedObjectCacheVmImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RelatedObjectCacheVmImpl.java index f3d2e166ab0eefe6151f18ac9ad52fd033450abd..c6ba7d0906690c1bee850805e720e7f903603b5c 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RelatedObjectCacheVmImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/cache/RelatedObjectCacheVmImpl.java @@ -20,8 +20,6 @@ import org.opengroup.osdu.core.common.model.storage.RecordData; import org.opengroup.osdu.indexer.model.Constants; import org.springframework.stereotype.Component; -import java.util.Map; - @Component public class RelatedObjectCacheVmImpl implements IRelatedObjectCache { private VmCache<String, RecordData> cache; diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/Constants.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/Constants.java index 91017c2fe1fbfa1773fcd611773849e47a889d5c..5e4588e15b2e965f1468a9c0d0fb8b2063070291 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/Constants.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/Constants.java @@ -21,9 +21,10 @@ public class Constants { // Specifications using kind as key is not partition safe if the specifications are per data partition public static final int SPEC_CACHE_EXPIRATION = 600; - public static final int SPEC_MAX_CACHE_SIZE = 2000; + public static final int SPEC_MAX_CACHE_SIZE = 20000; // Data id itself is partition safe public static final int DATA_CACHE_EXPIRATION = 120; - public static final int DATA_MAX_CACHE_SIZE = 2000; + public static final int DATA_CHANGE_INFO_CACHE_EXPIRATION = 3600; + public static final int DATA_MAX_CACHE_SIZE = 20000; } diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RecordChangeInfoRedisCache.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RecordChangeInfoRedisCache.java new file mode 100644 index 0000000000000000000000000000000000000000..0f2634719b91a5fe752266cd7a0ed674a1bfbd15 --- /dev/null +++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RecordChangeInfoRedisCache.java @@ -0,0 +1,39 @@ +/* + * Copyright © Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.indexer.azure.cache; + +import org.opengroup.osdu.core.common.cache.RedisCache; +import org.opengroup.osdu.indexer.cache.IRecordChangeInfoCache; +import org.opengroup.osdu.indexer.model.RecordChangeInfo; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import javax.inject.Named; + +@Component +@Primary +@ConditionalOnProperty(value = "runtime.env.local", havingValue = "false", matchIfMissing = true) +public class RecordChangeInfoRedisCache extends RedisCache<String, RecordChangeInfo> implements IRecordChangeInfoCache { + public RecordChangeInfoRedisCache(final @Named("REDIS_HOST") String host, + final @Named("REDIS_PORT") int port, + final @Named("REDIS_PASSWORD") String password, + final @Named("RECORD_CHANGE_INFO_REDIS_TTL") int timeout, + @Value("${redis.database}") final int database) { + super(host, port, password, timeout, database, String.class, RecordChangeInfo.class); + } +} diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RelatedObjectRedisCache.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RelatedObjectRedisCache.java new file mode 100644 index 0000000000000000000000000000000000000000..9e6c0b58f60c51e25f8265f9b5ac36395ad8b7ee --- /dev/null +++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/cache/RelatedObjectRedisCache.java @@ -0,0 +1,39 @@ +/* + * Copyright © Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.indexer.azure.cache; + +import org.opengroup.osdu.core.common.cache.RedisCache; +import org.opengroup.osdu.core.common.model.storage.RecordData; +import org.opengroup.osdu.indexer.cache.IRelatedObjectCache; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import javax.inject.Named; + +@Component +@Primary +@ConditionalOnProperty(value = "runtime.env.local", havingValue = "false", matchIfMissing = true) +public class RelatedObjectRedisCache extends RedisCache<String, RecordData> implements IRelatedObjectCache { + public RelatedObjectRedisCache(final @Named("REDIS_HOST") String host, + final @Named("REDIS_PORT") int port, + final @Named("REDIS_PASSWORD") String password, + final @Named("RECORDS_REDIS_TTL") int timeout, + @Value("${redis.database}") final int database) { + super(host, port, password, timeout, database, String.class, RecordData.class); + } +} diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/RedisConfig.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/RedisConfig.java index 6b98eb7ce0eb6f54dff8cb13279224b91add958f..3a98634b81ce1c3729d988dd82cf4110f2eb9bae 100644 --- a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/RedisConfig.java +++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/RedisConfig.java @@ -38,6 +38,12 @@ public class RedisConfig { @Value("${redis.schema.ttl:3600}") public int schemaTtl; + @Value("${redis.records.ttl:120}") + public int recordsTtl; + + @Value("${redis.record.change.info.ttl:3600}") + public int recordChangeInfoTtl; + @Bean @Named("REDIS_PORT") public int getRedisPort() { @@ -62,6 +68,18 @@ public class RedisConfig { return schemaTtl; } + @Bean + @Named("RECORDS_REDIS_TTL") + public int getRecordsRedisTtl() { + return recordsTtl; + } + + @Bean + @Named("RECORD_CHANGE_INFO_REDIS_TTL") + public int getRecordChangeInfoRedisTtl() { + return recordChangeInfoTtl; + } + @Bean @Named("REDIS_HOST") public String redisHost(SecretClient kv) {