コード例 #1
0
ファイル: command_instance.cpp プロジェクト: wgsyd/wgtf
//==============================================================================
void CommandInstance::consolidateChildren()
{
	auto commands_compressible = [](const CommandInstancePtr& command_a, const CommandInstancePtr& command_b) {
		auto command_a_type_ok =
		strcmp(command_a->getCommandId(), getClassIdentifier<SetReflectedPropertyCommand>()) == 0;
		auto command_b_type_ok =
		strcmp(command_b->getCommandId(), getClassIdentifier<SetReflectedPropertyCommand>()) == 0;
		auto command_a_argument = command_a->getArguments().getBase<ReflectedPropertyCommandArgument>();
		auto command_b_argument = command_b->getArguments().getBase<ReflectedPropertyCommandArgument>();

		bool commands_has_correct_type =
		command_a_type_ok && command_b_type_ok && command_a_argument && command_b_argument;
		return commands_has_correct_type &&
		(command_a_argument->getContextId() == command_b_argument->getContextId()) &&
		(command_a_argument->getContextId() == command_b_argument->getContextId());
	};

	size_t j = 0;
	for (size_t i = 0; i < children_.size(); ++i)
	{
		if (commands_compressible(children_[j], children_[i]) || children_[i] == children_[j])
		{
			children_[j] = children_[i];
		}
		else
		{
			children_[++j] = children_[i];
		}
	}

	children_.resize(std::min(children_.size(), j + 1));
}
コード例 #2
0
void EnumerationContext::setClientClosed()
{
    PEGASUS_DEBUG_ASSERT(valid());

    _clientClosed = true;
    _processing = false;

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3,
        "setClientClosed. ContextId=%s ", *Str(getContextId()) ));
#endif

    // Clear any existing responses out of the cache.  They will never
    // be used.
    _responseCache.clear();

    if (!_providersComplete)
    {
        // Signal that cache size has dropped.
        signalProviderWaitCondition();
    }

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    trace();
#endif
}
コード例 #3
0
// Wait until cache size drops below defined limit. Saves time
// in wait in EnumerationContext for statistics and uses
// waitProviderLimitCondition condition variable.
void EnumerationContext::waitCacheSize()
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContext::waitCacheSize()");

    PEGASUS_DEBUG_ASSERT(valid());

    _providerWaitConditionMutex.lock();

    Uint64 startTime = System::getCurrentTimeUsec();

    while ((!_clientClosed) && (responseCacheSize() > _responseCacheMaximumSize)
           && !_providersComplete)
    {
        _providerWaitCondition.wait(_providerWaitConditionMutex);
    }

    _providerWaitConditionMutex.unlock();

    Uint64 interval = System::getCurrentTimeUsec() - startTime;

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "waitCacheSize  ContextId=%s Wait=%lu usec",
       *Str(getContextId()), (unsigned long int)interval ));
#endif

    _totalWaitTimeUsec += interval;
    if (interval > _maxWaitTimeUsec)
    {
        _maxWaitTimeUsec = interval;
    }
    PEG_METHOD_EXIT();
}
コード例 #4
0
/*
    Test interoperation timer against current time. Return true if timed out
    or timer set 0 zero indicating that the timer is not active.
    Returns bool true if timer not zero and Interoperation timer
    is greater than interoperation timeout (i.e timed out).
*/
bool EnumerationContext::isTimedOut(Uint64 currentTime)
{
    PEGASUS_DEBUG_ASSERT(valid());

    if (_operationTimerUsec == 0)
    {
            return false;
    }

    bool timedOut = _operationTimerUsec <= currentTime;

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "isTimedOut Timer. ContextId=%s timer(sec)=%lu"
           " current(sec)=%lu time to timeout(usec)=%ld isTimedOut=%s",
        *Str(getContextId()),
        (long unsigned int)(_operationTimerUsec / PEG_MICROSEC),
        (long unsigned int)(currentTime / PEG_MICROSEC),
        (long signed int)((_operationTimerUsec - currentTime)),
        boolToString(timedOut) ));
