Package com.linkedin.venice.helix
Class StoragePersonaRepository
- java.lang.Object
-
- com.linkedin.venice.helix.StoragePersonaRepository
-
public class StoragePersonaRepository extends java.lang.Object
Cached wrapper for theStoragePersonaAccessor
class, which keeps a map of store names to personas that contain them, as well as caches Zookeeper personas. Class Invariants:- Each method is thread-safe.
- The state of the repository (including the cache) will not be affected by object mutations until update methods from the repository are called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StoragePersonaRepository.StoragePersonaStoreDataListener
Helper class which listens to changes from aReadOnlyStoreRepository
and updates the caches and ZK of the StoragePersonaRepository accordingly.
-
Constructor Summary
Constructors Constructor Description StoragePersonaRepository(java.lang.String clusterName, ReadOnlyStoreRepository repository, HelixAdapterSerializer compositeSerializer, org.apache.helix.zookeeper.impl.client.ZkClient zkClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPersona(java.lang.String name, long quotaNumber, java.util.Set<java.lang.String> storesToEnforce, java.util.Set<java.lang.String> owners)
Creates a new persona with the given parameters.void
addStoresToPersona(java.lang.String personaName, java.util.List<java.lang.String> storeNames)
This operation assumes that stores which are added to the persona are not contained within any store, but does not do any validity checks.void
deletePersona(java.lang.String personaName)
Deletes the persona with the given name.java.util.List<StoragePersona>
getAllPersonas()
StoragePersona
getPersona(java.lang.String name)
Returns a persona with the given name within the cluster that the repository is located.StoragePersona
getPersonaContainingStore(java.lang.String storeName)
boolean
hasPersona(java.lang.String name)
boolean
personaContainsStore(java.lang.String personaName, java.lang.String storeName)
void
refresh()
Clears the cache and re-loads the cache data from Zookeeper.void
updatePersona(java.lang.String personaName, UpdateStoragePersonaQueryParams params)
Updates a persona with the given parameters.void
validateAddUpdatedStore(StoragePersona persona, java.util.Optional<Store> store)
void
validatePersona(StoragePersona persona)
void
validatePersona(java.lang.String personaName, long quota, java.util.Set<java.lang.String> storesToEnforce, java.util.Set<java.lang.String> owners)
void
validatePersonaUpdate(java.lang.String personaName, UpdateStoragePersonaQueryParams params)
-
-
-
Constructor Detail
-
StoragePersonaRepository
public StoragePersonaRepository(java.lang.String clusterName, ReadOnlyStoreRepository repository, HelixAdapterSerializer compositeSerializer, org.apache.helix.zookeeper.impl.client.ZkClient zkClient)
-
-
Method Detail
-
getPersona
public StoragePersona getPersona(java.lang.String name)
Returns a persona with the given name within the cluster that the repository is located. In the case that no persona with this name exists, this method returns null.
-
getAllPersonas
public java.util.List<StoragePersona> getAllPersonas()
-
hasPersona
public boolean hasPersona(java.lang.String name)
-
refresh
public final void refresh()
Clears the cache and re-loads the cache data from Zookeeper.
-
addPersona
public void addPersona(java.lang.String name, long quotaNumber, java.util.Set<java.lang.String> storesToEnforce, java.util.Set<java.lang.String> owners)
Creates a new persona with the given parameters. This method will throw an error if:- A persona with the given name already exists in the cluster.
- One of the stores in storesToEnforce does not exist in the cluster.
- The total quota of the stores exceeds the given persona budget.
-
updatePersona
public void updatePersona(java.lang.String personaName, UpdateStoragePersonaQueryParams params)
Updates a persona with the given parameters. This method will throw an error if:- There is no persona with this name in the cluster.
- One of the stores in storesToEnforce does not exist in the cluster.
- The total quota of the stores exceeds the given persona budget.
-
deletePersona
public void deletePersona(java.lang.String personaName)
Deletes the persona with the given name. If no persona is found, this method does nothing.
-
getPersonaContainingStore
public StoragePersona getPersonaContainingStore(java.lang.String storeName)
-
validatePersona
public void validatePersona(java.lang.String personaName, long quota, java.util.Set<java.lang.String> storesToEnforce, java.util.Set<java.lang.String> owners)
-
validatePersonaUpdate
public void validatePersonaUpdate(java.lang.String personaName, UpdateStoragePersonaQueryParams params)
-
validatePersona
public void validatePersona(StoragePersona persona)
-
validateAddUpdatedStore
public void validateAddUpdatedStore(StoragePersona persona, java.util.Optional<Store> store)
-
addStoresToPersona
public void addStoresToPersona(java.lang.String personaName, java.util.List<java.lang.String> storeNames)
This operation assumes that stores which are added to the persona are not contained within any store, but does not do any validity checks.
-
personaContainsStore
public boolean personaContainsStore(java.lang.String personaName, java.lang.String storeName)
-
-