(file) Return to ProviderIndicationCountTable.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / IndicationService

File: [Pegasus] / pegasus / src / Pegasus / IndicationService / ProviderIndicationCountTable.h (download)
Revision: 1.3, Tue May 27 16:49:24 2008 UTC (16 years, 1 month ago) by yi.zhou
Branch: MAIN
CVS Tags: TASK_PEP328_SOLARIS_NEVADA_PORT, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-root, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-branch, TASK-PEP328_SOLARIS_NEVADA_PORT-root, TASK-PEP328_SOLARIS_NEVADA_PORT-branch, TASK-PEP328_SOLARIS_IX86_CC_PORT-root, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch-v2, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch, TASK-PEP311_WSMan-root, TASK-PEP311_WSMan-branch, RELEASE_2_8_2-RC1, RELEASE_2_8_2, RELEASE_2_8_1-RC1, RELEASE_2_8_1, RELEASE_2_8_0_BETA, RELEASE_2_8_0-RC2, RELEASE_2_8_0-RC1, RELEASE_2_8_0-FC, RELEASE_2_8_0, RELEASE_2_8-root, RELEASE_2_8-branch
Changes since 1.2: +45 -2 lines
BUG#: 7683
TITLE: PEP 322 Track Generated Indications Data - support GetInstance and EnumerateInstanceNames operations

DESCRIPTION: Implemented GetInstance and EnumerateInstanceNames operations for both class PG_ProviderIndicationData and class PG_SubscriptionIndicationData. Also, added aotomated tests for both operations.

//%2006////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation, The Open Group.
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; Symantec Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
//%/////////////////////////////////////////////////////////////////////////////

#ifndef Pegasus_ProviderIndicationCountTable_h
#define Pegasus_ProviderIndicationCountTable_h

#include <Pegasus/Common/Config.h>
#include <Pegasus/Server/Linkage.h>
#include <Pegasus/Common/String.h>
#include <Pegasus/Common/Array.h>
#include <Pegasus/Common/CIMInstance.h>
#include <Pegasus/Common/CIMObjectPath.h>
#include <Pegasus/Common/HashTable.h>
#include <Pegasus/Common/ReadWriteSem.h>

PEGASUS_NAMESPACE_BEGIN

/**
    The ProviderIndicationCountTable is used to track the number of indications
    generated by each active indication provider.  Each entry consists of a
    provider module name, provider name, the number of indications generated by
    the provider, and the number of "orphan" indications (which do not match
    any subscriptions) generated by the provider.
*/
class PEGASUS_SERVER_LINKAGE ProviderIndicationCountTable
{
public:

    /**
        Constructs a ProviderIndicationCountTable instance.
    */
    ProviderIndicationCountTable();

    /**
        Destructs a ProviderIndicationCountTable instance.
    */
    ~ProviderIndicationCountTable();

    /**
        Inserts an entry for the specified provider. If the entry 
        already exists, this method has no effect.

        @param providerInstance A PG_Provider instance representing the
            provider for which to insert
    */
    void insertEntry(const CIMInstance& providerInstance);

    /**
        Updates the indication count for a specified provider if the provider
        entry exists.  Updates the orphan indication count also, if applicable.

        @param providerInstance A PG_Provider instance representing the
            provider for which to update the counts.
        @param isOrphan A Boolean indicating whether the indication did not
            match any active subscriptions
    */
    void incrementEntry(
        const CIMInstance& providerInstance,
        Boolean isOrphan);

    /**
        Removes the entry for the specified provider from the table.

        @param providerInstance A PG_Provider instance specifying the provider
            for which to remove the entry.
    */
    void removeEntry(const CIMInstance& providerInstance);

    /**
        Removes all provider entries for the specified provider module from
        the table.

        @param providerModuleName The name of the provider module for which to
            remove the provider entries.
    */
    void removeModuleEntries(const String& providerModuleName);

    /**
        Gets the provider module name and provider name from a PG_Provider
        instance.

        @param providerInstance A PG_Provider instance for which to retrieve 
            the provider module name and the provider name.
        @param providerModuleName Output String containing the provider module
            name.
        @param providerName Output String containing the provider name.
    */
    static void getProviderKeys(
        const CIMInstance& providerInstance,
        String& providerModuleName,
        String& providerName);

    Array<CIMInstance> enumerateProviderIndicationDataInstances();

    /** 
        Enumerates PG_ProviderIndicationData instance names using the data
        stored in the Provider Indication Count table. 

        @return All the PG_ProviderIndicationData instanceName.
    */
    Array<CIMObjectPath> enumerateProviderIndicationDataInstanceNames();

    /**
        Gets the Provider Indication Data instance for the specified CIM 
        object path.

        @param instanceName CIMObjectPath specifies a CIM instance to be 
            returned 
        @return The specified PG_ProviderIndicationData instance.
        @exception CIMObjectNotFoundException If the specified instance does 
            not exist
    */
    CIMInstance getProviderIndicationDataInstance(
        const CIMObjectPath& instanceName);

private:

    ProviderIndicationCountTable(const ProviderIndicationCountTable&);
    ProviderIndicationCountTable& operator=(
        const ProviderIndicationCountTable&);

    /**
        Generates a unique String key for a ProviderIndicationCountTableEntry.
        The key is generated by concatenating the provider name, the provider
        module name, colon, and the length of the provider name.

        @param providerModuleName The provider module name used to generate
            the key.
        @param providerName The provider name used to generate the key.
        @return A String containing the generated key.
    */
    static String _generateKey(
        const String& providerModuleName,
        const String& providerName);

    struct _ProviderIndicationCountTableEntry
    {
        String providerModuleName;
        String providerName;
        Uint32 indicationCount;
        Uint32 orphanIndicationCount;
    };

    /**
        Returns all the table entries.
        @return A complete list of ProviderIndicationCountTableEntry objects.
    */
    Array<_ProviderIndicationCountTableEntry> _getAllEntries();

    /**
        Builds the provider indication data instance object path by using the 
            specified provider indication count table entry.

        @param providerIndCountTableEntry The provider indication count table
            entry used to build the provider indication data instance name.
        @return The created provider indication data instance object path.
    */
    CIMObjectPath _buildProviderIndDataInstanceName(
        const _ProviderIndicationCountTableEntry& providerIndCountTableEntry);

    /**
        Builds the provider indication data instance by using the 
            specified provider indication count table entry.

        @param providerIndCountTableEntry The provider indication count table
            entry used to build the provider indication data instance.
        @return The created provider indication data instance
    */
    CIMInstance _buildProviderIndDataInstance(
        const _ProviderIndicationCountTableEntry& providerIndCountTableEntry);

    /**
        Hash function used in _ProviderIndicationCountTable.  The algorithm is
        optimized for the key format and the hash table size (32 by default).
    */
    struct _ProviderIndicationCountHashFunc
    {
        static Uint32 hash(const String& key);
    };

    /**
        Table of generated indications counts.  Access to this table
        is controlled by the _tableLock.
    */
    typedef HashTable<
        String,
        _ProviderIndicationCountTableEntry,
        EqualNoCaseFunc,
        _ProviderIndicationCountHashFunc> _ProviderIndicationCountTable;
    _ProviderIndicationCountTable _table;

    /**
        A lock to control access to the _table.  Before accessing the _table,
        one must first lock this for read access.  Before updating the _table,
        one must first lock this for write access.
    */
    mutable ReadWriteSem _tableLock;
};

PEGASUS_NAMESPACE_END

#endif  /* Pegasus_ProviderIndicationCountTable_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2