#endif
    // If it is timed out, set timer inactive.
    if (timedOut)
    {
        _operationTimerUsec = 0;
    }
    return(timedOut);
}
コード例 #5
0
void CrossfireEvent::clone(CrossfirePacket** _value) {
	CrossfireEvent* result = new CrossfireEvent();
	result->setContextId(getContextId());
	result->setBody(m_body);
	result->setName(getName());
	*_value = result;
}
コード例 #6
0
// Create a new context. This is called only from the enumerationTable
// createContext function.
EnumerationContext::EnumerationContext(const String& contextId,
    const CIMNamespaceName& nameSpace,
    Uint32 interOperationTimeoutValue,
    Boolean continueOnError,
    MessageType pullRequestType,
    CIMResponseData::ResponseDataContent contentType )
    :
    _cimException(CIMException()),
    _savedRequest(NULL),             // Clear because used as a flag
    _savedResponse(NULL),
    _contextId(contextId),
    _nameSpace(nameSpace),
    _operationTimeoutSec(interOperationTimeoutValue),
    _continueOnError(continueOnError),
    _operationTimerUsec(0),
    _pullRequestType(pullRequestType),
    _clientClosed(false),
    _providersComplete(false),
    _processing(true),    // set true because always created during processing
    _error(false),
    _responseCache(contentType),
    _providerWaitConditionMutex(Mutex::NON_RECURSIVE),
    _totalWaitTimeUsec(0),
    _maxWaitTimeUsec(0),
    _pullOperationCounter(0),
    _consecutiveZeroLenMaxObjectRequestCounter(0),
    _consecutiveZeroLenObjectResponseCounter(0),
    _responseCacheMaximumSize(0),
    _requestCount(1),
    _responseObjectsCount(0),
    _requestedResponseObjectsCount(0),
    _totalZeroLenObjectResponseCounter(0),
    _cacheHighWaterMark(0)
{
    PEGASUS_DEBUG_ASSERT(_responseCache.valid());

    // set start time for this enumeration sequence
    _startTimeUsec = System::getCurrentTimeUsec();

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3,
        "Create EnumerationContext ContextId=%s operationTimeoutSec %u"
        " responseCacheDataType %u StartTime %lu",
        *Str(getContextId()),
        _operationTimeoutSec,
        _responseCache.getResponseDataContent(),
        (unsigned long int)_startTimeUsec));
#endif
}
コード例 #7
0
void EnumerationContext::signalProviderWaitCondition()
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
        "EnumerationContext::signalProviderLimitCondition");

    PEGASUS_DEBUG_ASSERT(valid());

    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
      "EnumerationContext::signalProviderWait Condition ContextId=%s"
          " cacheSize=%u", *Str(getContextId()), responseCacheSize() ));

    AutoMutex autoMut(_providerWaitConditionMutex);

    _providerWaitCondition.signal();

    PEG_METHOD_EXIT();
}
コード例 #8
0
void EnumerationContext::stopTimer()
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT,"EnumerationContext::stopTimer");

    PEGASUS_DEBUG_ASSERT(valid());

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "StopTimer ContextId=%s,"
           " OperationTimeout=%u sec,"
           " (timerTime - curtime)=%ld sec,",
       *Str(getContextId()), _operationTimeoutSec,
       (long signed int)(_operationTimerUsec -
           System::getCurrentTimeUsec())/PEG_MICROSEC ));
