idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
22,000
public final void receive ( final LogEvent logEvent ) { final String sClassName = logEvent . getSource ( ) . getClass ( ) . getName ( ) ; Logger logger = loggersMap . get ( sClassName ) ; if ( logger == null ) { logger = LoggerFactory . getLogger ( logEvent . getSource ( ) . getClass ( ) ) ; loggersMap . put ( sClassName , logger ) ; } final Throwable error = logEvent . getCause ( ) ; switch ( logEvent . getLogType ( ) ) { case TRACE : logger . trace ( logEvent . getMessage ( ) , error ) ; break ; case DEBUG : logger . debug ( logEvent . getMessage ( ) , error ) ; break ; case INFO : logger . info ( logEvent . getMessage ( ) , error ) ; break ; case WARNING : logger . warn ( logEvent . getMessage ( ) , error ) ; break ; case ERROR : logger . error ( logEvent . getMessage ( ) , error ) ; break ; case FATAL : logger . error ( logEvent . getMessage ( ) , error ) ; break ; } }
This method receives the log event and logs it .
22,001
public static InputStream routeStreamThroughProcess ( final Process p , final InputStream origin , final boolean closeInput ) { InputStream processSTDOUT = p . getInputStream ( ) ; OutputStream processSTDIN = p . getOutputStream ( ) ; StreamUtil . doBackgroundCopy ( origin , processSTDIN , DUMMY_MONITOR , true , closeInput ) ; return processSTDOUT ; }
Given a Process this function will route the flow of data through it & out again
22,002
public static long eatInputStream ( InputStream is ) { try { long eaten = 0 ; try { Thread . sleep ( STREAM_SLEEP_TIME ) ; } catch ( InterruptedException e ) { } int avail = Math . min ( is . available ( ) , CHUNKSIZE ) ; byte [ ] eatingArray = new byte [ CHUNKSIZE ] ; while ( avail > 0 ) { is . read ( eatingArray , 0 , avail ) ; eaten += avail ; if ( avail < CHUNKSIZE ) { if ( STREAM_SLEEP_TIME != 0 ) try { Thread . sleep ( STREAM_SLEEP_TIME ) ; } catch ( InterruptedException e ) { } } avail = Math . min ( is . available ( ) , CHUNKSIZE ) ; } return eaten ; } catch ( IOException e ) { log . error ( e . getMessage ( ) , e ) ; return - 1 ; } }
Eats an inputstream discarding its contents
22,003
public static void streamCopy ( InputStream input , Writer output ) throws IOException { if ( input == null ) throw new IllegalArgumentException ( "Must provide something to read from" ) ; if ( output == null ) throw new IllegalArgumentException ( "Must provide something to write to" ) ; streamCopy ( new InputStreamReader ( input ) , output ) ; }
Copies the contents of an InputStream using the default encoding into a Writer
22,004
private void recache ( ) { if ( mask == 0 && prefix != 0 ) { this . mask = - 1 << ( 32 - prefix ) ; this . maskedNetwork = IpHelper . aton ( network ) & mask ; } }
Repopulates the transient fields based on the IP and prefix
22,005
public long get ( final TimeUnit toUnit ) { if ( this . unit == toUnit ) return period ; else return toUnit . convert ( period , this . unit ) ; }
Get this timeout represented in a different unit
22,006
public static Timeout max ( Timeout ... timeouts ) { Timeout max = null ; for ( Timeout timeout : timeouts ) { if ( timeout != null ) if ( max == null || max . getMilliseconds ( ) < timeout . getMilliseconds ( ) ) max = timeout ; } if ( max != null ) return max ; else throw new IllegalArgumentException ( "Must specify at least one non-null timeout!" ) ; }
Filter through a number of timeouts to find the one with the longest period
22,007
public static Timeout min ( Timeout ... timeouts ) { Timeout min = null ; for ( Timeout timeout : timeouts ) { if ( timeout != null ) if ( min == null || min . getMilliseconds ( ) > timeout . getMilliseconds ( ) ) min = timeout ; } if ( min != null ) return min ; else throw new IllegalArgumentException ( "Must specify at least one non-null timeout!" ) ; }
Filter through a number of timeouts to find the one with the shortest period
22,008
public static Timeout sum ( Timeout ... timeouts ) { long sum = 0 ; for ( Timeout timeout : timeouts ) if ( timeout != null ) sum += timeout . getMilliseconds ( ) ; if ( sum != 0 ) return new Timeout ( sum ) ; else return Timeout . ZERO ; }
Adds together all the supplied timeouts
22,009
public synchronized static boolean hasSudo ( ) { if ( ! sudoTested ) { String [ ] cmdArr = new String [ ] { "which" , "sudo" } ; List < String > cmd = new ArrayList < String > ( cmdArr . length ) ; Collections . addAll ( cmd , cmdArr ) ; ProcessBuilder whichsudo = new ProcessBuilder ( cmd ) ; try { Process p = whichsudo . start ( ) ; try { Execed e = new Execed ( cmd , p , false ) ; int returnCode = e . waitForExit ( new Deadline ( 3 , TimeUnit . SECONDS ) ) ; sudoSupported = ( returnCode == 0 ) ; sudoTested = true ; } finally { p . destroy ( ) ; } } catch ( Throwable t ) { sudoSupported = false ; sudoTested = true ; } } return sudoSupported ; }
Determines whether sudo is supported on the local machine
22,010
public final void channelRead ( final ChannelHandlerContext ctx , final Object msg ) { try { JNRPERequest req = ( JNRPERequest ) msg ; ReturnValue ret = commandInvoker . invoke ( req . getCommand ( ) , req . getArguments ( ) ) ; JNRPEResponse res = new JNRPEResponse ( ) ; res . setResult ( ret . getStatus ( ) . intValue ( ) , ret . getMessage ( ) ) ; ChannelFuture channelFuture = ctx . writeAndFlush ( res ) ; channelFuture . addListener ( ChannelFutureListener . CLOSE ) ; } catch ( RuntimeException re ) { re . printStackTrace ( ) ; } finally { ReferenceCountUtil . release ( msg ) ; } }
Method channelRead .
22,011
private static void applyConfigs ( final ClassLoader classloader , final GuiceConfig config ) { for ( String configFile : getPropertyFiles ( config ) ) { try { for ( PropertyFile properties : loadConfig ( classloader , configFile ) ) config . setAll ( properties ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Error loading configuration URLs from " + configFile , e ) ; } } try { applyNetworkConfiguration ( config ) ; } catch ( Throwable t ) { throw new RuntimeException ( "Failed to retrieve configuration from network!" , t ) ; } }
Discover and add to the configuration any properties on disk and on the network
22,012
public String parse ( final String threshold , final RangeConfig tc ) { configure ( tc ) ; return threshold . substring ( 1 ) ; }
Parses the threshold to remove the matched braket .
22,013
public String getOptionValue ( final String optionName ) { if ( optionName . length ( ) == 1 ) { return getOptionValue ( optionName . charAt ( 0 ) ) ; } return ( String ) commandLine . getValue ( "--" + optionName ) ; }
Returns the value of the specified option .
22,014
public String getOptionValue ( final char shortOption , final String defaultValue ) { return ( String ) commandLine . getValue ( "-" + shortOption , defaultValue ) ; }
Returns the value of the specified option If the option is not present returns the default value .
22,015
public TimecodeRange add ( SampleCount samples ) { final Timecode newStart = start . add ( samples ) ; final Timecode newEnd = end . add ( samples ) ; return new TimecodeRange ( newStart , newEnd ) ; }
Move the range right by the specified number of samples
22,016
public synchronized void opportunisticallyRefreshUserData ( final String username , final String password ) { if ( shouldOpportunisticallyRefreshUserData ( ) ) { this . lastOpportunisticUserDataRefresh = System . currentTimeMillis ( ) ; Thread thread = new Thread ( ( ) -> refreshAllUserData ( ldap . parseUser ( username ) , password , true ) ) ; thread . setDaemon ( true ) ; thread . setName ( "UserManager_OpportunisticRefresh" ) ; thread . start ( ) ; } }
Temporarily borrow a user s credentials to run an opportunistic user data refresh
22,017
public String relative ( String url ) { try { final URI uri = absolute ( url ) . build ( ) ; return new URI ( null , null , uri . getPath ( ) , uri . getQuery ( ) , uri . getFragment ( ) ) . toString ( ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( e ) ; } }
Return only the path for a given URL
22,018
void reload ( NetworkConfig config ) { try { log . trace ( "Load config data from " + config . path + " into " + config ) ; final ConfigPropertyData read = configService . read ( config . path , configInstanceId , config . getLastRevision ( ) ) ; if ( read == null || read . properties == null || read . properties . isEmpty ( ) ) return ; for ( ConfigPropertyValue property : read . properties ) { config . properties . set ( property . getName ( ) , property . getValue ( ) ) ; } config . setLastRevision ( read . revision ) ; } catch ( Throwable t ) { log . warn ( "Error loading config from path " + config . path , t ) ; } }
Called to initiate an intelligent reload of a particular config
22,019
@ Named ( "logdata" ) public CloudTable getLogDataTable ( @ Named ( "azure.storage-connection-string" ) String storageConnectionString , @ Named ( "azure.logging-table" ) String logTableName ) throws URISyntaxException , StorageException , InvalidKeyException { CloudStorageAccount storageAccount = CloudStorageAccount . parse ( storageConnectionString ) ; CloudTableClient tableClient = storageAccount . createCloudTableClient ( ) ; CloudTable table = tableClient . getTableReference ( logTableName ) ; table . createIfNotExists ( ) ; return table ; }
For the Azure Log Store the underlying table to use
22,020
public final ReturnValue execute ( final ICommandLine cl ) { if ( cl . hasOption ( 'U' ) ) { setUrl ( cl . getOptionValue ( 'U' ) ) ; } if ( cl . hasOption ( 'O' ) ) { setObject ( cl . getOptionValue ( 'O' ) ) ; } if ( cl . hasOption ( 'A' ) ) { setAttribute ( cl . getOptionValue ( 'A' ) ) ; } if ( cl . hasOption ( 'I' ) ) { setInfo_attribute ( cl . getOptionValue ( 'I' ) ) ; } if ( cl . hasOption ( 'J' ) ) { setInfo_key ( cl . getOptionValue ( 'J' ) ) ; } if ( cl . hasOption ( 'K' ) ) { setAttribute_key ( cl . getOptionValue ( 'K' ) ) ; } if ( cl . hasOption ( 'w' ) ) { setWarning ( cl . getOptionValue ( 'w' ) ) ; } if ( cl . hasOption ( 'c' ) ) { setCritical ( cl . getOptionValue ( 'c' ) ) ; } if ( cl . hasOption ( "username" ) ) { setUsername ( cl . getOptionValue ( "username" ) ) ; } if ( cl . hasOption ( "password" ) ) { setPassword ( cl . getOptionValue ( "password" ) ) ; } setVerbatim ( 2 ) ; try { connect ( ) ; execute ( ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; PrintStream ps = new PrintStream ( bout ) ; Status status = report ( ps ) ; ps . flush ( ) ; ps . close ( ) ; return new ReturnValue ( status , new String ( bout . toByteArray ( ) ) ) ; } catch ( Exception ex ) { LOG . warn ( getContext ( ) , "An error has occurred during execution " + "of the CHECK_JMX plugin : " + ex . getMessage ( ) , ex ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; PrintStream ps = new PrintStream ( bout ) ; Status status = report ( ex , ps ) ; ps . flush ( ) ; ps . close ( ) ; return new ReturnValue ( status , new String ( bout . toByteArray ( ) ) ) ; } finally { try { disconnect ( ) ; } catch ( IOException e ) { LOG . warn ( getContext ( ) , "An error has occurred during execution (disconnect) of the CHECK_JMX plugin : " + e . getMessage ( ) , e ) ; } } }
Executes the plugin .
22,021
public static boolean overlapping ( Version min1 , Version max1 , Version min2 , Version max2 ) { return min1 . equals ( min2 ) || max1 . equals ( max2 ) || min2 . within ( min1 , max1 ) || max2 . within ( min1 , min2 ) || min1 . within ( min2 , max2 ) || max1 . within ( min2 , max2 ) ; }
Determines if 2 version ranges have any overlap
22,022
public String createPartitionAndRowQuery ( final DateTime from , final DateTime to ) { final String parMin = TableQuery . generateFilterCondition ( "PartitionKey" , TableQuery . QueryComparisons . GREATER_THAN_OR_EQUAL , from . toLocalDate ( ) . toString ( ) ) ; final String rowMin = TableQuery . generateFilterCondition ( "RowKey" , TableQuery . QueryComparisons . GREATER_THAN_OR_EQUAL , LogLineTableEntity . toRowKey ( from , null ) ) ; if ( to == null || from . toLocalDate ( ) . equals ( to . toLocalDate ( ) ) || to . isAfterNow ( ) ) { return andFilters ( parMin , rowMin ) ; } else { final String parMax = TableQuery . generateFilterCondition ( "PartitionKey" , TableQuery . QueryComparisons . LESS_THAN , to . toLocalDate ( ) . plusDays ( 1 ) . toString ( ) ) ; final String rowMax = TableQuery . generateFilterCondition ( "RowKey" , TableQuery . QueryComparisons . LESS_THAN , LogLineTableEntity . toRowKey ( to . plusSeconds ( 1 ) , null ) ) ; return andFilters ( parMin , parMax , rowMin , rowMax ) ; } }
Create a filter condition that returns log lines between two dates . Designed to be used in addition to other criteria
22,023
public ServiceInstanceEntity get ( final String serviceId ) { try { return serviceCache . get ( serviceId , ( ) -> dao . getById ( serviceId ) ) ; } catch ( Exception e ) { throw new RuntimeException ( "Error loading service: " + serviceId , e ) ; } }
Get service information reading from cache if possible
22,024
public ReturnValue execute ( final String [ ] argsAry ) throws BadThresholdException { try { HelpFormatter hf = new HelpFormatter ( ) ; Parser cliParser = new Parser ( ) ; cliParser . setGroup ( mainOptionsGroup ) ; cliParser . setHelpFormatter ( hf ) ; CommandLine cl = cliParser . parse ( argsAry ) ; InjectionUtils . inject ( proxiedPlugin , getContext ( ) ) ; Thread . currentThread ( ) . setContextClassLoader ( proxiedPlugin . getClass ( ) . getClassLoader ( ) ) ; ReturnValue retValue = proxiedPlugin . execute ( new PluginCommandLine ( cl ) ) ; if ( retValue == null ) { String msg = "Plugin [" + getPluginName ( ) + "] with args [" + StringUtils . join ( argsAry ) + "] returned null" ; retValue = new ReturnValue ( Status . UNKNOWN , msg ) ; } return retValue ; } catch ( OptionException e ) { String msg = e . getMessage ( ) ; LOG . error ( getContext ( ) , "Error parsing plugin '" + getPluginName ( ) + "' command line : " + msg , e ) ; return new ReturnValue ( Status . UNKNOWN , msg ) ; } }
Executes the proxied plugin passing the received arguments as parameters .
22,025
public void printHelp ( final PrintWriter out ) { HelpFormatter hf = new HelpFormatter ( ) ; StringBuilder sbDivider = new StringBuilder ( "=" ) ; while ( sbDivider . length ( ) < hf . getPageWidth ( ) ) { sbDivider . append ( '=' ) ; } out . println ( sbDivider . toString ( ) ) ; out . println ( "PLUGIN NAME : " + proxyedPluginDefinition . getName ( ) ) ; if ( description != null && description . trim ( ) . length ( ) != 0 ) { out . println ( sbDivider . toString ( ) ) ; out . println ( "Description : " ) ; out . println ( ) ; out . println ( description ) ; } hf . setGroup ( mainOptionsGroup ) ; hf . setDivider ( sbDivider . toString ( ) ) ; hf . setPrintWriter ( out ) ; hf . print ( ) ; }
Prints the help related to the plugin to a specified output .
22,026
public static Timecode max ( final Timecode ... timecodes ) { Timecode max = null ; for ( Timecode timecode : timecodes ) if ( max == null || lt ( max , timecode ) ) max = timecode ; return max ; }
Returns the larger of a number of timecodes
22,027
public static Timecode min ( final Timecode ... timecodes ) { Timecode min = null ; for ( Timecode timecode : timecodes ) if ( min == null || ge ( min , timecode ) ) min = timecode ; return min ; }
Returns the smaller of some timecodes
22,028
public long getDurationMillis ( ) { List < Element > durations = element . getChildren ( "Duration" ) ; if ( durations . size ( ) != 0 ) { final String durationString = durations . get ( 0 ) . getValue ( ) ; final long duration = Long . parseLong ( durationString ) ; return duration ; } else { throw new RuntimeException ( "No Duration elements present on track!" ) ; } }
Gets duration of video track in milliseconds .
22,029
private static Group configureCommandLine ( ) { DefaultOptionBuilder oBuilder = new DefaultOptionBuilder ( ) ; ArgumentBuilder aBuilder = new ArgumentBuilder ( ) ; GroupBuilder gBuilder = new GroupBuilder ( ) ; DefaultOption listOption = oBuilder . withLongName ( "list" ) . withShortName ( "l" ) . withDescription ( "Lists all the installed plugins" ) . create ( ) ; DefaultOption versionOption = oBuilder . withLongName ( "version" ) . withShortName ( "v" ) . withDescription ( "Print the server version number" ) . create ( ) ; DefaultOption helpOption = oBuilder . withLongName ( "help" ) . withShortName ( "h" ) . withDescription ( "Show this help" ) . create ( ) ; DefaultOption pluginHelpOption = oBuilder . withLongName ( "help" ) . withShortName ( "h" ) . withDescription ( "Shows help about a plugin" ) . withArgument ( aBuilder . withName ( "name" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . create ( ) ; Group alternativeOptions = gBuilder . withOption ( listOption ) . withOption ( pluginHelpOption ) . create ( ) ; DefaultOption confOption = oBuilder . withLongName ( "conf" ) . withShortName ( "c" ) . withDescription ( "Specifies the JNRPE configuration file" ) . withArgument ( aBuilder . withName ( "path" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withChildren ( alternativeOptions ) . withRequired ( true ) . create ( ) ; DefaultOption interactiveOption = oBuilder . withLongName ( "interactive" ) . withShortName ( "i" ) . withDescription ( "Starts JNRPE in command line mode" ) . create ( ) ; Group jnrpeOptions = gBuilder . withOption ( confOption ) . withOption ( interactiveOption ) . withMinimum ( 1 ) . create ( ) ; return gBuilder . withOption ( versionOption ) . withOption ( helpOption ) . withOption ( jnrpeOptions ) . create ( ) ; }
Configure the command line parser .
22,030
private static void printHelp ( final IPluginRepository pr , final String pluginName ) { try { PluginProxy pp = ( PluginProxy ) pr . getPlugin ( pluginName ) ; if ( pp == null ) { System . out . println ( "Plugin " + pluginName + " does not exists." ) ; } else { pp . printHelp ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } System . exit ( 0 ) ; }
Prints the help about a plugin .
22,031
private static void printVersion ( ) { System . out . println ( "JNRPE version " + VERSION ) ; System . out . println ( "Copyright (c) 2011 Massimiliano Ziccardi" ) ; System . out . println ( "Licensed under the Apache License, Version 2.0" ) ; System . out . println ( ) ; }
Prints the JNRPE Server version .
22,032
@ SuppressWarnings ( "unchecked" ) private static void printUsage ( final Exception e ) { printVersion ( ) ; if ( e != null ) { System . out . println ( e . getMessage ( ) + "\n" ) ; } HelpFormatter hf = new HelpFormatter ( ) ; StringBuilder sbDivider = new StringBuilder ( "=" ) ; while ( sbDivider . length ( ) < hf . getPageWidth ( ) ) { sbDivider . append ( "=" ) ; } hf . getDisplaySettings ( ) . clear ( ) ; hf . getDisplaySettings ( ) . add ( DisplaySetting . DISPLAY_GROUP_EXPANDED ) ; hf . getDisplaySettings ( ) . add ( DisplaySetting . DISPLAY_PARENT_CHILDREN ) ; hf . getFullUsageSettings ( ) . clear ( ) ; hf . getFullUsageSettings ( ) . add ( DisplaySetting . DISPLAY_PARENT_ARGUMENT ) ; hf . getFullUsageSettings ( ) . add ( DisplaySetting . DISPLAY_ARGUMENT_BRACKETED ) ; hf . getFullUsageSettings ( ) . add ( DisplaySetting . DISPLAY_PARENT_CHILDREN ) ; hf . getFullUsageSettings ( ) . add ( DisplaySetting . DISPLAY_GROUP_EXPANDED ) ; hf . setDivider ( sbDivider . toString ( ) ) ; hf . setGroup ( configureCommandLine ( ) ) ; hf . print ( ) ; System . exit ( 0 ) ; }
Prints the JNRPE Server usage and eventually the error about the last invocation .
22,033
private static JNRPEConfiguration loadConfiguration ( final String configurationFilePath ) throws ConfigurationException { File confFile = new File ( configurationFilePath ) ; if ( ! confFile . exists ( ) || ! confFile . canRead ( ) ) { throw new ConfigurationException ( "Cannot access config file : " + configurationFilePath ) ; } return JNRPEConfigurationFactory . createConfiguration ( configurationFilePath ) ; }
Loads the JNRPE configuration from the INI or the XML file .
22,034
private static IPluginRepository loadPluginDefinitions ( final String sPluginDirPath ) throws PluginConfigurationException { File fDir = new File ( sPluginDirPath ) ; DynaPluginRepository repo = new DynaPluginRepository ( ) ; repo . load ( fDir ) ; return repo ; }
Loads a plugin repository from a directory .
22,035
private static void printPluginList ( final IPluginRepository pr ) { System . out . println ( "List of installed plugins : " ) ; for ( PluginDefinition pd : pr . getAllPlugins ( ) ) { System . out . println ( " * " + pd . getName ( ) ) ; } System . exit ( 0 ) ; }
Prints the list of installed plugins .
22,036
public void setAttribute ( String name , String value ) { if ( value != null ) getElement ( ) . setAttribute ( name , value ) ; else getElement ( ) . removeAttribute ( name ) ; }
Helper method to set the value of an attribute on this Element
22,037
protected Element getElement ( String name , int index ) { List < Element > children = getElement ( ) . getChildren ( name ) ; if ( children . size ( ) > index ) return children . get ( index ) ; else return null ; }
Helper method to retrieve a child element with a particular name and index
22,038
private static TimeUnit pickUnit ( final Duration iso ) { final long millis = iso . toMillis ( ) ; if ( millis < 1000 ) return TimeUnit . MILLISECONDS ; final long SECOND = 1000 ; final long MINUTE = 60 * SECOND ; final long HOUR = 60 * MINUTE ; final long DAY = 24 * HOUR ; if ( millis % DAY == 0 ) return TimeUnit . DAYS ; else if ( millis % HOUR == 0 ) return TimeUnit . HOURS ; else if ( millis % MINUTE == 0 ) return TimeUnit . MINUTES ; else if ( millis % SECOND == 0 ) return TimeUnit . SECONDS ; else return TimeUnit . MILLISECONDS ; }
Identify the largest unit that can accurately represent the provided duration
22,039
@ SuppressWarnings ( "unchecked" ) public Iterator < T > iterator ( ) { final List < T > services = new ArrayList < T > ( ) ; if ( m_serviceTracker != null ) { final Object [ ] trackedServices = m_serviceTracker . getServices ( ) ; if ( trackedServices != null ) { for ( Object trackedService : trackedServices ) { services . add ( ( T ) trackedService ) ; } } } return Collections . unmodifiableCollection ( services ) . iterator ( ) ; }
Returns an iterator over the tracked services at the call point in time . Note that a susequent call can produce a different list of services as the services are dynamic . If there are no services available returns an empty iterator .
22,040
public < T > T get ( Class < T > clazz , final String name ) { JAXBNamedResourceFactory < T > cached = cachedReferences . get ( name ) ; if ( cached == null ) { cached = new JAXBNamedResourceFactory < T > ( this . config , this . factory , name , clazz ) ; cachedReferences . put ( name , cached ) ; } return cached . get ( ) ; }
Resolve the JAXB resource permitting caching behind the scenes
22,041
public < T > T getOnce ( final Class < T > clazz , final String name ) { return new JAXBNamedResourceFactory < T > ( this . config , this . factory , name , clazz ) . get ( ) ; }
Resolve the JAXB resource once without caching anything
22,042
public static String pretty ( final Source source ) { StreamResult result = new StreamResult ( new StringWriter ( ) ) ; pretty ( source , result ) ; return result . getWriter ( ) . toString ( ) ; }
Serialise the provided source to a pretty - printed String with the default indent settings
22,043
public static void pretty ( final Source input , final StreamResult output ) { try { Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "utf-8" ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "no" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , Integer . toString ( DEFAULT_INDENT ) ) ; transformer . transform ( input , output ) ; } catch ( Throwable t ) { throw new RuntimeException ( "Error during pretty-print operation" , t ) ; } }
Serialise the provided source to the provided destination pretty - printing with the default indent settings
22,044
public void process ( Writer writer ) { try { template . process ( data , writer ) ; } catch ( IOException e ) { throw new RuntimeException ( "Error writing template to writer" , e ) ; } catch ( TemplateException e ) { throw new RuntimeException ( e . getMessage ( ) , e ) ; } }
Render the template to a Writer
22,045
private void storeWithSubscribers ( final List < LogLineTableEntity > lines ) { synchronized ( subscribers ) { if ( subscribers . isEmpty ( ) ) return ; for ( LogSubscriber subscriber : subscribers ) { subscriber . append ( lines ) ; } if ( System . currentTimeMillis ( ) > nextSubscriberPurge ) { purgeIdleSubscribers ( ) ; nextSubscriberPurge = System . currentTimeMillis ( ) + purgeSubscriberInterval . getMilliseconds ( ) ; } } }
Makes the provided log lines available to all log tail subscribers
22,046
public UserLogin getLogin ( @ Named ( JAXRS_SERVER_WEBAUTH_PROVIDER ) CurrentUser user ) { return ( UserLogin ) user ; }
Auto - cast the user manager s CurrentUser to a UserLogin
22,047
public final IPluginInterface getPlugin ( final String name ) throws UnknownPluginException { PluginDefinition pluginDef = pluginsDefinitionsMap . get ( name ) ; if ( pluginDef == null ) { throw new UnknownPluginException ( name ) ; } try { IPluginInterface pluginInterface = pluginDef . getPluginInterface ( ) ; if ( pluginInterface == null ) { pluginInterface = pluginDef . getPluginClass ( ) . newInstance ( ) ; } return new PluginProxy ( pluginInterface , pluginDef ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; }
Returns the implementation of the plugin identified by the given name .
22,048
public static org . w3c . dom . Element convert ( org . jdom2 . Element node ) throws JDOMException { if ( node == null ) return null ; try { DOMOutputter outputter = new DOMOutputter ( ) ; return outputter . output ( node ) ; } catch ( JDOMException e ) { throw new RuntimeException ( "Error converting JDOM to DOM: " + e . getMessage ( ) , e ) ; } }
Convert a JDOM Element to a DOM Element
22,049
public static org . jdom2 . Element convert ( org . w3c . dom . Element node ) { if ( node == null ) return null ; DOMBuilder builder = new DOMBuilder ( ) ; return builder . build ( node ) ; }
Convert a DOM Element to a JDOM Element
22,050
public static synchronized void register ( Class < ? > clazz , boolean indexable ) { if ( ! resources . containsKey ( clazz ) ) { resources . put ( clazz , new RestResource ( clazz ) ) ; if ( indexable ) { IndexableServiceRegistry . register ( clazz ) ; } revision ++ ; } }
Register a new resource - N . B . currently this resource cannot be safely unregistered without restarting the webapp
22,051
public void validate ( final Node document ) throws SchemaValidationException { try { final Validator validator = schema . newValidator ( ) ; validator . validate ( new DOMSource ( document ) ) ; } catch ( SAXException | IOException e ) { throw new SchemaValidationException ( e . getMessage ( ) , e ) ; } }
Validate some XML against this schema
22,052
public String parse ( final String threshold , final RangeConfig tc ) { tc . setNegativeInfinity ( true ) ; if ( threshold . startsWith ( INFINITY ) ) { return threshold . substring ( INFINITY . length ( ) ) ; } else { return threshold . substring ( NEG_INFINITY . length ( ) ) ; } }
Parses the threshold to remove the matched - inf or inf string .
22,053
@ SuppressWarnings ( "rawtypes" ) private static void inject ( final Class c , final IPluginInterface plugin , final IJNRPEExecutionContext context ) throws IllegalAccessException { final Field [ ] fields = c . getDeclaredFields ( ) ; for ( final Field f : fields ) { final Annotation an = f . getAnnotation ( Inject . class ) ; if ( an != null ) { final boolean isAccessible = f . isAccessible ( ) ; if ( ! isAccessible ) { f . setAccessible ( true ) ; } f . set ( plugin , context ) ; if ( ! isAccessible ) { f . setAccessible ( false ) ; } } } }
Perform the real injection .
22,054
@ SuppressWarnings ( "rawtypes" ) public static void inject ( final IPluginInterface plugin , final IJNRPEExecutionContext context ) { try { Class clazz = plugin . getClass ( ) ; inject ( clazz , plugin , context ) ; while ( IPluginInterface . class . isAssignableFrom ( clazz . getSuperclass ( ) ) ) { clazz = clazz . getSuperclass ( ) ; inject ( clazz , plugin , context ) ; } } catch ( Exception e ) { throw new Error ( e . getMessage ( ) , e ) ; } }
Inject JNRPE code inside the passed in plugin . The annotation is searched in the whole hierarchy .
22,055
public String parse ( final String threshold , final RangeConfig tc ) throws RangeException { StringBuilder numberString = new StringBuilder ( ) ; for ( int i = 0 ; i < threshold . length ( ) ; i ++ ) { if ( Character . isDigit ( threshold . charAt ( i ) ) ) { numberString . append ( threshold . charAt ( i ) ) ; continue ; } if ( threshold . charAt ( i ) == '.' ) { if ( numberString . toString ( ) . endsWith ( "." ) ) { numberString . deleteCharAt ( numberString . length ( ) - 1 ) ; break ; } else { numberString . append ( threshold . charAt ( i ) ) ; continue ; } } if ( threshold . charAt ( i ) == '+' || threshold . charAt ( i ) == '-' ) { if ( numberString . length ( ) == 0 ) { numberString . append ( threshold . charAt ( i ) ) ; continue ; } else { throw new RangeException ( "Unexpected '" + threshold . charAt ( i ) + "' sign parsing boundary" ) ; } } break ; } if ( numberString . length ( ) != 0 && ! justSign ( numberString . toString ( ) ) ) { BigDecimal bd = new BigDecimal ( numberString . toString ( ) ) ; setBoundary ( tc , bd ) ; return threshold . substring ( numberString . length ( ) ) ; } else { throw new InvalidRangeSyntaxException ( this , threshold ) ; } }
Parses the threshold to remove the matched number string .
22,056
public boolean assessMatch ( final OgnlContext ognlContext ) throws OgnlException { if ( ! inputRun ) { throw new IllegalArgumentException ( "Attempted to match on a rule whose rulesets input has not yet been produced" ) ; } final Object result = condition . run ( ognlContext , ognlContext ) ; if ( result == null || ! Boolean . class . isAssignableFrom ( result . getClass ( ) ) ) { throw new IllegalArgumentException ( "Expression " + condition . getOriginalExpression ( ) + " did not return a boolean value" ) ; } matches = ( Boolean ) result ; return matches ; }
returns true if the rules condition holds should not be called until after the rule sets input has been produced
22,057
public static KeyStore loadCertificates ( final File pemFile ) { try ( final PemReader pem = new PemReader ( new FileReader ( pemFile ) ) ) { final KeyStore ks = createEmptyKeyStore ( ) ; int certIndex = 0 ; Object obj ; while ( ( obj = parse ( pem . readPemObject ( ) ) ) != null ) { if ( obj instanceof Certificate ) { final Certificate cert = ( Certificate ) obj ; ks . setCertificateEntry ( "cert" + Integer . toString ( certIndex ++ ) , cert ) ; } else { throw new RuntimeException ( "Unknown PEM contents: " + obj + ". Expected a Certificate" ) ; } } return ks ; } catch ( Exception e ) { throw new RuntimeException ( "Error parsing PEM " + pemFile , e ) ; } }
Load one or more X . 509 Certificates from a PEM file
22,058
public T get ( ) { T value = get ( null ) ; if ( value == null ) throw new RuntimeException ( "Missing property for JAXB resource: " + name ) ; else return value ; }
Resolve this property reference to a deserialised JAXB value
22,059
private T loadResourceValue ( final URL resource ) { try ( final InputStream is = resource . openStream ( ) ) { cached = null ; return setCached ( clazz . cast ( factory . getInstance ( clazz ) . deserialise ( is ) ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Error loading JAXB resource " + name + " " + clazz + " from " + resource , e ) ; } }
Load from a classpath resource ; reloads every time
22,060
private void analyze ( final List < Metric > metrics , final long elapsed , final Date now , final Date date ) { long diff = 0 ; boolean behind = false ; if ( now . before ( date ) ) { behind = true ; diff = date . getTime ( ) - now . getTime ( ) ; } else if ( now . after ( date ) ) { diff = now . getTime ( ) - date . getTime ( ) ; } Elapsed elapsedTime = new Elapsed ( diff , TimeUnit . MILLISECOND ) ; String msg = getMessage ( elapsedTime ) ; if ( diff > TimeUnit . SECOND . convert ( 1 ) ) { if ( behind ) { msg += "behind" ; } else { msg += "ahead" ; } } metrics . add ( new Metric ( "offset" , msg , new BigDecimal ( TimeUnit . MILLISECOND . convert ( diff , TimeUnit . SECOND ) ) , null , null ) ) ; metrics . add ( new Metric ( "time" , "" , new BigDecimal ( TimeUnit . MILLISECOND . convert ( elapsed , TimeUnit . SECOND ) ) , null , null ) ) ; }
Analizes the data and produces the metrics .
22,061
public String parse ( final String threshold , final RangeConfig tc ) { tc . setPositiveInfinity ( true ) ; if ( threshold . startsWith ( INFINITY ) ) { return threshold . substring ( INFINITY . length ( ) ) ; } else { return threshold . substring ( POS_INFINITY . length ( ) ) ; } }
Parses the threshold to remove the matched inf or + inf string .
22,062
public static String sha1hmac ( String key , String plaintext ) { return sha1hmac ( key , plaintext , ENCODE_HEX ) ; }
Performs HMAC - SHA1 on the UTF - 8 byte representation of strings
22,063
public static String sha1hmac ( String key , String plaintext , int encoding ) { byte [ ] signature = sha1hmac ( key . getBytes ( ) , plaintext . getBytes ( ) ) ; return encode ( signature , encoding ) ; }
Performs HMAC - SHA1 on the UTF - 8 byte representation of strings returning the hexidecimal hash as a result
22,064
private void register ( final Bundle bundle ) { LOG . debug ( "Scanning bundle [" + bundle . getSymbolicName ( ) + "]" ) ; final List < T > resources = m_scanner . scan ( bundle ) ; m_mappings . put ( bundle , resources ) ; if ( resources != null && resources . size ( ) > 0 ) { LOG . debug ( "Found resources " + resources ) ; for ( final BundleObserver < T > observer : m_observers ) { try { executorService . submit ( new Runnable ( ) { public void run ( ) { try { observer . addingEntries ( bundle , Collections . unmodifiableList ( resources ) ) ; } catch ( Throwable t ) { LOG . error ( "Exception in executor thread" , t ) ; } } } ) ; } catch ( Throwable ignore ) { LOG . error ( "Ignored exception during register" , ignore ) ; } } } }
Scans entries using the bundle scanner and registers the result of scanning process . Then notify the observers . If an exception appears during notification it is ignored .
22,065
private void unregister ( final Bundle bundle ) { if ( bundle == null ) return ; LOG . debug ( "Releasing bundle [" + bundle . getSymbolicName ( ) + "]" ) ; final List < T > resources = m_mappings . get ( bundle ) ; if ( resources != null && resources . size ( ) > 0 ) { LOG . debug ( "Un-registering " + resources ) ; for ( BundleObserver < T > observer : m_observers ) { try { observer . removingEntries ( bundle , Collections . unmodifiableList ( resources ) ) ; } catch ( Throwable ignore ) { LOG . error ( "Ignored exception during un-register" , ignore ) ; } } } m_mappings . remove ( bundle ) ; }
Un - registers each entry from the unregistered bundle by first notifying the observers . If an exception appears during notification it is ignored .
22,066
public static void verifyChain ( List < X509Certificate > chain ) { if ( chain == null || chain . isEmpty ( ) ) throw new IllegalArgumentException ( "Must provide a chain that is non-null and non-empty" ) ; for ( int i = 0 ; i < chain . size ( ) ; i ++ ) { final X509Certificate certificate = chain . get ( i ) ; final int issuerIndex = ( i != 0 ) ? i - 1 : 0 ; final X509Certificate issuer = chain . get ( issuerIndex ) ; try { certificate . verify ( issuer . getPublicKey ( ) ) ; } catch ( GeneralSecurityException e ) { final String msg = "Failure verifying " + certificate + " against claimed issuer " + issuer ; throw new IllegalArgumentException ( msg + ": " + e . getMessage ( ) , e ) ; } } }
Verifies that a certificate chain is valid
22,067
public static void main ( String args [ ] ) { String home = "/home/user1/content/myfolder" ; String file = "/home/user1/figures/fig.png" ; System . out . println ( "home = " + home ) ; System . out . println ( "file = " + file ) ; System . out . println ( "path = " + getRelativePath ( new File ( home ) , new File ( file ) ) ) ; }
test the function
22,068
private InjectingEntityResolver createEntityResolver ( EntityResolver resolver ) { if ( getEntities ( ) != null ) { return new InjectingEntityResolver ( getEntities ( ) , resolver , getType ( ) , getLog ( ) ) ; } else { return null ; } }
Creates an XML entity resolver .
22,069
protected URL getNonDefaultStylesheetURL ( ) { if ( getNonDefaultStylesheetLocation ( ) != null ) { URL url = this . getClass ( ) . getClassLoader ( ) . getResource ( getNonDefaultStylesheetLocation ( ) ) ; return url ; } else { return null ; } }
Returns the URL of the default stylesheet .
22,070
private String [ ] scanIncludedFiles ( ) { final DirectoryScanner scanner = new DirectoryScanner ( ) ; scanner . setBasedir ( sourceDirectory ) ; scanner . setIncludes ( new String [ ] { inputFilename } ) ; scanner . scan ( ) ; return scanner . getIncludedFiles ( ) ; }
Returns the list of docbook files to include .
22,071
void setHTTPResponse ( HTTPResponse resp ) { lock . lock ( ) ; try { if ( response != null ) { throw ( new IllegalStateException ( "HTTPResponse was already set" ) ) ; } response = resp ; ready . signalAll ( ) ; } finally { lock . unlock ( ) ; } }
Set the HTTPResponse instance .
22,072
HTTPResponse getHTTPResponse ( ) { lock . lock ( ) ; try { while ( response == null ) { try { ready . await ( ) ; } catch ( InterruptedException intx ) { LOG . log ( Level . FINEST , "Interrupted" , intx ) ; } } return response ; } finally { lock . unlock ( ) ; } }
Get the HTTPResponse instance .
22,073
private static List < String > loadServicesImplementations ( final Class < ? > ofClass ) { List < String > result = new ArrayList < String > ( ) ; String override = System . getProperty ( ofClass . getName ( ) ) ; if ( override != null ) { result . add ( override ) ; } ClassLoader loader = ServiceLib . class . getClassLoader ( ) ; URL url = loader . getResource ( "org.igniterealtime.jbosh/" + ofClass . getName ( ) ) ; if ( url == null ) { return result ; } InputStream inStream = null ; InputStreamReader reader = null ; BufferedReader bReader = null ; try { inStream = url . openStream ( ) ; reader = new InputStreamReader ( inStream ) ; bReader = new BufferedReader ( reader ) ; String line ; while ( ( line = bReader . readLine ( ) ) != null ) { if ( ! line . matches ( "\\s*(#.*)?" ) ) { result . add ( line . trim ( ) ) ; } } } catch ( IOException iox ) { LOG . log ( Level . WARNING , "Could not load services descriptor: " + url . toString ( ) , iox ) ; } finally { finalClose ( bReader ) ; finalClose ( reader ) ; finalClose ( inStream ) ; } return result ; }
Generates a list of implementation class names by using the Jar SPI technique . The order in which the class names occur in the service manifest is significant .
22,074
private static < T > T attemptLoad ( final Class < T > ofClass , final String className ) { if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "Attempting service load: " + className ) ; } Level level ; Throwable thrown ; try { Class < ? > clazz = Class . forName ( className ) ; if ( ! ofClass . isAssignableFrom ( clazz ) ) { if ( LOG . isLoggable ( Level . WARNING ) ) { LOG . warning ( clazz . getName ( ) + " is not assignable to " + ofClass . getName ( ) ) ; } return null ; } return ofClass . cast ( clazz . newInstance ( ) ) ; } catch ( LinkageError ex ) { level = Level . FINEST ; thrown = ex ; } catch ( ClassNotFoundException ex ) { level = Level . FINEST ; thrown = ex ; } catch ( InstantiationException ex ) { level = Level . WARNING ; thrown = ex ; } catch ( IllegalAccessException ex ) { level = Level . WARNING ; thrown = ex ; } LOG . log ( level , "Could not load " + ofClass . getSimpleName ( ) + " instance: " + className , thrown ) ; return null ; }
Attempts to load the specified implementation class . Attempts will fail if - for example - the implementation depends on a class not found on the classpath .
22,075
private static void finalClose ( final Closeable closeMe ) { if ( closeMe != null ) { try { closeMe . close ( ) ; } catch ( IOException iox ) { LOG . log ( Level . FINEST , "Could not close: " + closeMe , iox ) ; } } }
Check and close a closeable object trapping and ignoring any exception that might result .
22,076
public synchronized ConfigurationAgent getConfigurationAgent ( ) { if ( this . configurationAgent == null ) { if ( isService ) { this . configurationAgent = new ConfigurationAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . configurationAgent = new ConfigurationAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . configurationAgent ; }
Returns a ConfigurationAgent with which requests regarding Configurations can be sent to the NFVO .
22,077
public synchronized NetworkServiceDescriptorAgent getNetworkServiceDescriptorAgent ( ) { if ( this . networkServiceDescriptorAgent == null ) { if ( isService ) { this . networkServiceDescriptorAgent = new NetworkServiceDescriptorAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . networkServiceDescriptorAgent = new NetworkServiceDescriptorAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . networkServiceDescriptorAgent ; }
Returns a NetworkServiceDescriptorAgent with which requests regarding NetworkServiceDescriptors can be sent to the NFVO .
22,078
public synchronized NetworkServiceRecordAgent getNetworkServiceRecordAgent ( ) { if ( this . networkServiceRecordAgent == null ) { if ( isService ) { this . networkServiceRecordAgent = new NetworkServiceRecordAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . networkServiceRecordAgent = new NetworkServiceRecordAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . networkServiceRecordAgent ; }
Returns a NetworkServiceRecordAgent with which requests regarding NetworkServiceRecords can be sent to the NFVO .
22,079
public synchronized VimInstanceAgent getVimInstanceAgent ( ) { if ( this . vimInstanceAgent == null ) { if ( isService ) { this . vimInstanceAgent = new VimInstanceAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . vimInstanceAgent = new VimInstanceAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . vimInstanceAgent ; }
Returns a VimInstanceAgent with which requests regarding VimInstances can be sent to the NFVO .
22,080
public synchronized VirtualLinkAgent getVirtualLinkAgent ( ) { if ( this . virtualLinkAgent == null ) { if ( isService ) { this . virtualLinkAgent = new VirtualLinkAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . virtualLinkAgent = new VirtualLinkAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . virtualLinkAgent ; }
Returns a VirtualLinkAgent with which requests regarding VirtualLinks can be sent to the NFVO .
22,081
public synchronized VirtualNetworkFunctionDescriptorAgent getVirtualNetworkFunctionDescriptorRestAgent ( ) { if ( this . virtualNetworkFunctionDescriptorAgent == null ) { if ( isService ) { this . virtualNetworkFunctionDescriptorAgent = new VirtualNetworkFunctionDescriptorAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . virtualNetworkFunctionDescriptorAgent = new VirtualNetworkFunctionDescriptorAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . virtualNetworkFunctionDescriptorAgent ; }
Returns a VirtualNetworkFunctionDescriptorAgent with which requests regarding VirtualNetworkFunctionDescriptors can be sent to the NFVO .
22,082
public synchronized VNFFGAgent getVNFFGAgent ( ) { if ( this . vnffgAgent == null ) { if ( isService ) { this . vnffgAgent = new VNFFGAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . vnffgAgent = new VNFFGAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . vnffgAgent ; }
Returns a VNFFGAgent with which requests regarding VNFFGAgent can be sent to the NFVO .
22,083
public synchronized EventAgent getEventAgent ( ) { if ( this . eventAgent == null ) { if ( isService ) { this . eventAgent = new EventAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . eventAgent = new EventAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . eventAgent ; }
Returns an EventAgent with which requests regarding Events can be sent to the NFVO .
22,084
public synchronized VNFPackageAgent getVNFPackageAgent ( ) { if ( this . vnfPackageAgent == null ) { if ( isService ) { this . vnfPackageAgent = new VNFPackageAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . vnfPackageAgent = new VNFPackageAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . vnfPackageAgent ; }
Returns a VNFPackageAgent with which requests regarding VNFPackages can be sent to the NFVO .
22,085
public synchronized ProjectAgent getProjectAgent ( ) { if ( this . projectAgent == null ) { if ( isService ) { this . projectAgent = new ProjectAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . projectAgent = new ProjectAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . projectAgent ; }
Returns a ProjectAgent with which requests regarding Projects can be sent to the NFVO .
22,086
public synchronized UserAgent getUserAgent ( ) { if ( this . userAgent == null ) { if ( isService ) { this . userAgent = new UserAgent ( this . serviceName , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version , this . serviceKey ) ; } else { this . userAgent = new UserAgent ( this . username , this . password , this . projectId , this . sslEnabled , this . nfvoIp , this . nfvoPort , this . version ) ; } } return this . userAgent ; }
Returns a UserAgent with which requests regarding Users can be sent to the NFVO .
22,087
private String getProjectIdForProjectName ( String projectName ) throws SDKException { String projectId = this . getProjectAgent ( ) . findAll ( ) . stream ( ) . filter ( p -> p . getName ( ) . equals ( projectName ) ) . findFirst ( ) . orElseThrow ( ( ) -> new SDKException ( "Did not find a Project named " + projectName , null , "Did not find a Project named " + projectName ) ) . getId ( ) ; this . projectAgent = null ; return projectId ; }
Return the project id for a given project name .
22,088
private void resetAgents ( ) { this . configurationAgent = null ; this . keyAgent = null ; this . userAgent = null ; this . vnfPackageAgent = null ; this . projectAgent = null ; this . eventAgent = null ; this . vnffgAgent = null ; this . virtualNetworkFunctionDescriptorAgent = null ; this . virtualLinkAgent = null ; this . vimInstanceAgent = null ; this . networkServiceDescriptorAgent = null ; this . networkServiceRecordAgent = null ; this . serviceAgent = null ; }
Set all the agent objects to null .
22,089
@ Help ( help = "Get all the VirtualNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id" ) public List < VirtualNetworkFunctionDescriptor > getVirtualNetworkFunctionDescriptors ( final String idNSD ) throws SDKException { String url = idNSD + "/vnfdescriptors" ; return Arrays . asList ( ( VirtualNetworkFunctionDescriptor [ ] ) requestGetAll ( url , VirtualNetworkFunctionDescriptor . class ) ) ; }
Get all VirtualNetworkFunctionDescriptors contained in a NetworkServiceDescriptor specified by its ID .
22,090
@ Help ( help = "Get a specific VirtualNetworkFunctionDescriptor of a particular NetworkServiceDescriptor specified by their IDs" ) public VirtualNetworkFunctionDescriptor getVirtualNetworkFunctionDescriptor ( final String idNSD , final String idVfn ) throws SDKException { String url = idNSD + "/vnfdescriptors" + "/" + idVfn ; return ( VirtualNetworkFunctionDescriptor ) requestGet ( url , VirtualNetworkFunctionDescriptor . class ) ; }
Return a VirtualNetworkFunctionDescriptor that is contained in a particular NetworkServiceDescriptor .
22,091
@ Help ( help = "Delete the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public void deleteVirtualNetworkFunctionDescriptors ( final String idNSD , final String idVnf ) throws SDKException { String url = idNSD + "/vnfdescriptors" + "/" + idVnf ; requestDelete ( url ) ; }
Delete a specific VirtualNetworkFunctionDescriptor that is contained in a particular NetworkServiceDescriptor .
22,092
@ Help ( help = "create the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public VirtualNetworkFunctionDescriptor createVNFD ( final String idNSD , final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor ) throws SDKException { String url = idNSD + "/vnfdescriptors" + "/" ; return ( VirtualNetworkFunctionDescriptor ) requestPost ( url , virtualNetworkFunctionDescriptor ) ; }
Create a VirtualNetworkFunctionDescriptor in a specific NetworkServiceDescriptor .
22,093
@ Help ( help = "Update the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public VirtualNetworkFunctionDescriptor updateVNFD ( final String idNSD , final String idVfn , final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor ) throws SDKException { String url = idNSD + "/vnfdescriptors" + "/" + idVfn ; return ( VirtualNetworkFunctionDescriptor ) requestPut ( url , virtualNetworkFunctionDescriptor ) ; }
Update a specific VirtualNetworkFunctionDescriptor that is contained in a particular NetworkServiceDescriptor .
22,094
@ Help ( help = "Get all the VirtualNetworkFunctionDescriptor Dependency of a NetworkServiceDescriptor with specific id" ) public List < VNFDependency > getVNFDependencies ( final String idNSD ) throws SDKException { String url = idNSD + "/vnfdependencies" ; return Arrays . asList ( ( VNFDependency [ ] ) requestGetAll ( url , VNFDependency . class ) ) ; }
Return a List with all the VNFDependencies that are contained in a specific NetworkServiceDescriptor .
22,095
@ Help ( help = "get the VirtualNetworkFunctionDescriptor dependency with specific id of a NetworkServiceDescriptor with specific id" ) public VNFDependency getVNFDependency ( final String idNSD , final String idVnfd ) throws SDKException { String url = idNSD + "/vnfdependencies" + "/" + idVnfd ; return ( VNFDependency ) requestGet ( url , VNFDependency . class ) ; }
Return a specific VNFDependency that is contained in a particular NetworkServiceDescriptor .
22,096
@ Help ( help = "Delete the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id" ) public void deleteVNFDependency ( final String idNSD , final String idVnfd ) throws SDKException { String url = idNSD + "/vnfdependencies" + "/" + idVnfd ; requestDelete ( url ) ; }
Delete a VNFDependency .
22,097
@ Help ( help = "Create the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id" ) public VNFDependency createVNFDependency ( final String idNSD , final VNFDependency vnfDependency ) throws SDKException { String url = idNSD + "/vnfdependencies" + "/" ; return ( VNFDependency ) requestPost ( url , vnfDependency ) ; }
Add a new VNFDependency to a specific NetworkServiceDescriptor .
22,098
@ Help ( help = "Update the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id" ) public VNFDependency updateVNFD ( final String idNSD , final String idVnfDep , final VNFDependency vnfDependency ) throws SDKException { String url = idNSD + "/vnfdependencies" + "/" + idVnfDep ; return ( VNFDependency ) requestPut ( url , vnfDependency ) ; }
Update a specific VNFDependency which is contained in a particular NetworkServiceDescriptor .
22,099
@ Help ( help = "Get all the PhysicalNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id" ) public List < PhysicalNetworkFunctionDescriptor > getPhysicalNetworkFunctionDescriptors ( final String idNSD ) throws SDKException { String url = idNSD + "/pnfdescriptors" ; return Arrays . asList ( ( PhysicalNetworkFunctionDescriptor [ ] ) requestGetAll ( url , PhysicalNetworkFunctionDescriptor . class ) ) ; }
Returns the List of PhysicalNetworkFunctionDescriptors that are contained in a specific NetworkServiceDescriptor .