idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
35,200
public void setMetatags ( Map < String , String > metatags , String key ) { if ( metatags != null ) { TSDBEntity . validateTags ( metatags ) ; _metatags . clear ( ) ; _metatags . putAll ( metatags ) ; _key = key ; } }
Replaces the metatags for a metric . Metatags cannot use any of the reserved tag names .
35,201
public static < D extends TSDBEntityDto , E extends TSDBEntity > D createDtoObject ( Class < D > clazz , E tsdbEntity ) { D result = null ; try { result = clazz . newInstance ( ) ; BeanUtils . copyProperties ( result , tsdbEntity ) ; } catch ( Exception ex ) { throw new WebApplicationException ( "DTO transformation fai...
Converts a TSDB entity to a DTO .
35,202
public HttpClient getHttpClient ( SystemConfiguration config ) { HttpClient httpclient = new HttpClient ( theConnectionManager ) ; httpclient . getParams ( ) . setParameter ( "http.connection-manager.timeout" , 2000L ) ; String host = config . getValue ( Property . GUS_PROXY_HOST . getName ( ) , Property . GUS_PROXY_HO...
Get HttpClient with proper proxy and timeout settings .
35,203
public String getTSDBMetricName ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( getMetric ( ) ) . append ( DefaultTSDBService . DELIMITER ) . append ( getScope ( ) ) ; if ( _namespace != null && ! _namespace . isEmpty ( ) ) { sb . append ( DefaultTSDBService . DELIMITER ) . append ( getNamespace ( ) ) ; ...
Returns the TSDB metric name .
35,204
public static ItemsCountDto transformToDto ( int value ) { if ( value < 0 ) { throw new WebApplicationException ( "Items count cannot be negative" , Status . INTERNAL_SERVER_ERROR ) ; } ItemsCountDto result = new ItemsCountDto ( ) ; result . setValue ( value ) ; return result ; }
Converts an integer to ItemsCountDto instance .
35,205
public void initializeTopic ( String topic ) { if ( _topics . get ( topic ) == null ) { synchronized ( this ) { if ( _topics . get ( topic ) == null ) { _logger . info ( "Initializing streams for topic: {}" , topic ) ; Properties props = new Properties ( ) ; props . setProperty ( "zookeeper.connect" , _configuration . ...
This method creates Kafka streams for a topic so that messages can be streamed to the local buffer . If the streams for the given topic have already been initialized the returns . Information about a particular topic is stored in a HashMap . This method uses double - checked locking to make sure only one client thread ...
35,206
private void _startStreamingMessages ( String topic , List < KafkaStream < byte [ ] , byte [ ] > > streams ) { ExecutorService executorService = _topics . get ( topic ) . getStreamExecutorService ( ) ; for ( final KafkaStream < byte [ ] , byte [ ] > stream : streams ) { executorService . submit ( new KafkaConsumer ( st...
Retrieves the executor service for the given topic from the map of topics and submits a KafkaConsumer task for each stream in the list of streams .
35,207
public < T extends Serializable > List < T > dequeueFromBuffer ( String topic , Class < T > type , int timeout , int limit ) { List < T > result = new ArrayList < T > ( ) ; long cutoff = System . currentTimeMillis ( ) + timeout ; BlockingQueue < String > queue = _topics . get ( topic ) . getMessages ( ) ; while ( Syste...
Dequeues messages from the local buffer as specified by the limit . If no messages are available to dequeue then waits for at most timeout milliseconds before returning .
35,208
public void shutdown ( ) { for ( Topic topic : _topics . values ( ) ) { if ( topic . getConsumerConnector ( ) != null ) { topic . getConsumerConnector ( ) . shutdown ( ) ; } topic . getStreamExecutorService ( ) . shutdownNow ( ) ; try { topic . getStreamExecutorService ( ) . awaitTermination ( 60 , TimeUnit . SECONDS )...
Enqueue un - flushed messages back on to Kafka .
35,209
public static boolean shouldRun ( String entry , Date atTime ) { entry = entry . trim ( ) . toUpperCase ( ) ; if ( ANNUALLY . equals ( entry ) || ( YEARLY . equals ( entry ) ) ) { entry = "0 0 1 1 *" ; } else if ( MONTHLY . equals ( entry ) ) { entry = "0 0 1 * *" ; } else if ( WEEKLY . equals ( entry ) ) { entry = "0 ...
Determines if the given CRON entry is runnable at this current moment in time . This mimics the original implementation of the CRON table .
35,210
public static boolean isValid ( String entry ) { boolean result = true ; try { shouldRun ( entry ) ; } catch ( Exception ex ) { result = false ; } return result ; }
Determines if an entry is valid CRON syntax .
35,211
public List < Audit > getAuditsForEntity ( BigInteger entityId ) throws IOException , TokenExpiredException { String requestUrl = RESOURCE + "/entity/" + entityId . toString ( ) ; ArgusResponse response = getClient ( ) . executeHttpRequest ( ArgusHttpClient . RequestType . GET , requestUrl , null ) ; assertValidRespons...
Returns the audit history for the given entity .
35,212
public Audit getAudit ( BigInteger id ) throws IOException , TokenExpiredException { String requestUrl = RESOURCE + "/" + id . toString ( ) ; ArgusResponse response = getClient ( ) . executeHttpRequest ( ArgusHttpClient . RequestType . GET , requestUrl , null ) ; assertValidResponse ( response , requestUrl ) ; return f...
Returns the audit item for the given audit ID .
35,213
public void setTag ( String key , String value ) { requireArgument ( key != null && ! key . trim ( ) . isEmpty ( ) , "Tag key cannot be null." ) ; requireArgument ( ! ReservedField . isReservedField ( key ) , "Tag is a reserved tag name." ) ; if ( value == null || value . isEmpty ( ) ) { _tags . remove ( key ) ; } else...
Sets a single tag for the query .
35,214
public String getTag ( String key ) { return ( ! Metric . ReservedField . isReservedField ( key ) ) ? _tags . get ( key ) : null ; }
Returns the tag value for the given key .
35,215
public final void setTags ( Map < String , String > tags ) { Map < String , String > updatedTags = new TreeMap < > ( ) ; if ( tags != null ) { for ( Map . Entry < String , String > entry : tags . entrySet ( ) ) { String key = entry . getKey ( ) ; requireArgument ( ! Metric . ReservedField . isReservedField ( key ) , Me...
Replaces the tags for the query .
35,216
protected void setScope ( String scope ) { requireArgument ( scope != null && ! scope . isEmpty ( ) , "Scope cannot be null or empty." ) ; _scope = scope ; }
Sets the scope of the query .
35,217
protected void setMetric ( String metric ) { requireArgument ( metric != null && ! metric . isEmpty ( ) , "Metric name cannot be null or empty." ) ; _metric = metric ; }
Sets the metric name for the query .
35,218
protected String toTagParameterArray ( Map < String , String > tags ) throws UnsupportedEncodingException { if ( tags == null || tags . isEmpty ( ) ) { return "" ; } StringBuilder sb = new StringBuilder ( encode ( "{" , "UTF-8" ) ) ; for ( Map . Entry < String , String > tagEntry : tags . entrySet ( ) ) { sb . append (...
Returns the tags in TSDB query string format .
35,219
private Map < String , Double > getMinMax ( Map < Long , Double > metricData ) { double min = 0.0 ; double max = 0.0 ; boolean isMinMaxSet = false ; for ( Double value : metricData . values ( ) ) { double valueDouble = value ; if ( ! isMinMaxSet ) { min = valueDouble ; max = valueDouble ; isMinMaxSet = true ; } else { ...
Identifies the min and max values of a metric
35,220
static void main ( String [ ] args , PrintStream out ) throws IOException { try { Main main = null ; Option [ ] options = Option . parseCLArgs ( args , TEMPLATES ) ; Option helpOption = ( options == null ) ? null : findOption ( HELP_OPTION . getName ( ) , options ) ; Option installOption = ( options == null ) ? null : ...
The main invocation method .
35,221
void invoke ( ClientType clientType ) { try { LOGGER . info ( "Starting service." ) ; ExecutorService service = ClientServiceFactory . startClientService ( _system , clientType , _jobCounter ) ; LOGGER . info ( "Service started." ) ; Thread currentThread = Thread . currentThread ( ) ; while ( ! currentThread . isInterr...
This method creates multiple threads to dequeue messages from message queue and push into TSDB . One thread is created for every type . Depending on message queue connection count multiple threads may be created for Metric type
35,222
public boolean enter ( ) throws KeeperException , InterruptedException { zooKeeper . create ( rootPath + "/" + name , new byte [ 0 ] , Ids . OPEN_ACL_UNSAFE , CreateMode . EPHEMERAL ) ; while ( true ) { synchronized ( mutex ) { List < String > list = zooKeeper . getChildren ( rootPath , true ) ; if ( list . size ( ) < ...
Wait until required number of nodes join barrier
35,223
public boolean leave ( ) throws KeeperException , InterruptedException { zooKeeper . delete ( rootPath + "/" + name , 0 ) ; while ( true ) { synchronized ( mutex ) { List < String > list = zooKeeper . getChildren ( rootPath , true ) ; if ( list . size ( ) > 0 ) { mutex . wait ( ) ; } else { return true ; } } } }
Wait until all nodes leave barrier
35,224
public List < Metric > getMetrics ( List < String > expressions ) throws IOException , TokenExpiredException { StringBuilder requestUrl = new StringBuilder ( RESOURCE ) ; for ( int i = 0 ; i < expressions . size ( ) ; i ++ ) { requestUrl . append ( i == 0 ? "?" : "&" ) ; requestUrl . append ( "expression=" ) . append (...
Returns the metrics for the given set of expressions .
35,225
public static String obtainLock ( EntityManager em , long expiration , long type , String note ) { EntityTransaction tx = null ; try { long now = System . currentTimeMillis ( ) ; tx = em . getTransaction ( ) ; tx . begin ( ) ; GlobalInterlock lock = _findAndRefreshLock ( em , type ) ; if ( lock != null && now - lock . ...
Obtains a global lock of a given type .
35,226
public static void releaseLock ( EntityManager em , long type , String key ) { EntityTransaction tx = null ; try { tx = em . getTransaction ( ) ; tx . begin ( ) ; GlobalInterlock lock = _findAndRefreshLock ( em , type ) ; if ( lock == null ) { throw new GlobalInterlockException ( "No lock of type " + type + " exists fo...
Releases a global lock of the indicated type if the supplied key is a match for the lock .
35,227
public static String refreshLock ( EntityManager em , long type , String key , String note ) { EntityTransaction tx = null ; try { tx = em . getTransaction ( ) ; tx . begin ( ) ; GlobalInterlock lock = _findAndRefreshLock ( em , type ) ; if ( lock == null ) { throw new GlobalInterlockException ( "No lock of type " + ty...
Refreshes a global lock of the indicated type if the supplied key is a match for the lock .
35,228
public static AuditDto transformToDto ( Audit audit ) { if ( audit == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } AuditDto auditDto = new AuditDto ( ) ; try { auditDto . setId ( audit . getId ( ) ) ; auditDto . setHostName (...
Converts the audit entity to DTO .
35,229
public static List < AuditDto > transformToDto ( List < Audit > audits ) { if ( audits == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } List < AuditDto > result = new ArrayList < AuditDto > ( ) ; for ( Audit audit : audits ) {...
Converts a list of audit entities to DTOs .
35,230
public static int findInfractionCount ( EntityManager em , PrincipalUser user , SubSystem subSystem , long startTime ) { List < SuspensionRecord > records ; if ( subSystem == null ) { records = findByUser ( em , user ) ; } else { SuspensionRecord record = findByUserAndSubsystem ( em , user , subSystem ) ; records = rec...
Finds the number of user infractions for a subsystem that have occurred since the given start time .
35,231
public static SuspensionRecord findByUserAndSubsystem ( EntityManager em , PrincipalUser user , SubSystem subSystem ) { TypedQuery < SuspensionRecord > query = em . createNamedQuery ( "SuspensionRecord.findByUserAndSubsystem" , SuspensionRecord . class ) ; try { query . setParameter ( "user" , user ) ; query . setParam...
Find the suspension record for a given user - subsystem combination .
35,232
public static List < SuspensionRecord > findByUser ( EntityManager em , PrincipalUser user ) { TypedQuery < SuspensionRecord > query = em . createNamedQuery ( "SuspensionRecord.findByUser" , SuspensionRecord . class ) ; try { query . setParameter ( "user" , user ) ; return query . getResultList ( ) ; } catch ( NoResult...
Find all suspension records for a given user .
35,233
public void setInfractionHistory ( List < Long > history ) { SystemAssert . requireArgument ( history != null && ! history . isEmpty ( ) , "Infraction History cannot be set to null or empty." ) ; this . infractionHistory = history ; }
Sets the detailed infraction history .
35,234
public Map < String , String > getTags ( ) { Map < String , String > result = new HashMap < > ( ) ; for ( Map . Entry < String , String > entry : _tags . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( ! ReservedField . isReservedField ( key ) ) { result . put ( key , entry . getValue ( ) ) ; } } return Collect...
Returns an unmodifiable collection of tags associated with the metric .
35,235
public void setTags ( Map < String , String > tags ) { TSDBEntity . validateTags ( tags ) ; _tags . clear ( ) ; if ( tags != null ) { _tags . putAll ( tags ) ; } }
Replaces the tags for a metric . Tags cannot use any of the reserved tag names .
35,236
private void setType ( String type ) { requireArgument ( type != null && ! type . trim ( ) . isEmpty ( ) , "Type cannot be null or empty." ) ; _type = type ; }
Sets the category of the metric .
35,237
private void setSource ( String source ) { requireArgument ( source != null && ! source . trim ( ) . isEmpty ( ) , "Source cannot be null or empty." ) ; _source = source ; }
Sets the source of the annotation .
35,238
private void setId ( String id ) { requireArgument ( id != null && ! id . trim ( ) . isEmpty ( ) , "ID cannot be null or empty." ) ; _id = id ; }
Sets the ID of the annotation as indicated by the data source .
35,239
public void setFields ( Map < String , String > fields ) { _fields . clear ( ) ; if ( fields != null ) { _fields . putAll ( fields ) ; } }
Replaces the user defined fields associated with the annotation . This information can be used to store information about the annotation such as the event name the associated user or any other relevant information . Existing fields will always be deleted .
35,240
public static PolicyLimit findPolicyLimitByUserAndCounter ( EntityManager em , PrincipalUser user , PolicyCounter counter ) { TypedQuery < PolicyLimit > query = em . createNamedQuery ( "PolicyLimit.findPolicyLimitByUserAndCounter" , PolicyLimit . class ) ; try { query . setParameter ( "user" , user ) ; query . setParam...
Retrieves the policy limit object for a given user - counter combination .
35,241
public static double getLimitByUserAndCounter ( EntityManager em , PrincipalUser user , PolicyCounter counter ) { PolicyLimit pLimit = findPolicyLimitByUserAndCounter ( em , user , counter ) ; if ( pLimit != null ) { return pLimit . getLimit ( ) ; } return counter . getDefaultValue ( ) ; }
Retrieves the limit for a given user - counter combination .
35,242
public static ServiceManagementRecord findServiceManagementRecord ( EntityManager em , Service service ) { requireArgument ( em != null , "Entity manager can not be null." ) ; requireArgument ( service != null , "Service cannot be null." ) ; TypedQuery < ServiceManagementRecord > query = em . createNamedQuery ( "Servic...
Returns a record for the specified service .
35,243
public static boolean isServiceEnabled ( EntityManager em , Service service ) { ServiceManagementRecord record = findServiceManagementRecord ( em , service ) ; return record == null ? true : record . isEnabled ( ) ; }
Determine a given service s enability .
35,244
public static ServiceManagementRecord updateServiceManagementRecord ( EntityManager em , ServiceManagementRecord record ) { SystemAssert . requireArgument ( em != null , "Entity manager can not be null." ) ; SystemAssert . requireArgument ( record != null , "ServiceManagementRecord cannot be null." ) ; TypedQuery < Ser...
Updates the ServiceManagementRecord entity .
35,245
private void _processNotification ( Alert alert , History history , List < Metric > metrics , Map < BigInteger , Map < Metric , Long > > triggerFiredTimesAndMetricsByTrigger , Notification notification , Long alertEnqueueTimestamp ) { boolean isRefocusNotifier = SupportedNotifier . REFOCUS . getName ( ) . equals ( noti...
Evaluates all triggers associated with the notification and updates the job history .
35,246
private void _processMissingDataNotification ( Alert alert , History history , Set < Trigger > triggers , Notification notification , boolean isDataMissing , Long alertEnqueueTimestamp ) { boolean isRefocusNotifier = SupportedNotifier . REFOCUS . getName ( ) . equals ( notification . getNotifierName ( ) ) ; for ( Trigg...
Evaluates all triggers associated with the missing data notification and updates the job history .
35,247
private boolean _shouldEvaluateAlert ( Alert alert , BigInteger alertId ) { if ( alert == null ) { _logger . warn ( MessageFormat . format ( "Could not find alert ID {0}" , alertId ) ) ; return false ; } if ( ! alert . isEnabled ( ) ) { _logger . warn ( MessageFormat . format ( "Alert {0} has been disabled. Will not ev...
Determines if the alert should be evaluated or not .
35,248
private Map < BigInteger , Map < Metric , Long > > _evaluateTriggers ( Set < Trigger > triggers , List < Metric > metrics , String queryExpression , Long alertEnqueueTimestamp ) { Map < BigInteger , Map < Metric , Long > > triggerFiredTimesAndMetricsByTrigger = new HashMap < > ( ) ; for ( Trigger trigger : triggers ) {...
Evaluates all triggers for the given set of metrics and returns a map of triggerIds to a map containing the triggered metric and the trigger fired time .
35,249
public Notifier getNotifier ( SupportedNotifier notifier ) { switch ( notifier ) { case CALLBACK : return _notifierFactory . getCallbackNotifier ( ) ; case EMAIL : return _notifierFactory . getEmailNotifier ( ) ; case GOC : return _notifierFactory . getGOCNotifier ( ) ; case DATABASE : return _notifierFactory . getDBNo...
Returns an instance of a supported notifier .
35,250
public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { HttpServletRequest req = HttpServletRequest . class . cast ( request ) ; long start = System . currentTimeMillis ( ) ; try { chain . doFilter ( request , response ) ; } finally { long d...
Updates performance counters using the Argus monitoring service .
35,251
public static void setCommonAttributes ( List < Metric > metrics , Metric result ) { MetricDistiller distiller = new MetricDistiller ( ) ; distiller . distill ( metrics ) ; result . setDisplayName ( distiller . getDisplayName ( ) ) ; result . setUnits ( distiller . getUnits ( ) ) ; result . setTags ( distiller . getTag...
Filters common attributes from list of metrics and writes them to result metric .
35,252
public Map < String , String > getTags ( ) { Map < String , String > distilledTags = new HashMap < String , String > ( ) ; for ( Map . Entry < String , String > entry : potentialTags . entrySet ( ) ) { String key = entry . getKey ( ) ; String value = entry . getValue ( ) ; if ( tagCounts . get ( key ) . equals ( totalA...
The common tags .
35,253
public static < D extends EntityDTO , E extends JPAEntity > D createDtoObject ( Class < D > clazz , E entity ) { D result = null ; try { result = clazz . newInstance ( ) ; BeanUtils . copyProperties ( result , entity ) ; result . setCreatedById ( entity . getCreatedBy ( ) != null ? entity . getCreatedBy ( ) . getId ( )...
Creates BaseDto object and copies properties from entity object .
35,254
public void execute ( JobExecutionContext context ) throws JobExecutionException { JobDataMap map = context . getJobDetail ( ) . getJobDataMap ( ) ; AlertService alertService = ( AlertService ) map . get ( "AlertService" ) ; AuditService auditService = ( AuditService ) map . get ( "AuditService" ) ; if ( map . contains...
Passing the service instance from quartz main thread to worker thread as a parameter . Although the alert service used here is not thread safe we are using the enqueueAlerts in a thread safe manner since there is no shared mutable state in this method .
35,255
public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { HttpServletRequest req = HttpServletRequest . class . cast ( request ) ; String url = req . getRequestURI ( ) ; LoggerFactory . getLogger ( getClass ( ) ) . debug ( "Request started: {}...
Logs username request count and timing information .
35,256
public < T extends Serializable > int enqueue ( final String topic , List < T > objects ) { int messagesBuffered = 0 ; for ( T object : objects ) { final String value ; if ( String . class . isAssignableFrom ( object . getClass ( ) ) ) { value = String . class . cast ( object ) ; } else { try { value = _mapper . writeV...
Adds the messages to the Producer Buffer which will later be batched by Kafka and sent to the brokers .
35,257
public void shutdown ( ) { if ( _producer != null ) { _producer . close ( ) ; } _executorService . shutdown ( ) ; try { if ( ! _executorService . awaitTermination ( 10 , TimeUnit . SECONDS ) ) { _logger . warn ( "Shutdown of Kafka executor service timed out after 10 seconds." ) ; _executorService . shutdownNow ( ) ; } ...
Shuts down the producer .
35,258
public static Metric getMetricToAnnotate ( String metric ) { Metric result = null ; if ( metric != null && ! metric . isEmpty ( ) ) { Pattern pattern = Pattern . compile ( "([\\w,\\-,\\.,/]+):([\\w,\\-,\\.,/]+)(\\{(?:[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)(?:,[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)*\\})?:([\\w,\\-,\\...
Given a metric to annotate expression return a corresponding metric object .
35,259
public void setSubscriptions ( List < String > subscriptions ) { this . subscriptions . clear ( ) ; if ( subscriptions == null ) return ; for ( String currentSubscription : subscriptions ) { if ( this . getNotifierName ( ) . equals ( AlertService . SupportedNotifier . GUS . getName ( ) ) ) { if ( currentSubscription . ...
Replaces the subscriptions used by the notifier to send the notifications .
35,260
public long getCooldownExpirationByTriggerAndMetric ( Trigger trigger , Metric metric ) { String key = _hashTriggerAndMetric ( trigger , metric ) ; return this . cooldownExpirationByTriggerAndMetric . containsKey ( key ) ? this . cooldownExpirationByTriggerAndMetric . get ( key ) : 0 ; }
Returns the cool down expiration time of the notification given a metric trigger combination .
35,261
public void setCooldownExpirationByTriggerAndMetric ( Trigger trigger , Metric metric , long cooldownExpiration ) { requireArgument ( cooldownExpiration >= 0 , "Cool down expiration time cannot be negative." ) ; String key = _hashTriggerAndMetric ( trigger , metric ) ; this . cooldownExpirationByTriggerAndMetric . put ...
Sets the cool down expiration time of the notification given a metric trigger combination .
35,262
public void setMetricsToAnnotate ( List < String > metricsToAnnotate ) { this . metricsToAnnotate . clear ( ) ; if ( metricsToAnnotate != null && ! metricsToAnnotate . isEmpty ( ) ) { for ( String metric : metricsToAnnotate ) { requireArgument ( getMetricToAnnotate ( metric ) != null , "Metrics to annotate should be of...
Sets metrics to be annotated .
35,263
public void setTriggers ( List < Trigger > triggers ) { this . triggers . clear ( ) ; if ( triggers != null ) { this . triggers . addAll ( triggers ) ; } }
Replaces the triggers associated with the notification .
35,264
public boolean isActiveForTriggerAndMetric ( Trigger trigger , Metric metric ) { String key = _hashTriggerAndMetric ( trigger , metric ) ; return this . activeStatusByTriggerAndMetric . containsKey ( key ) ? activeStatusByTriggerAndMetric . get ( key ) : false ; }
Given a metric notification combination indicates whether a triggering condition associated with this notification is still in a triggering state .
35,265
public void setActiveForTriggerAndMetric ( Trigger trigger , Metric metric , boolean active ) { String key = _hashTriggerAndMetric ( trigger , metric ) ; this . activeStatusByTriggerAndMetric . put ( key , active ) ; }
When a notification is sent out when a metric violates the trigger threshold set this notification active for that trigger metric combination
35,266
public static Option createFlag ( String name , String description ) { return new Option ( Type . FLAG , name , 0 , description ) ; }
Creates a new flag type option . These types of options are used to indicate some application switch is either on or off .
35,267
public static Option createOption ( String name , String description ) { return new Option ( Type . OPTION , name , 1 , description ) ; }
Returns a named option having one value . An example may be a logfile option for a program .
35,268
public static Option findListOption ( Option [ ] options ) { for ( int i = 0 ; i < options . length ; i ++ ) { if ( options [ i ] . getType ( ) == Type . LIST ) { return options [ i ] ; } } return null ; }
Returns a list type application option if one exists in the list provided .
35,269
public static Option findOption ( String name , Option [ ] options ) { for ( int i = 0 ; i < options . length ; i ++ ) { if ( options [ i ] . getName ( ) . equals ( name ) ) { return options [ i ] ; } } return null ; }
Returns an option with the given name .
35,270
public static Option [ ] parseCLArgs ( String [ ] args , Option [ ] templates ) { int i = 0 ; List < Option > options = new ArrayList < Option > ( args . length ) ; try { while ( i < args . length ) { String name = args [ i ++ ] ; Option template = findTemplate ( name , templates ) ; StringBuilder values = new StringBu...
Parses the command line arguments of an application and compares those options against a list of expected options .
35,271
private static Option findTemplate ( String name , Option [ ] templates ) { boolean listAllowed = false ; Option listOption = null ; for ( int i = 0 ; i < templates . length ; i ++ ) { if ( templates [ i ] . getName ( ) . equals ( name ) ) { return templates [ i ] ; } if ( Type . LIST . equals ( templates [ i ] . getTy...
Searches an array of option templates and returns an option matching the supplied name or null if no match is found .
35,272
public String [ ] getValues ( ) { return value == null || value . isEmpty ( ) ? new String [ 0 ] : len == 1 ? new String [ ] { value } : value . split ( "\\s+" ) ; }
Returns the value of this option as an array . This array will be empty for flag options contain a single value for a simple option or a list of values for list type options .
35,273
private void sendMessage ( String aspectPath , boolean fired ) { if ( Boolean . valueOf ( _config . getValue ( SystemConfiguration . Property . REFOCUS_ENABLED ) ) ) { int refreshMaxTimes = Integer . parseInt ( _config . getValue ( Property . REFOCUS_CONNECTION_REFRESH_MAX_TIMES . getName ( ) , Property . REFOCUS_CONNE...
Sends an Refocus sample .
35,274
public static NamespaceDto transformToDto ( Namespace namespace ) { if ( namespace == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } NamespaceDto result = createDtoObject ( NamespaceDto . class , namespace ) ; for ( PrincipalUs...
Converts a namespace entity to a DTO .
35,275
public void addUsername ( String username ) { SystemAssert . requireArgument ( username != null && ! username . isEmpty ( ) , "Username cannot be null or empty." ) ; this . usernames . add ( username ) ; }
Adds an authorized user .
35,276
public void setScope ( String scope ) { SystemAssert . requireArgument ( scope != null && ! scope . isEmpty ( ) , "Scope cannot be null or empty." ) ; this . scope = scope ; }
Specifies the scope of the query .
35,277
public void setMetric ( String metric ) { SystemAssert . requireArgument ( metric != null && ! metric . isEmpty ( ) , "Metric cannot be null or empty." ) ; this . metric = metric ; }
Specifies the metric name of the query .
35,278
private List < Alert > getSharedAlertsObj ( boolean populateMetaFieldsOnly , PrincipalUser owner , Integer limit ) { Set < Alert > result = new HashSet < > ( ) ; result . addAll ( populateMetaFieldsOnly ? alertService . findSharedAlerts ( true , owner , limit ) : alertService . findSharedAlerts ( false , owner , limit ...
Returns list of shared alerts .
35,279
public void setCreatedDate ( Date createdDate ) { _createdDate = createdDate == null ? null : new Date ( createdDate . getTime ( ) ) ; }
Specifies the created date .
35,280
public static TriggerDto transformToDto ( Trigger trigger ) { TriggerDto result = createDtoObject ( TriggerDto . class , trigger ) ; result . setAlertId ( trigger . getAlert ( ) . getId ( ) ) ; for ( Notification notification : trigger . getNotifications ( ) ) { result . addNotificationIds ( notification ) ; } return r...
Converts trigger entity to triggerDto object .
35,281
public static List < TriggerDto > transformToDto ( List < Trigger > triggers ) { List < TriggerDto > result = new ArrayList < TriggerDto > ( ) ; for ( Trigger trigger : triggers ) { result . add ( transformToDto ( trigger ) ) ; } return result ; }
Converts list of trigger entity objects to list of triggerDto objects .
35,282
public static HistoryDTO transformToDto ( History history ) { if ( history == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } HistoryDTO historyDto = new HistoryDTO ( ) ; try { BeanUtils . copyProperties ( historyDto , history )...
Converts a history object to DTO .
35,283
public static List < HistoryDTO > transformToDto ( List < History > list ) { if ( list == null ) { throw new WebApplicationException ( "Null entity object cannot be converted to Dto object." , Status . INTERNAL_SERVER_ERROR ) ; } List < HistoryDTO > result = new ArrayList < HistoryDTO > ( ) ; for ( History history : li...
Converts a list of history entities to DTOs .
35,284
public < E extends Identifiable > E mergeEntity ( EntityManager em , E entity ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( entity != null , "The entity cannot be null." ) ; E ret = em . merge ( entity ) ; return ret ; }
Persists an entity to the database .
35,285
protected < E extends Identifiable > void deleteEntity ( EntityManager em , E entity ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( entity != null , "The entity cannot be null." ) ; if ( ! em . contains ( entity ) ) { Identifiable attached = findEntity ( em , entity . getI...
Removes an entity from the database .
35,286
protected < E extends Identifiable > E findEntity ( EntityManager em , BigInteger id , Class < E > type ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( id != null && id . compareTo ( ZERO ) > 0 , "ID must be positive and non-zero" ) ; requireArgument ( type != null , "The e...
Locates an entity based on it s primary key value .
35,287
protected < E extends Identifiable > List < E > findEntitiesMarkedForDeletion ( EntityManager em , Class < E > type , final int limit ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( type != null , "The entity cannot be null." ) ; requireArgument ( limit == - 1 || limit > 0 ...
Returns a list of entities of the given type that are marked for deletion but have not yet been physically deleted .
35,288
private void fitParameters ( Map < Long , Double > metricData ) { mean = getMetricMean ( metricData ) ; variance = getMetricVariance ( metricData ) ; }
Fits the mean and variance parameters to the data
35,289
private Metric predictAnomalies ( Map < Long , Double > metricData ) { Metric predictions = new Metric ( getResultScopeName ( ) , getResultMetricName ( ) ) ; Map < Long , Double > predictionDatapoints = new HashMap < > ( ) ; if ( variance == 0.0 ) { for ( Entry < Long , Double > entry : metricData . entrySet ( ) ) { Lo...
Assigns an anomaly score to each data point indicating how likely it is to be an anomaly relative to other points .
35,290
private Alert _constructWardenAlertForUser ( PrincipalUser user , PolicyCounter counter ) { String metricExp = _constructWardenMetricExpression ( "-1h" , user , counter ) ; Alert alert = new Alert ( _adminUser , _adminUser , _constructWardenAlertName ( user , counter ) , metricExp , "*/5 * * * *" ) ; List < Trigger > t...
Create a warden alert which will annotate the corresponding warden metric with suspension events .
35,291
private void _startScheduledExecutorService ( ) { DisableWardenAlertsThread disableWardenAlertThread = new DisableWardenAlertsThread ( ) ; _scheduledExecutorService . scheduleAtFixedRate ( disableWardenAlertThread , 0L , TIME_BETWEEN_WARDEN_ALERT_DISABLEMENT_MILLIS , TimeUnit . MILLISECONDS ) ; }
Starts the scheduled executor service .
35,292
private void _shutdownScheduledExecutorService ( ) { _logger . info ( "Shutting down scheduled disable warden alerts executor service" ) ; _scheduledExecutorService . shutdown ( ) ; try { if ( ! _scheduledExecutorService . awaitTermination ( 5 , TimeUnit . SECONDS ) ) { _logger . warn ( "Shutdown of scheduled disable w...
Shuts down the scheduled executor service .
35,293
protected void _sendAdditionalNotification ( NotificationContext context , NotificationStatus status ) { requireArgument ( context != null , "Notification context cannot be null." ) ; if ( status == NotificationStatus . TRIGGERED ) { super . sendAdditionalNotification ( context ) ; } else { super . clearAdditionalNotif...
Update the state of the notification to indicate whether the triggering condition exists or has been cleared .
35,294
public static < E extends Identifiable > E findByPrimaryKey ( EntityManager em , BigInteger id , Class < E > type ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( id != null && id . compareTo ( ZERO ) > 0 , "ID cannot be null and must be positive and non-zero" ) ; requireArg...
Finds a JPA entity by its primary key .
35,295
public static < E extends Identifiable > List < E > findByPrimaryKeys ( EntityManager em , List < BigInteger > ids , Class < E > type ) { requireArgument ( em != null , "The entity manager cannot be null." ) ; requireArgument ( ids != null && ! ids . isEmpty ( ) , "IDs cannot be null or empty." ) ; requireArgument ( ty...
Finds JPA entities by their primary keys .
35,296
public static < E extends Identifiable > List < E > findEntitiesMarkedForDeletion ( EntityManager em , Class < E > type , final int limit ) { requireArgument ( em != null , "Entity Manager cannot be null" ) ; requireArgument ( limit == - 1 || limit > 0 , "Limit if not -1, must be greater than 0." ) ; TypedQuery < E > q...
Finds all entities that have been marked for deletion .
35,297
public PutResult putAnnotations ( List < Annotation > annotations ) throws IOException , TokenExpiredException { String requestUrl = COLLECTION_RESOURCE + RESOURCE ; ArgusResponse response = getClient ( ) . executeHttpRequest ( ArgusHttpClient . RequestType . POST , requestUrl , annotations ) ; assertValidResponse ( re...
Submits annotations .
35,298
public static Double downsamplerReducer ( List < Double > values , String reducerType ) { List < Double > operands = new ArrayList < Double > ( ) ; for ( Double value : values ) { if ( value == null ) { operands . add ( 0.0 ) ; } else { operands . add ( value ) ; } } InternalReducerType type = InternalReducerType . fro...
Implements down sampling .
35,299
public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { String user = null ; if ( HttpServletRequest . class . isAssignableFrom ( request . getClass ( ) ) ) { HttpServletRequest req = HttpServletRequest . class . cast ( request ) ; String au...
Authenticates a user if required .