#endif
    _operationTimerUsec = 0;
    PEG_METHOD_EXIT();
}
コード例 #9
0
//// KS_FUTURE make DEBUG compile only
// Diagnostic display of data in the enumeration context object
void EnumerationContext::trace()
{
    PEGASUS_DEBUG_ASSERT(valid());
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3,
        "EnumerationContextTrace ContextId=%s "
        "requestOperationTimeOut=%u "
        "operationTimer=%lu sec "
        "continueOnError=%s "
        "pullMsgType=%s "
        "processingState=%s "
        "providersComplete=%s "
        "closed=%s "
        "timeOpen=%lu ms "
        "totalPullCount=%u "
        "cacheHighWaterMark=%u "
        "Request count=%u "
        "ResponseObjectCount=%u "
        "totalWaitTimeUsec=%llu "
        "maxWaitTimeUsec=%llu "
        "RequestedResponseObjectCount=%u "
        "consecutiveZeroLenObjectResponseCtr=%u "
        "totalZeroLenObjectResponseCounter=%u"
        "ResponseCacheSize=%u",
        *Str(getContextId()),
        _operationTimeoutSec,
        (long unsigned int)_operationTimerUsec,
        boolToString(_continueOnError),
        MessageTypeToString(_pullRequestType),
        processingState(),
        boolToString(_providersComplete),
        boolToString(_clientClosed),
        (long unsigned int)
            (System::getCurrentTimeUsec() - _startTimeUsec)/1000,
        _pullOperationCounter,
        _cacheHighWaterMark,
        _requestCount,
        _responseObjectsCount,
        _totalWaitTimeUsec,
        _maxWaitTimeUsec,
        _requestedResponseObjectsCount,
        _consecutiveZeroLenObjectResponseCounter,
        _totalZeroLenObjectResponseCounter,
         responseCacheSize()));
}
コード例 #10
0
//==============================================================================
bool SetReflectedPropertyCommand::validateArguments(const ObjectHandle& arguments) const
{
	if ( !arguments.isValid() ) 
	{
		return false;
	}

	auto commandArgs = arguments.getBase< ReflectedPropertyCommandArgument >();
	
	if ( commandArgs == nullptr ) 
	{
			return false;
	}

	auto objManager = definitionManager_.getObjectManager();
	if ( objManager == nullptr ) 
	{
		return false;
	}

	const ObjectHandle & object = objManager->getObject( commandArgs->getContextId() );
	if (!object.isValid())
	{
		return false;
	}

	const IClassDefinition* defn = object.getDefinition( definitionManager_ );
	PropertyAccessor property = defn->bindProperty(commandArgs->getPropertyPath(), object );
	if (property.isValid() == false)
	{
		return false;
	}
	
	const MetaType * dataType = commandArgs->getPropertyValue().type();
	const MetaType * propertyValueType = property.getValue().type();

	if ( !dataType->canConvertTo(propertyValueType) ) 
	{
		return false;
	}

	return true;
}
コード例 #11
0
/*
    Move the number of objects defined by count from the CIMResponseData
    cache for this EnumerationContext to theCIMResponseData object
    defined by the input parameter.

    Returns true if data acquired from cache. Returns false if CIMException
    found (i.e. returned an error).
*/
bool EnumerationContext::getCache(Uint32 count, CIMResponseData& rtnData)
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContext::getCache");

    PEGASUS_DEBUG_ASSERT(valid());

    // Move attributes from Cache to new CIMResponseData object
    // sets the attributes for propertyList, includeQualifiers,
    // classOrigin
    rtnData.setResponseAttributes(_responseCache);

    // if Error set, return false to signal the error to caller.
    if (isErrorState())
    {
        PEG_METHOD_EXIT();
        return false;
    }

    // Move the defined number of objects from the cache to the return object.
    rtnData.moveObjects(_responseCache, count);

    // add to statistics for this enumerationContext. Counts objects actuallly
    // sent.
    _responseObjectsCount += rtnData.size();
    // Accumulation of count of request maxObjectCounts
    _requestedResponseObjectsCount += count;

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
      "EnumerationContext::getCache ContextId=%s moveObjects expected=%u"
          " actual=%u", *Str(getContextId()), count, rtnData.size()));
#endif

    // Signal the ProviderLimitCondition that the cache size may
    // have changed.
    signalProviderWaitCondition();

    PEG_METHOD_EXIT();
    return true;
}
コード例 #12
0
/*
    Test the cache to see if there is information that could be used
    for an immediate response. Returns immediatly with true or false
    indicating that a response should be issued.
    @param count Uint32 count of objects that the requests set as
    max number for response
    @return True if passes tests for something to send or error flag
    set.
*/
bool EnumerationContext::testCacheForResponses(
    Uint32 operationMaxObjectCount,
    bool requiresAll)
{
    bool rtn = false;

    // Error encountered, must send response. This makes error highest
    // priority.
    if (isErrorState())
    {
        rtn = true;
    }
    // Always allow requests for no objects
    else if (operationMaxObjectCount == 0)
    {
        rtn = true;
    }
    // If cache has enough objects return true
    else if (requiresAll && (responseCacheSize() >= operationMaxObjectCount))
    {
        rtn = true;
    }
    // anything in cache to return
    else if (!requiresAll && responseCacheSize() > 0)
    {
        rtn = true;
    }
    // Nothing more from providers. Must return response
    else if (providersComplete())
    {
        rtn = true;
    }

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
       "testCacheForResponse returns %s for ContextId=%s",
               boolToString(rtn), *Str(getContextId()) ));
#endif
    return rtn;
}
コード例 #13
0
/*
    Set the processing state. Processing is true if the Dispatcher is
    actively handling a request. The dispatcher sets processing = true
    at the start of processing and false at the completion of processing.
*/
void EnumerationContext::setProcessingState(bool state)
{
    // Diagnostic to confirm we are changing state
    PEGASUS_DEBUG_ASSERT(valid());
    PEGASUS_DEBUG_ASSERT(_processing != state); // not setting to same state

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "setProcessingState. ContextId=%s nextProcessingStat=%s",
        *Str(getContextId()), (state? "active" : "inactive") ));
#endif

    _processing = state;
    if (_processing)
    {
        stopTimer();
    }
    else
    {
        startTimer();
    }
}
コード例 #14
0
void EnumerationContext::startTimer(Uint64 timeoutUsec)
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT,"EnumerationContext::startTimer");

    PEGASUS_DEBUG_ASSERT(valid());

    Uint64 currentTime = System::getCurrentTimeUsec();

    _operationTimerUsec =  currentTime + timeoutUsec;

    _enumerationContextTable->dispatchTimerThread();

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "StartTimer, ContextId=%s, This timeoutTime(sec)=%llu"
           " OperationTimeout=%u sec,"
           " next timeout in %ld sec,",
       *Str(getContextId()),
       (timeoutUsec / PEG_MICROSEC),
       _operationTimeoutSec,
       (long signed int)(_operationTimerUsec - currentTime)/PEG_MICROSEC ));
