mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-05-31 17:20:57 +00:00
o changed definition of +formatDescription:forResponse:inContext:
o implemented +formatDescription:forResponse:inContext: o change types from double to NSTimeInterval o implemented missing methods git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18153 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e0770de4db
commit
57e7f44775
2 changed files with 350 additions and 245 deletions
|
@ -42,37 +42,40 @@
|
||||||
int _transactionsCount;
|
int _transactionsCount;
|
||||||
int _lastStatsTransactionsCount;
|
int _lastStatsTransactionsCount;
|
||||||
int _directActionTransactionsCount;
|
int _directActionTransactionsCount;
|
||||||
|
int _webServiceTransactionsCount;
|
||||||
int _componentActionTransactionsCount;
|
int _componentActionTransactionsCount;
|
||||||
int _sessionsCount;
|
int _sessionsCount;
|
||||||
int _lastStatsSessionsCount;
|
int _lastStatsSessionsCount;
|
||||||
int _maxActiveSessionsCount;
|
int _maxActiveSessionsCount;
|
||||||
NSDate* _maxActiveSessionsDate;
|
NSDate* _maxActiveSessionsDate;
|
||||||
float _averageRequestsPerSession;
|
float _averageRequestsPerSession;
|
||||||
double _averageSessionLife;
|
NSTimeInterval _averageSessionLife;
|
||||||
NSArray* _lastSessionStatistics;
|
NSArray* _lastSessionStatistics;
|
||||||
double _movingAverageSessionLife;
|
NSTimeInterval _movingAverageSessionLife;
|
||||||
float _movingAverageRequestsPerSession;
|
float _movingAverageRequestsPerSession;
|
||||||
int _movingAverageSessionsCount;
|
int _movingAverageSessionsCount;
|
||||||
NSDate* _startDate;
|
NSDate* _startDate;
|
||||||
NSDate* _lastStatsDate;
|
NSDate* _lastStatsDate;
|
||||||
double _lastWillHandleRequestTimeInterval;
|
NSTimeInterval _lastWillHandleRequestTimeInterval;
|
||||||
double _lastDidHandleRequestTimeInterval;
|
NSTimeInterval _lastDidHandleRequestTimeInterval;
|
||||||
double _totalIdleTimeInterval;
|
NSTimeInterval _totalIdleTimeInterval;
|
||||||
double _totalTransactionTimeInterval;
|
NSTimeInterval _totalTransactionTimeInterval;
|
||||||
double _totalDATransactionTimeInterval;
|
NSTimeInterval _totalDATransactionTimeInterval;
|
||||||
double _totalCATransactionTimeInterval;
|
NSTimeInterval _totalWSTransactionTimeInterval;
|
||||||
double _movingIdleTimeInterval;
|
NSTimeInterval _totalCATransactionTimeInterval;
|
||||||
double _movingTransactionTimeInterval;
|
NSTimeInterval _movingIdleTimeInterval;
|
||||||
|
NSTimeInterval _movingTransactionTimeInterval;
|
||||||
int _movingAverageTransactionsCount;
|
int _movingAverageTransactionsCount;
|
||||||
NSDictionary* _initializationMemory;
|
NSDictionary* _initializationMemory;
|
||||||
NSMutableDictionary* _pagesStatistics;
|
NSMutableDictionary* _pagesStatistics;
|
||||||
NSString* _currentPage;
|
NSString* _currentPage;
|
||||||
NSMutableDictionary* _pathsStatistics;
|
NSMutableDictionary* _pathsStatistics;
|
||||||
NSString* _logPath;
|
NSString* _logPath;
|
||||||
double _logRotation;
|
NSTimeInterval _logRotation;
|
||||||
NSDate* _logCreationDate;
|
NSDate* _logCreationDate;
|
||||||
NSString* _password;
|
NSString* _password;
|
||||||
NSMutableDictionary* _directActionStatistics;
|
NSMutableDictionary* _directActionStatistics;
|
||||||
|
NSMutableDictionary* _webServiceStatistics;
|
||||||
};
|
};
|
||||||
|
|
||||||
-(id)init;
|
-(id)init;
|
||||||
|
@ -90,19 +93,17 @@
|
||||||
@interface GSWStatisticsStore (GSWStatisticsStoreA)
|
@interface GSWStatisticsStore (GSWStatisticsStoreA)
|
||||||
-(void)_purgePathsStatistics;
|
-(void)_purgePathsStatistics;
|
||||||
-(void)_updatePathsStatisticsWithPaths:(id)paths;
|
-(void)_updatePathsStatisticsWithPaths:(id)paths;
|
||||||
-(void)_updatePagesStatisticsForPage:(id)page
|
-(void)sessionTerminating:(GSWSession*)session;
|
||||||
timeInterval:(NSTimeInterval)timeInterval;
|
|
||||||
-(void)_updateDAStatisticsForActionNamed:(id)name
|
|
||||||
timeInterval:(NSTimeInterval)timeInterval;
|
|
||||||
-(void)_sessionTerminating:(GSWSession*)session;
|
-(void)_sessionTerminating:(GSWSession*)session;
|
||||||
-(void)_applicationCreatedSession:(GSWSession*)session;
|
-(void)_applicationCreatedSession:(GSWSession*)session;
|
||||||
-(void)_applicationDidHandleComponentActionRequest;
|
|
||||||
-(void)_applicationDidHandleComponentActionRequestInTimeInterval:(double)timeInterval;
|
-(void)applicationWillHandleDirectActionRequest;
|
||||||
-(void)_applicationDidHandleDirectActionRequestWithActionNamed:(id)name;
|
-(void)applicationWillHandleWebServiceRequest;
|
||||||
-(double)_applicationDidHandleRequest;
|
-(void)applicationWillHandleComponentActionRequest;
|
||||||
-(void)_applicationWillHandleDirectActionRequest;
|
|
||||||
-(void)_applicationWillHandleComponentActionRequest;
|
-(void)applicationDidHandleComponentActionRequestWithPageNamed:(NSString*)pageName;
|
||||||
-(void)_applicationWillHandleRequest;
|
-(void)applicationDidHandleDirectActionRequestWithActionNamed:(NSString*)actionName;
|
||||||
|
-(void)applicationDidHandleWebServiceRequestWithActionNamed:(NSString*)actionName;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GSWStatisticsStore (GSWStatisticsStoreB)
|
@interface GSWStatisticsStore (GSWStatisticsStoreB)
|
||||||
|
@ -115,13 +116,13 @@
|
||||||
|
|
||||||
@interface GSWStatisticsStore (GSWStatisticsStoreC)
|
@interface GSWStatisticsStore (GSWStatisticsStoreC)
|
||||||
-(void)logString:(id)string;
|
-(void)logString:(id)string;
|
||||||
-(double)logFileRotationFrequencyInDays;
|
-(NSTimeInterval)logFileRotationFrequencyInDays;
|
||||||
-(NSString*)logFile;
|
-(NSString*)logFile;
|
||||||
-(void) setLogFile:(NSString*)logFile
|
-(void) setLogFile:(NSString*)logFile
|
||||||
rotationFrequencyInDays:(double)rotationFrequency;
|
rotationFrequencyInDays:(NSTimeInterval)rotationFrequency;
|
||||||
-(id)formatDescription:(id)description
|
+(NSString*)formatDescription:(NSString*)description
|
||||||
forResponse:(GSWResponse*)aResponse
|
forResponse:(GSWResponse*)aResponse
|
||||||
inContext:(GSWContext*)aContext;
|
inContext:(GSWContext*)aContext;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GSWStatisticsStore (GSWStatisticsStoreD)
|
@interface GSWStatisticsStore (GSWStatisticsStoreD)
|
||||||
|
@ -131,19 +132,19 @@
|
||||||
-(id)_lastSessionStatistics;
|
-(id)_lastSessionStatistics;
|
||||||
-(NSDictionary*)_memoryUsage;
|
-(NSDictionary*)_memoryUsage;
|
||||||
-(id)_averageSessionMemory;
|
-(id)_averageSessionMemory;
|
||||||
-(double)_movingAverageSessionLife;
|
-(NSTimeInterval)_movingAverageSessionLife;
|
||||||
-(double)_averageSessionLife;
|
-(NSTimeInterval)_averageSessionLife;
|
||||||
-(float)_movingAverageRequestsPerSession;
|
-(float)_movingAverageRequestsPerSession;
|
||||||
-(float)_averageRequestsPerSession;
|
-(float)_averageRequestsPerSession;
|
||||||
-(NSDate*)_maxActiveSessionsDate;
|
-(NSDate*)_maxActiveSessionsDate;
|
||||||
-(int)_maxActiveSessionsCount;
|
-(int)_maxActiveSessionsCount;
|
||||||
-(int)_sessionsCount;
|
-(int)_sessionsCount;
|
||||||
-(double)_movingAverageTransactionTime;
|
-(NSTimeInterval)_movingAverageTransactionTime;
|
||||||
-(double)_movingAverageIdleTime;
|
-(NSTimeInterval)_movingAverageIdleTime;
|
||||||
-(double)_averageCATransactionTime;
|
-(NSTimeInterval)_averageCATransactionTime;
|
||||||
-(double)_averageDATransactionTime;
|
-(NSTimeInterval)_averageDATransactionTime;
|
||||||
-(double)_averageTransactionTime;
|
-(NSTimeInterval)_averageTransactionTime;
|
||||||
-(double)_averageIdleTime;
|
-(NSTimeInterval)_averageIdleTime;
|
||||||
-(int)_directActionTransactionsCount;
|
-(int)_directActionTransactionsCount;
|
||||||
-(int)_componentActionTransactionsCount;
|
-(int)_componentActionTransactionsCount;
|
||||||
-(int)_transactionsCount;
|
-(int)_transactionsCount;
|
||||||
|
@ -167,6 +168,6 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GSWStatisticsStore (GSWStatisticsStoreH)
|
@interface GSWStatisticsStore (GSWStatisticsStoreH)
|
||||||
+(id)timeIntervalDescription:(double)timeInterval;
|
+(id)timeIntervalDescription:(NSTimeInterval)timeInterval;
|
||||||
@end
|
@end
|
||||||
#endif //_GSWStatisticsStore_h__
|
#endif //_GSWStatisticsStore_h__
|
||||||
|
|
|
@ -264,128 +264,31 @@ RCS_ID("$Id$")
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
-(void)_updatePagesStatisticsForPage:(id)aPage
|
|
||||||
timeInterval:(NSTimeInterval)aTimeInterval
|
|
||||||
{
|
|
||||||
//OK
|
|
||||||
NSMutableDictionary* pageStats=nil;
|
|
||||||
NSNumber* AvgRespTime=nil;
|
|
||||||
NSNumber* MinRespTime=nil;
|
|
||||||
NSNumber* MaxRespTime=nil;
|
|
||||||
NSNumber* Served=nil;
|
|
||||||
double AvgRespTimeValue=0;
|
|
||||||
double MinRespTimeValue=0;
|
|
||||||
double MaxRespTimeValue=0;
|
|
||||||
int ServedValue=0;
|
|
||||||
LOGObjectFnStart();
|
|
||||||
[self lock];
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
NSDebugMLog(@"aPage=%@",aPage);
|
|
||||||
if (!_pagesStatistics)
|
|
||||||
_pagesStatistics=[NSMutableDictionary new];
|
|
||||||
else
|
|
||||||
pageStats=[_pagesStatistics objectForKey:aPage];
|
|
||||||
NSDebugMLog(@"pagesStatistics=%@",_pagesStatistics);
|
|
||||||
NSDebugMLog(@"pageStats=%@",pageStats);
|
|
||||||
if (pageStats)
|
|
||||||
{
|
|
||||||
AvgRespTime=[pageStats objectForKey:@"Avg Resp. Time"];
|
|
||||||
MinRespTime=[pageStats objectForKey:@"Min Resp. Time"];
|
|
||||||
MaxRespTime=[pageStats objectForKey:@"Max Resp. Time"];
|
|
||||||
Served=[pageStats objectForKey:@"Served"];
|
|
||||||
|
|
||||||
ServedValue=[Served intValue];
|
|
||||||
if (MinRespTime)
|
|
||||||
{
|
|
||||||
MinRespTimeValue=[MinRespTime doubleValue];
|
|
||||||
MinRespTimeValue=min(MinRespTimeValue,aTimeInterval);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
MinRespTimeValue=aTimeInterval;
|
|
||||||
if (MaxRespTime)
|
|
||||||
{
|
|
||||||
MaxRespTimeValue=[MaxRespTime doubleValue];
|
|
||||||
MaxRespTimeValue=max(MaxRespTimeValue,aTimeInterval);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
MaxRespTimeValue=aTimeInterval;
|
|
||||||
if (AvgRespTime)
|
|
||||||
{
|
|
||||||
AvgRespTimeValue=[AvgRespTime doubleValue];
|
|
||||||
AvgRespTimeValue=((AvgRespTimeValue*ServedValue)+aTimeInterval)/(ServedValue+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
AvgRespTimeValue=aTimeInterval;
|
|
||||||
ServedValue++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pageStats=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
|
||||||
[_pagesStatistics setObject:pageStats
|
|
||||||
forKey:aPage];
|
|
||||||
AvgRespTimeValue=aTimeInterval;
|
|
||||||
MinRespTimeValue=aTimeInterval;
|
|
||||||
MaxRespTimeValue=aTimeInterval;
|
|
||||||
ServedValue=1;
|
|
||||||
};
|
|
||||||
AvgRespTime=[NSNumber numberWithDouble:AvgRespTimeValue];
|
|
||||||
MinRespTime=[NSNumber numberWithDouble:MinRespTimeValue];
|
|
||||||
MaxRespTime=[NSNumber numberWithDouble:MaxRespTimeValue];
|
|
||||||
Served=[NSNumber numberWithInt:ServedValue];
|
|
||||||
NSDebugMLog(@"AvgRespTime=%@",AvgRespTime);
|
|
||||||
NSDebugMLog(@"MinRespTime=%@",MinRespTime);
|
|
||||||
NSDebugMLog(@"MaxRespTime=%@",MaxRespTime);
|
|
||||||
NSDebugMLog(@"Served=%@",Served);
|
|
||||||
[pageStats setObject:AvgRespTime
|
|
||||||
forKey:@"Avg Resp. Time"];
|
|
||||||
[pageStats setObject:MinRespTime
|
|
||||||
forKey:@"Min Resp. Time"];
|
|
||||||
[pageStats setObject:MaxRespTime
|
|
||||||
forKey:@"Max Resp. Time"];
|
|
||||||
[pageStats setObject:Served
|
|
||||||
forKey:@"Served"];
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
|
||||||
localException,[localException reason],
|
|
||||||
__FILE__,__LINE__);
|
|
||||||
//TODO
|
|
||||||
[self unlock];
|
|
||||||
[localException raise];
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
[self unlock];
|
|
||||||
LOGObjectFnStop();
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
-(void)_updateDAStatisticsForActionNamed:(id)aName
|
|
||||||
timeInterval:(NSTimeInterval)aTimeInterval
|
|
||||||
{
|
|
||||||
LOGObjectFnNotImplemented(); //TODOFN
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(void)_sessionTerminating:(GSWSession*)aSession
|
-(void)_sessionTerminating:(GSWSession*)aSession
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
|
LOGObjectFnStart();
|
||||||
|
int activeSessionsCount=[GSWApp _activeSessionsCount];
|
||||||
|
NSArray* statistics=[aSession statistics];
|
||||||
|
NSDate* sessionBirthDate=nil;
|
||||||
|
NSTimeInterval sessionTimeOut=0;
|
||||||
|
int sessionRequestCounter=0;
|
||||||
|
[self _updatePathsStatisticsWithPaths:statistics];
|
||||||
|
sessionBirthDate=[aSession _birthDate];
|
||||||
|
sessionTimeOut=[aSession timeOut];
|
||||||
|
sessionRequestCounter=[aSession _requestCounter];
|
||||||
|
LOGObjectFnStop();
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)sessionTerminating:(GSWSession*)aSession
|
||||||
|
{
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
[self lock];
|
[self lock];
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
int activeSessionsCount=[GSWApp _activeSessionsCount];
|
[self _sessionTerminating:aSession];
|
||||||
NSArray* statistics=[aSession statistics];
|
|
||||||
NSDate* sessionBirthDate=nil;
|
|
||||||
NSTimeInterval sessionTimeOut=0;
|
|
||||||
int sessionRequestCounter=0;
|
|
||||||
[self _updatePathsStatisticsWithPaths:statistics];
|
|
||||||
sessionBirthDate=[aSession _birthDate];
|
|
||||||
sessionTimeOut=[aSession timeOut];
|
|
||||||
sessionRequestCounter=[aSession _requestCounter];
|
|
||||||
//TODOFN
|
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
@ -430,91 +333,34 @@ RCS_ID("$Id$")
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(void)_applicationDidHandleComponentActionRequest
|
-(void)_applicationWillHandleRequest
|
||||||
{
|
{
|
||||||
//OK
|
NSTimeInterval idleTimeInterval = 0;
|
||||||
double timeInterval=0;
|
NSDate* currentDate=nil;
|
||||||
LOGObjectFnStart();
|
|
||||||
[self lock];
|
currentDate=[NSDate date];
|
||||||
NS_DURING
|
|
||||||
|
_transactionsCount++;
|
||||||
|
|
||||||
|
_lastWillHandleRequestTimeInterval = [currentDate timeIntervalSinceDate:_startDate];
|
||||||
|
|
||||||
|
idleTimeInterval = _lastWillHandleRequestTimeInterval - _lastDidHandleRequestTimeInterval;
|
||||||
|
_totalIdleTimeInterval += idleTimeInterval;
|
||||||
|
if (_transactionMovingAverageSampleCount>0)
|
||||||
{
|
{
|
||||||
timeInterval=[self _applicationDidHandleRequest];
|
_movingAverageTransactionsCount++;
|
||||||
NSDebugMLog(@"currentPage=%@",_currentPage);
|
_movingIdleTimeInterval += idleTimeInterval;
|
||||||
if (_currentPage) { //TODO no current page if no session (error page,...)
|
if(_movingAverageTransactionsCount > _transactionMovingAverageSampleCount)
|
||||||
NSLog(@"GSWStatisticsStore timeInterval=%f",timeInterval);
|
{
|
||||||
[self _updatePagesStatisticsForPage:_currentPage
|
_movingIdleTimeInterval -=
|
||||||
timeInterval:timeInterval];
|
_movingIdleTimeInterval / (double)_transactionMovingAverageSampleCount;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
|
||||||
localException,[localException reason],
|
|
||||||
__FILE__,__LINE__);
|
|
||||||
//TODO
|
|
||||||
[self unlock];
|
|
||||||
[localException raise];
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
[self unlock];
|
|
||||||
LOGObjectFnStop();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(void)_applicationDidHandleComponentActionRequestInTimeInterval:(double)timeInterval
|
-(void)applicationWillHandleDirectActionRequest
|
||||||
{
|
{
|
||||||
//OK
|
|
||||||
// double timeInterval=0;
|
|
||||||
LOGObjectFnStart();
|
|
||||||
[self lock];
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
// timeInterval=[self _applicationDidHandleRequest];
|
|
||||||
NSDebugMLog(@"currentPage=%@",_currentPage);
|
|
||||||
if (_currentPage) { //TODO no current page if no session (error page,...)
|
|
||||||
NSLog(@"GSWStatisticsStore timeInterval=%f",timeInterval);
|
|
||||||
[self _updatePagesStatisticsForPage:_currentPage
|
|
||||||
timeInterval:timeInterval];
|
|
||||||
DESTROY(_currentPage); // otherwise a reload of the statistics page will change this page's stats
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
|
||||||
localException,[localException reason],
|
|
||||||
__FILE__,__LINE__);
|
|
||||||
//TODO
|
|
||||||
[self unlock];
|
|
||||||
[localException raise];
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
[self unlock];
|
|
||||||
LOGObjectFnStop();
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
-(void)_applicationDidHandleDirectActionRequestWithActionNamed:(id)aName
|
|
||||||
{
|
|
||||||
LOGObjectFnNotImplemented(); //TODOFN
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
-(double)_applicationDidHandleRequest
|
|
||||||
{
|
|
||||||
//OK
|
|
||||||
LOGObjectFnNotImplemented(); //TODOFN
|
|
||||||
//_lastDidHandleRequestTimeInterval=115.005370 (ancien=53.516954)
|
|
||||||
//_totalTransactionTimeInterval=double DOUBLE:61.488416 (ancien=0)
|
|
||||||
//_movingTransactionTimeInterval=double DOUBLE:61.488416 (ancien=0)
|
|
||||||
|
|
||||||
return _movingTransactionTimeInterval; //??? 61.488416: ou _totalTransactionTimeInterval - precedent
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
-(void)_applicationWillHandleDirectActionRequest
|
|
||||||
{
|
|
||||||
//OK
|
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
[self lock];
|
[self lock];
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
@ -537,9 +383,32 @@ RCS_ID("$Id$")
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(void)_applicationWillHandleComponentActionRequest
|
-(void)applicationWillHandleWebServiceRequest
|
||||||
|
{
|
||||||
|
LOGObjectFnStart();
|
||||||
|
[self lock];
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
_webServiceTransactionsCount++;
|
||||||
|
[self _applicationWillHandleRequest];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
||||||
|
localException,[localException reason],
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
//TODO
|
||||||
|
[self unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
[self unlock];
|
||||||
|
LOGObjectFnStop();
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)applicationWillHandleComponentActionRequest
|
||||||
{
|
{
|
||||||
//OK
|
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
[self lock];
|
[self lock];
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
@ -561,20 +430,210 @@ RCS_ID("$Id$")
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
-(void)_updateHandlerStatistics:(NSMutableDictionary*)statistics
|
||||||
|
withKey:(NSString*)aKey
|
||||||
|
handlingTimeInterval:(NSTimeInterval)handlingTimeInterval
|
||||||
|
{
|
||||||
|
LOGObjectFnStart();
|
||||||
|
if (aKey)
|
||||||
|
{
|
||||||
|
NSNumber* AvgRespTime=nil;
|
||||||
|
NSNumber* MinRespTime=nil;
|
||||||
|
NSNumber* MaxRespTime=nil;
|
||||||
|
NSNumber* Served=nil;
|
||||||
|
double AvgRespTimeValue=0;
|
||||||
|
double MinRespTimeValue=0;
|
||||||
|
double MaxRespTimeValue=0;
|
||||||
|
int ServedValue=0;
|
||||||
|
NSMutableDictionary* statsForKey=[statistics objectForKey:aKey];
|
||||||
|
|
||||||
|
NSDebugMLog(@"statsForKey=%@",statsForKey);
|
||||||
|
if (statsForKey)
|
||||||
|
{
|
||||||
|
AvgRespTime=[statsForKey objectForKey:@"Avg Resp. Time"];
|
||||||
|
MinRespTime=[statsForKey objectForKey:@"Min Resp. Time"];
|
||||||
|
MaxRespTime=[statsForKey objectForKey:@"Max Resp. Time"];
|
||||||
|
Served=[statsForKey objectForKey:@"Served"];
|
||||||
|
|
||||||
|
ServedValue=[Served intValue];
|
||||||
|
if (MinRespTime)
|
||||||
|
{
|
||||||
|
MinRespTimeValue=[MinRespTime doubleValue];
|
||||||
|
MinRespTimeValue=min(MinRespTimeValue,handlingTimeInterval);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MinRespTimeValue=handlingTimeInterval;
|
||||||
|
if (MaxRespTime)
|
||||||
|
{
|
||||||
|
MaxRespTimeValue=[MaxRespTime doubleValue];
|
||||||
|
MaxRespTimeValue=max(MaxRespTimeValue,handlingTimeInterval);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MaxRespTimeValue=handlingTimeInterval;
|
||||||
|
if (AvgRespTime)
|
||||||
|
{
|
||||||
|
AvgRespTimeValue=[AvgRespTime doubleValue];
|
||||||
|
AvgRespTimeValue=((AvgRespTimeValue*ServedValue)+handlingTimeInterval)/(ServedValue+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AvgRespTimeValue=handlingTimeInterval;
|
||||||
|
ServedValue++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statsForKey=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||||
|
[statistics setObject:statsForKey
|
||||||
|
forKey:aKey];
|
||||||
|
AvgRespTimeValue=handlingTimeInterval;
|
||||||
|
MinRespTimeValue=handlingTimeInterval;
|
||||||
|
MaxRespTimeValue=handlingTimeInterval;
|
||||||
|
ServedValue=1;
|
||||||
|
};
|
||||||
|
AvgRespTime=[NSNumber numberWithDouble:AvgRespTimeValue];
|
||||||
|
MinRespTime=[NSNumber numberWithDouble:MinRespTimeValue];
|
||||||
|
MaxRespTime=[NSNumber numberWithDouble:MaxRespTimeValue];
|
||||||
|
Served=[NSNumber numberWithInt:ServedValue];
|
||||||
|
NSDebugMLog(@"AvgRespTime=%@",AvgRespTime);
|
||||||
|
NSDebugMLog(@"MinRespTime=%@",MinRespTime);
|
||||||
|
NSDebugMLog(@"MaxRespTime=%@",MaxRespTime);
|
||||||
|
NSDebugMLog(@"Served=%@",Served);
|
||||||
|
[statsForKey setObject:AvgRespTime
|
||||||
|
forKey:@"Avg Resp. Time"];
|
||||||
|
[statsForKey setObject:MinRespTime
|
||||||
|
forKey:@"Min Resp. Time"];
|
||||||
|
[statsForKey setObject:MaxRespTime
|
||||||
|
forKey:@"Max Resp. Time"];
|
||||||
|
[statsForKey setObject:Served
|
||||||
|
forKey:@"Served"];
|
||||||
|
};
|
||||||
|
LOGObjectFnStop();
|
||||||
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(void)_applicationWillHandleRequest
|
-(NSTimeInterval)_applicationDidHandleRequest
|
||||||
|
{
|
||||||
|
NSTimeInterval handlingTimeInterval=0;
|
||||||
|
NSDate* currentDate=nil;
|
||||||
|
|
||||||
|
currentDate=[NSDate date];
|
||||||
|
|
||||||
|
_lastDidHandleRequestTimeInterval = [currentDate timeIntervalSinceDate:_startDate];
|
||||||
|
handlingTimeInterval = _lastDidHandleRequestTimeInterval - _lastWillHandleRequestTimeInterval;
|
||||||
|
|
||||||
|
_totalTransactionTimeInterval += handlingTimeInterval;
|
||||||
|
if (_transactionMovingAverageSampleCount>0)
|
||||||
|
{
|
||||||
|
_movingTransactionTimeInterval += handlingTimeInterval;
|
||||||
|
if (_movingAverageTransactionsCount>_transactionMovingAverageSampleCount)
|
||||||
|
{
|
||||||
|
_movingTransactionTimeInterval -=
|
||||||
|
_movingTransactionTimeInterval / (NSTimeInterval)_transactionMovingAverageSampleCount;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return handlingTimeInterval;
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)_applicationDidHandleComponentActionRequest
|
||||||
|
{
|
||||||
|
NSTimeInterval handlingTimeInterval=[self _applicationDidHandleRequest];
|
||||||
|
_totalCATransactionTimeInterval += handlingTimeInterval;
|
||||||
|
[self _updateHandlerStatistics:_pagesStatistics
|
||||||
|
withKey:_currentPage
|
||||||
|
handlingTimeInterval:handlingTimeInterval];
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)_applicationDidHandleDirectActionRequestWithActionNamed:(NSString*)actionName
|
||||||
|
{
|
||||||
|
NSTimeInterval handlingTimeInterval=[self _applicationDidHandleRequest];
|
||||||
|
_totalDATransactionTimeInterval += handlingTimeInterval;
|
||||||
|
[self _updateHandlerStatistics:_directActionStatistics
|
||||||
|
withKey:actionName
|
||||||
|
handlingTimeInterval:handlingTimeInterval];
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)_applicationDidHandleWebServiceRequestWithActionNamed:(NSString*)actionName
|
||||||
|
{
|
||||||
|
NSTimeInterval handlingTimeInterval=[self _applicationDidHandleRequest];
|
||||||
|
_totalWSTransactionTimeInterval += handlingTimeInterval;
|
||||||
|
[self _updateHandlerStatistics:_webServiceStatistics
|
||||||
|
withKey:actionName
|
||||||
|
handlingTimeInterval:handlingTimeInterval];
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)applicationDidHandleComponentActionRequestWithPageNamed:(NSString*)pageName
|
||||||
|
{
|
||||||
|
LOGObjectFnStart();
|
||||||
|
[self lock];
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[self _applicationDidHandleComponentActionRequest];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
||||||
|
localException,[localException reason],
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
//TODO
|
||||||
|
[self unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
[self unlock];
|
||||||
|
LOGObjectFnStop();
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)applicationDidHandleDirectActionRequestWithActionNamed:(NSString*)actionName
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
LOGObjectFnNotImplemented(); //TODOFN
|
LOGObjectFnStart();
|
||||||
_transactionsCount++;
|
[self lock];
|
||||||
/*
|
NS_DURING
|
||||||
lastWillHandleRequestTimeInterval=double DOUBLE:53.516954 [RC=4294967295]
|
{
|
||||||
totalIdleTimeInterval=double DOUBLE:53.516954 [RC=4294967295]
|
[self _applicationDidHandleDirectActionRequestWithActionNamed:actionName];
|
||||||
movingIdleTimeInterval=double DOUBLE:53.516954 [RC=4294967295]
|
}
|
||||||
*/
|
NS_HANDLER
|
||||||
_movingAverageTransactionsCount++;
|
{
|
||||||
|
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
||||||
|
localException,[localException reason],
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
//TODO
|
||||||
|
[self unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
[self unlock];
|
||||||
|
LOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(void)applicationDidHandleWebServiceRequestWithActionNamed:(NSString*)actionName
|
||||||
|
{
|
||||||
|
LOGObjectFnStart();
|
||||||
|
[self lock];
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[self _applicationDidHandleWebServiceRequestWithActionNamed:actionName];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
|
||||||
|
localException,[localException reason],
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
//TODO
|
||||||
|
[self unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
[self unlock];
|
||||||
|
LOGObjectFnStop();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
@ -699,12 +758,57 @@ RCS_ID("$Id$")
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(id)formatDescription:(id)description
|
+(NSString*)formatDescription:(NSString*)description
|
||||||
forResponse:(GSWResponse*)aResponse
|
forResponse:(GSWResponse*)aResponse
|
||||||
inContext:(GSWContext*)aContext
|
inContext:(GSWContext*)aContext
|
||||||
{
|
{
|
||||||
LOGObjectFnNotImplemented(); //TODOFN
|
NSString* formattedDescr=nil;
|
||||||
return nil;
|
// public String formatDescription(String s, WOResponse woresponse, WOContext wocontext)
|
||||||
|
if (description)
|
||||||
|
{
|
||||||
|
GSWRequest* request = [aContext request];
|
||||||
|
NSString* remoteHost=nil;
|
||||||
|
NSString* remoteUser=nil;
|
||||||
|
NSString* requestMethod=nil;
|
||||||
|
NSString* httpVersion=nil;
|
||||||
|
if (request)
|
||||||
|
{
|
||||||
|
remoteHost=[request headerForKey:GSWHTTPHeader_RemoteHost[GSWebNamingConv]];
|
||||||
|
if ([remoteHost length]==0)
|
||||||
|
{
|
||||||
|
remoteHost=[request headerForKey:GSWHTTPHeader_RemoteAddress[GSWebNamingConv]];
|
||||||
|
if ([remoteHost length]==0)
|
||||||
|
remoteHost=@"-";
|
||||||
|
};
|
||||||
|
remoteUser=[request headerForKey:GSWHTTPHeader_RemoteUser[GSWebNamingConv]];
|
||||||
|
if ([remoteHost length]==0)
|
||||||
|
{
|
||||||
|
remoteUser=@"-";
|
||||||
|
};
|
||||||
|
requestMethod=[request method];
|
||||||
|
httpVersion=[request httpVersion];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remoteHost=@"?";
|
||||||
|
remoteUser=@"?";
|
||||||
|
requestMethod=@"?";
|
||||||
|
httpVersion=@"?";
|
||||||
|
};
|
||||||
|
description = [description stringByReplacingString:@" "
|
||||||
|
withString:@"_"];
|
||||||
|
formattedDescr=[NSString stringWithFormat:@"%@ - %@ [%@] \"%@ %@/%@ %@\" %u %u\n",
|
||||||
|
remoteHost,
|
||||||
|
remoteUser,
|
||||||
|
[NSDate date],
|
||||||
|
requestMethod,
|
||||||
|
[[GSWApplication application]name],
|
||||||
|
description,
|
||||||
|
httpVersion,
|
||||||
|
(unsigned int)[aResponse status],
|
||||||
|
(unsigned int)[aResponse _contentDataLength]];
|
||||||
|
};
|
||||||
|
return formattedDescr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue