code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
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... | java |
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( Standard... | java |
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(" ");
}
if (c == '_') {
... | java |
AbstractCommandExecution findExecutor( AbstractCommandInstruction instr ) {
AbstractCommandExecution result = null;
if( RenameCommandInstruction.class.equals( instr.getClass()))
result = new RenameCommandExecution((RenameCommandInstruction) instr);
else if( ReplicateCommandInstruction.class.equals( instr.ge... | java |
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 = false;
int i = 1;
... | java |
public void targetAppears( TargetHandler targetItf ) {
this.defaultTargetHandlerResolver.addTargetHandler( targetItf );
// When a target is deployed, we may also have to update instance states.
// Consider as an example when the DM restarts. Targets may be injected
// before and after the pojo was started by i... | java |
public void setTargetResolver( ITargetHandlerResolver targetHandlerResolver ) {
if( targetHandlerResolver == null ) {
this.targetConfigurator.setTargetHandlerResolver( this.defaultTargetHandlerResolver );
this.instancesMngr.setTargetHandlerResolver( this.defaultTargetHandlerResolver );
} else {
this.targe... | java |
void restoreAllInstances() {
// instancesMngr() instead of this.instancesMngr (for unit tests).
this.logger.fine( "Restoring all the instance states from the current target handlers." );
for( ManagedApplication ma : this.applicationMngr.getManagedApplications()) {
// Build a new snapshot on every loop
Lis... | java |
void restoreInstancesFrom( TargetHandler targetHandler ) {
// instancesMngr() instead of this.instancesMngr (for unit tests).
this.logger.fine( "Restoring the instance states with the '" + targetHandler.getTargetId() + "' target handler." );
for( ManagedApplication ma : this.applicationMngr.getManagedApplication... | java |
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, true);
return res... | java |
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);
return result;
} | java |
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 c... | java |
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." );
... | java |
public void checkStates( INotificationMngr notificationMngr ) {
// Check the status of scoped instances
Collection<Instance> scopedInstances = InstanceHelpers.findAllScopedInstances( this.application );
for( Instance scopedInstance : scopedInstances ) {
// Never started instances,
// or scoped instances t... | java |
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( Ins... | java |
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.add( this.component )... | java |
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.typeTo... | java |
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 {
// Absolute URL ?
importUri = ur... | java |
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 = executeCommandWithResul... | java |
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.toArr... | java |
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;
try {
br... | java |
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 );
} | java |
public static String getVMIP(String hostIpPort, String id) throws TargetException {
//TODO Expecting more interoperable implem... /compute/urn:uuid:ID for Scalair, /ID for CA !
if(! hostIpPort.endsWith("/compute") && id.startsWith("urn:uuid:")) id = id.substring(9);
String vmIp = null;
URL url = null;
try {
... | java |
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 Logge... | java |
@Override
public String createTarget( String targetContent ) throws IOException {
// Get the target ID
TargetValidator tv = new TargetValidator( targetContent );
tv.validate();
if( RoboconfErrorHelpers.containsCriticalErrors( tv.getErrors()))
throw new IOException( "There are errors in the target definitio... | java |
@Override
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> exclusionPattern... | java |
@Override
public List<TargetWrapperDescriptor> listPossibleTargets( AbstractApplication app ) {
// Find the matching targets based on registered hints
String key = new InstanceContext( app ).toString();
String tplKey = null;
if( app instanceof Application )
tplKey = new InstanceContext(((Application) app).... | java |
@Override
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 f... | java |
public static void verify( CommandExecutionContext executionContext, Component component )
throws CommandException {
if( executionContext != null
&& Constants.TARGET_INSTALLER.equalsIgnoreCase( component.getInstallerName())
&& executionContext.getMaxVm() > 0
&& executionContext.getMaxVm() <= executionCo... | java |
public static void update( CommandExecutionContext executionContext, Instance createdInstance ) {
if( executionContext != null ) {
createdInstance.data.put( executionContext.getNewVmMarkerKey(), executionContext.getNewVmMarkerValue());
executionContext.getGlobalVmNumber().incrementAndGet();
executionContext... | java |
public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) {
List<ModelError> result;
if( "puppet".equalsIgnoreCase( component.getInstallerName()))
result = validatePuppetComponent( applicationFilesDirectory, component );
else if( "script".equalsIgnoreCase( ... | java |
private static void checkPuppetFile( File pp, boolean withUpdateParams, Component component, Collection<ModelError> errors )
throws IOException {
// Try to use the Puppet validator
String[] cmd = { "puppet", "parser", "validate", pp.getAbsolutePath()};
Logger logger = Logger.getLogger( RecipesValidator.class.ge... | java |
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 );
... | java |
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());
break;
}
}
retur... | java |
public static ErrorDetails applicationTpl( String tplName, String tplVersion ) {
return new ErrorDetails( tplName + " (" + tplVersion + ")", ErrorDetailsKind.APPLICATION_TEMPLATE );
} | java |
public static ErrorDetails exception( Throwable t ) {
return new ErrorDetails( Utils.writeExceptionButDoNotUseItForLogging( t ), ErrorDetailsKind.EXCEPTION );
} | java |
public static ErrorDetails exceptionName( Throwable t ) {
return new ErrorDetails( t.getClass().getName(), ErrorDetailsKind.EXCEPTION_NAME );
} | java |
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,
Az... | java |
public static ApplicationTemplateDescriptor load( File f ) throws IOException {
// Read the file's content
String fileContent = Utils.readFileContent( f );
Logger logger = Logger.getLogger( ApplicationTemplateDescriptor.class.getName());
Properties properties = Utils.readPropertiesQuietly( fileContent, logger ... | java |
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_VERSION... | java |
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;
} | java |
public static void createProjectSkeleton( File targetDirectory, CreationBean creationBean ) throws IOException {
if( creationBean.isMavenProject())
createMavenProject( targetDirectory, creationBean );
else
createSimpleProject( targetDirectory, creationBean );
} | java |
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 : ComponentHelper... | java |
private static void createSimpleProject( File targetDirectory, CreationBean creationBean )
throws IOException {
// Create the directory structure
String[] directoriesToCreate = creationBean.isReusableRecipe() ? RR_DIRECTORIES : ALL_DIRECTORIES;
for( String s : directoriesToCreate ) {
File dir = new File( tar... | java |
private static void createMavenProject( File targetDirectory, CreationBean creationBean ) throws IOException {
// Create the directory structure
File rootDir = new File( targetDirectory, Constants.MAVEN_SRC_MAIN_MODEL );
String[] directoriesToCreate = creationBean.isReusableRecipe() ? RR_DIRECTORIES : ALL_DIRECT... | java |
private static void completeProjectCreation(
File targetDirectory,
String descriptorContent,
CreationBean creationBean )
throws IOException {
// Create a sample graph file
File f = new File( targetDirectory, Constants.PROJECT_DIR_GRAPH + "/" + GRAPH_EP );
InputStream in = ProjectUtils.class.getResource... | java |
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 ));
updatedDetails.add( l... | java |
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, instancePath );
result.p... | java |
List<MonitoringHandlerRun> extractRuleSections( File file, String fileContent, Properties params ) {
// Find rules sections
StringBuilder sb = new StringBuilder();
List<String> sections = new ArrayList<String>();
for( String s : Arrays.asList( fileContent.trim().split( "\n" ))) {
s = s.trim();
if( s.leng... | java |
public void setTags( Collection<String> tags ) {
synchronized( this.tags ) {
this.tags.clear();
if( tags != null )
this.tags.addAll( tags );
}
} | java |
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.getProperty... | java |
public static List<ModelError> parseDirectory( File directory, Component c ) {
// Validate all the properties
List<ModelError> result = new ArrayList<> ();
Set<String> targetIds = new HashSet<> ();
for( File f : Utils.listDirectFiles( directory, Constants.FILE_EXT_PROPERTIES )) {
TargetValidator tv = new T... | java |
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())
errors = pars... | java |
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 < full... | java |
void createImage( String imageId ) throws TargetException {
// If there is no Dockerfile, this method will do nothing
File targetDirectory = this.parameters.getTargetPropertiesDirectory();
String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM );
if( ! Utils.isEmptyOrWhitespaces... | java |
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( LoginException... | java |
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().... | java |
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (!FacesContext.getCurrentInstance().isPostback()) {
// if (!(getParent() instanceof Column)) {
insertLabelBeforeThisInputField();
insertMessageBehindThisInputField();
}
// }
} | java |
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 = new Associat... | java |
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()
.withA... | java |
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.describeVolumes(dv... | java |
private boolean volumesCreated() {
for( Map.Entry<String,String> entry : this.storageIdToVolumeId.entrySet()) {
String volumeId = entry.getValue();
if(! volumeCreated(volumeId)) return false;
}
return true;
} | java |
private String lookupVolume(String volumeIdOrName) {
String ret = null;
if(! Utils.isEmptyOrWhitespaces(volumeIdOrName)) {
// Lookup by volume ID
DescribeVolumesRequest dvs = new DescribeVolumesRequest(Collections.singletonList(volumeIdOrName));
DescribeVolumesResult dvsresult = null;
try {
dvsres... | java |
public String get( String key ) {
String result;
try {
result = this.bundle.getString( key );
} catch( MissingResourceException e ) {
result = OOPS + key + '!';
}
return result;
} | java |
public Map<String,String> getExternalExports() {
return this.template != null ? this.template.externalExports : new HashMap<String,String>( 0 );
} | java |
public boolean replaceApplicationBindings( String externalExportPrefix, Set<String> applicationNames ) {
// There is a change if the set do not have the same size or if they do not contain the same
// number of element. If no binding had been registered previously, then we only check whether
// the new set conta... | java |
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 realKey =... | java |
public void run( String[] args ) throws Exception {
// Check the argument
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 exis... | java |
public void extendComponent( Component component ) {
if( this.extendedComponent != null )
this.extendedComponent.extendingComponents.remove( this );
component.extendingComponents.add( this );
this.extendedComponent = component;
} | java |
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 all the rules, find if there are events that should trigger its execution.
*... | java |
private String safeApply( Collection<InstanceContextBean> instances, Options options, String componentPath )
throws IOException {
// Parse the filter.
String installerName = (String) options.hash.get( "installer" );
final InstanceFilter filter = InstanceFilter.createFilter( componentPath, installerName );
//... | java |
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( descendantInstan... | java |
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();
} | java |
public <T> ClassController<T> on(final Class<T> clazz) {
return new DefaultClassController<T>(provider, clazz);
} | java |
ComputeService jcloudContext( Map<String,String> targetProperties ) throws TargetException {
validate( targetProperties );
ComputeServiceContext context = ContextBuilder
.newBuilder( targetProperties.get( PROVIDER_ID ))
.endpoint( targetProperties.get( ENDPOINT ))
.credentials( targetProperties.get( ID... | java |
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, targetPr... | java |
void updateAgentConfigurationFile(
TargetHandlerParameters parameters,
SSHClient ssh,
File tmpDir,
Map<String,String> keyToNewValue )
throws IOException {
this.logger.fine( "Updating agent parameters on remote host..." );
// Update the agent's configuration file
String agentConfigDir = Utils.getVal... | java |
public static void updateImports( Instance instance, Map<String,Collection<Import>> variablePrefixToImports ) {
instance.getImports().clear();
if( variablePrefixToImports != null )
instance.getImports().putAll( variablePrefixToImports );
} | java |
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;
br... | java |
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 ? HttpConstants.DEFAULT_IP : ip ... | java |
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<List<Preference>>... | java |
public static String resolve( String lang ) {
String result;
if( ! LANGUAGES.contains( lang ))
result = EN;
else
result = lang;
return result;
} | java |
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 );
String content... | java |
static void parseProperties( Map<String, String> targetProperties ) throws TargetException {
// Quick check
String[] properties = {
Ec2Constants.EC2_ENDPOINT,
Ec2Constants.EC2_ACCESS_KEY,
Ec2Constants.EC2_SECRET_KEY,
Ec2Constants.AMI_VM_NODE,
Ec2Constants.VM_INSTANCE_TYPE,
Ec2Constants.SSH_KEY_NA... | java |
public static AmazonEC2 createEc2Client( Map<String,String> targetProperties ) throws TargetException {
parseProperties( targetProperties );
// Configure the IaaS client
AWSCredentials credentials = new BasicAWSCredentials(
targetProperties.get(Ec2Constants.EC2_ACCESS_KEY),
targetProperties.get(Ec2Const... | java |
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.isEmptyOrWhitespaces... | java |
private Set<String> registerTargets( ApplicationTemplate tpl )
throws IOException, UnauthorizedActionException {
// Find all the properties files and register them
IOException conflictException = null;
Set<String> newTargetIds = new HashSet<> ();
Map<Component,Set<String>> componentToTargetIds = new HashMap<>... | java |
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( ... | java |
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 );
qualifier = m.gr... | java |
public static String buildTopicNameForAgent( Instance instance ) {
Instance scopedInstance = InstanceHelpers.findScopedInstance( instance );
return buildTopicNameForAgent( InstanceHelpers.computeInstancePath( scopedInstance ));
} | java |
public static String escapeInstancePath( String instancePath ) {
String result;
if( Utils.isEmptyOrWhitespaces( instancePath ))
result = "";
else
result = instancePath.replaceFirst( "^/*", "" ).replaceFirst( "/*$", "" ).replaceAll( "/+", "." );
return result;
} | java |
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 {
... | java |
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());
} | java |
public boolean prepareObjectStorage() throws TargetException {
String domains = this.targetProperties.get( OBJ_STORAGE_DOMAINS );
if( ! Utils.isEmptyOrWhitespaces( domains )) {
// Get the Swift API
String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
SwiftApi swiftA... | java |
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 ) {
// Find extra spaces before the in-line comment and pu... | java |
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 ) {
... | java |
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;
} | java |
static String cleanPath( String path ) {
return path
.replaceFirst( "^" + ServletRegistrationComponent.REST_CONTEXT + "/", "/" )
.replaceFirst( "^" + ServletRegistrationComponent.WEBSOCKET_CONTEXT + "/", "/" )
.replaceFirst( "\\?.*", "" );
} | java |
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 );
} | java |
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 establish... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.