#endif
    PEG_METHOD_EXIT();
}
コード例 #15
0
ファイル: filterdialog.cpp プロジェクト: mikelima/dlt-viewer
void FilterDialog::validate()
{
    QString
    error =  "Could not parse %1 regular expression. \n";
    error += "Please correct the error or remove the regular expression.\n";
    error += "Expression: '%2' \n";
    error += "Error: %3 ";


    if(!(getEnableRegexp_Context()||getEnableRegexp_Header()||getEnableRegexp_Payload()))
    {
        emit accept();
        return;
    }

    QRegExp rx;
    rx.setPattern(getPayloadText());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("PAYLOAD").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    rx.setPattern(getHeaderText());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("HEADER").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    rx.setPattern(getContextId());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("CONTEXTID").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    emit accept();
}
コード例 #16
0
/*
    Insert complete CIMResponseData entities into the cache. If the
    cache is at its max size limit, and there are more provider responses
    wait until it the size drops below the full limit.
    If the operation is closed, ignore the response.
    Return true if putCache worked, false if closed and nothing put into
    the cache.
    NOTE: This function assumes that responses for a request are serialized
    in _enqueueResponse See _enqueueResponseMutex.
*/
bool EnumerationContext::putCache(CIMResponseMessage*& response,
    bool providersComplete)
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContext::putCache");

    PEGASUS_DEBUG_ASSERT(valid());

    // Design error if we ever get here with providers already set complete
    PEGASUS_DEBUG_ASSERT(!_providersComplete);

    CIMResponseDataMessage* localResponse =
        dynamic_cast<CIMResponseDataMessage*>(response);
    CIMResponseData & from = localResponse->getResponseData();
    //// from.traceResponseData();

    // If there is any binary data, reformat it to SCMO.  There are no
    // size counters for the binary data so reformat to generate
    // counters and make it compatible with the cache access mechanisms
    if (from.hasBinaryData())
    {
        from.resolveBinaryToSCMO();
        //// from.traceResponseData();
    }

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "putCache, ContextId=%s isComplete=%s cacheResponseDataType=%u "
            " cacheSize=%u putSize=%u putResponseDataType=%u clientClosed=%s",
        *Str(getContextId()),
        boolToString(providersComplete),
        _responseCache.getResponseDataContent(),
        _responseCache.size(), from.size(), from.getResponseDataContent(),
        boolToString(_clientClosed)));
#endif

    // This test should not be required.  Somewhere in the processing there
    // is a rare return of an erronous response from OOP. This covers that
    // case until we find the issue.  It issues an error a discard trace
    if (from.getResponseDataContent()!=_responseCache.getResponseDataContent())
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
            "Pull Provider Response DataContentType in error. cacheType=%u "
            "responseType=%u "
            "ResponseMsgType=%s ContextId=%s",
            _responseCache.getResponseDataContent(),
            from.getResponseDataContent(),
            MessageTypeToString(response->getType()),
            *Str(getContextId()) ));
        trace();
        // This is temp for testing. KS_TODO delete this console display
        //// cout << System::getCurrentASCIITime()
        ////      << "Error CIMResponseDataMismatch "
        ////     << getContextId() << endl;

        CIMException sysErr = CIMException(CIM_ERR_FAILED,
            "Internal Error in EnumerationContext processing");
        setErrorState(sysErr);
        // Output warning log to indicate that this system failure has occurred

        Logger::put(
                Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
                "Response msg data type mismatch from providers."
                "Internal Error in EnumerationContext processing. "
                " ContextId=", *Str(getContextId() ));
        return _clientClosed;

    }
    // If an operation has closed the enumerationContext
    // ignore any received responses until the providersComplete is received
    // and then remove the Context.
    if (_clientClosed)
    {
        PEG_METHOD_EXIT();
        return false;
    }
    else  // client not closed
    {
        // put the current response into the cache. Lock cache for this
        // operation

        _responseCache.appendResponseData(from);

        // set providersComplete flag from flag in call parameter.
        _providersComplete = providersComplete;

        // test and set the high water mark for this cache.
        if (responseCacheSize() > _cacheHighWaterMark)
        {
            _cacheHighWaterMark = responseCacheSize();
        }
    }

    // Return true indicating that input added to cache and cache is still open
    PEG_METHOD_EXIT();
    return true;
}