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

File: [Pegasus] / pegasus / src / Pegasus / ProviderManagerService / ProviderAgent / ProviderAgent.h (download)
Revision: 1.1, Wed Aug 23 18:47:48 2006 UTC (17 years, 10 months ago) by kumpf
Branch: MAIN
CVS Tags: TASK-TASK-BUG4011_WinLocalConnect-branch-New-root, TASK-TASK-BUG4011_WinLocalConnect-branch-New-merged_out_to_branch, TASK-TASK-BUG4011_WinLocalConnect-branch-New-merged_out_from_trunk, TASK-TASK-BUG4011_WinLocalConnect-branch-New-merged_in_to_trunk, TASK-TASK-BUG4011_WinLocalConnect-branch-New-merged_in_from_branch, TASK-TASK-BUG4011_WinLocalConnect-branch-New-branch, TASK-PEP291_IPV6-root, TASK-PEP291_IPV6-branch, TASK-PEP286_PRIVILEGE_SEPARATION-root, TASK-PEP286_PRIVILEGE_SEPARATION-branch, TASK-PEP274_dacim-root, TASK-PEP274_dacim-merged_out_to_branch, TASK-PEP274_dacim-merged_out_from_trunk, TASK-PEP274_dacim-merged_in_to_trunk, TASK-PEP274_dacim-merged_in_from_branch, TASK-PEP274_dacim-branch, TASK-PEP268_SSLClientCertificatePropagation-root, TASK-PEP268_SSLClientCertificatePropagation-merged_out_to_branch, TASK-PEP268_SSLClientCertificatePropagation-merged_out_from_trunk, TASK-PEP268_SSLClientCertificatePropagation-merged_in_to_trunk, TASK-PEP268_SSLClientCertificatePropagation-merged_in_from_branch, TASK-PEP268_SSLClientCertificatePropagation-branch, TASK-PEP267_SLPReregistrationSupport-root, TASK-PEP267_SLPReregistrationSupport-merging_out_to_branch, TASK-PEP267_SLPReregistrationSupport-merging_out_from_trunk, TASK-PEP267_SLPReregistrationSupport-merged_out_to_branch, TASK-PEP267_SLPReregistrationSupport-merged_out_from_trunk, TASK-PEP267_SLPReregistrationSupport-merged_in_to_trunk, TASK-PEP267_SLPReregistrationSupport-merged_in_from_branch, TASK-PEP267_SLPReregistrationSupport-branch, TASK-Bugs5690_3913_RemoteCMPI-root, TASK-Bugs5690_3913_RemoteCMPI-merged_out_to_branch, TASK-Bugs5690_3913_RemoteCMPI-merged_out_from_trunk, TASK-Bugs5690_3913_RemoteCMPI-merged_in_to_trunk, TASK-Bugs5690_3913_RemoteCMPI-merged_in_from_branch, TASK-Bugs5690_3913_RemoteCMPI-branch, TASK-Bug2102_RCMPIWindows-root, TASK-Bug2102_RCMPIWindows-merged_out_to_branch, TASK-Bug2102_RCMPIWindows-merged_out_from_trunk, TASK-Bug2102_RCMPIWindows-merged_in_to_trunk, TASK-Bug2102_RCMPIWindows-merged_in_from_branch, TASK-Bug2102_RCMPIWindows-branch, TASK-Bug2102Final-root, TASK-Bug2102Final-merged_out_to_branch, TASK-Bug2102Final-merged_out_from_trunk, TASK-Bug2102Final-merged_in_to_trunk, TASK-Bug2102Final-merged_in_from_branch, TASK-Bug2102Final-branch, TASK-Bug2021_RemoteCMPIonWindows-root, TASK-Bug2021_RemoteCMPIonWindows-merged_out_to_branch, TASK-Bug2021_RemoteCMPIonWindows-merged_out_from_trunk, TASK-Bug2021_RemoteCMPIonWindows-merged_in_to_trunk, TASK-Bug2021_RemoteCMPIonWindows-merged_in_from_branch, TASK-Bug2021_RemoteCMPIonWindows-branch, TASK-Bug2021_RCMPIonWindows-root, TASK-Bug2021_RCMPIonWindows-merged_out_to_branch, TASK-Bug2021_RCMPIonWindows-merged_out_from_trunk, TASK-Bug2021_RCMPIonWindows-merged_in_to_trunk, TASK-Bug2021_RCMPIonWindows-merged_in_from_branch, TASK-Bug2021_RCMPIonWindows-branch, TASK-BUG7240-root, TASK-BUG7240-branch, TASK-BUG4011_WinLocalConnect-branch-New, RELEASE_2_7_0-BETA, RELEASE_2_6_3-RC2, RELEASE_2_6_3-RC1, RELEASE_2_6_3, RELEASE_2_6_2-RC1, RELEASE_2_6_2, RELEASE_2_6_1-RC1, RELEASE_2_6_1, RELEASE_2_6_0-RC1, RELEASE_2_6_0-FC, RELEASE_2_6_0, RELEASE_2_6-root, RELEASE_2_6-branch-clean, RELEASE_2_6-branch, PEP286_PRIVILEGE_SEPARATION_ROOT, PEP286_PRIVILEGE_SEPARATION_CODE_FREEZE, PEP286_PRIVILEGE_SEPARATION_BRANCH, PEP286_PRIVILEGE_SEPARATION_1
BUG#: 5425
TITLE: Split ProviderManagerService from ProviderManager2
DESCRIPTION: Move the ProviderManagerService from the ProviderManager2 directory to a new ProviderManagerService directory.

