idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
21,900 | public void shutdown ( ) { ServiceManagerAppender . shutdown ( ) ; try { final LinkedList < LogLine > copy ; synchronized ( incoming ) { if ( ! incoming . isEmpty ( ) ) { copy = new LinkedList < > ( incoming ) ; incoming . clear ( ) ; } else { copy = null ; } } if ( copy != null ) { while ( ! copy . isEmpty ( ) && ( fo... | Shuts down the log forwarding |
21,901 | public List < CarbonProfile > getProfileList ( ) { final List < CarbonProfile > profiles = new ArrayList < CarbonProfile > ( ) ; Element profileList = element . getChild ( "ProfileList" ) ; if ( profileList != null ) { for ( Element profileElement : profileList . getChildren ( ) ) { CarbonProfile profile = new CarbonPr... | Return the list of profiles contained within the response |
21,902 | Node compile ( final Object root ) { if ( compiled == null ) { compiled = compileExpression ( root , this . expr ) ; parsed = null ; if ( this . notifyOnCompiled != null ) this . notifyOnCompiled . accept ( this . expr , this ) ; } return compiled ; } | Eagerly compile this OGNL expression |
21,903 | public final ReturnValue sendCommand ( final String sCommandName , final String ... arguments ) throws JNRPEClientException { return sendRequest ( new JNRPERequest ( sCommandName , arguments ) ) ; } | Inovoke a command installed in JNRPE . |
21,904 | private static void printVersion ( ) { System . out . println ( "jcheck_nrpe version " + JNRPEClient . class . getPackage ( ) . getImplementationVersion ( ) ) ; System . out . println ( "Copyright (c) 2013 Massimiliano Ziccardi" ) ; System . out . println ( "Licensed under the Apache License, Version 2.0" ) ; System . ... | Prints the application version . |
21,905 | @ SuppressWarnings ( "unchecked" ) private static void printUsage ( final Exception e ) { printVersion ( ) ; StringBuilder sbDivider = new StringBuilder ( "=" ) ; if ( e != null ) { System . out . println ( e . getMessage ( ) + "\n" ) ; } HelpFormatter hf = new HelpFormatter ( ) ; while ( sbDivider . length ( ) < hf . ... | Prints usage instrunctions and eventually an error message about the latest execution . |
21,906 | public boolean isFinished ( ) { if ( finished ) return true ; try { final int code = exitCode ( ) ; finished ( code ) ; return true ; } catch ( IllegalThreadStateException e ) { return false ; } } | Determines if the application has completed yet |
21,907 | protected Thread copy ( final InputStream in , final Writer out ) { Runnable r = ( ) -> { try { StreamUtil . streamCopy ( in , out ) ; } catch ( IOException e ) { try { out . flush ( ) ; } catch ( Throwable t ) { } unexpectedFailure ( e ) ; } } ; Thread t = new Thread ( r ) ; t . setName ( this + " - IOCopy " + in + " ... | Commence a background copy |
21,908 | protected void configure ( ServletContainerDispatcher dispatcher ) throws ServletException { registry . register ( this , true ) ; final Registry resteasyRegistry ; final ResteasyProviderFactory providerFactory ; { final ResteasyRequestResponseFactory converter = new ResteasyRequestResponseFactory ( dispatcher ) ; disp... | Try to initialise a ServletContainerDispatcher with the connection to the Guice REST services |
21,909 | private static String parseExpecting ( final Stage stage ) { StringBuilder expected = new StringBuilder ( ) ; for ( String key : stage . getTransitionNames ( ) ) { expected . append ( ',' ) . append ( stage . getTransition ( key ) . expects ( ) ) ; } return expected . substring ( 1 ) ; } | Utility method for error messages . |
21,910 | public static File createTempFile ( final String prefix , final String suffix ) { try { File tempFile = File . createTempFile ( prefix , suffix ) ; if ( tempFile . exists ( ) ) { if ( ! tempFile . delete ( ) ) throw new RuntimeException ( "Could not delete new temp file: " + tempFile ) ; } return tempFile ; } catch ( I... | Creates a temporary file name |
21,911 | public static boolean safeMove ( File src , File dest ) throws SecurityException { assert ( src . exists ( ) ) ; final boolean createDestIfNotExist = true ; try { if ( src . isFile ( ) ) FileUtils . moveFile ( src , dest ) ; else FileUtils . moveDirectoryToDirectory ( src , dest , createDestIfNotExist ) ; return true ;... | Safely moves a file from one place to another ensuring the filesystem is left in a consistent state |
21,912 | public static boolean delete ( File f ) throws IOException { assert ( f . exists ( ) ) ; if ( f . isDirectory ( ) ) { FileUtils . deleteDirectory ( f ) ; return true ; } else { return f . delete ( ) ; } } | Deletes a local file or directory from the filesystem |
21,913 | public static boolean smartEquals ( File one , File two , boolean checkName ) throws IOException { if ( checkName ) { if ( ! one . getName ( ) . equals ( two . getName ( ) ) ) { return false ; } } if ( one . isDirectory ( ) == two . isDirectory ( ) ) { if ( one . isDirectory ( ) ) { File [ ] filesOne = one . listFiles ... | Determines if 2 files or directories are equivalent by looking inside them |
21,914 | public CarbonReply send ( Element element ) throws CarbonException { try { final String responseXml = send ( serialise ( element ) ) ; return new CarbonReply ( deserialise ( responseXml ) ) ; } catch ( CarbonException e ) { throw e ; } catch ( Exception e ) { throw new CarbonException ( e ) ; } } | Send some XML |
21,915 | private synchronized void setService ( final T newService ) { if ( m_service != newService ) { LOG . debug ( "Service changed [" + m_service + "] -> [" + newService + "]" ) ; final T oldService = m_service ; m_service = newService ; if ( m_serviceListener != null ) { m_serviceListener . serviceChanged ( oldService , m... | Sets the new service and notifies the listener that the service was changed . |
21,916 | private synchronized void resolveService ( ) { T newService = null ; final Iterator < T > it = m_serviceCollection . iterator ( ) ; while ( newService == null && it . hasNext ( ) ) { final T candidateService = it . next ( ) ; if ( ! candidateService . equals ( getService ( ) ) ) { newService = candidateService ; } } se... | Resolves a new service by serching the services collection for first available service . |
21,917 | protected void onStart ( ) { m_serviceCollection = new ServiceCollection < T > ( m_context , m_serviceClass , new CollectionListener ( ) ) ; m_serviceCollection . start ( ) ; } | Creates a service collection and starts it . |
21,918 | protected void onStop ( ) { if ( m_serviceCollection != null ) { m_serviceCollection . stop ( ) ; m_serviceCollection = null ; } setService ( null ) ; } | Stops the service collection and releases resources . |
21,919 | public ProcessBuilder getProcessBuilder ( ) { if ( spawned ) return builder ; if ( runAs != null ) { String command = cmd . get ( 0 ) ; if ( command . charAt ( 0 ) == '-' && ! SudoFeature . hasArgumentsEnd ( ) ) throw new IllegalArgumentException ( "Command to runAs starts with - but this version of sudo does not suppo... | Returns a ProcessBuilder for use in a manual launching |
21,920 | private int percent ( final long val , final long total ) { if ( total == 0 ) { return 100 ; } if ( val == 0 ) { return 0 ; } double dVal = ( double ) val ; double dTotal = ( double ) total ; return ( int ) ( dVal / dTotal * 100 ) ; } | Compute the percent values . |
21,921 | private String format ( final long bytes ) { if ( bytes > MB ) { return String . valueOf ( bytes / MB ) + " MB" ; } return String . valueOf ( bytes / KB ) + " KB" ; } | Format the size returning it as MB or KB . |
21,922 | private boolean passes ( final AuthScope scope , final AuthConstraint constraint , final CurrentUser user ) { if ( scope . getSkip ( constraint ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( "Allowing method invocation (skip=true)." ) ; return true ; } else { final boolean pass = user . hasRole ( scope . getRole (... | Determines whether a given user has the necessary role to pass a constraint |
21,923 | void addInstance ( final Class < ? > discoveredType , final Object newlyConstructed ) { WeakHashMap < Object , Void > map ; synchronized ( instances ) { map = instances . get ( discoveredType ) ; if ( map == null ) { map = new WeakHashMap < > ( ) ; instances . put ( discoveredType , map ) ; } } synchronized ( map ) { m... | Register an instance of a property - consuming type ; the registry will use a weak reference to hold on to this instance so that it can be discarded if it has a short lifespan |
21,924 | public static String doGET ( final URL url , final Properties requestProps , final Integer timeout , boolean includeHeaders , boolean ignoreBody ) throws Exception { return doRequest ( url , requestProps , timeout , includeHeaders , ignoreBody , "GET" ) ; } | Do a http get request and return response |
21,925 | public static String doPOST ( final URL url , final Properties requestProps , final Integer timeout , final String encodedData , boolean includeHeaders , boolean ignoreBody ) throws IOException { HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; setRequestProperties ( requestProps , conn , timeo... | Do a http post request and return response |
21,926 | public static void sendPostData ( HttpURLConnection conn , String encodedData ) throws IOException { StreamManager sm = new StreamManager ( ) ; try { conn . setDoOutput ( true ) ; conn . setRequestMethod ( "POST" ) ; if ( conn . getRequestProperty ( "Content-Type" ) == null ) { conn . setRequestProperty ( "Content-Type... | Submits http post data to an HttpURLConnection . |
21,927 | public static void setRequestProperties ( final Properties props , HttpURLConnection conn , Integer timeout ) { if ( props != null ) { if ( props . get ( "User-Agent" ) == null ) { conn . setRequestProperty ( "User-Agent" , "Java" ) ; } for ( Entry entry : props . entrySet ( ) ) { conn . setRequestProperty ( String . v... | Sets request headers for an http connection |
21,928 | public static String parseHttpResponse ( HttpURLConnection conn , boolean includeHeaders , boolean ignoreBody ) throws IOException { StringBuilder buff = new StringBuilder ( ) ; if ( includeHeaders ) { buff . append ( conn . getResponseCode ( ) ) . append ( ' ' ) . append ( conn . getResponseMessage ( ) ) . append ( '\... | Parses an http request response |
21,929 | private List < Metric > checkAlive ( final Connection c , final ICommandLine cl ) throws BadThresholdException , SQLException { List < Metric > metricList = new ArrayList < Metric > ( ) ; Statement stmt = null ; ResultSet rs = null ; long lStart = System . currentTimeMillis ( ) ; try { stmt = c . createStatement ( ) ; ... | Checks if the database is reacheble . |
21,930 | private List < Metric > checkTablespace ( final Connection c , final ICommandLine cl ) throws BadThresholdException , SQLException { List < Metric > metricList = new ArrayList < Metric > ( ) ; String sTablespace = cl . getOptionValue ( "tablespace" ) . toUpperCase ( ) ; final String sQry = String . format ( QRY_CHECK_T... | Checks database usage . |
21,931 | private List < Metric > checkCache ( final Connection c , final ICommandLine cl ) throws BadThresholdException , SQLException { List < Metric > metricList = new ArrayList < Metric > ( ) ; String sQry1 = "select (1-(pr.value/(dbg.value+cg.value)))*100" + " from v$sysstat pr, v$sysstat dbg, v$sysstat cg" + " where pr.nam... | Checks cache hit rates . |
21,932 | public void rotateUserAccessKey ( final int id ) { final UserEntity account = getById ( id ) ; if ( account != null ) { account . setAccessKeySecondary ( account . getAccessKey ( ) ) ; account . setAccessKey ( SimpleId . alphanumeric ( UserManagerBearerToken . PREFIX , 100 ) ) ; update ( account ) ; } else { throw new ... | Rotate the primary access key - > secondary access key dropping the old secondary access key and generating a new primary access key |
21,933 | private String hashPassword ( String password ) { return BCrypt . hash ( password . toCharArray ( ) , BCrypt . DEFAULT_COST ) ; } | Creates a BCrypted hash for a password |
21,934 | public static String formatSize ( final long value ) { double size = value ; DecimalFormat df = new DecimalFormat ( "#.##" ) ; if ( size >= GB ) { return df . format ( size / GB ) + " GB" ; } if ( size >= MB ) { return df . format ( size / MB ) + " MB" ; } if ( size >= KB ) { return df . format ( size / KB ) + " KB" ; ... | Returns formatted size of a file size . |
21,935 | public static boolean extractArchive ( File tarFile , File extractTo ) { try { TarArchive ta = getArchive ( tarFile ) ; try { if ( ! extractTo . exists ( ) ) if ( ! extractTo . mkdir ( ) ) throw new RuntimeException ( "Could not create extract dir: " + extractTo ) ; ta . extractContents ( extractTo ) ; } finally { ta .... | Extracts a . tar or . tar . gz archive to a given folder |
21,936 | public static boolean addFilesToExistingJar ( File jarFile , String basePathWithinJar , Map < String , File > files , ActionOnConflict action ) throws IOException { File tempFile = FileHelper . createTempFile ( jarFile . getName ( ) , null ) ; boolean renamed = jarFile . renameTo ( tempFile ) ; if ( ! renamed ) { throw... | Adds a file or files to a jar file replacing the original one |
21,937 | public static < T > List < T > list ( Iterable < T > iterable ) { List < T > list = new ArrayList < T > ( ) ; for ( T item : iterable ) { list . add ( item ) ; } return list ; } | Converts an Iterable into a List |
21,938 | public static < T > List < T > last ( final List < T > src , int count ) { if ( count >= src . size ( ) ) { return new ArrayList < T > ( src ) ; } else { final List < T > dest = new ArrayList < T > ( count ) ; final int size = src . size ( ) ; for ( int i = size - count ; i < size ; i ++ ) { dest . add ( src . get ( i ... | Return at most the last n items from the source list |
21,939 | public static < T > List < T > tail ( List < T > list ) { if ( list . isEmpty ( ) ) return Collections . emptyList ( ) ; else return list . subList ( 1 , list . size ( ) ) ; } | Returns a sublist containing all the items in the list after the first |
21,940 | public static int [ ] flip ( int [ ] src , int [ ] dest , final int start , final int length ) { if ( dest == null || dest . length < length ) dest = new int [ length ] ; int srcIndex = start + length ; for ( int i = 0 ; i < length ; i ++ ) { dest [ i ] = src [ -- srcIndex ] ; } return dest ; } | Reverses an integer array |
21,941 | public static < T > List < T > concat ( final Collection < ? extends T > ... lists ) { ArrayList < T > al = new ArrayList < T > ( ) ; for ( Collection < ? extends T > list : lists ) if ( list != null ) al . addAll ( list ) ; return al ; } | Concatenates a number of Collections into a single List |
21,942 | public static < T > Set < T > union ( final Collection < ? extends T > ... lists ) { Set < T > s = new HashSet < T > ( ) ; for ( Collection < ? extends T > list : lists ) if ( list != null ) s . addAll ( list ) ; return s ; } | Concatenates a number of Collections into a single Set |
21,943 | private ThymeleafTemplater getOrCreateTemplater ( ) { ThymeleafTemplater templater = this . templater . get ( ) ; if ( templater == null ) { final TemplateEngine engine = getOrCreateEngine ( ) ; templater = new ThymeleafTemplater ( engine , configuration , metrics , userProvider ) ; templater . set ( "coreRestPrefix" ,... | Retrieve or build a Thymeleaf templater |
21,944 | public static boolean isPrimitive ( final Object value ) { return ( value == null || value instanceof String || value instanceof Number || value instanceof Boolean || value instanceof DateTime || value instanceof Date || value instanceof SampleCount || value instanceof Timecode || value . getClass ( ) . isEnum ( ) || v... | Helper method that returns True if the provided value should be represented as a String |
21,945 | public String toPerformanceString ( ) { final StringBuilder res = new StringBuilder ( ) . append ( quote ( metric . getMetricName ( ) ) ) . append ( '=' ) . append ( ( metric . getMetricValue ( prefix ) ) . toPrettyPrintedString ( ) ) ; if ( unitOfMeasure != null ) { switch ( unitOfMeasure ) { case milliseconds : res .... | Produce a performance string according to Nagios specification based on the value of this performance data object . |
21,946 | private String quote ( final String lbl ) { if ( lbl . indexOf ( ' ' ) == - 1 ) { return lbl ; } return new StringBuffer ( "'" ) . append ( lbl ) . append ( '\'' ) . toString ( ) ; } | Quotes the label if required . |
21,947 | public String getSchema ( Class < ? > clazz ) { if ( clazz == Integer . class || clazz == Integer . TYPE ) { return "integer [" + Integer . MIN_VALUE + " to " + Integer . MAX_VALUE + "]" ; } else if ( clazz == Long . class || clazz == Long . TYPE ) { return "long [" + Long . MIN_VALUE + " to " + Long . MAX_VALUE + "]" ... | Retrieve a schema description for a type |
21,948 | public MetricBuilder withValue ( Number value , String prettyPrintFormat ) { current = new MetricValue ( value . toString ( ) , prettyPrintFormat ) ; return this ; } | Sets the value of the metric to be built . |
21,949 | public MetricBuilder withMinValue ( Number value , String prettyPrintFormat ) { min = new MetricValue ( value . toString ( ) , prettyPrintFormat ) ; return this ; } | Sets the minimum value of the metric to be built . |
21,950 | public MetricBuilder withMaxValue ( Number value , String prettyPrintFormat ) { max = new MetricValue ( value . toString ( ) , prettyPrintFormat ) ; return this ; } | Sets the maximum value of the metric to be built . |
21,951 | public MetricBuilder withMessage ( String messagePattern , Object ... params ) { this . metricMessage = MessageFormat . format ( messagePattern , params ) ; return this ; } | Sets the message to be associated with this metric . |
21,952 | public ResultSetConstraint build ( Map < String , List < String > > constraints ) { return builder ( constraints ) . build ( ) ; } | Convenience method to build based on a Map of constraints quickly |
21,953 | @ SuppressWarnings ( "unchecked" ) public void setTypeLiteral ( TypeLiteral < T > clazz ) { if ( clazz == null ) throw new IllegalArgumentException ( "Cannot set null TypeLiteral on " + this ) ; if ( this . clazz != null && ! this . clazz . equals ( clazz . getRawType ( ) ) ) throw new IllegalStateException ( "Cannot c... | Called by guice to provide the Class associated with T |
21,954 | public Collection < ID > getIds ( final WebQuery constraints ) { return ( Collection < ID > ) find ( constraints , JPASearchStrategy . ID ) . getList ( ) ; } | Get a list of IDs matching a WebQuery |
21,955 | private SSLEngine getSSLEngine ( ) throws KeyStoreException , CertificateException , IOException , UnrecoverableKeyException , KeyManagementException { final StreamManager streamManager = new StreamManager ( ) ; SSLContext ctx ; KeyManagerFactory kmf ; try { final InputStream ksStream = getClass ( ) . getClassLoader ( ... | Creates configures and returns the SSL engine . |
21,956 | private ServerBootstrap getServerBootstrap ( final boolean useSSL ) { final CommandInvoker invoker = new CommandInvoker ( pluginRepository , commandRepository , acceptParams , getExecutionContext ( ) ) ; final ServerBootstrap serverBootstrap = new ServerBootstrap ( ) ; serverBootstrap . group ( bossGroup , workerGroup ... | Creates and returns a configured NETTY ServerBootstrap object . |
21,957 | public SampleCount resample ( Timebase newRate ) { if ( ! this . rate . equals ( newRate ) ) { final long newSamples = getSamples ( newRate ) ; return new SampleCount ( newSamples , newRate ) ; } else { return this ; } } | Resample this sample count to another rate |
21,958 | protected void onStart ( ) { m_mappings = new HashMap < Bundle , List < T > > ( ) ; m_context . addBundleListener ( m_bundleListener = new SynchronousBundleListener ( ) { public void bundleChanged ( final BundleEvent bundleEvent ) { switch ( bundleEvent . getType ( ) ) { case BundleEvent . STARTED : register ( bundleEv... | Registers a listener for bundle events and scans already active bundles . |
21,959 | protected void onStop ( ) { m_context . removeBundleListener ( m_bundleListener ) ; final Bundle [ ] toBeRemoved = m_mappings . keySet ( ) . toArray ( new Bundle [ m_mappings . keySet ( ) . size ( ) ] ) ; for ( Bundle bundle : toBeRemoved ) { unregister ( bundle ) ; } m_bundleListener = null ; m_mappings = null ; } | Un - register the bundle listener releases resources |
21,960 | public final CommandRepository createCommandRepository ( ) { CommandRepository cr = new CommandRepository ( ) ; for ( Command c : commandSection . getAllCommands ( ) ) { CommandDefinition cd = new CommandDefinition ( c . getName ( ) , c . getPlugin ( ) ) ; cd . setArgs ( c . getCommandLine ( ) ) ; cr . addCommandDefini... | Returns a command repository containing all the commands configured inside the configuration file . |
21,961 | private void init ( final String commandName , final String ... arguments ) { if ( arguments != null ) { if ( arguments . length == 1 ) { init ( commandName , arguments [ 0 ] ) ; return ; } String [ ] ary = new String [ arguments . length ] ; for ( int i = 0 ; i < arguments . length ; i ++ ) { if ( arguments [ i ] . in... | Initializes the object with the given command and the given arguments . |
21,962 | private void init ( final String commandName , final String argumentsString ) { String fullCommandString ; String tmpArgumentsString = argumentsString ; if ( tmpArgumentsString != null && ! tmpArgumentsString . isEmpty ( ) && tmpArgumentsString . charAt ( 0 ) == '!' ) { tmpArgumentsString = tmpArgumentsString . substri... | Initializes the object with the given command and the given list of ! separated list of arguments . |
21,963 | public final String [ ] getArguments ( ) { String [ ] partsAry = split ( this . packet . getBufferAsString ( ) ) ; String [ ] argsAry = new String [ partsAry . length - 1 ] ; System . arraycopy ( partsAry , 1 , argsAry , 0 , argsAry . length ) ; return argsAry ; } | Returns the command arguments . |
21,964 | private String [ ] split ( final String sCommandLine ) { return it . jnrpe . utils . StringUtils . split ( sCommandLine , '!' , false ) ; } | Utility method that splits using the ! character and handling quoting by and . |
21,965 | private UserEntity ensureRolesFetched ( final UserEntity user ) { if ( user != null ) user . getRoles ( ) . stream ( ) . map ( r -> r . getId ( ) ) . collect ( Collectors . toList ( ) ) ; return user ; } | Make sure the roles have been fetched from the database |
21,966 | private UserLogin tryBasicAuthLogin ( UserLogin login , UserAuthenticationService authService , HttpServletRequest request ) { final String header = request . getHeader ( HttpHeaderNames . AUTHORIZATION ) ; if ( header != null ) { final String [ ] credentials = BasicAuthHelper . parseHeader ( header ) ; if ( credential... | Support proactive HTTP BASIC authentication |
21,967 | private void prune ( ) { if ( useSoftReferences ) { Iterator < Map . Entry < String , Object > > it = cache . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final Map . Entry < String , Object > entry = it . next ( ) ; if ( dereference ( entry . getValue ( ) ) == null ) it . remove ( ) ; } } } | Finds stale entries in the map |
21,968 | public final ThresholdsEvaluatorBuilder withLegacyThreshold ( final String metric , final String okRange , final String warnRange , final String critRange ) throws BadThresholdException { LegacyRange ok = null , warn = null , crit = null ; if ( okRange != null ) { ok = new LegacyRange ( okRange ) ; } if ( warnRange != ... | This method allows to specify thresholds using the old format . |
21,969 | public static synchronized void register ( Class < ? > clazz ) { if ( clazz . isAnnotationPresent ( javax . ws . rs . ext . Provider . class ) ) { classes . add ( clazz ) ; revision ++ ; } else { throw new RuntimeException ( "Class " + clazz . getName ( ) + " is not annotated with javax.ws.rs.ext.Provider" ) ; } } | Register a provider class |
21,970 | private static PipedInputStream createInputStream ( final Jar jar ) throws IOException { final CloseAwarePipedInputStream pin = new CloseAwarePipedInputStream ( ) ; final PipedOutputStream pout = new PipedOutputStream ( pin ) ; new Thread ( ) { public void run ( ) { try { jar . write ( pout ) ; } catch ( Exception e ) ... | Creates an piped input stream for the wrapped jar . This is done in a thread so we can return quickly . |
21,971 | private static void checkMandatoryProperties ( final Analyzer analyzer , final Jar jar , final String symbolicName ) { final String importPackage = analyzer . getProperty ( Analyzer . IMPORT_PACKAGE ) ; if ( importPackage == null || importPackage . trim ( ) . length ( ) == 0 ) { analyzer . setProperty ( Analyzer . IMPO... | Check if manadatory properties are present otherwise generate default . |
21,972 | public static Properties parseInstructions ( final String query ) throws MalformedURLException { final Properties instructions = new Properties ( ) ; if ( query != null ) { try { final String segments [ ] = query . split ( "&" ) ; for ( String segment : segments ) { if ( segment . trim ( ) . length ( ) > 0 ) { final Ma... | Parses bnd instructions out of an url query string . |
21,973 | private static void throwAsMalformedURLException ( final String message , final Exception cause ) throws MalformedURLException { final MalformedURLException exception = new MalformedURLException ( message ) ; exception . initCause ( cause ) ; throw exception ; } | Creates an MalformedURLException with a message and a cause . |
21,974 | private void validateHibernateProperties ( final GuiceConfig configuration , final Properties hibernateProperties ) { final boolean allowCreateSchema = configuration . getBoolean ( GuiceProperties . HIBERNATE_ALLOW_HBM2DDL_CREATE , false ) ; if ( ! allowCreateSchema ) { final String hbm2ddl = hibernateProperties . getP... | Checks whether hbm2ddl is set to a prohibited value throwing an exception if it is |
21,975 | public static ReturnValueBuilder forPlugin ( final String name , final ThresholdsEvaluator thr ) { if ( thr != null ) { return new ReturnValueBuilder ( name , thr ) ; } return new ReturnValueBuilder ( name , new ThresholdsEvaluatorBuilder ( ) . create ( ) ) ; } | Constructs the object with the given threshold evaluator . |
21,976 | private void formatResultMessage ( final Metric pluginMetric ) { if ( StringUtils . isEmpty ( pluginMetric . getMessage ( ) ) ) { return ; } if ( StringUtils . isEmpty ( retValMessage ) ) { retValMessage = pluginMetric . getMessage ( ) ; return ; } retValMessage += " " + pluginMetric . getMessage ( ) ; } | Formats the message to return to Nagios according to the specifications contained inside the pluginMetric object . |
21,977 | public static String getLocalhost ( ) throws RuntimeException { String hostname = null ; try { InetAddress addr = InetAddress . getLocalHost ( ) ; hostname = addr . getHostName ( ) ; } catch ( UnknownHostException e ) { throw new RuntimeException ( "[FileHelper] {getLocalhost}: Can't get local hostname" ) ; } return ho... | Gets the hostname of localhost |
21,978 | public static String getLocalIp ( ) throws RuntimeException { try { InetAddress addr = getLocalIpAddress ( ) ; return addr . getHostAddress ( ) ; } catch ( RuntimeException e ) { throw new RuntimeException ( "[FileHelper] {getLocalIp}: Unable to find the local machine" , e ) ; } } | Gets the local IP address |
21,979 | public static InetAddress getLocalIpAddress ( ) throws RuntimeException { try { List < InetAddress > ips = getLocalIpAddresses ( false , true ) ; for ( InetAddress ip : ips ) { log . debug ( "[IpHelper] {getLocalIpAddress} Considering locality of " + ip . getHostAddress ( ) ) ; if ( ! ip . isAnyLocalAddress ( ) && ( ip... | Returns the primary InetAddress of localhost |
21,980 | public static InetAddress getLocalIpAddress ( String iface ) throws RuntimeException { try { NetworkInterface nic = NetworkInterface . getByName ( iface ) ; Enumeration < InetAddress > ips = nic . getInetAddresses ( ) ; InetAddress firstIP = null ; while ( ips != null && ips . hasMoreElements ( ) ) { InetAddress ip = i... | Returns the IP address associated with iface |
21,981 | public static List < InetAddress > getLocalIpAddresses ( boolean pruneSiteLocal , boolean pruneDown ) throws RuntimeException { try { Enumeration < NetworkInterface > nics = NetworkInterface . getNetworkInterfaces ( ) ; List < InetAddress > addresses = new Vector < InetAddress > ( ) ; while ( nics . hasMoreElements ( )... | Returns a list of local InetAddresses for this machine |
21,982 | public static String getMacFor ( NetworkInterface iface ) throws SocketException , NoMacAddressException { assert ( iface != null ) ; byte [ ] hwaddr = iface . getHardwareAddress ( ) ; if ( hwaddr == null || hwaddr . length == 0 ) { throw new NoMacAddressException ( "Interface " + iface . getName ( ) + " has no physica... | Given a network interface determines its mac address |
21,983 | public static NetworkInterface getInterfaceForLocalIp ( InetAddress addr ) throws SocketException , NoInterfaceException { assert ( getLocalIpAddresses ( false ) . contains ( addr ) ) : "IP is not local" ; NetworkInterface iface = NetworkInterface . getByInetAddress ( addr ) ; if ( iface != null ) return iface ; else t... | Given a local IP address returns the Interface it corresponds to |
21,984 | public static InetAddress ntoa ( final int address ) { try { final byte [ ] addr = new byte [ 4 ] ; addr [ 0 ] = ( byte ) ( ( address >>> 24 ) & 0xFF ) ; addr [ 1 ] = ( byte ) ( ( address >>> 16 ) & 0xFF ) ; addr [ 2 ] = ( byte ) ( ( address >>> 8 ) & 0xFF ) ; addr [ 3 ] = ( byte ) ( address & 0xFF ) ; return InetAddre... | Converts numeric address to an InetAddress |
21,985 | public static boolean isPubliclyRoutable ( final InetAddress addrIP ) { if ( addrIP == null ) throw new NullPointerException ( "isPubliclyRoutable requires an IP address be passed to it!" ) ; return ! addrIP . isSiteLocalAddress ( ) && ! addrIP . isLinkLocalAddress ( ) && ! addrIP . isLoopbackAddress ( ) ; } | Determines whether a particular IP address is publicly routable on the internet |
21,986 | public WebQuery buildQuery ( ) { Map < String , List < String > > map = new HashMap < > ( constraints ) ; applyDefault ( WQUriControlField . FETCH , map , defaultFetch ) ; applyDefault ( WQUriControlField . EXPAND , map , defaultExpand ) ; applyDefault ( WQUriControlField . ORDER , map , defaultOrder ) ; applyDefault (... | Construct a WebQueryDefinition from this applying the web query semantics |
21,987 | private void configurePlugins ( final File fDir ) throws PluginConfigurationException { LOG . trace ( "READING PLUGIN CONFIGURATION FROM DIRECTORY {}" , fDir . getName ( ) ) ; StreamManager streamMgr = new StreamManager ( ) ; File [ ] vfJars = fDir . listFiles ( JAR_FILE_FILTER ) ; if ( vfJars == null || vfJars . lengt... | Loads all the plugins definitions from the given directory . |
21,988 | public final void load ( final File fDirectory ) throws PluginConfigurationException { File [ ] vFiles = fDirectory . listFiles ( ) ; if ( vFiles != null ) { for ( File f : vFiles ) { if ( f . isDirectory ( ) ) { configurePlugins ( f ) ; } } } } | Loops through all the directories present inside the JNRPE plugin directory . |
21,989 | public static Session getSession ( final ICommandLine cl ) throws Exception { JSch jsch = new JSch ( ) ; Session session = null ; int timeout = DEFAULT_TIMEOUT ; int port = cl . hasOption ( "port" ) ? Integer . parseInt ( cl . getOptionValue ( "port" ) ) : + DEFAULT_PORT ; String hostname = cl . getOptionValue ( "hostn... | Starts an ssh session |
21,990 | public Timeout getTimeoutLeft ( ) { final long left = getTimeLeft ( ) ; if ( left != 0 ) return new Timeout ( left , TimeUnit . MILLISECONDS ) ; else return Timeout . ZERO ; } | Determines the amount of time leftuntil the deadline and returns it as a timeout |
21,991 | public static Deadline soonest ( Deadline ... deadlines ) { Deadline min = null ; if ( deadlines != null ) for ( Deadline deadline : deadlines ) { if ( deadline != null ) { if ( min == null ) min = deadline ; else if ( deadline . getTimeLeft ( ) < min . getTimeLeft ( ) ) { min = deadline ; } } } return min ; } | Retrieve the deadline with the least time remaining until it expires |
21,992 | public RestFailure renderFailure ( Throwable e ) { if ( e . getCause ( ) != null && ( e instanceof ApplicationException ) ) { return renderFailure ( e . getCause ( ) ) ; } RestFailure failure = new RestFailure ( ) ; failure . id = getOrGenerateFailureId ( ) ; failure . date = new Date ( ) ; if ( e instanceof RestExcept... | Render a Throwable as a RestFailure |
21,993 | public HibernateTransaction start ( ) { final Session session = sessionProvider . get ( ) ; final Transaction tx = session . beginTransaction ( ) ; return new HibernateTransaction ( tx ) ; } | Starts a new Hibernate transaction . Note that the caller accepts responsibility for closing the transaction |
21,994 | public void execute ( Runnable statements ) { try ( HibernateTransaction tx = start ( ) . withAutoRollback ( ) ) { statements . run ( ) ; tx . commit ( ) ; } } | Execute the provided Runnable within a transaction committing if no exceptions are thrown |
21,995 | public void addCommitAction ( final Runnable action ) throws HibernateException { if ( action == null ) return ; addAction ( new BaseSessionEventListener ( ) { public void transactionCompletion ( final boolean successful ) { if ( successful ) action . run ( ) ; } } ) ; } | Register an action to run on the successful commit of the transaction |
21,996 | public void deleteOnRollback ( final Collection < File > files ) { addRollbackAction ( new Runnable ( ) { public void run ( ) { for ( File file : files ) { if ( log . isTraceEnabled ( ) ) log . trace ( "Delete file on transaction rollback: " + file ) ; final boolean success = FileUtils . deleteQuietly ( file ) ; if ( !... | Adds an action to the transaction to delete a set of files once rollback completes |
21,997 | public Object newInstanceWithId ( final Object id ) { try { final Object o = clazz . newInstance ( ) ; idProperty . set ( o , id ) ; return o ; } catch ( Throwable e ) { throw new RuntimeException ( "Cannot create new instance of " + clazz + " with ID " + id + " (of type " + id . getClass ( ) + ") populated!" , e ) ; }... | Create a new instance of this entity setting only the ID field |
21,998 | public EntityGraph getDefaultGraph ( final Session session ) { if ( this . defaultExpandGraph == null ) { final EntityGraph < ? > graph = session . createEntityGraph ( clazz ) ; populateGraph ( graph , getEagerFetch ( ) ) ; this . defaultExpandGraph = graph ; return graph ; } else { return this . defaultExpandGraph ; }... | Build or return the default Entity Graph that represents defaultExpand |
21,999 | private void populateGraph ( final EntityGraph < ? > graph , final Set < String > fetches ) { Map < String , Subgraph < ? > > created = new HashMap < > ( ) ; for ( String fetch : fetches ) { final String [ ] parts = StringUtils . split ( fetch , '.' ) ; Subgraph < ? > parent = null ; for ( int i = 0 ; i < parts . lengt... | Creates an EntityGraph representing the |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.