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

File: [Pegasus] / pegasus / src / Pegasus / Server / CIMOperationRequestDispatcher.h (download)
Revision: 1.65.2.3, Thu Feb 17 22:40:20 2005 UTC (19 years, 4 months ago) by w.otsuka
Branch: RELEASE_2_4-branch
CVS Tags: RELEASE_2_4_3, RELEASE_2_4_2, RELEASE_2_4_1-BETA3, RELEASE_2_4_1-BETA2, RELEASE_2_4_1, IBM_241_April1405
Changes since 1.65.2.2: +1 -1 lines
BUG#: 2766
TITLE:   Rename compile flag PEGASUS_ARCHITECTURE_IA64 to PEGASUS_POINTER_64BIT

DESCRIPTION: Port of bug 2686 to 2.4.

//%2004////////////////////////////////////////////////////////////////////////
//
// 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.
//
// 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.
//
//==============================================================================
//
// Author: Mike Brasher (mbrasher@bmc.com)
//
// Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
//              Mike Day (mdday@us.ibm.com)
//              Yi Zhou (yi_zhou@hp.com)
//              Carol Ann Krug Graves, Hewlett-Packard Company
//                  (carolann_graves@hp.com)
//              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
//		        Karl Schopmeyer (k.schopmeyer@opengroup.org)
//      		Adrian Schuur (schuur@de.ibm.com)
//				Seema Gupta (gseema@in.ibm.com for PEP135)
//              Chip Vincent (cvincent@us.ibm.com)
//              Alagaraja Ramasubramanian (alags_raj@in.ibm.com) for Bug#1090
//
//%/////////////////////////////////////////////////////////////////////////////

#ifndef PegasusDispatcher_Dispatcher_h
#define PegasusDispatcher_Dispatcher_h

#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/IPC.h>
#include <Pegasus/Common/DQueue.h>
#include <Pegasus/Common/Thread.h>
#include <Pegasus/Common/MessageQueue.h>
#include <Pegasus/Common/CIMMessage.h>
#include <Pegasus/Common/CIMObject.h>
#include <Pegasus/Common/OperationContextInternal.h>
#include <Pegasus/Common/ObjectNormalizer.h>
#include <Pegasus/Common/QueryExpressionRep.h>
#include <Pegasus/Common/AutoPtr.h>

#include <Pegasus/Repository/CIMRepository.h>

#include <Pegasus/Server/CIMServer.h>
#include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
#include <Pegasus/Server/Linkage.h>

PEGASUS_NAMESPACE_BEGIN

// Class to aggregate and manage the information about classes and providers
// this simply masks some of the confusion of control providers, etc. today.

class PEGASUS_SERVER_LINKAGE ProviderInfo
{
public:
    ProviderInfo(CIMName& className)
    : className(className),
      hasNoQuery(true)
    {
    }

    ProviderInfo(
        const CIMName& className, 
        const String& serviceName, 
        const String& controlProviderName)
    : className(className),
      serviceName(serviceName),
      controlProviderName(controlProviderName),
      hasNoQuery(true)
    {
    }

    ProviderInfo(const ProviderInfo& providerInfo)
    : className(providerInfo.className),
      serviceName(providerInfo.serviceName),
      controlProviderName(providerInfo.controlProviderName),
      hasProvider(providerInfo.hasProvider),
      hasNoQuery(providerInfo.hasNoQuery)
    {
        if (providerInfo.providerIdContainer.get() != 0)
        {
            providerIdContainer.reset(
                new ProviderIdContainer(*providerInfo.providerIdContainer));
        }
    }

    ProviderInfo& operator=(const ProviderInfo& providerInfo)
    {
        if (&providerInfo != this)
        {
            className = providerInfo.className;
            serviceName = providerInfo.serviceName;
            controlProviderName = providerInfo.controlProviderName;
            hasProvider = providerInfo.hasProvider;
            hasNoQuery = providerInfo.hasNoQuery;
            providerIdContainer.reset();
            if (providerInfo.providerIdContainer.get() != 0)
            {
                providerIdContainer.reset(
                    new ProviderIdContainer(*providerInfo.providerIdContainer));
            }
        }
        return *this;
    }