//%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_ProviderAgent_h
#define Pegasus_ProviderAgent_h

#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/AnonymousPipe.h>
#include <Pegasus/Common/Thread.h>
#include <Pegasus/Common/ThreadPool.h>
#include <Pegasus/Common/Signal.h>
#include <Pegasus/ProviderManagerService/BasicProviderManagerRouter.h>

PEGASUS_NAMESPACE_BEGIN

class ProviderAgent
{
public:
    /** Constructor */
    ProviderAgent(
        const String& agentId,
        AnonymousPipe* pipeFromServer,
        AnonymousPipe* pipeToServer);

    /** Destructor */
    ~ProviderAgent();

    /**
        Start the Provider Agent reading and processing requests from the
        CIM Server.  This method returns when the Provider Agent is exiting.
        The Provider Agent exits when: 1) Its provider module is disabled,
        stopped, or idle, 2) It is unable to communicate with the CIM Server,
        3) It receives a TERM or HUP signal, or 4) It encounters an
        unrecoverable error.
     */
    void run();

private:
    //
    // Private methods
    //

    /** Unimplemented */
    ProviderAgent();
    /** Unimplemented */
    ProviderAgent(const ProviderAgent&);
    /** Unimplemented */
    ProviderAgent& operator=(const ProviderAgent&);

    /**
        Read a request from the _pipeFromServer and process it.

        @return true if the Provider Agent successfully received a request
                from the CIM Server; false otherwise.
     */
    Boolean _readAndProcessRequest();

    /**
        Forward a request to the _providerManagerRouter.  Catch exceptions
        and add them to the cimException attribute in the response.

        @param request The CIMRequestMessage to process.
        @return A CIMResponseMessage resulting from the processing of the
                specified CIMRequestMessage.
     */
    Message* _processRequest(CIMRequestMessage* request);

    /**
        Write a message to the _pipeToServer.  On error, set _terminating
        to true.

        @param message The message to write to the CIM Server.
     */
    void _writeResponse(Message* message);

    /**
        Forward a request to the _providerManagerRouter.  Catch exceptions
        and add them to the cimException attribute in the response.
        Write the response message to the _pipeToServer.  On error, set
        _terminating to true.

        This method allows a request message to be processed asynchronously
        in its own thread.

        @param arg A pointer to a ProviderAgentRequest object containing a
                   reference to the ProviderAgent object and the request
                   message to process.
     */
    static ThreadReturnType PEGASUS_THREAD_CDECL
        _processRequestAndWriteResponse(void* arg);

    /**
        Callback function to which all generated indications are sent for
        processing.
     */
    static void _indicationCallback(
        CIMProcessIndicationRequestMessage* request);

    /**
        Callback function to which all response chunks are sent for processing.
     */
    static void _responseChunkCallback(
        CIMRequestMessage* request, CIMResponseMessage* response);

    void _unloadIdleProviders();
    static ThreadReturnType PEGASUS_THREAD_CDECL
        _unloadIdleProvidersHandler(void* arg) throw();

    static void _terminateSignalHandler(
        int s_n, PEGASUS_SIGINFO_T* s_info, void* sig);

    //
    // Private data
    //

    /**
        ProviderAgent reference used by the terminateSignalHandler to
        indicate that the Provider Agent should exit.
     */
    static ProviderAgent* _providerAgent;

    /**
        String used to identify this Provider Agent instance.
     */
    String _agentId;

    /**
        The pipe connection on which the Provider Agent reads requests
        from the CIM Server.
     */
    AnonymousPipe* _pipeFromServer;
    /**
        The pipe connection on which the Provider Agent writes responses
        (and indications) to the CIM Server.
     */
    AnonymousPipe* _pipeToServer;
    /**
        This lock must be held whenever writing on the _pipeToServer
        connection.
     */
    Mutex _pipeToServerMutex;

    /**
        Indicates whether the Provider Agent should exit.
     */
    Boolean _terminating;

    /**
        The ProviderManagerRouter to which all provider operations are
        forwarded for processing.
     */
    BasicProviderManagerRouter _providerManagerRouter;

    /**
        Indicates the number of threads currently attempting to unload idle
        providers.  This value is used to prevent multiple threads from
        unloading idle providers concurrently.
     */
    AtomicInt _unloadIdleProvidersBusy;

    /**
        Holds the last provider module instance received from the CIM Server
        in a ProviderIdContainer.  Since the provider module instance rarely
        changes, an optimization is used to send it only when it differs from
        the last provider module instance sent.
     */
    CIMInstance _providerModuleCache;

    /**
        Indicates whether the Indication Service has completed initialization.

        For more information, please see the description of the
        ProviderManagerRouter::_subscriptionInitComplete member variable.
     */
    Boolean _subscriptionInitComplete;

    /**
        A thread pool used for asynchronous processing of provider operations.
     */
    ThreadPool _threadPool;

    /**
       Indicates if the provider agent has been successful initialised already.
     */
    Boolean _isInitialised;
};

PEGASUS_NAMESPACE_END

#endif /* Pegasus_ProviderAgent_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2