|
|
|
@ -42,6 +42,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
@ -123,6 +124,7 @@ public class CachedAttributesService implements AttributesService { |
|
|
|
return result; |
|
|
|
} catch (Throwable e) { |
|
|
|
cacheTransaction.rollback(); |
|
|
|
log.debug("Could not find attribute from cache: [{}] [{}] [{}]", entityId, scope, attributeKey, e); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -132,6 +134,7 @@ public class CachedAttributesService implements AttributesService { |
|
|
|
@Override |
|
|
|
public ListenableFuture<List<AttributeKvEntry>> find(TenantId tenantId, EntityId entityId, String scope, Collection<String> attributeKeys) { |
|
|
|
validate(entityId, scope); |
|
|
|
attributeKeys = new LinkedHashSet<>(attributeKeys); // deduplicate the attributes
|
|
|
|
attributeKeys.forEach(attributeKey -> Validator.validateString(attributeKey, "Incorrect attribute key " + attributeKey)); |
|
|
|
|
|
|
|
Map<String, TbCacheValueWrapper<AttributeKvEntry>> wrappedCachedAttributes = findCachedAttributes(entityId, scope, attributeKeys); |
|
|
|
@ -170,6 +173,7 @@ public class CachedAttributesService implements AttributesService { |
|
|
|
return mergedAttributes; |
|
|
|
} catch (Throwable e) { |
|
|
|
cacheTransaction.rollback(); |
|
|
|
log.debug("Could not find attributes from cache: [{}] [{}] [{}]", entityId, scope, notFoundAttributeKeys, e); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
}); |
|
|
|
|