    CIMName className;
    String serviceName;
    String controlProviderName;
    Boolean hasProvider;
    Boolean hasNoQuery;
    AutoPtr<ProviderIdContainer> providerIdContainer;

private:
    ProviderInfo() {}
};

/* Class to manage the aggregation of data required by post processors. This
    class is private to the dispatcher. An instance is created by the operation
    dispatcher to aggregate request and response information and used by the
    post processor to aggregate responses together.
*/
class PEGASUS_SERVER_LINKAGE OperationAggregate
{
public:
    /* Operation Aggregate constructor.  Builds an aggregate
        object.
        @param request
        @param msgRequestType
        @param messageId
        @param dest

        NOTE: This is the version we will generally use
    */

    OperationAggregate(CIMRequestMessage* request,
                                Uint32 msgRequestType,
                                String messageId,
                                Uint32 dest,
                                CIMName className,
				QueryExpressionRep* query=NULL,
				String queryLanguage=String::EMPTY)
    : _messageId(messageId), _msgRequestType(msgRequestType),
      _dest(dest), _className(className), _query(query),
      _queryLanguage(queryLanguage),
      _request(request), _totalIssued(0), _magicNumber(12345)
    {}

    /* Constructor with nameSpace object also.
    */
    OperationAggregate(CIMRequestMessage* request,
                                Uint32 msgRequestType,
                                String messageId,
                                Uint32 dest,
                                CIMName className,
                                CIMNamespaceName nameSpace,
				QueryExpressionRep* query=NULL,
				String queryLanguage=String::EMPTY)
    : _messageId(messageId), _msgRequestType(msgRequestType),
      _dest(dest), _nameSpace(nameSpace), _className(className),  
      _query(query),_queryLanguage(queryLanguage),
      _request(request), _totalIssued(0), _magicNumber(12345)
    {}


    ~OperationAggregate()
    {
        _magicNumber = 0;
        delete _request;
    }
    // Tests validity by checking the magic number we put into the
    // packet.
    Boolean valid() {return(_magicNumber == 12345)? true: false; }

    // Returns count of total responses collected into this aggregation
    Uint32 totalIssued() { return _totalIssued; }

    // increment the count of requests issued
    void incIssued() { _totalIssued++;}

    // Sets the total issued to the input parameter
    void setTotalIssued(Uint32 i) {_totalIssued = i; }

    // Append a new entry to the response list.  Return value indicates
    // whether this response is the last one expected
    Boolean appendResponse(CIMResponseMessage* response)
    {
        AutoMutex autoMut(_appendResponseMutex);
        _responseList.append(response);
        Boolean returnValue = (totalIssued() == numberResponses());

        return returnValue;
    }


    Uint32 numberResponses() {
      //      _appendResponseMutex.lock(pegasus_thread_self());
      Uint32 size =  _responseList.size();
      //      _appendResponseMutex.unlock();
      return size;

    }

    CIMRequestMessage* getRequest(void)
    {
        return(_request);
    }

    CIMResponseMessage* getResponse(const Uint32& pos)
      {
      CIMResponseMessage *tmp;
      AutoMutex autoMut(_appendResponseMutex);
      tmp = _responseList[pos];

      return tmp;

    }

    // << Fri Sep 26 12:28:53 2003 mdd >>

    // allow dispatcher to remove the response so it doesn't become
    // destroyed when the poA is destroyed.

    CIMResponseMessage* removeResponse(const Uint32& pos)
      {
	CIMResponseMessage* tmp;
	
	AutoMutex autoMut(_appendResponseMutex);
	tmp = _responseList[pos];
	_responseList.remove(pos);

	return tmp;
	
      }


    void deleteResponse(const Uint32&pos)
    {
      AutoMutex autoMut(_appendResponseMutex);
      delete _responseList[pos];
      _responseList.remove(pos);

    }

    Uint32 getRequestType(){ return _msgRequestType;}

    String _messageId;
    Uint32 _msgRequestType;
    Uint32 _dest;
    CIMNamespaceName _nameSpace;
    CIMName _className;

    Array<String> propertyList;

    Uint64 _aggregationSN;
//    WQLSelectStatement* _query;
    QueryExpressionRep* _query;
    String _queryLanguage;
private:
    /** Hidden (unimplemented) copy constructor */
    OperationAggregate(const OperationAggregate& x) : _query(NULL) {}

