idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
120,200
public void addExecutionTime ( long time ) { totalTime . increaseByLong ( time ) ; lastRequest . setValueAsLong ( time ) ; minTime . setValueIfLesserThanCurrentAsLong ( time ) ; maxTime . setValueIfGreaterThanCurrentAsLong ( time ) ; }
Adds messed execution time to the total execution time .
120,201
public double getAverageRequestDuration ( String intervalName , TimeUnit unit ) { return unit . transformNanos ( totalTime . getValueAsLong ( intervalName ) ) / totalRequests . getValueAsDouble ( intervalName ) ; }
Returns the average request duration for the given interval and converted to the given timeunit .
120,202
public double getErrorRate ( String intervalName ) { long tr = getTotalRequests ( intervalName ) ; double errorRate = tr == 0 ? 0 : ( ( double ) getErrors ( intervalName ) ) / tr ; return ( double ) ( ( int ) ( errorRate * 10000 ) ) / 100 ; }
Returns the error rate . This value was previously calculated in decorator but we moved it into the stats object to be able to define threshold on top of it .
120,203
protected void handleStatsResetIfNeeded ( StatusData < ApacheMetrics > status ) { StatValue uptime = getStatValue ( ApacheMetrics . SERVER_UPTIME ) ; Long currUptime = Long . class . cast ( status . get ( ApacheMetrics . SERVER_UPTIME ) ) ; if ( uptime != null && currUptime != null && uptime . getValueAsLong ( ) > curr...
Check SERVER_UPTIME metric and if its value is lower than the stored one - monitored apache server was restarted . In this case all DIFFLONG statValues need resetting .
120,204
public AccumulatorDefinition toAccumulatorDefinition ( String producerId ) { AccumulatorDefinition ret = new AccumulatorDefinition ( ) ; ret . setProducerName ( producerId ) ; ret . setName ( replaceName ( producerId ) ) ; ret . setStatName ( getStatName ( ) ) ; ret . setValueName ( getValueName ( ) ) ; ret . setInterv...
Creates a new AccumulatorDefinition object for matched producer .
120,205
public String getAttributeName ( ) { return ! StringUtils . isEmpty ( attribute ) && attribute . contains ( "." ) ? attribute . substring ( attribute . indexOf ( "." ) + 1 , attribute . length ( ) ) : "" ; }
Retrieves attribute name .
120,206
private static String [ ] extract ( List < ? extends IGenericMetrics > metrics , Extractor e ) { List < String > strings = new ArrayList < > ( metrics . size ( ) ) ; for ( IGenericMetrics metric : metrics ) { strings . add ( e . extract ( metric ) ) ; } return strings . toArray ( new String [ strings . size ( ) ] ) ; }
Get array of Strings from metrics - one from each with given Extractor .
120,207
public void setUsed ( long value ) { used . setValueAsLong ( value ) ; minUsed . setValueIfLesserThanCurrentAsLong ( value ) ; maxUsed . setValueIfGreaterThanCurrentAsLong ( value ) ; }
Sets new used memory amount .
120,208
public void setCommited ( long value ) { commited . setValueAsLong ( value ) ; minCommited . setValueIfLesserThanCurrentAsLong ( value ) ; maxCommited . setValueIfGreaterThanCurrentAsLong ( value ) ; }
Sets new commited memory amount .
120,209
public void addLoadTime ( final long domLoadTime , final long windowLoadTime ) { totalDomLoadTime . increaseByLong ( domLoadTime ) ; domMinLoadTime . setValueIfLesserThanCurrentAsLong ( domLoadTime ) ; domMaxLoadTime . setValueIfGreaterThanCurrentAsLong ( domLoadTime ) ; domLastLoadTime . setValueAsLong ( domLoadTime )...
Adds DOM load time and page load time to the stats .
120,210
public long getDomMinLoadTime ( final String intervalName , final TimeUnit unit ) { final long min = domMinLoadTime . getValueAsLong ( intervalName ) ; return min == Constants . MIN_TIME_DEFAULT ? min : unit . transformMillis ( min ) ; }
Returns DOM minimum load time for given interval and time unit .
120,211
public long getDomMaxLoadTime ( final String intervalName , final TimeUnit unit ) { final long max = domMaxLoadTime . getValueAsLong ( intervalName ) ; return max == Constants . MAX_TIME_DEFAULT ? max : unit . transformMillis ( max ) ; }
Returns DOM maximum load time for given interval and time unit .
120,212
public static List < ProducerDecoratorBean > getDecoratedProducers ( HttpServletRequest req , List < ProducerAO > producers , Map < String , GraphDataBean > graphData ) { Map < IDecorator , List < ProducerAO > > decoratorMap = new HashMap < > ( producers . size ( ) ) ; for ( ProducerAO producer : producers ) { try { ID...
todo make separate method for graphData in future
120,213
public static ProducerDecoratorBean filterProducersByDecoratorName ( String decoratorName , List < ProducerAO > producers , Map < String , GraphDataBean > graphData ) { ProducerDecoratorBean result = new ProducerDecoratorBean ( ) ; result . setName ( decoratorName ) ; List < ProducerAO > decoratedProducers = new ArrayL...
Filters producers by decorator and returns it .
120,214
public StatusData < NginxMetrics > parse ( String nginxStatus ) { StatusData < NginxMetrics > status = new StatusData < > ( ) ; if ( StringUtils . isEmpty ( nginxStatus ) ) { throw new IllegalArgumentException ( "nginx status is empty!" ) ; } else { Matcher matcher = pattern . matcher ( nginxStatus ) ; if ( matcher . m...
Parse NGINX stub status into StatusData&lt ; NginxMetrics&gt ; .
120,215
public Object execute ( BlueprintCallExecutor executor , Object ... parameters ) throws Exception { stats . addRequest ( ) ; long startTime = System . nanoTime ( ) ; TracedCall aTracedCall = RunningTraceContainer . getCurrentlyTracedCall ( ) ; TraceStep currentElement = null ; CurrentlyTracedCall currentlyTracedCall = ...
Called by the surrounding code whenever the action which we are measuring is actually executed .
120,216
public void addConnector ( Connector connector ) { connectors . put ( connector . getClass ( ) . getCanonicalName ( ) , new ConnectorEntry ( connector ) ) ; }
Registers new connector
120,217
public void enableConnector ( String connectorClass , Properties connectorInitProperties ) throws ConnectorInitException { ConnectorEntry connector = connectors . get ( connectorClass ) ; if ( connector != null ) connectors . get ( connectorClass ) . enableConnector ( connectorInitProperties ) ; }
Makes enable connector with given class name if it registered and not already enabled . Non - existing or already enabled connectors be ignored
120,218
public void disableConnector ( String connectorClass ) { ConnectorEntry connector = connectors . get ( connectorClass ) ; if ( connector != null ) connectors . get ( connectorClass ) . disableConnector ( ) ; }
Denitializes connector with given class name .
120,219
protected OnDemandStatsProducer < S > getProducer ( final ProceedingJoinPoint pjp , final String aProducerId , final String aCategory , final String aSubsystem , final boolean withMethod , final IOnDemandStatsFactory < S > factory , final boolean tracingSupported , final boolean attachDefaultStatsLoggers ) { final Stri...
Returns the producer for the given pjp and producerId . Registers the producer in the registry if it s not already registered .
120,220
private String getProducerId ( final ProceedingJoinPoint pjp , final String aPId , final boolean withMethod ) { if ( ! StringUtils . isEmpty ( aPId ) ) return aPId ; String res = pjp . getSignature ( ) . getDeclaringTypeName ( ) ; try { res = MoskitoUtils . producerName ( res ) ; } catch ( final RuntimeException e ) { ...
Fetch producer id - for further usage .
120,221
private String getMethodName ( Method method ) { StatName statName = method . getAnnotation ( StatName . class ) ; return statName == null ? method . getName ( ) : statName . value ( ) ; }
Returns name for monitored method .
120,222
private String createName ( String producerId , String statName ) { String appName = encodeAppName ( MoskitoConfigurationHolder . getConfiguration ( ) . getApplicationName ( ) ) ; return "MoSKito." + ( appName . length ( ) > 0 ? appName + '.' : "" ) + "producers:type=" + producerId + '.' + statName ; }
Creates JMX name for a producer .
120,223
public void update ( long aStarted , long aDaemon , long aCurrent ) { current . setValueAsLong ( aCurrent ) ; started . setValueAsLong ( aStarted ) ; daemon . setValueAsLong ( aDaemon ) ; minCurrent . setValueIfLesserThanCurrentAsLong ( aCurrent ) ; maxCurrent . setValueIfGreaterThanCurrentAsLong ( aCurrent ) ; }
Called regularly by a timer updates the internal stats .
120,224
private String getValueOrDefault ( HttpServletRequest req , String paramName , String defaultValue ) { final String value = req . getParameter ( paramName ) ; return StringUtils . isEmpty ( value ) ? defaultValue : value ; }
Returns parameter value from request if exists otherwise - default value .
120,225
private boolean isLoadTimeValid ( final String loadTimeParam ) { return ! StringUtils . isEmpty ( loadTimeParam ) && isLong ( loadTimeParam ) && Long . valueOf ( loadTimeParam ) > 0 ; }
Validate given load time request parameter .
120,226
private OnDemandStatsProducer < PageInBrowserStats > createProducer ( final String producerId , final String category , final String subsystem ) { OnDemandStatsProducer < PageInBrowserStats > producer = limit == - 1 ? new OnDemandStatsProducer < PageInBrowserStats > ( producerId , category , subsystem , new PageInBrows...
Creates producer with given producer id category and subsystem and register it in producer registry .
120,227
private boolean isLong ( final String str ) { try { Long . valueOf ( str ) ; return true ; } catch ( NumberFormatException e ) { return false ; } }
Checks if given string is long .
120,228
private boolean processingAllowed ( final String prefix , final String variable , final TemplateReplacementContext context ) { return ( PREFIX . equals ( prefix ) && ! StringUtils . isEmpty ( variable ) && context instanceof MailTemplateReplacementContext ) ; }
Checks whether processing is allowed .
120,229
public static final void createSLF4JIntervalStatsLoggerForAllConfiguredIntervals ( IStatsProducer producer , String loggerNamePrefix ) { List < String > configuredIntervals = MoskitoConfigurationHolder . getConfiguration ( ) . getConfiguredIntervalNames ( ) ; for ( String intervalName : configuredIntervals ) { new Inte...
Creates interval stats loggers for all configured intervals . Every logger is attached to a logger with name loggerNamePrefix&lt ; intervalName&gt ; . If loggerNamePrefix is for example foo then all loggers are attached to foo1m foo5m foo15m etc for all configured intervals .
120,230
private List < GaugeZoneAO > createDefaultZones ( ) { ArrayList < GaugeZoneAO > ret = new ArrayList < > ( 1 ) ; GaugeZoneAO redZone = new GaugeZoneAO ( ) ; redZone . setColor ( "red" ) ; redZone . setLeft ( 0.9f ) ; redZone . setRight ( 1.0f ) ; ret . add ( redZone ) ; return ret ; }
This method creates some default zones if nothing is configured .
120,231
private void guessExceptions ( ) { List < Class < ? > > tmpExceptionList = new ArrayList < > ( ) ; for ( Class < ? > c : supportedInterfaces ) { Method [ ] methods = c . getDeclaredMethods ( ) ; for ( Method m : methods ) { for ( Class < ? > exc : m . getExceptionTypes ( ) ) { if ( ! tmpExceptionList . contains ( exc )...
Looks up all possible exceptions .
120,232
private void init ( ) { errorProducerEnabled = MoskitoConfigurationHolder . getConfiguration ( ) . getBuiltinProducersConfig ( ) . isErrorProducer ( ) ; statsMap = new ConcurrentHashMap < > ( ) ; statsList = new CopyOnWriteArrayList < > ( ) ; cumulatedStats = new ErrorStats ( "cumulated" ) ; statsList . add ( cumulated...
Initialization . Moved out to be reused in unit - tests .
120,233
private AccumulatorDefinition createAccumulatorDefinition ( String name , String valueName , String statName ) { AccumulatorDefinition definition = new AccumulatorDefinition ( ) ; definition . setName ( name ) ; definition . setProducerName ( getProducerId ( ) ) ; definition . setStatName ( statName ) ; definition . se...
Helper method to create a accumulator definiton .
120,234
public void afterConfiguration ( ErrorHandlingConfig errorHandlingConfig ) { if ( ! errorProducerEnabled ) return ; this . errorHandlingConfig = errorHandlingConfig ; ErrorCatcherConfig [ ] defaultCatcherConfigs = errorHandlingConfig . getDefaultCatchers ( ) ; if ( defaultCatcherConfigs != null && defaultCatcherConfigs...
Called from the error handling config instance after a configuration update or initial configuration .
120,235
private SessionThrottleFilterConfig getConfigFromConfigureMe ( ) { SessionThrottleFilterConfig config = new SessionThrottleFilterConfig ( ) ; try { ConfigurationManager . INSTANCE . configure ( config ) ; } catch ( IllegalArgumentException e ) { log . warn ( "Incompatible configuration selected, configureme as source c...
Reads config via configureme from sessionthrottle . json .
120,236
private SessionThrottleFilterConfig getConfigFromWebXML ( FilterConfig filterConfig ) { int limit = - 1 ; String l = filterConfig . getInitParameter ( "limit" ) ; try { if ( l != null ) limit = Integer . parseInt ( l ) ; } catch ( NumberFormatException ignored ) { } String target = filterConfig . getInitParameter ( "re...
Reads config from web . xml .
120,237
public void put ( T key , Object value ) { data . put ( key , ensureValueCorrectness ( key , value ) ) ; }
Stores given key - value mapping if no restrictions are violated by them .
120,238
private Object ensureValueCorrectness ( T key , Object value ) { checkKey ( key ) ; if ( key . isCorrectValue ( value ) || value == null ) { return value ; } if ( value instanceof String ) { value = key . parseValue ( String . class . cast ( value ) ) ; return value ; } throw new IllegalArgumentException ( "Entry <'" +...
Ensure that value is of correct type for the given key . If value is not already of correct type but of type String attempt parsing into correct type .
120,239
protected void invokeExecute ( final ActionMapping mapping , final FormBean bean , final HttpServletRequest req , final HttpServletResponse res , final JSONResponse jsonResponse ) throws Exception { }
Override this method for invoking main action code .
120,240
public void update ( StatusData < T > status ) { if ( status == null ) { throw new IllegalArgumentException ( "Received null as status data!" ) ; } neverUpdated = false ; handleStatsResetIfNeeded ( status ) ; for ( T metric : metrics ) { Object value = status . get ( metric ) ; if ( value == null ) { getLogger ( ) . wa...
Update this stats with new data contained in StatusData parameter .
120,241
public long getStatValueAsLong ( T metric , String interval ) { if ( metric . isRateMetric ( ) ) { return ( long ) ( getStatValueAsDouble ( metric , interval ) ) ; } return getMonitoredStatValue ( metric ) . getValueAsLong ( interval ) ; }
Get value of provided metric for the given interval as long value .
120,242
public int getStatValueAsInteger ( T metric , String interval ) { if ( metric . isRateMetric ( ) ) { return ( int ) ( getStatValueAsDouble ( metric , interval ) ) ; } return getMonitoredStatValue ( metric ) . getValueAsInt ( interval ) ; }
Get value of provided metric for the given interval as int value .
120,243
public String getStatValueAsString ( T metric , String interval ) { if ( metric . isRateMetric ( ) ) { return String . valueOf ( getStatValueAsDouble ( metric , interval ) ) ; } return getMonitoredStatValue ( metric ) . getValueAsString ( interval ) ; }
Get value of provided metric for the given interval as String value .
120,244
public double getStatValueAsDouble ( T metric , String interval ) { StatValue statValue = getMonitoredStatValue ( metric ) ; if ( metric . isRateMetric ( ) ) { if ( "default" . equals ( interval ) ) { interval = DefaultIntervals . ONE_MINUTE . getName ( ) ; } double result = statValue . getValueAsLong ( interval ) ; lo...
Get value of provided metric for the given interval as double value .
120,245
public void add ( TracedCallStepAO step ) { elements . add ( step ) ; step . setId ( ( counter ++ ) ) ; ReversedCallHelper helper = stepsReversed . get ( step . getCall ( ) ) ; if ( helper == null ) { helper = new ReversedCallHelper ( ) ; stepsReversed . put ( step . getCall ( ) , helper ) ; } helper . add ( step . get...
Adds a new TracedCallStepAO .
120,246
public ReplyObject getAccumulators ( ) { try { return ReplyObject . success ( "accumulators" , getAccumulatorAPI ( ) . getAccumulatorDefinitions ( ) ) ; } catch ( APIException e ) { return ReplyObject . error ( e ) ; } }
Returns all accumulators .
120,247
@ Path ( "/{id}" ) public ReplyObject deleteAccumulator ( @ PathParam ( "id" ) String id ) { try { getAccumulatorAPI ( ) . removeAccumulator ( id ) ; return ReplyObject . success ( ) ; } catch ( APIException e ) { return ReplyObject . error ( e ) ; } }
Removes one accumulator by id .
120,248
public ReplyObject createAccumulator ( AccumulatorPO po ) { try { AccumulatorDefinitionAO ret = getAccumulatorAPI ( ) . createAccumulator ( po ) ; return ReplyObject . success ( "created" , ret ) ; } catch ( APIException e ) { return ReplyObject . error ( e ) ; } }
Creates new accumulator .
120,249
Interval getInterval ( int aId ) { Interval interval = intervalsById . get ( aId ) ; if ( interval == null ) { throw new UnknownIntervalException ( aId ) ; } return interval ; }
This method retrieves an Interval with the given id .
120,250
private Interval createInterval ( String aName , int aLength ) { if ( aName . equals ( "1m" ) ) { System . out . println ( "CREATE INTERVAL 1M CALLED " ) ; new RuntimeException ( ) . fillInStackTrace ( ) . printStackTrace ( ) ; } IntervalImpl interval = new IntervalImpl ( obtainNextUniqueId ( ) , aName , aLength ) ; if...
This method creates a new Interval with the given name and length .
120,251
public Long getUpdateTimestamp ( String intervalName ) { return intervalName == null ? Long . valueOf ( 0 ) : intervalUpdateTimestamp . get ( intervalName ) ; }
Returns last update timestamp of an interval by name .
120,252
public Object aroundInvoke ( InvocationContext ctx ) throws Throwable { final Method method = ctx . getMethod ( ) ; final Count annotation = getAnnotationFromContext ( ctx , Count . class ) ; final CountParameter parameter = method . getAnnotation ( CountParameter . class ) ; final String producerId = annotation . prod...
Around method invoke .
120,253
public void update ( ) { if ( tieable . isActivated ( ) ) { return ; } for ( IStats s : producer . getStats ( ) ) { if ( s . getName ( ) . equals ( tieable . getTargetStatName ( ) ) ) { tieable . tieToStats ( s ) ; tieable . update ( ) ; return ; } } }
Called whenever the appropriate interval has passed and the stats should be updated .
120,254
public ThresholdStatus getWorstStatus ( ) { if ( configuration . getKillSwitch ( ) . disableMetricCollection ( ) ) return ThresholdStatus . OFF ; ThresholdStatus ret = ThresholdStatus . GREEN ; for ( Threshold t : getThresholds ( ) ) { if ( t . getStatus ( ) . overrules ( ret ) ) ret = t . getStatus ( ) ; } return ret ...
Returns the worst threshold status in the system .
120,255
public ThresholdStatus getWorstStatus ( List < String > names ) { if ( configuration . getKillSwitch ( ) . disableMetricCollection ( ) ) return ThresholdStatus . OFF ; ThresholdStatus ret = ThresholdStatus . GREEN ; for ( Threshold t : getThresholds ( ) ) { if ( names . indexOf ( t . getName ( ) ) == - 1 ) continue ; i...
Returns the worst threshold status in the system for given threshold names .
120,256
private void readConfig ( ) { configuration = MoskitoConfigurationHolder . getConfiguration ( ) ; ThresholdsConfig config = configuration . getThresholdsConfig ( ) ; ThresholdConfig [ ] tcs = config . getThresholds ( ) ; if ( tcs != null && tcs . length > 0 ) { for ( ThresholdConfig tc : tcs ) { ThresholdDefinition td ...
Reads the config and creates configured thresholds . For now this method is only executed on startup .
120,257
private void readMemory ( ) { long space ; try { space = root . getUsableSpace ( ) ; } catch ( IOException e ) { log . error ( "Querying space. Querying error: " + e . toString ( ) ) ; return ; } stats . updateMemoryValue ( space ) ; }
Reads the memory value from the resolver and updates internal stats .
120,258
public static < T > void registerPluginType ( String pluginType , StatsFactory statsFactory , StatusFetcherFactory < T > statusFetcherFactory , StatusParser < T , StatusData > parser ) { PluginTypeConfiguration conf = new PluginTypeConfiguration < > ( statsFactory , statusFetcherFactory , parser ) ; PluginTypeConfigura...
Register plugin type and associate given factories with it .
120,259
public static AlertBean create ( AlertType type , String message ) { AlertBean result = new AlertBean ( type , message ) ; result . setAnimate ( false ) ; result . setFullWidth ( true ) ; result . setRoundBorders ( false ) ; return result ; }
Creates default alert without animation with square borders and full width .
120,260
public static HttpResponse getHttpResponse ( String url , UsernamePasswordCredentials credentials ) throws IOException { HttpGet request = new HttpGet ( url ) ; if ( credentials != null ) { URI uri = request . getURI ( ) ; AuthScope authScope = new AuthScope ( uri . getHost ( ) , uri . getPort ( ) ) ; Credentials cache...
Executes a request using the given URL and credentials .
120,261
private static boolean areSame ( Credentials c1 , Credentials c2 ) { if ( c1 == null ) { return c2 == null ; } else { return StringUtils . equals ( c1 . getUserPrincipal ( ) . getName ( ) , c1 . getUserPrincipal ( ) . getName ( ) ) && StringUtils . equals ( c1 . getPassword ( ) , c1 . getPassword ( ) ) ; } }
Compare two instances of Credentials .
120,262
public static String getResponseContent ( HttpResponse response ) throws IOException { final HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { try { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; entity . writeTo ( out ) ; return isScOk ( response ) ? new String ( out . toByteArray ( )...
Get text content from the response if response status code is 200 .
120,263
public ThresholdConfig toConfigObject ( ) { ThresholdConfig ret = new ThresholdConfig ( ) ; ret . setIntervalName ( getDefinition ( ) . getIntervalName ( ) ) ; ret . setName ( getDefinition ( ) . getName ( ) ) ; ret . setProducerName ( getDefinition ( ) . getProducerName ( ) ) ; ret . setStatName ( getDefinition ( ) . ...
This method allows to recreate proper configuration object for this threshold .
120,264
public TraceStep startStep ( String call , IStatsProducer producer , String methodName ) { TraceStep last = current ; current = new TraceStep ( call , producer , methodName ) ; if ( last != null ) last . addChild ( current ) ; return current ; }
Creates a new sub step in current call .
120,265
public int getNumberOfSteps ( ) { int result = 0 ; final Queue < TraceStep > queue = new LinkedList < > ( ) ; queue . add ( root ) ; while ( ! queue . isEmpty ( ) ) { final TraceStep currentTraceStep = queue . poll ( ) ; result ++ ; final List < TraceStep > children = currentTraceStep . getChildren ( ) ; if ( ! childre...
Calculates the number of steps .
120,266
public void dumpOut ( ) { System . out . println ( this . toString ( ) ) ; TraceStep root = getRootStep ( ) ; dumpOut ( root , 1 ) ; }
This is a debug method used to dump out the call into stdout .
120,267
private static void init ( ) { String junittest = System . getProperty ( "JUNITTEST" ) ; if ( junittest != null && ( junittest . equalsIgnoreCase ( "true" ) ) ) return ; StartBuiltInProducers . startbuiltin ( ) ; PluginRepository . getInstance ( ) ; AccumulatorRepository . getInstance ( ) ; ThresholdRepository . getIns...
Initializes the registry . If we are not in junit mode start built - in producers .
120,268
public void disableAll ( ) { javaMemoryProducers = javaMemoryPoolProducers = javaThreadingProducers = osProducer = runtimeProducer = mbeanProducers = gcProducer = errorProducer = false ; }
this method is for unit - test .
120,269
protected String getForward ( HttpServletRequest req ) { String forward = req . getParameter ( PARAM_FORWARD ) ; if ( forward == null ) forward = DEFAULT_FORWARD ; return forward ; }
Returns the specified forward .
120,270
protected String getCurrentInterval ( HttpServletRequest req , boolean saveToSession ) { String intervalParameter = req . getParameter ( PARAM_INTERVAL ) ; String interval = intervalParameter ; if ( interval == null ) { interval = ( String ) req . getSession ( ) . getAttribute ( BEAN_INTERVAL ) ; if ( interval == null ...
Returns the currently selected interval either as parameter or from session .
120,271
protected UnitBean getCurrentUnit ( HttpServletRequest req , boolean saveToSession ) { String unitParameter = req . getParameter ( PARAM_UNIT ) ; if ( unitParameter == null ) { UnitBean ret = ( UnitBean ) req . getSession ( ) . getAttribute ( BEAN_UNIT ) ; if ( ret == null ) { ret = DEFAULT_UNIT_BEAN ; req . getSession...
Returns the currently selected unit either from request or session .
120,272
private void fetchRemoteConnectionFromUrl ( HttpServletRequest req ) { String connection = req . getParameter ( "remoteConnection" ) ; if ( connection != null ) try { connection = URLDecoder . decode ( connection , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { return ; } else return ; String [ ] remoteHostAn...
Acquire remote connection url from request parameter . If current user is not connected to application from url - moskito will be connected to this application . This made up for possibility to share links on moskito - inspect pages .
120,273
protected String rebuildQueryStringWithoutParameter ( String source , String ... params ) { if ( source == null || source . length ( ) == 0 ) return "" ; if ( params == null || params . length == 0 ) return source ; HashSet < String > paramsSet = new HashSet < String > ( params . length ) ; paramsSet . addAll ( Arrays ...
Rebuilds query string from source .
120,274
private void checkNavigationMenuState ( final HttpServletRequest req ) { if ( req == null ) return ; if ( req . getSession ( ) . getAttribute ( ATTR_IS_NAV_MENU_COLLAPSED ) != null ) return ; req . getSession ( ) . setAttribute ( ATTR_IS_NAV_MENU_COLLAPSED , false ) ; }
Check if navigation menu default state present in request . If there is no state set default value .
120,275
protected void setInfoMessage ( String message ) { try { APICallContext . getCallContext ( ) . getCurrentSession ( ) . setAttribute ( "infoMessage" , APISession . POLICY_FLASH , message ) ; } catch ( NullPointerException e ) { log . error ( "Can't set info message (flash) due" , e ) ; log . error ( "APICallContext: " +...
Sets an info message that can be shown on next screen . The info message is readable exactly once .
120,276
protected String getInfoMessage ( ) { try { return ( String ) APICallContext . getCallContext ( ) . getCurrentSession ( ) . getAttribute ( "infoMessage" ) ; } catch ( Exception any ) { return null ; } }
Returns a previously set info message or null if no message has been set .
120,277
public synchronized void updateProducer ( PHPProducerDTO producerDTO ) { Mapper mapper = mappersRegistry . getMapper ( producerDTO . getMapperId ( ) ) ; if ( mapper == null ) { log . error ( "Mapper with id " + producerDTO . getMapperId ( ) + " is not found to map producer " + producerDTO . getProducerId ( ) ) ; return...
Processes incoming producer data .
120,278
public void init ( ServletConfig config ) throws ServletException { super . init ( config ) ; getStats = new ServletStats ( "get" , getMonitoringIntervals ( ) ) ; postStats = new ServletStats ( "post" , getMonitoringIntervals ( ) ) ; putStats = new ServletStats ( "put" , getMonitoringIntervals ( ) ) ; headStats = new S...
Creates the stats objects . Registers the servlet at the ProducerRegistry .
120,279
protected void moskitoDoDelete ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doDelete ( req , res ) ; }
Override this method to react on http delete method .
120,280
protected void moskitoDoGet ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doGet ( req , res ) ; }
Override this method to react on http get method .
120,281
protected void moskitoDoHead ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doHead ( req , res ) ; }
Override this method to react on http head method .
120,282
protected void moskitoDoOptions ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doOptions ( req , res ) ; }
Override this method to react on http options method .
120,283
protected void moskitoDoPost ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doPost ( req , res ) ; }
Override this method to react on http post method .
120,284
protected void moskitoDoPut ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doPut ( req , res ) ; }
Override this method to react on http put method .
120,285
protected void moskitoDoTrace ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { super . doTrace ( req , res ) ; }
Override this method to react on http trace method .
120,286
private void updateStats ( ) { EhcacheStats stats = getProducerStats ( ) ; Statistics statistics = underlyingCache . getStatistics ( ) ; double accesses = statistics . getCacheHits ( ) + statistics . getCacheMisses ( ) ; double hitRatio = accesses != 0 ? statistics . getCacheHits ( ) / accesses : 0 ; stats . getStatist...
Updates internal producer s stats using Ehcache statistics .
120,287
private void populateStats ( final StatDecoratorBean statDecoratorBean , final List < StatLineAO > allStatLines , final StatBeanSortType sortType ) { if ( allStatLines == null || allStatLines . isEmpty ( ) ) { LOGGER . warn ( "Producer's stats are empty" ) ; return ; } final int cumulatedIndex = getCumulatedIndex ( all...
Allows to set all stats to decorator except cumulated stat . Stats will be sorted using given sort type .
120,288
private void populateGraphData ( final IDecorator decorator , final Map < String , GraphDataBean > graphData , final List < StatLineAO > allStatLines ) { final int cumulatedIndex = getCumulatedIndex ( allStatLines ) ; for ( int i = 0 ; i < allStatLines . size ( ) ; i ++ ) { if ( i == cumulatedIndex ) continue ; final S...
Allows to populate graph data .
120,289
private int getCumulatedIndex ( final List < StatLineAO > allStatLines ) { if ( allStatLines == null || allStatLines . isEmpty ( ) ) { return - 1 ; } int cumulatedIndex = - 1 ; for ( int i = 0 , allStatLinesSize = allStatLines . size ( ) ; i < allStatLinesSize ; i ++ ) { final StatLineAO statLine = allStatLines . get (...
Returns index of cumulated stat in producer s stats .
120,290
protected final T getDefaultStats ( OnDemandStatsProducer producer ) { try { return getStatsClass ( ) . cast ( producer . getDefaultStats ( ) ) ; } catch ( ClassCastException e ) { LOGGER . error ( "getDefaultStats(): Unexpected stats type" , e ) ; return null ; } }
Returns default stats for producer .
120,291
protected final T getStats ( OnDemandStatsProducer producer , String name ) { try { return getStatsClass ( ) . cast ( producer . getStats ( name ) ) ; } catch ( ClassCastException e ) { LOGGER . error ( "getStats(): Unexpected stats type" , e ) ; } catch ( OnDemandStatsProducerException e ) { LOGGER . error ( "getStats...
Returns stats for producer .
120,292
protected static Object proceed ( InvocationContext ctx ) throws Throwable { try { return ctx . proceed ( ) ; } catch ( InvocationTargetException e ) { throw e . getCause ( ) ; } }
Proceed further .
120,293
private void createAccumulator ( String producerId , Accumulate annotation , String accName , String statsName ) { if ( annotation != null && producerId != null && ! producerId . isEmpty ( ) && accName != null && ! accName . isEmpty ( ) && statsName != null && ! statsName . isEmpty ( ) ) { AccumulatorDefinition definit...
Create accumulator and register it .
120,294
private String getMethodName ( Method method ) { StatName statNameAnnotation = method . getAnnotation ( StatName . class ) ; return statNameAnnotation != null ? statNameAnnotation . value ( ) : method . getName ( ) ; }
Returns name of the given method .
120,295
public void addProducerCall ( String producerId , long duration ) { AnalyzedProducerCallsAO bean = beans . get ( producerId ) ; if ( bean == null ) { bean = new AnalyzedProducerCallsAO ( producerId ) ; beans . put ( producerId , bean ) ; } bean . addCall ( duration ) ; totalCalls ++ ; totalDuration += duration ; }
Adds a new producer call . The duration and the number of calls for each producer will be increased accordingly .
120,296
public static String getInputStreamAsString ( InputStream is ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ReadableByteChannel rbch = Channels . newChannel ( is ) ; WritableByteChannel wbch = Channels . newChannel ( baos ) ; fastChannelCopy ( rbch , wbch ) ; rbch . close ( ) ; wbch...
converts input stream to string value
120,297
private void rebuildProducerCache ( Collection < IStatsProducer > producers ) { log . debug ( "Rebuilding producer cache with " + producers . size ( ) + " producers." ) ; log . debug ( "Following producers known: " + producers ) ; synchronized ( cacheLock ) { final int approxSize = ( int ) ( producers . size ( ) * 1.5 ...
Rebuilds the caches with given producers ..
120,298
public List < IStatsProducer > getAllProducers ( ) { if ( _cachedProducerList == null ) buildProducerCacheFromScratch ( ) ; List < IStatsProducer > ret = new ArrayList < > ( ) ; for ( ProducerReference pr : _cachedProducerList ) { if ( pr . get ( ) != null ) ret . add ( pr . get ( ) ) ; } return ret ; }
producer during processing .
120,299
private void createIntervalList ( ) { synchronized ( intervalLock ) { if ( _cachedIntervalInfos != null ) return ; List < Interval > intervals = intervalRegistry . getIntervals ( ) ; _cachedIntervalInfos = new ArrayList < IntervalInfo > ( intervals . size ( ) ) ; for ( Interval interval : intervals ) { _cachedIntervalI...
Creates the list of existing intervals .