Class DefaultConfigService

  • All Implemented Interfaces:
    ConfigService
    Direct Known Subclasses:
    ConfigServiceForTests

    public class DefaultConfigService
    extends Object
    implements ConfigService
    This is the default config service for the archiver appliance. There is a subclass that is used in the junit tests.
    Author:
    mshankar
    • Constructor Detail

      • DefaultConfigService

        protected DefaultConfigService()
    • Method Detail

      • initialize

        public void initialize​(javax.servlet.ServletContext sce)
                        throws ConfigException
        Description copied from interface: ConfigService
        If you have a null constructor and need a ServletContext, implement this method.
        Specified by:
        initialize in interface ConfigService
        Parameters:
        sce - ServletContext
        Throws:
        ConfigException -  
      • postStartup

        public void postStartup()
                         throws ConfigException
        Description copied from interface: ConfigService
        This method is called after the mgmt WAR file has started up and set up the cluster and recovered data from persistence. Each appliance's mgmt war is responsible for calling this method on the other components (engine, etl and retrieval) using BPL. Until this method is called on all the web apps, the cluster is not considered to have started up.
        Specified by:
        postStartup in interface ConfigService
        Throws:
        ConfigException -  
      • updatePVSForThisAppliance

        public void updatePVSForThisAppliance​(PVTypeInfoEvent event)
      • publishEventIntoCluster

        public void publishEventIntoCluster​(PubSubEvent pubSubEvent)
      • isStartupComplete

        public boolean isStartupComplete()
        Description copied from interface: ConfigService
        Have we completed all the startup steps?
        Specified by:
        isStartupComplete in interface ConfigService
        Returns:
        boolean True or False
      • getInstallationProperties

        public Properties getInstallationProperties()
        Description copied from interface: ConfigService
        An arbitrary list of name/value pairs can be specified in a file called archappl.properties that is loaded from the classpath.
        Specified by:
        getInstallationProperties in interface ConfigService
        Returns:
        Properties  
      • getAppliancesInCluster

        public Collection<ApplianceInfo> getAppliancesInCluster()
        Description copied from interface: ConfigService
        Get all the appliances in this cluster. Much goodness is facilitated if the objects are returned in the same order (perhaps order of creation) all the time.
        Specified by:
        getAppliancesInCluster in interface ConfigService
        Returns:
        ApplianceInfo  
      • getAppliance

        public ApplianceInfo getAppliance​(String identity)
        Description copied from interface: ConfigService
        Given an identity of an appliance, return the appliance info for that appliance
        Specified by:
        getAppliance in interface ConfigService
        Parameters:
        identity - The appliance identify
        Returns:
        ApplianceInfo  
      • getAllPVs

        public Collection<String> getAllPVs()
        Description copied from interface: ConfigService
        Get an exhaustive list of all the PVs this cluster of appliances knows about Much goodness is facilitated if the objects are returned in the same order (perhaps order of creation) all the time.
        Specified by:
        getAllPVs in interface ConfigService
        Returns:
        String AllPVs  
      • getApplianceForPV

        public ApplianceInfo getApplianceForPV​(String pvName)
        Description copied from interface: ConfigService
        Given a PV, get us the appliance that is responsible for archiving it. Note that this may be null as the assignment of PV's to appliances can take some time.
        Specified by:
        getApplianceForPV in interface ConfigService
        Parameters:
        pvName - The name of PV.
        Returns:
        ApplianceInfo  
      • getPVsForAppliance

        public Iterable<String> getPVsForAppliance​(ApplianceInfo info)
        Description copied from interface: ConfigService
        Get all PVs being archived by this appliance. Much goodness is facilitated if the objects are returned in the same order (perhaps order of creation) all the time.
        Specified by:
        getPVsForAppliance in interface ConfigService
        Parameters:
        info - ApplianceInfo
        Returns:
        string All PVs being archiveed by this appliance
      • getPVsForThisAppliance

        public Iterable<String> getPVsForThisAppliance()
        Description copied from interface: ConfigService
        Get all the PVs for this appliance. Much goodness is facilitated if the objects are returned in the same order (perhaps order of creation) all the time.
        Specified by:
        getPVsForThisAppliance in interface ConfigService
        Returns:
        String All PVs being archiveed for this appliance
      • isBeingArchivedOnThisAppliance

        public boolean isBeingArchivedOnThisAppliance​(String pvName)
        Description copied from interface: ConfigService
        Is this PV archived on this appliance. This method also checks aliases and fields.
        Specified by:
        isBeingArchivedOnThisAppliance in interface ConfigService
        Parameters:
        pvName - The name of PV.
        Returns:
        boolean True or False
      • getPVsForApplianceMatchingRegex

        public Set<String> getPVsForApplianceMatchingRegex​(String nameToMatch)
        Description copied from interface: ConfigService
        Get the pvNames for this appliance matching the given regex.
        Specified by:
        getPVsForApplianceMatchingRegex in interface ConfigService
        Parameters:
        nameToMatch -  
        Returns:
        string PVsForApplianceMatchingRegex  
      • getTypeInfoForPV

        public PVTypeInfo getTypeInfoForPV​(String pvName)
        Description copied from interface: ConfigService
        Gets information about a PV's type, i.e its DBR type, graphic limits etc. This information is assumed to be somewhat static and is expected to come from a cache if possible as it is used in data retrieval.
        Specified by:
        getTypeInfoForPV in interface ConfigService
        Parameters:
        pvName - The name of PV.
        Returns:
        PVTypeInfo  
      • updateTypeInfoForPV

        public void updateTypeInfoForPV​(String pvName,
                                        PVTypeInfo typeInfo)
        Description copied from interface: ConfigService
        Update the type information about a PV; updating both ther persistent and cached versions of the information. Clients are not expected to call this method a million times a second. In general, this is expected to be called when archiving a PV for the first time, or perhaps when an appserver startups etc...
        Specified by:
        updateTypeInfoForPV in interface ConfigService
        Parameters:
        pvName - The name of PV.
        typeInfo - PVTypeInfo
      • removePVFromCluster

        public void removePVFromCluster​(String pvName)
        Description copied from interface: ConfigService
        Remove the pv from all cached and persisted configuration.
        Specified by:
        removePVFromCluster in interface ConfigService
        Parameters:
        pvName - The name of PV.
      • addToArchiveRequests

        public void addToArchiveRequests​(String pvName,
                                         UserSpecifiedSamplingParams userSpecifiedSamplingParams)
        Description copied from interface: ConfigService
        The workflow for requesting a PV to be archived consists of multiple steps This method adds a PV to the persisted list of PVs that are currently engaged in this workflow in addition to any user specified overrides
        Specified by:
        addToArchiveRequests in interface ConfigService
        Parameters:
        pvName - The name of PV.
        userSpecifiedSamplingParams - - Use a null contructor for userSpecifiedSamplingParams if no override specified.
      • updateArchiveRequest

        public void updateArchiveRequest​(String pvName,
                                         UserSpecifiedSamplingParams userSpecifiedSamplingParams)
        Description copied from interface: ConfigService
        Update the archive request (mostly with aliases) if and only if we have this in our persistence.
        Specified by:
        updateArchiveRequest in interface ConfigService
        Parameters:
        pvName - The name of PV.
        userSpecifiedSamplingParams -  
      • doesPVHaveArchiveRequestInWorkflow

        public boolean doesPVHaveArchiveRequestInWorkflow​(String pvname)
        Description copied from interface: ConfigService
        Is this pv in the archive request workflow.
        Specified by:
        doesPVHaveArchiveRequestInWorkflow in interface ConfigService
        Parameters:
        pvname - The name of PV.
        Returns:
        boolean True or False
      • archiveRequestWorkflowCompleted

        public void archiveRequestWorkflowCompleted​(String pvName)
        Description copied from interface: ConfigService
        Mark this pv as having it archive pv request completed and pull this request out of persistent store Can be used in the case of aborting a PV archive request as well
        Specified by:
        archiveRequestWorkflowCompleted in interface ConfigService
        Parameters:
        pvName - The name of PV.
      • getInitialDelayBeforeStartingArchiveRequestWorkflow

        public int getInitialDelayBeforeStartingArchiveRequestWorkflow()
        Description copied from interface: ConfigService
        In clustered environments, to give capacity planning a chance to work correctly, we want to kick off the archive PV workflow only after all the machines have started. This is an approximation for that metric; though not a very satisfactory approximation. TODO -- Think thru implications of making the appliances.xml strict...
        Specified by:
        getInitialDelayBeforeStartingArchiveRequestWorkflow in interface ConfigService
        Returns:
        - Initial delay in seconds.
      • addAlias

        public void addAlias​(String aliasName,
                             String realName)
        Description copied from interface: ConfigService
        Register an alias
        Specified by:
        addAlias in interface ConfigService
        Parameters:
        aliasName -  
        realName - This is the name under which the PV will be archived under
      • removeAlias

        public void removeAlias​(String aliasName,
                                String realName)
        Description copied from interface: ConfigService
        Remove an alias for the specified realname
        Specified by:
        removeAlias in interface ConfigService
        Parameters:
        aliasName -  
        realName - This is the name under which the PV will be archived under
      • getRealNameForAlias

        public String getRealNameForAlias​(String aliasName)
        Description copied from interface: ConfigService
        Gets the .NAME field for a PV if it exists. Otherwise, this returns null
        Specified by:
        getRealNameForAlias in interface ConfigService
        Parameters:
        aliasName -  
        Returns:
        String RealNameForAlias
      • getAllAliases

        public List<String> getAllAliases()
        Description copied from interface: ConfigService
        Get all the aliases in the system. This is used for matching during glob requests in the UI.
        Specified by:
        getAllAliases in interface ConfigService
        Returns:
        String AllAliases  
      • getExtraFields

        public String[] getExtraFields()
        Description copied from interface: ConfigService
        Get a list of extra fields that are obtained when we initially make a request for archiving. These are used in the policies to make decisions on how to archive the PV.
        Specified by:
        getExtraFields in interface ConfigService
        Returns:
        String ExtraFields  
      • getRuntimeFields

        public Set<String> getRuntimeFields()
        Description copied from interface: ConfigService
        Get a list of fields for PVs that are monitored and maintained in the engine. These are used when displaying the PV in visualization tools like the ArchiveViewer as additional information for the PV. Some of these could be archived along with the PV but need not be. In this case, the engine simply maintains the latest copy in memory and this is served up when data from the engine in included in the stream.
        Specified by:
        getRuntimeFields in interface ConfigService
        Returns:
        String RuntimeFields
      • getETLLookup

        public PBThreeTierETLPVLookup getETLLookup()
        Description copied from interface: ConfigService
        Return the runtime state for ETL. This may eventually be moved to a RunTime class but that would still start from the configservice.
        Specified by:
        getETLLookup in interface ConfigService
        Returns:
        PBThreeTierETLPVLookup  
      • isShuttingDown

        public boolean isShuttingDown()
        Description copied from interface: ConfigService
        Is this appliance component shutting down?
        Specified by:
        isShuttingDown in interface ConfigService
        Returns:
        boolean True or False
      • addShutdownHook

        public void addShutdownHook​(Runnable runnable)
        Description copied from interface: ConfigService
        Add an appserver agnostic shutdown hook; for example, to close the CA channels on shutdown
        Specified by:
        addShutdownHook in interface ConfigService
        Parameters:
        runnable - Runnable
      • shutdownNow

        public void shutdownNow()
        Description copied from interface: ConfigService
        Call the registered shutdown hooks and shut the archive appliance down.
        Specified by:
        shutdownNow in interface ConfigService
      • getExternalArchiverDataServers

        public Map<String,​String> getExternalArchiverDataServers()
        Description copied from interface: ConfigService
        This product has the ability to proxy data from other archiver data servers. We currently integrate with Channel Archiver XMLRPC data servers and other EPICS Archiver Appliance clusters. Get a list of external Archiver Data Servers that we know about.
        Specified by:
        getExternalArchiverDataServers in interface ConfigService
        Returns:
        Map ExternalArchiverDataServers
      • addExternalArchiverDataServer

        public void addExternalArchiverDataServer​(String serverURL,
                                                  String archivesCSV)
                                           throws IOException
        Description copied from interface: ConfigService
        Add a external Archiver Data Server into the system.
        Specified by:
        addExternalArchiverDataServer in interface ConfigService
        Parameters:
        serverURL - - For Channel Archivers, this is the URL to the XML-RPC server. For other EPICS Archiver Appliance clusters, this is the data_retrieval_url of the cluster as defined in the appliances.xml.
        archivesCSV - - For Channel Archivers, this is a comma separated list of indexes. For other EPICS Archiver Appliance clusters, this is the string pbraw.
        Throws:
        IOException -  
      • removeExternalArchiverDataServer

        public void removeExternalArchiverDataServer​(String serverURL,
                                                     String archivesCSV)
                                              throws IOException
        Description copied from interface: ConfigService
        Removes an entry for an external Archiver Data Server from the system Note; we may need to restart the entire cluster for this change to take effect.
        Specified by:
        removeExternalArchiverDataServer in interface ConfigService
        Parameters:
        serverURL - - For Channel Archivers, this is the URL to the XML-RPC server. For other EPICS Archiver Appliance clusters, this is the data_retrieval_url of the cluster as defined in the appliances.xml.
        archivesCSV - - For Channel Archivers, this is a comma separated list of indexes. For other EPICS Archiver Appliance clusters, this is the string pbraw.
        Throws:
        IOException -  
      • getChannelArchiverDataServers

        public List<ChannelArchiverDataServerPVInfo> getChannelArchiverDataServers​(String pvName)
        Description copied from interface: ConfigService
        Return a list of ChannelArchiverDataServerPVInfos for a PV if one exists; otherwise return null. The servers are sorted in order of the start seconds. Note: this only applies to Channel Archiver XML RPC servers. For proxying external EPICS Archiver Appliance clusters, we do not cache the PV's that are being archived on the external system.
        Specified by:
        getChannelArchiverDataServers in interface ConfigService
        Parameters:
        pvName - The name of PV.
        Returns:
        ChannelArchiverDataServerPVInfo  
      • getFieldsArchivedAsPartOfStream

        public List<String> getFieldsArchivedAsPartOfStream()
                                                     throws IOException
        Description copied from interface: ConfigService
        This product offers the ability to archive certain fields (like HIHI, LOLO etc) as part of every PV. The data for these fields is embedded into the stream as extra fields using the FieldValues interface of events. This method lists all these fields. Requests for archiving these fields are deferred to and combined with the request for archiving the .VAL. We also assume that the data type (double/float) for these fields is the same as the .VAL.
        Specified by:
        getFieldsArchivedAsPartOfStream in interface ConfigService
        Returns:
        String  
        Throws:
        IOException -  
      • getArchiverTypeSystem

        public TypeSystem getArchiverTypeSystem()
        Description copied from interface: ConfigService
        Returns a TypeSystem object that is used to convert from JCA DBR's to Event's (actually, DBRTimeEvents)
        Specified by:
        getArchiverTypeSystem in interface ConfigService
        Returns:
        TypeSystem  
      • getEventBus

        public com.google.common.eventbus.EventBus getEventBus()
        Description copied from interface: ConfigService
        Get the event bus used for events within this appliance.
        Specified by:
        getEventBus in interface ConfigService
        Returns:
        EventBus  
      • getPVNameToKeyConverter

        public PVNameToKeyMapping getPVNameToKeyConverter()
        Description copied from interface: ConfigService
        Implementation for converting a PV name to something that forms the prefix of a chunk's key. See @see{PVNameToKeyMapping} for more details.
        Specified by:
        getPVNameToKeyConverter in interface ConfigService
        Returns:
        PVNameToKeyMapping  
      • getWebInfFolder

        public String getWebInfFolder()
        Description copied from interface: ConfigService
        We expect to live within a servlet container. This call returns the full path to the WEB-INF folder of the webapp as it is deployed in the container. Is typically a call to the servletContext.getRealPath("WEB-INF/")
        Specified by:
        getWebInfFolder in interface ConfigService
        Returns:
        String WebInfFolder  
      • refreshPVDataFromChannelArchiverDataServers

        public void refreshPVDataFromChannelArchiverDataServers()
        Description copied from interface: ConfigService
        For all the Channel Archiver XMLRPC data servers in the mix, update the PV info. This should help improve performance a little in proxying data from ChannelArchiver data servers that are still active. For proxying external EPICS Archiver Appliance clusters, since we do not cache the PV's that are being archived on the external system, this is a no-op.
        Specified by:
        refreshPVDataFromChannelArchiverDataServers in interface ConfigService
      • getFailoverApplianceURL

        public String getFailoverApplianceURL​(String pvName)
        Description copied from interface: ConfigService
        Get the first external archiver appliance that also archives this PV and is configured with a mergeDuringRetrieval query parameter.
        Specified by:
        getFailoverApplianceURL in interface ConfigService
        Returns:
        - Returns null if no failover appliance.
      • getFailoverServerURLs

        public Set<String> getFailoverServerURLs()
        Description copied from interface: ConfigService
        Get a list of external archiver appliances configured for failover. Failover appliances are not used as proxies to minimize imposing the retrieval load of the this installation on a potentially less powerful appliance used principally for failover.
        Specified by:
        getFailoverServerURLs in interface ConfigService
        Returns:
      • resetFailoverCaches

        public void resetFailoverCaches()
        Description copied from interface: ConfigService
        Each retrieval component in a cluster caches the PV's from remote failover appliances. These caches contain one entry for each PV in this appliance indicating if the PV is being archived in the remote appliance. This information is cached using a TTL to minimize the impact on the remote failover appliance. This method manually unloads this cache.
        Specified by:
        resetFailoverCaches in interface ConfigService
      • getNamedFlag

        public boolean getNamedFlag​(String name)
        Description copied from interface: ConfigService
        Named flags are used to control various process in the appliance; for example, the ETL process in a PlainPBStoragePlugin Named flags are not persistent; each time the server starts up, all the named flags are set to false You can optionally load values for named flags from a file by specifying the ARCHAPPL_NAMEDFLAGS_PROPERTIES_FILE_PROPERTY property in archappl.properties. This method gets the value of the specified named flag. If the flag has not been defined before in the cluster, this method will return false.
        Specified by:
        getNamedFlag in interface ConfigService
        Parameters:
        name -  
        Returns:
        boolean True or False
      • setNamedFlag

        public void setNamedFlag​(String name,
                                 boolean value)
        Description copied from interface: ConfigService
        Sets the value of the named flag specified by name to the specified value
        Specified by:
        setNamedFlag in interface ConfigService
        Parameters:
        name -  
        value -  
      • getTimeOfAppserverStartup

        public long getTimeOfAppserverStartup()
        Description copied from interface: ConfigService
        Get an approximate time in epoch seconds when the appserver started up.
        Specified by:
        getTimeOfAppserverStartup in interface ConfigService
        Returns:
        The time this app server started up.
      • getAllExpandedNames

        public void getAllExpandedNames​(Consumer<String> func)
        Description copied from interface: ConfigService
        For automated PV submission, IOC engineers could add .VAL, fields, aliases etc. This method attempts to return all possible PV's that the archiver could know about. This is a lot of names; so we take in a consumer that potentially streams a name out as quickly as possible.
        Specified by:
        getAllExpandedNames in interface ConfigService
        Parameters:
        func - A consumer of pvNames