    Array<CIMResponseMessage*> _responseList;
    Mutex _appendResponseMutex;
    CIMRequestMessage* _request;
    Uint32 _totalIssued;
    Uint32 _magicNumber;
};

class PEGASUS_SERVER_LINKAGE CIMOperationRequestDispatcher : public MessageQueueService
{
   friend class QuerySupportRouter;
   public:

      typedef MessageQueueService Base;

      CIMOperationRequestDispatcher(
    	 CIMRepository* repository,
         ProviderRegistrationManager* providerRegistrationManager);

      virtual ~CIMOperationRequestDispatcher();

      virtual void handleEnqueue(Message *);

      virtual void handleEnqueue();

      void handleGetClassRequest(
    	 CIMGetClassRequestMessage* request);

      void handleGetInstanceRequest(
    	 CIMGetInstanceRequestMessage* request);

      void handleDeleteClassRequest(
    	 CIMDeleteClassRequestMessage* request);

      void handleDeleteInstanceRequest(
          CIMDeleteInstanceRequestMessage* request);

      void handleCreateClassRequest(
          CIMCreateClassRequestMessage* request);

      void handleCreateInstanceRequest(
          CIMCreateInstanceRequestMessage* request);

      void handleModifyClassRequest(
    	 CIMModifyClassRequestMessage* request);

      void handleModifyInstanceRequest(
    	 CIMModifyInstanceRequestMessage* request);

      void handleEnumerateClassesRequest(
    	 CIMEnumerateClassesRequestMessage* request);

      void handleEnumerateClassNamesRequest(
    	 CIMEnumerateClassNamesRequestMessage* request);

      void handleEnumerateInstancesRequest(
    	 CIMEnumerateInstancesRequestMessage* request);

      void handleEnumerateInstanceNamesRequest(
    	 CIMEnumerateInstanceNamesRequestMessage* request);

      void handleAssociatorsRequest(
    	 CIMAssociatorsRequestMessage* request);

      void handleAssociatorNamesRequest(
    	 CIMAssociatorNamesRequestMessage* request);

      void handleReferencesRequest(
    	 CIMReferencesRequestMessage* request);

      void handleReferenceNamesRequest(
          CIMReferenceNamesRequestMessage* request);

      void handleGetPropertyRequest(
    	 CIMGetPropertyRequestMessage* request);

      void handleSetPropertyRequest(
    	 CIMSetPropertyRequestMessage* request);

      void handleGetQualifierRequest(
    	 CIMGetQualifierRequestMessage* request);

      void handleSetQualifierRequest(
    	 CIMSetQualifierRequestMessage* request);

      void handleDeleteQualifierRequest(
    	 CIMDeleteQualifierRequestMessage* request);

      void handleEnumerateQualifiersRequest(
    	 CIMEnumerateQualifiersRequestMessage* request);

      void handleExecQueryRequest(
    	 CIMExecQueryRequestMessage* request);

      void handleInvokeMethodRequest(
    	 CIMInvokeMethodRequestMessage* request);

      static void _forwardForAggregationCallback(AsyncOpNode *,
					   MessageQueue *,
					   void *);
      static void _forwardRequestCallback(AsyncOpNode *,
					   MessageQueue *,
					   void *);

      // Response Handler functions

      void handleOperationResponseAggregation(OperationAggregate* poA);

      void handleReferencesResponseAggregation(OperationAggregate* poA);

      void handleReferenceNamesResponseAggregation(OperationAggregate* poA);

      void handleAssociatorsResponseAggregation(OperationAggregate* poA);

      void handleAssociatorNamesResponseAggregation(OperationAggregate* poA);

      void handleEnumerateInstancesResponseAggregation(OperationAggregate* poA);

      void handleEnumerateInstanceNamesResponseAggregation(OperationAggregate* poA);

      void handleExecQueryResponseAggregation(OperationAggregate* poA);

   protected:

	/** _getSubClassNames - Gets the names of all subclasses of the defined
	    class (including the class) and returns it in an array of strings. Uses
	    a similar function in the repository class to get the names.
	    @param namespace
	    @param className
	    @return Array of strings with class names.  Note that there should be
	    at least one classname in the array (the input name)
	    Note that there is a special exception to this function, the __namespace
	    class which does not have any representation in the class repository.
	    @exception CIMException(CIM_ERR_INVALID_CLASS)
	*/
    Array<CIMName> _getSubClassNames(
        const CIMNamespaceName& nameSpace,
        const CIMName& className) throw(CIMException);

    Boolean _lookupInternalProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        String& service,
        String& provider);

/*    Boolean _lookupNewQueryProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        String& serviceName,
        String& controlProviderName,
	Boolean* notQueryProvider); */

    Boolean _lookupNewInstanceProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        String& serviceName,
        String& controlProviderName,
		ProviderIdContainer **container,
        Boolean *has_no_query = NULL);

/*    String _lookupQueryProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
	Boolean* notQueryProvider); */

    String _lookupInstanceProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
		ProviderIdContainer **container,
        Boolean *has_no_query = NULL);

/*   Array<ProviderInfo> _lookupAllQueryProviders(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        Uint32& providerCount)  throw(CIMException); */

    Array<ProviderInfo> _lookupAllInstanceProviders(
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        Uint32& providerCount,
        Boolean is_query = false)  throw(CIMException);

    Array<ProviderInfo> _lookupAllAssociationProviders(
        const CIMNamespaceName& nameSpace,
        const CIMObjectPath& objectName,
        const CIMName& assocClass,
        const String& role,
        Uint32& providerCount);

    Boolean _lookupNewAssociationProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& assocClass,
        String& serviceName,
        String& controlProviderName,
		ProviderIdContainer **container);

    Array<String> _lookupAssociationProvider(
        const CIMNamespaceName& nameSpace,
        const CIMName& assocClass,
		ProviderIdContainer **container);

      String _lookupMethodProvider(const CIMNamespaceName& nameSpace,
    	const CIMName& className, const CIMName& methodName,
		ProviderIdContainer **providerIdContainer);

      void _forwardRequestToService(
        const String& serviceName,
        CIMRequestMessage* request,
        CIMResponseMessage*& response);

      void _forwardRequestToControlProvider(
        const String& serviceName,
        const String& controlProviderName,
        CIMRequestMessage* request,
        CIMResponseMessage*& response);

      void _forwardRequestForAggregation(
        const String& serviceName,
        const String& controlProviderName,
        CIMRequestMessage* request,
        OperationAggregate* poA);

      void _forwardRequestToProviderManager(
        const CIMName& className,
        const String& serviceName,
        const String& controlProviderName,
        CIMRequestMessage* request);

      void _enqueueResponse(
          CIMRequestMessage* request, CIMResponseMessage* response);

      CIMValue _convertValueType(const CIMValue& value, CIMType type);

      void _fixInvokeMethodParameterTypes(CIMInvokeMethodRequestMessage* request);

      void _fixSetPropertyValueType(CIMSetPropertyRequestMessage* request);

      void _checkExistenceOfClass(const CIMNamespaceName& nameSpace,
		                          const CIMName& className,
		                          CIMException& cimException);
	
	  CIMClass _getClass(const CIMNamespaceName& nameSpace,
		                 const CIMName& className,
		                 CIMException& cimException);


      CIMRepository * _repository;

      ProviderRegistrationManager* _providerRegistrationManager;

      AtomicInt _dying;

      Boolean _enableAssociationTraversal;
      Boolean _enableIndicationService;
      Uint32 _maximumEnumerateBreadth;
      static Uint64 cimOperationAggregationSN;

      // << Tue Feb 12 08:48:09 2002 mdd >> meta dispatcher integration
      virtual void _handle_async_request(AsyncRequest *req);

      // the following two methods enable specific query language implementations

 /*     void handleQueryRequest(
    	 CIMExecQueryRequestMessage* request);

      void handleQueryResponseAggregation(
         OperationAggregate* poA);

      void applyQueryToEnumeration(CIMResponseMessage* msg,
         QueryExpressionRep* query);
*/
      ObjectNormalizer _normalizer;

   private:
      static void _handle_enqueue_callback(AsyncOpNode *, MessageQueue *, void *);

};

PEGASUS_NAMESPACE_END

#endif /* PegasusDispatcher_Dispatcher_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2