idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
134,500
public static void saveRelationsFile ( FileDefinition relationsFile , boolean writeComments , String lineSeparator ) throws IOException { if ( relationsFile . getEditedFile ( ) == null ) throw new IOException ( "Save operation could not be performed. The model was not loaded from a local file." ) ; saveRelationsFileInt...
Saves the model into the original file .
134,501
public static void saveRelationsFileInto ( File targetFile , FileDefinition relationsFile , boolean writeComments , String lineSeparator ) throws IOException { String s = writeConfigurationFile ( relationsFile , writeComments , lineSeparator ) ; Utils . copyStream ( new ByteArrayInputStream ( s . getBytes ( StandardCha...
Saves the model into another file .
134,502
public static String labelFromCamelCase ( String camel ) { StringBuilder label = new StringBuilder ( ) ; for ( int i = 0 ; i < camel . length ( ) ; i ++ ) { char c = camel . charAt ( i ) ; if ( Character . isDigit ( c ) ) { if ( i > 0 && Character . isAlphabetic ( camel . charAt ( i - 1 ) ) ) label . append ( " " ) ; }...
Converts a camelcase variable name to a human readable text .
134,503
AbstractCommandExecution findExecutor ( AbstractCommandInstruction instr ) { AbstractCommandExecution result = null ; if ( RenameCommandInstruction . class . equals ( instr . getClass ( ) ) ) result = new RenameCommandExecution ( ( RenameCommandInstruction ) instr ) ; else if ( ReplicateCommandInstruction . class . equ...
Finds the right executor for an instruction .
134,504
private String convertPropertyFileLineToJSon ( String line , String json ) { if ( line == null ) return json ; String l = line . trim ( ) ; if ( l . length ( ) == 0 || l . startsWith ( "//" ) ) return json ; boolean inString = l . startsWith ( "\"" ) ; String english ; String rest ; if ( inString ) { boolean esc = fals...
Note this method has a side effect - it also fills the HashMap of translations .
134,505
public void targetAppears ( TargetHandler targetItf ) { this . defaultTargetHandlerResolver . addTargetHandler ( targetItf ) ; if ( this . timer != null ) restoreInstancesFrom ( targetItf ) ; }
This method is invoked by iPojo every time a new target handler appears .
134,506
public void setTargetResolver ( ITargetHandlerResolver targetHandlerResolver ) { if ( targetHandlerResolver == null ) { this . targetConfigurator . setTargetHandlerResolver ( this . defaultTargetHandlerResolver ) ; this . instancesMngr . setTargetHandlerResolver ( this . defaultTargetHandlerResolver ) ; } else { this ....
Sets the target resolver .
134,507
void restoreAllInstances ( ) { this . logger . fine ( "Restoring all the instance states from the current target handlers." ) ; for ( ManagedApplication ma : this . applicationMngr . getManagedApplications ( ) ) { List < TargetHandler > snapshot = this . defaultTargetHandlerResolver . getTargetHandlersSnapshot ( ) ; fo...
Restores the states of all the instances from the current target handlers .
134,508
void restoreInstancesFrom ( TargetHandler targetHandler ) { this . logger . fine ( "Restoring the instance states with the '" + targetHandler . getTargetId ( ) + "' target handler." ) ; for ( ManagedApplication ma : this . applicationMngr . getManagedApplications ( ) ) instancesMngr ( ) . restoreInstanceStates ( ma , t...
Restores the states of all the instances from a given target handler .
134,509
public boolean addMessagingClientFactory ( IMessagingClientFactory factory ) { final String type = factory . getType ( ) ; this . logger . fine ( "Adding messaging client factory: " + type ) ; final boolean result = this . factories . putIfAbsent ( type , factory ) == null ; if ( result ) notifyListeners ( factory , tr...
Adds a messaging client factory to this registry unless a similar one was already registered .
134,510
public boolean removeMessagingClientFactory ( IMessagingClientFactory factory ) { final String type = factory . getType ( ) ; this . logger . fine ( "Removing messaging client factory: " + type ) ; final boolean result = this . factories . remove ( type , factory ) ; if ( result ) notifyListeners ( factory , false ) ; ...
Removes a messaging client factory from this registry .
134,511
public static Object getValueToRender ( FacesContext context , UIComponent component ) { if ( component instanceof ValueHolder ) { if ( component instanceof EditableValueHolder ) { EditableValueHolder input = ( EditableValueHolder ) component ; Object submittedValue = input . getSubmittedValue ( ) ; ConfigContainer con...
This method has been copied from the PrimeFaces 5 project .
134,512
public void acknowledgeHeartBeat ( Instance scopedInstance ) { String count = scopedInstance . data . get ( MISSED_HEARTBEATS ) ; if ( count != null && Integer . parseInt ( count ) > THRESHOLD ) this . logger . info ( "Agent " + InstanceHelpers . computeInstancePath ( scopedInstance ) + " is alive and reachable again."...
Acknowledges a heart beat .
134,513
public void checkStates ( INotificationMngr notificationMngr ) { Collection < Instance > scopedInstances = InstanceHelpers . findAllScopedInstances ( this . application ) ; for ( Instance scopedInstance : scopedInstances ) { if ( scopedInstance . getStatus ( ) == InstanceStatus . NOT_DEPLOYED || scopedInstance . getSta...
Check the scoped instances states with respect to missed heart beats .
134,514
public static void markScopedInstanceAsNotDeployed ( Instance scopedInstance , ManagedApplication ma , INotificationMngr notificationMngr , IInstancesMngr instanceMngr ) { scopedInstance . data . remove ( Instance . IP_ADDRESS ) ; scopedInstance . data . remove ( Instance . MACHINE_ID ) ; scopedInstance . data . remove...
Updates a scoped instance and its children to be marked as not deployed .
134,515
private void dealWithMainComponent ( ) { this . typeToLocation . put ( this . component , new Point2D . Double ( this . hMargin , this . currentHeigth ) ) ; int width = H_PADDING + GraphUtils . computeShapeWidth ( this . component ) ; this . maxRowWidth = Math . max ( this . maxRowWidth , width ) ; this . aloneOnRow . ...
Finds the position for the main component .
134,516
private void dealWithOthers ( Collection < AbstractType > others ) { int col = 1 ; this . currentWidth = this . hMargin ; for ( AbstractType t : others ) { if ( col > this . maxPerLine ) { col = 1 ; this . currentHeigth += V_PADDING + GraphUtils . SHAPE_HEIGHT ; this . currentWidth = this . hMargin ; } this . typeToLoc...
Finds the position of other components .
134,517
public static URI buildNewURI ( URI referenceUri , String uriSuffix ) throws URISyntaxException { if ( uriSuffix == null ) throw new IllegalArgumentException ( "The URI suffix cannot be null." ) ; uriSuffix = uriSuffix . replaceAll ( "\\\\" , "/" ) ; URI importUri = null ; try { importUri = urlToUri ( new URL ( uriSuff...
Builds an URI from an URI and a suffix .
134,518
public static int executeCommand ( final Logger logger , final String [ ] command , final File workingDir , final Map < String , String > environmentVars , final String applicationName , final String scopedInstancePath ) throws IOException , InterruptedException { ExecutionResult result = executeCommandWithResult ( log...
Executes a command on the VM and logs the output .
134,519
public static int executeCommand ( final Logger logger , final List < String > command , final File workingDir , final Map < String , String > environmentVars , final String applicationName , final String scopedInstanceName ) throws IOException , InterruptedException { return executeCommand ( logger , command . toArray...
Executes a command on the VM and prints on the console its output .
134,520
public static List < DockerCommand > dockerfileToCommandList ( File dockerfile ) throws IOException { List < DockerCommand > result = new ArrayList < > ( ) ; FileInputStream in = new FileInputStream ( dockerfile ) ; Logger logger = Logger . getLogger ( DockerfileParser . class . getName ( ) ) ; BufferedReader br = null...
Parses a dockerfile to a list of commands .
134,521
public void enableCors ( boolean enableCors ) { if ( enableCors ) getProperties ( ) . put ( ResourceConfig . PROPERTY_CONTAINER_RESPONSE_FILTERS , ResponseCorsFilter . class . getName ( ) ) ; else getProperties ( ) . remove ( ResourceConfig . PROPERTY_CONTAINER_RESPONSE_FILTERS ) ; }
Enables or disables CORS .
134,522
public static String getVMIP ( String hostIpPort , String id ) throws TargetException { if ( ! hostIpPort . endsWith ( "/compute" ) && id . startsWith ( "urn:uuid:" ) ) id = id . substring ( 9 ) ; String vmIp = null ; URL url = null ; try { CookieHandler . setDefault ( new CookieManager ( null , CookiePolicy . ACCEPT_A...
Retrieves VM IP .
134,523
public static boolean isVMRunning ( String hostIpPort , String id ) throws TargetException { boolean result = false ; String ip = OcciVMUtils . getVMIP ( hostIpPort , id ) ; try { InetAddress inet = InetAddress . getByName ( ip ) ; result = inet . isReachable ( 5000 ) ; } catch ( Exception e ) { result = false ; final ...
Checks if VM is running .
134,524
public String createTarget ( String targetContent ) throws IOException { TargetValidator tv = new TargetValidator ( targetContent ) ; tv . validate ( ) ; if ( RoboconfErrorHelpers . containsCriticalErrors ( tv . getErrors ( ) ) ) throw new IOException ( "There are errors in the target definition." ) ; String targetId =...
CRUD operations on targets
134,525
public Map < String , byte [ ] > findScriptResourcesForAgent ( String targetId ) throws IOException { Map < String , byte [ ] > result = new HashMap < > ( 0 ) ; File targetDir = new File ( findTargetDirectory ( targetId ) , Constants . PROJECT_SUB_DIR_SCRIPTS ) ; if ( targetDir . isDirectory ( ) ) { List < String > exc...
Finding script resources
134,526
public List < TargetWrapperDescriptor > listPossibleTargets ( AbstractApplication app ) { String key = new InstanceContext ( app ) . toString ( ) ; String tplKey = null ; if ( app instanceof Application ) tplKey = new InstanceContext ( ( ( Application ) app ) . getTemplate ( ) ) . toString ( ) ; List < File > targetDir...
In relation with hints
134,527
public TargetProperties lockAndGetTarget ( Application app , Instance scopedInstance ) throws IOException { String instancePath = InstanceHelpers . computeInstancePath ( scopedInstance ) ; String targetId = findTargetId ( app , instancePath ) ; if ( targetId == null ) throw new IOException ( "No target was found for " ...
Atomic operations ...
134,528
public static void verify ( CommandExecutionContext executionContext , Component component ) throws CommandException { if ( executionContext != null && Constants . TARGET_INSTALLER . equalsIgnoreCase ( component . getInstallerName ( ) ) && executionContext . getMaxVm ( ) > 0 && executionContext . getMaxVm ( ) <= execut...
Verifies a new VM model can be created according to a given context .
134,529
public static void update ( CommandExecutionContext executionContext , Instance createdInstance ) { if ( executionContext != null ) { createdInstance . data . put ( executionContext . getNewVmMarkerKey ( ) , executionContext . getNewVmMarkerValue ( ) ) ; executionContext . getGlobalVmNumber ( ) . incrementAndGet ( ) ; ...
Updates an instance with context information .
134,530
public static List < ModelError > validateComponentRecipes ( File applicationFilesDirectory , Component component ) { List < ModelError > result ; if ( "puppet" . equalsIgnoreCase ( component . getInstallerName ( ) ) ) result = validatePuppetComponent ( applicationFilesDirectory , component ) ; else if ( "script" . equ...
Validates the recipes of a component .
134,531
private static void checkPuppetFile ( File pp , boolean withUpdateParams , Component component , Collection < ModelError > errors ) throws IOException { String [ ] cmd = { "puppet" , "parser" , "validate" , pp . getAbsolutePath ( ) } ; Logger logger = Logger . getLogger ( RecipesValidator . class . getName ( ) ) ; try ...
Reads a Puppet script and validates it .
134,532
public static String findManifestProperty ( String propertyName ) { String result = null ; InputStream is = null ; try { is = ManifestUtils . class . getResourceAsStream ( "/META-INF/MANIFEST.MF" ) ; Properties props = new Properties ( ) ; props . load ( is ) ; result = findManifestProperty ( props , propertyName ) ; }...
Finds a property in the MANIFEST file .
134,533
public static String findManifestProperty ( Properties props , String propertyName ) { String result = null ; for ( Map . Entry < Object , Object > entry : props . entrySet ( ) ) { if ( propertyName . equalsIgnoreCase ( String . valueOf ( entry . getKey ( ) ) ) ) { result = String . valueOf ( entry . getValue ( ) ) ; b...
Finds a property in the MANIFEST properties .
134,534
public static ErrorDetails applicationTpl ( String tplName , String tplVersion ) { return new ErrorDetails ( tplName + " (" + tplVersion + ")" , ErrorDetailsKind . APPLICATION_TEMPLATE ) ; }
Details for an application .
134,535
public static ErrorDetails exception ( Throwable t ) { return new ErrorDetails ( Utils . writeExceptionButDoNotUseItForLogging ( t ) , ErrorDetailsKind . EXCEPTION ) ; }
Details for an exception .
134,536
public static ErrorDetails exceptionName ( Throwable t ) { return new ErrorDetails ( t . getClass ( ) . getName ( ) , ErrorDetailsKind . EXCEPTION_NAME ) ; }
Details for an exception name .
134,537
static AzureProperties buildProperties ( Map < String , String > targetProperties ) throws TargetException { String [ ] properties = { AzureConstants . AZURE_SUBSCRIPTION_ID , AzureConstants . AZURE_KEY_STORE_FILE , AzureConstants . AZURE_KEY_STORE_PASSWORD , AzureConstants . AZURE_CREATE_CLOUD_SERVICE_TEMPLATE , Azure...
Validates the received properties and builds a Java bean from them .
134,538
public static ApplicationTemplateDescriptor load ( File f ) throws IOException { String fileContent = Utils . readFileContent ( f ) ; Logger logger = Logger . getLogger ( ApplicationTemplateDescriptor . class . getName ( ) ) ; Properties properties = Utils . readPropertiesQuietly ( fileContent , logger ) ; if ( propert...
Loads an application template s descriptor .
134,539
public static void save ( File f , ApplicationTemplateDescriptor descriptor ) throws IOException { Properties properties = new Properties ( ) ; if ( descriptor . name != null ) properties . setProperty ( APPLICATION_NAME , descriptor . name ) ; if ( descriptor . version != null ) properties . setProperty ( APPLICATION_...
Saves an application template s descriptor .
134,540
static String getLegacyProperty ( Properties props , String property , String defaultValue ) { String result = props . getProperty ( property , null ) ; if ( result == null ) result = props . getProperty ( LEGACY_PREFIX + property , defaultValue ) ; return result ; }
Gets a property value while supporting legacy ones .
134,541
public static void createProjectSkeleton ( File targetDirectory , CreationBean creationBean ) throws IOException { if ( creationBean . isMavenProject ( ) ) createMavenProject ( targetDirectory , creationBean ) ; else createSimpleProject ( targetDirectory , creationBean ) ; }
Creates a project for Roboconf .
134,542
public static List < File > createRecipeDirectories ( File applicationDirectory ) throws IOException { List < File > result = new ArrayList < > ( ) ; ApplicationLoadResult alr = RuntimeModelIo . loadApplicationFlexibly ( applicationDirectory ) ; if ( alr . getApplicationTemplate ( ) != null ) { for ( Component c : Comp...
Creates the recipes directories for a Roboconf components .
134,543
private static void createSimpleProject ( File targetDirectory , CreationBean creationBean ) throws IOException { String [ ] directoriesToCreate = creationBean . isReusableRecipe ( ) ? RR_DIRECTORIES : ALL_DIRECTORIES ; for ( String s : directoriesToCreate ) { File dir = new File ( targetDirectory , s ) ; Utils . creat...
Creates a simple project for Roboconf .
134,544
private static void createMavenProject ( File targetDirectory , CreationBean creationBean ) throws IOException { File rootDir = new File ( targetDirectory , Constants . MAVEN_SRC_MAIN_MODEL ) ; String [ ] directoriesToCreate = creationBean . isReusableRecipe ( ) ? RR_DIRECTORIES : ALL_DIRECTORIES ; for ( String s : dir...
Creates a Maven project for Roboconf .
134,545
private static void completeProjectCreation ( File targetDirectory , String descriptorContent , CreationBean creationBean ) throws IOException { File f = new File ( targetDirectory , Constants . PROJECT_DIR_GRAPH + "/" + GRAPH_EP ) ; InputStream in = ProjectUtils . class . getResourceAsStream ( "/graph-skeleton.graph" ...
Completes the creation of a Roboconf project .
134,546
private static ErrorDetails [ ] addLineAndFile ( int line , File file , ErrorDetails ... details ) { Set < ErrorDetails > updatedDetails = new LinkedHashSet < > ( ) ; if ( details != null ) updatedDetails . addAll ( Arrays . asList ( details ) ) ; if ( file != null ) { updatedDetails . add ( file ( file ) ) ; updatedDe...
Adds details about the line number and the file .
134,547
public static Map < String , String > buildReferenceMap ( Instance instance ) { Map < String , String > result = new HashMap < > ( ) ; String instancePath = InstanceHelpers . computeInstancePath ( instance ) ; result . put ( ROBOCONF_INSTANCE_NAME , instance . getName ( ) ) ; result . put ( ROBOCONF_INSTANCE_PATH , ins...
Builds a map with the variables defined by this class .
134,548
List < MonitoringHandlerRun > extractRuleSections ( File file , String fileContent , Properties params ) { StringBuilder sb = new StringBuilder ( ) ; List < String > sections = new ArrayList < String > ( ) ; for ( String s : Arrays . asList ( fileContent . trim ( ) . split ( "\n" ) ) ) { s = s . trim ( ) ; if ( s . len...
Reads the file content extracts rules sections and prepares the handler invocations .
134,549
public void setTags ( Collection < String > tags ) { synchronized ( this . tags ) { this . tags . clear ( ) ; if ( tags != null ) this . tags . addAll ( tags ) ; } }
Replaces all the tags .
134,550
public void validate ( ) { ErrorDetails details = null ; if ( this . fileName != null ) details = ErrorDetails . file ( this . fileName ) ; if ( this . failed ) { this . errors . add ( new ModelError ( ErrorCode . REC_TARGET_INVALID_FILE_OR_CONTENT , this . modelObject , details ) ) ; } else { String id = this . props ...
Validates target properties .
134,551
public static List < ModelError > parseDirectory ( File directory , Component c ) { List < ModelError > result = new ArrayList < > ( ) ; Set < String > targetIds = new HashSet < > ( ) ; for ( File f : Utils . listDirectFiles ( directory , Constants . FILE_EXT_PROPERTIES ) ) { TargetValidator tv = new TargetValidator ( ...
Parses a directory with one or several properties files .
134,552
public static List < ModelError > parseTargetProperties ( File projectDirectory , Component c ) { List < ModelError > errors ; File dir = ResourceUtils . findInstanceResourcesDirectory ( projectDirectory , c ) ; if ( dir . isDirectory ( ) && ! Utils . listAllFiles ( dir , Constants . FILE_EXT_PROPERTIES ) . isEmpty ( )...
Parses the target properties for a given component .
134,553
static int fixSelectionLength ( String fullText , int selectionOffset , int selectionLength ) { if ( selectionLength < 0 ) selectionLength = 0 ; else if ( selectionOffset + selectionLength > fullText . length ( ) ) selectionLength = fullText . length ( ) - selectionOffset ; for ( ; selectionOffset + selectionLength < f...
Fixes the selection length to get the whole line .
134,554
void createImage ( String imageId ) throws TargetException { File targetDirectory = this . parameters . getTargetPropertiesDirectory ( ) ; String dockerFilePath = this . parameters . getTargetProperties ( ) . get ( GENERATE_IMAGE_FROM ) ; if ( ! Utils . isEmptyOrWhitespaces ( dockerFilePath ) && targetDirectory != null...
Creates an image .
134,555
public String login ( String user , String pwd ) { String token = null ; try { this . authService . authenticate ( user , pwd ) ; token = UUID . randomUUID ( ) . toString ( ) ; Long now = new Date ( ) . getTime ( ) ; this . tokenToLoginTime . put ( token , now ) ; this . tokenToUsername . put ( token , user ) ; } catch...
Authenticates a user and creates a new session .
134,556
public boolean isSessionValid ( final String token , long validityPeriod ) { boolean valid = false ; Long loginTime = null ; if ( token != null ) loginTime = this . tokenToLoginTime . get ( token ) ; if ( validityPeriod < 0 ) { valid = loginTime != null ; } else if ( loginTime != null ) { long now = new Date ( ) . getT...
Determines whether a session is valid .
134,557
public void processEvent ( SystemEvent event ) throws AbortProcessingException { if ( ! FacesContext . getCurrentInstance ( ) . isPostback ( ) ) { insertLabelBeforeThisInputField ( ) ; insertMessageBehindThisInputField ( ) ; } }
Catching the PreRenderViewEvent allows AngularFaces to modify the JSF tree by adding a label and a message .
134,558
private boolean associateElasticIp ( ) { String elasticIp = this . targetProperties . get ( Ec2Constants . ELASTIC_IP ) ; if ( ! Utils . isEmptyOrWhitespaces ( elasticIp ) ) { this . logger . fine ( "Associating an elastic IP with the instance. IP = " + elasticIp ) ; AssociateAddressRequest associateAddressRequest = ne...
Associates an elastic IP with the VM .
134,559
private String createVolume ( String storageId , String snapshotId , int size ) { String volumeType = Ec2IaasHandler . findStorageProperty ( this . targetProperties , storageId , VOLUME_TYPE_PREFIX ) ; if ( volumeType == null ) volumeType = "standard" ; CreateVolumeRequest createVolumeRequest = new CreateVolumeRequest ...
Creates volume for EBS .
134,560
private boolean volumeCreated ( String volumeId ) { DescribeVolumesRequest dvs = new DescribeVolumesRequest ( ) ; ArrayList < String > volumeIds = new ArrayList < String > ( ) ; volumeIds . add ( volumeId ) ; dvs . setVolumeIds ( volumeIds ) ; DescribeVolumesResult dvsresult = null ; try { dvsresult = this . ec2Api . d...
Checks whether volume is created .
134,561
private boolean volumesCreated ( ) { for ( Map . Entry < String , String > entry : this . storageIdToVolumeId . entrySet ( ) ) { String volumeId = entry . getValue ( ) ; if ( ! volumeCreated ( volumeId ) ) return false ; } return true ; }
Checks whether all specified volumes are created .
134,562
private String lookupVolume ( String volumeIdOrName ) { String ret = null ; if ( ! Utils . isEmptyOrWhitespaces ( volumeIdOrName ) ) { DescribeVolumesRequest dvs = new DescribeVolumesRequest ( Collections . singletonList ( volumeIdOrName ) ) ; DescribeVolumesResult dvsresult = null ; try { dvsresult = this . ec2Api . d...
Looks up volume by ID or Name tag .
134,563
public String get ( String key ) { String result ; try { result = this . bundle . getString ( key ) ; } catch ( MissingResourceException e ) { result = OOPS + key + '!' ; } return result ; }
Finds an internationalized string by key .
134,564
public Map < String , String > getExternalExports ( ) { return this . template != null ? this . template . externalExports : new HashMap < String , String > ( 0 ) ; }
A shortcut method to access the template s external exports mapping .
134,565
public boolean replaceApplicationBindings ( String externalExportPrefix , Set < String > applicationNames ) { boolean changed = false ; Set < String > oldApplicationNames = this . applicationBindings . remove ( externalExportPrefix ) ; if ( oldApplicationNames == null ) { changed = ! applicationNames . isEmpty ( ) ; } ...
Replaces application bindings for a given prefix .
134,566
static void interceptLoadingFiles ( Properties props ) throws IOException { Logger logger = Logger . getLogger ( UserDataHelpers . class . getName ( ) ) ; Set < String > keys = props . stringPropertyNames ( ) ; for ( final String key : keys ) { if ( ! key . startsWith ( ENCODE_FILE_CONTENT_PREFIX ) ) continue ; String ...
Intercepts the properties and loads file contents .
134,567
public void run ( String [ ] args ) throws Exception { if ( args . length != 1 ) throw new RuntimeException ( "A file path was expected as an argument." ) ; File targetFile = new File ( args [ 0 ] ) ; if ( ! targetFile . isFile ( ) ) throw new RuntimeException ( "File " + targetFile + " does not exist." ) ; Field [ ] f...
The real method that does the job .
134,568
public void extendComponent ( Component component ) { if ( this . extendedComponent != null ) this . extendedComponent . extendingComponents . remove ( this ) ; component . extendingComponents . add ( this ) ; this . extendedComponent = component ; }
Creates a bi - directional relation between this component and an extended one .
134,569
public List < Rule > findRulesToExecute ( ) { this . logger . fine ( "Looking for rules to execute after an event was recorded for application " + this . app ) ; List < Rule > result = new ArrayList < > ( ) ; long now = System . nanoTime ( ) ; for ( Rule rule : this . ruleNameToRule . values ( ) ) { long validPeriodSta...
Finds the rules to execute after an event was recorded .
134,570
private String safeApply ( Collection < InstanceContextBean > instances , Options options , String componentPath ) throws IOException { String installerName = ( String ) options . hash . get ( "installer" ) ; final InstanceFilter filter = InstanceFilter . createFilter ( componentPath , installerName ) ; final Collectio...
Same as above but with type - safe arguments .
134,571
private static Collection < InstanceContextBean > descendantInstances ( final InstanceContextBean instance ) { final Collection < InstanceContextBean > result = new ArrayList < InstanceContextBean > ( ) ; for ( final InstanceContextBean child : instance . getChildren ( ) ) { result . add ( child ) ; result . addAll ( d...
Returns all the descendant instances of the given instance .
134,572
public Class < ? > reflectClass ( final String className ) { Preconditions . checkArgument ( className != null && className . trim ( ) . length ( ) > 0 , "className cannot be null or empty" ) ; return provider . getClassReflectionProvider ( className ) . reflectClass ( ) ; }
This method will reflect a Class object that is represented by className .
134,573
public < T > ClassController < T > on ( final Class < T > clazz ) { return new DefaultClassController < T > ( provider , clazz ) ; }
Method to access reflection on clazz .
134,574
ComputeService jcloudContext ( Map < String , String > targetProperties ) throws TargetException { validate ( targetProperties ) ; ComputeServiceContext context = ContextBuilder . newBuilder ( targetProperties . get ( PROVIDER_ID ) ) . endpoint ( targetProperties . get ( ENDPOINT ) ) . credentials ( targetProperties . ...
Creates a JCloud context .
134,575
static void validate ( Map < String , String > targetProperties ) throws TargetException { checkProperty ( PROVIDER_ID , targetProperties ) ; checkProperty ( ENDPOINT , targetProperties ) ; checkProperty ( IMAGE_NAME , targetProperties ) ; checkProperty ( SECURITY_GROUP , targetProperties ) ; checkProperty ( IDENTITY ,...
Validates the target properties .
134,576
void updateAgentConfigurationFile ( TargetHandlerParameters parameters , SSHClient ssh , File tmpDir , Map < String , String > keyToNewValue ) throws IOException { this . logger . fine ( "Updating agent parameters on remote host..." ) ; String agentConfigDir = Utils . getValue ( parameters . getTargetProperties ( ) , S...
Updates the configuration file of an agent .
134,577
public static void updateImports ( Instance instance , Map < String , Collection < Import > > variablePrefixToImports ) { instance . getImports ( ) . clear ( ) ; if ( variablePrefixToImports != null ) instance . getImports ( ) . putAll ( variablePrefixToImports ) ; }
Updates the imports of an instance with new values .
134,578
public static Import findImportByExportingInstance ( Collection < Import > imports , String exportingInstancePath ) { Import result = null ; if ( imports != null && exportingInstancePath != null ) { for ( Import imp : imports ) { if ( exportingInstancePath . equals ( imp . getInstancePath ( ) ) ) { result = imp ; break...
Finds a specific import from the path of the instance that exports it .
134,579
public static Map < String , String > httpMessagingConfiguration ( String ip , int port ) { final Map < String , String > result = new LinkedHashMap < > ( ) ; result . put ( MessagingConstants . MESSAGING_TYPE_PROPERTY , HttpConstants . FACTORY_HTTP ) ; result . put ( HttpConstants . HTTP_SERVER_IP , ip == null ? HttpC...
Return a HTTP messaging configuration for the given parameters .
134,580
public List < Preference > listPreferences ( ) { this . logger . finer ( "Getting all the preferences." ) ; WebResource path = this . resource . path ( UrlConstants . PREFERENCES ) ; List < Preference > result = this . wsClient . createBuilder ( path ) . accept ( MediaType . APPLICATION_JSON ) . get ( new GenericType <...
Lists all the preferences .
134,581
public static String resolve ( String lang ) { String result ; if ( ! LANGUAGES . contains ( lang ) ) result = EN ; else result = lang ; return result ; }
Resolves a language to a supported translation .
134,582
static Map < String , String > loadContent ( String lang ) { Map < String , String > result = new LinkedHashMap < > ( ) ; try { InputStream in = TranslationBundle . class . getResourceAsStream ( "/" + lang + ".json" ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; Utils . copyStreamSafely ( in , os ) ; St...
Loads content from JSon files .
134,583
static void parseProperties ( Map < String , String > targetProperties ) throws TargetException { String [ ] properties = { Ec2Constants . EC2_ENDPOINT , Ec2Constants . EC2_ACCESS_KEY , Ec2Constants . EC2_SECRET_KEY , Ec2Constants . AMI_VM_NODE , Ec2Constants . VM_INSTANCE_TYPE , Ec2Constants . SSH_KEY_NAME , Ec2Consta...
Parses the properties and saves them in a Java bean .
134,584
public static AmazonEC2 createEc2Client ( Map < String , String > targetProperties ) throws TargetException { parseProperties ( targetProperties ) ; AWSCredentials credentials = new BasicAWSCredentials ( targetProperties . get ( Ec2Constants . EC2_ACCESS_KEY ) , targetProperties . get ( Ec2Constants . EC2_SECRET_KEY ) ...
Creates a client for EC2 .
134,585
private RunInstancesRequest prepareEC2RequestNode ( Map < String , String > targetProperties , String userData ) throws UnsupportedEncodingException { RunInstancesRequest runInstancesRequest = new RunInstancesRequest ( ) ; String flavor = targetProperties . get ( Ec2Constants . VM_INSTANCE_TYPE ) ; if ( Utils . isEmpty...
Prepares the request .
134,586
private Set < String > registerTargets ( ApplicationTemplate tpl ) throws IOException , UnauthorizedActionException { IOException conflictException = null ; Set < String > newTargetIds = new HashSet < > ( ) ; Map < Component , Set < String > > componentToTargetIds = new HashMap < > ( ) ; componentLoop : for ( Map . Ent...
Registers the targets available in this template .
134,587
private void unregisterTargets ( Set < String > newTargetIds ) { for ( String targetId : newTargetIds ) { try { this . targetsMngr . deleteTarget ( targetId ) ; } catch ( Exception e ) { this . logger . severe ( "A target ID that has just been registered could not be created. That's weird." ) ; Utils . logException ( t...
Unregisters targets .
134,588
public static InstanceContext parse ( String s ) { String name = null , qualifier = null , instancePathOrComponentName = null ; if ( s != null ) { Matcher m = Pattern . compile ( "(.*)::(.*)::(.*)" ) . matcher ( s ) ; if ( m . matches ( ) ) { name = m . group ( 1 ) . equals ( "null" ) ? null : m . group ( 1 ) ; qualifi...
Parses a string to resolve a target mapping key .
134,589
public static String buildTopicNameForAgent ( Instance instance ) { Instance scopedInstance = InstanceHelpers . findScopedInstance ( instance ) ; return buildTopicNameForAgent ( InstanceHelpers . computeInstancePath ( scopedInstance ) ) ; }
Builds the default topic name for an agent .
134,590
public static String escapeInstancePath ( String instancePath ) { String result ; if ( Utils . isEmptyOrWhitespaces ( instancePath ) ) result = "" ; else result = instancePath . replaceFirst ( "^/*" , "" ) . replaceFirst ( "/*$" , "" ) . replaceAll ( "/+" , "." ) ; return result ; }
Removes unnecessary slashes and transforms the others into dots .
134,591
public static String buildId ( RecipientKind ownerKind , String domain , String applicationName , String scopedInstancePath ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "[ " ) ; sb . append ( domain ) ; sb . append ( " ] " ) ; if ( ownerKind == RecipientKind . DM ) { sb . append ( "DM" ) ; } else { sb ....
Builds a string identifying a messaging client .
134,592
private boolean checkVmIsOnline ( ) { String zoneName = OpenstackIaasHandler . findZoneName ( this . novaApi , this . targetProperties ) ; Server server = this . novaApi . getServerApiForZone ( zoneName ) . get ( this . machineId ) ; return Status . ACTIVE . equals ( server . getStatus ( ) ) ; }
Checks whether a VM is created .
134,593
public boolean prepareObjectStorage ( ) throws TargetException { String domains = this . targetProperties . get ( OBJ_STORAGE_DOMAINS ) ; if ( ! Utils . isEmptyOrWhitespaces ( domains ) ) { String zoneName = OpenstackIaasHandler . findZoneName ( this . novaApi , this . targetProperties ) ; SwiftApi swiftApi = Openstack...
Configures the object storage .
134,594
String [ ] splitFromInlineComment ( String line ) { String [ ] result = new String [ ] { line , "" } ; int index = line . indexOf ( ParsingConstants . COMMENT_DELIMITER ) ; if ( index >= 0 ) { result [ 0 ] = line . substring ( 0 , index ) ; if ( ! this . ignoreComments ) { Matcher m = Pattern . compile ( "(\\s+)$" ) . ...
Splits the line from the comment delimiter .
134,595
private void fillIn ( ) throws IOException { BufferedReader br = null ; InputStream in = null ; try { in = new FileInputStream ( this . definitionFile . getEditedFile ( ) ) ; br = new BufferedReader ( new InputStreamReader ( in , StandardCharsets . UTF_8 ) ) ; String line ; while ( ( line = nextLine ( br ) ) != null ) ...
Parses the file and fills - in the resulting structure .
134,596
public static String commentLine ( String line ) { String result = line ; if ( ! Utils . isEmptyOrWhitespaces ( line ) && ! line . trim ( ) . startsWith ( ParsingConstants . COMMENT_DELIMITER ) ) result = ParsingConstants . COMMENT_DELIMITER + line ; return result ; }
Comments a line .
134,597
static String cleanPath ( String path ) { return path . replaceFirst ( "^" + ServletRegistrationComponent . REST_CONTEXT + "/" , "/" ) . replaceFirst ( "^" + ServletRegistrationComponent . WEBSOCKET_CONTEXT + "/" , "/" ) . replaceFirst ( "\\?.*" , "" ) ; }
Cleans the path by removing the servlet paths and URL parameters .
134,598
public static synchronized void resetAllCounters ( ) { initializeCount . set ( 0 ) ; deployCount . set ( 0 ) ; undeployCount . set ( 0 ) ; startCount . set ( 0 ) ; stopCount . set ( 0 ) ; updateCount . set ( 0 ) ; errorCount . set ( 0 ) ; }
Resets all counters .
134,599
public String queryLivestatus ( String nagiosQuery ) throws UnknownHostException , IOException { Socket liveStatusSocket = null ; try { this . logger . fine ( "About to open a connection through Live Status..." ) ; liveStatusSocket = new Socket ( this . host , this . port ) ; this . logger . fine ( "A connection was es...
Queries a live status server .