/************************************************************************ * EOS - the CERN Disk Storage System * * Copyright (C) 2011 CERN/Switzerland * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see .* ************************************************************************/ //------------------------------------------------------------------------------ // author: Lukasz Janyst // desc: ContainerMD service interface //------------------------------------------------------------------------------ #ifndef EOS_NS_I_CONTAINER_MD_SVC_HH #define EOS_NS_I_CONTAINER_MD_SVC_HH #include "namespace/interface/IContainerMD.hh" #include "namespace/interface/IFileMDSvc.hh" #include "namespace/MDException.hh" #include #include EOSNSNAMESPACE_BEGIN //! Forward declaration class IQuotaStats; //---------------------------------------------------------------------------- //! Interface for the listener that is notified about all of the //! actions performed in a IContainerMDSvc //---------------------------------------------------------------------------- class IContainerMDChangeListener { public: enum Action { Updated = 0, Deleted, Created, MTimeChange }; virtual ~IContainerMDChangeListener() {} virtual void containerMDChanged(IContainerMD* obj, Action type) = 0; }; //---------------------------------------------------------------------------- //! Interface for class responsible for managing the metadata information //! concerning containers. It is responsible for assigning container IDs and //! managing storage of the metadata. Could be implemented as a change log or //! db based store or as an interface to memcached or some other caching //! system or key value store //---------------------------------------------------------------------------- class IContainerMDSvc { public: virtual ~IContainerMDSvc() {} //------------------------------------------------------------------------ //! Initialize the container service //------------------------------------------------------------------------ virtual void initialize() = 0; //---------------------------------------------------------------------------- //! Configure the container service //! //! @param config map of configuration parameters //---------------------------------------------------------------------------- virtual void configure(const std::map& config) = 0; //---------------------------------------------------------------------------- //! Finalize the container service //---------------------------------------------------------------------------- virtual void finalize() = 0; //---------------------------------------------------------------------------- //! Asynchronously get the container metadata information for the given ID //---------------------------------------------------------------------------- virtual folly::Future getContainerMDFut(IContainerMD::id_t id) = 0; //---------------------------------------------------------------------------- //! Get the container metadata information for the given ID //---------------------------------------------------------------------------- virtual std::shared_ptr getContainerMD(IContainerMD::id_t id) = 0; //---------------------------------------------------------------------------- //! Get the container metadata information for the given ID and read lock it //---------------------------------------------------------------------------- virtual IContainerMD::IContainerMDReadLockerPtr getContainerMDReadLocked(IContainerMD::id_t id) = 0; //---------------------------------------------------------------------------- //! Get the container metadata information for the given ID and write lock it //---------------------------------------------------------------------------- virtual IContainerMD::IContainerMDWriteLockerPtr getContainerMDWriteLocked(IContainerMD::id_t id) = 0; //---------------------------------------------------------------------------- //! Get the container metadata information for the given ID and clock //---------------------------------------------------------------------------- virtual std::shared_ptr getContainerMD(IContainerMD::id_t id, uint64_t* clock) = 0; //---------------------------------------------------------------------------- //! Drop cached ContainerMD - return true if found //---------------------------------------------------------------------------- virtual bool dropCachedContainerMD(ContainerIdentifier id) = 0; //---------------------------------------------------------------------------- //! Create new container metadata object with an assigned id, the user has //! to fill all the remaining fields //---------------------------------------------------------------------------- virtual std::shared_ptr createContainer(IContainerMD::id_t id) = 0; //---------------------------------------------------------------------------- //! Update the contaienr metadata in the backing store after the //! ContainerMD object has been changed //---------------------------------------------------------------------------- virtual void updateStore(IContainerMD* obj) = 0; //---------------------------------------------------------------------------- //! Remove object from the store //---------------------------------------------------------------------------- virtual void removeContainer(IContainerMD* obj) = 0; //---------------------------------------------------------------------------- //! Get number of containers //---------------------------------------------------------------------------- virtual uint64_t getNumContainers() = 0; //---------------------------------------------------------------------------- //! Add file listener that will be notified about all of the changes in //! the store //---------------------------------------------------------------------------- virtual void addChangeListener(IContainerMDChangeListener* listener) = 0; //---------------------------------------------------------------------------- //! Set the QuotaStats object for the follower //! //! @param quota_stats object implementing the IQuotaStats interface //---------------------------------------------------------------------------- virtual void setQuotaStats(IQuotaStats* quota_stats) = 0; //---------------------------------------------------------------------------- //! Notify all subscribed listener //---------------------------------------------------------------------------- virtual void notifyListeners(IContainerMD* obj, IContainerMDChangeListener::Action a) = 0; //---------------------------------------------------------------------------- //! Get the orphans container //---------------------------------------------------------------------------- virtual std::shared_ptr getLostFoundContainer(const std::string& name) = 0; //---------------------------------------------------------------------------- // Create container in parent //---------------------------------------------------------------------------- virtual std::shared_ptr createInParent(const std::string& name, IContainerMD* parent) = 0; //---------------------------------------------------------------------------- //! Set file metadata service //---------------------------------------------------------------------------- virtual void setFileMDService(IFileMDSvc* file_svc) = 0; //---------------------------------------------------------------------------- //! Set container accounting //--------------------------------------------------------------------------- virtual void setContainerAccounting(IFileMDChangeListener* containerAccounting) = 0; //---------------------------------------------------------------------------- //! Get first free container id //---------------------------------------------------------------------------- virtual IContainerMD::id_t getFirstFreeId() = 0; //---------------------------------------------------------------------------- //! Retrieve file metadata cache statistics //---------------------------------------------------------------------------- virtual CacheStatistics getCacheStatistics() = 0; //---------------------------------------------------------------------------- //! Blacklist IDs below the given threshold //---------------------------------------------------------------------------- virtual void blacklistBelow(ContainerIdentifier id) = 0; }; EOSNSNAMESPACE_END #endif // EOS_NS_I_CONTAINER_MD_SVC_HH