idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
22,100 | public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister ( final ConfigurationFile file , final HostControllerEnvironment environment , final ExecutorService executorService , final ExtensionRegistry hostExtensionRegistry , final LocalHostControllerInfo localHostControllerInfo ) { String defaultHostname = localHostControllerInfo . getLocalHostName ( ) ; if ( environment . getRunningModeControl ( ) . isReloaded ( ) ) { if ( environment . getRunningModeControl ( ) . getReloadHostName ( ) != null ) { defaultHostname = environment . getRunningModeControl ( ) . getReloadHostName ( ) ; } } HostXml hostXml = new HostXml ( defaultHostname , environment . getRunningModeControl ( ) . getRunningMode ( ) , environment . isUseCachedDc ( ) , Module . getBootModuleLoader ( ) , executorService , hostExtensionRegistry ) ; BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister ( file , new QName ( Namespace . CURRENT . getUriString ( ) , "host" ) , hostXml , hostXml , false ) ; for ( Namespace namespace : Namespace . domainValues ( ) ) { if ( ! namespace . equals ( Namespace . CURRENT ) ) { persister . registerAdditionalRootElement ( new QName ( namespace . getUriString ( ) , "host" ) , hostXml ) ; } } hostExtensionRegistry . setWriterRegistry ( persister ) ; return persister ; } | host . xml |
22,101 | public static ExtensibleConfigurationPersister createDomainXmlConfigurationPersister ( final ConfigurationFile file , ExecutorService executorService , ExtensionRegistry extensionRegistry , final HostControllerEnvironment environment ) { DomainXml domainXml = new DomainXml ( Module . getBootModuleLoader ( ) , executorService , extensionRegistry ) ; boolean suppressLoad = false ; ConfigurationFile . InteractionPolicy policy = file . getInteractionPolicy ( ) ; final boolean isReloaded = environment . getRunningModeControl ( ) . isReloaded ( ) ; if ( ! isReloaded && ( policy == ConfigurationFile . InteractionPolicy . NEW && ( file . getBootFile ( ) . exists ( ) && file . getBootFile ( ) . length ( ) != 0 ) ) ) { throw HostControllerLogger . ROOT_LOGGER . cannotOverwriteDomainXmlWithEmpty ( file . getBootFile ( ) . getName ( ) ) ; } if ( ! isReloaded && ( policy == ConfigurationFile . InteractionPolicy . NEW || policy == ConfigurationFile . InteractionPolicy . DISCARD ) ) { suppressLoad = true ; } BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister ( file , new QName ( Namespace . CURRENT . getUriString ( ) , "domain" ) , domainXml , domainXml , suppressLoad ) ; for ( Namespace namespace : Namespace . domainValues ( ) ) { if ( ! namespace . equals ( Namespace . CURRENT ) ) { persister . registerAdditionalRootElement ( new QName ( namespace . getUriString ( ) , "domain" ) , domainXml ) ; } } extensionRegistry . setWriterRegistry ( persister ) ; return persister ; } | domain . xml |
22,102 | public static ExtensibleConfigurationPersister createTransientDomainXmlConfigurationPersister ( ExecutorService executorService , ExtensionRegistry extensionRegistry ) { DomainXml domainXml = new DomainXml ( Module . getBootModuleLoader ( ) , executorService , extensionRegistry ) ; ExtensibleConfigurationPersister persister = new NullConfigurationPersister ( domainXml ) ; extensionRegistry . setWriterRegistry ( persister ) ; return persister ; } | slave = true |
22,103 | static void apply ( final String patchId , final Collection < ContentModification > modifications , final PatchEntry patchEntry , final ContentItemFilter filter ) { for ( final ContentModification modification : modifications ) { final ContentItem item = modification . getItem ( ) ; if ( ! filter . accepts ( item ) ) { continue ; } final Location location = new Location ( item ) ; final ContentEntry contentEntry = new ContentEntry ( patchId , modification ) ; ContentTaskDefinition definition = patchEntry . get ( location ) ; if ( definition == null ) { definition = new ContentTaskDefinition ( location , contentEntry , false ) ; patchEntry . put ( location , definition ) ; } else { definition . setTarget ( contentEntry ) ; } } } | Apply modifications to a content task definition . |
22,104 | protected ServiceName serviceName ( final String name ) { return baseServiceName != null ? baseServiceName . append ( name ) : null ; } | The service name to be removed . Can be overridden for unusual service naming patterns |
22,105 | private boolean subModuleExists ( File dir ) { if ( isSlotDirectory ( dir ) ) { return true ; } else { File [ ] children = dir . listFiles ( File :: isDirectory ) ; for ( File child : children ) { if ( subModuleExists ( child ) ) { return true ; } } } return false ; } | depth - first search for any module - just to check that the suggestion has any chance of delivering correct result |
22,106 | private String tail ( String moduleName ) { if ( moduleName . indexOf ( MODULE_NAME_SEPARATOR ) > 0 ) { return moduleName . substring ( moduleName . indexOf ( MODULE_NAME_SEPARATOR ) + 1 ) ; } else { return "" ; } } | get all parts of module name apart from first |
22,107 | void resolveBootUpdates ( final ModelController controller , final ActiveOperation . CompletedCallback < ModelNode > callback ) throws Exception { connection . openConnection ( controller , callback ) ; this . controller = controller ; } | Resolve the boot updates and register at the local HC . |
22,108 | static VaultConfig loadExternalFile ( File f ) throws XMLStreamException { if ( f == null ) { throw new IllegalArgumentException ( "File is null" ) ; } if ( ! f . exists ( ) ) { throw new XMLStreamException ( "Failed to locate vault file " + f . getAbsolutePath ( ) ) ; } final VaultConfig config = new VaultConfig ( ) ; BufferedInputStream input = null ; try { final XMLMapper mapper = XMLMapper . Factory . create ( ) ; final XMLElementReader < VaultConfig > reader = new ExternalVaultConfigReader ( ) ; mapper . registerRootElement ( new QName ( VAULT ) , reader ) ; FileInputStream is = new FileInputStream ( f ) ; input = new BufferedInputStream ( is ) ; XMLStreamReader streamReader = XMLInputFactory . newInstance ( ) . createXMLStreamReader ( input ) ; mapper . parseDocument ( config , streamReader ) ; streamReader . close ( ) ; } catch ( FileNotFoundException e ) { throw new XMLStreamException ( "Vault file not found" , e ) ; } catch ( XMLStreamException t ) { throw t ; } finally { StreamUtils . safeClose ( input ) ; } return config ; } | In the 2 . 0 xsd the vault is in an external file which has no namespace using the output of the vault tool . |
22,109 | static VaultConfig readVaultElement_3_0 ( XMLExtendedStreamReader reader , Namespace expectedNs ) throws XMLStreamException { final VaultConfig config = new VaultConfig ( ) ; final int count = reader . getAttributeCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final String value = reader . getAttributeValue ( i ) ; String name = reader . getAttributeLocalName ( i ) ; if ( name . equals ( CODE ) ) { config . code = value ; } else if ( name . equals ( MODULE ) ) { config . module = value ; } else { unexpectedVaultAttribute ( reader . getAttributeLocalName ( i ) , reader ) ; } } if ( config . code == null && config . module != null ) { throw new XMLStreamException ( "Attribute 'module' was specified without an attribute" + " 'code' for element '" + VAULT + "' at " + reader . getLocation ( ) ) ; } readVaultOptions ( reader , config ) ; return config ; } | In the 3 . 0 xsd the vault configuration and its options are part of the vault xsd . |
22,110 | private Set < String > checkModel ( final ModelNode model , TransformationContext context ) throws OperationFailedException { final Set < String > attributes = new HashSet < String > ( ) ; AttributeTransformationRequirementChecker checker ; for ( final String attribute : attributeNames ) { if ( model . hasDefined ( attribute ) ) { if ( attributeCheckers != null && ( checker = attributeCheckers . get ( attribute ) ) != null ) { if ( checker . isAttributeTransformationRequired ( attribute , model . get ( attribute ) , context ) ) { attributes . add ( attribute ) ; } } else if ( SIMPLE_EXPRESSIONS . isAttributeTransformationRequired ( attribute , model . get ( attribute ) , context ) ) { attributes . add ( attribute ) ; } } } return attributes ; } | Check the model for expression values . |
22,111 | public void setValue ( String propName , Object value ) { for ( RequestProp prop : props ) { if ( prop . getName ( ) . equals ( propName ) ) { JComponent valComp = prop . getValueComponent ( ) ; if ( valComp instanceof JTextComponent ) { ( ( JTextComponent ) valComp ) . setText ( value . toString ( ) ) ; } if ( valComp instanceof AbstractButton ) { ( ( AbstractButton ) valComp ) . setSelected ( ( Boolean ) value ) ; } if ( valComp instanceof JComboBox ) { ( ( JComboBox ) valComp ) . setSelectedItem ( value ) ; } return ; } } } | Set the value of the underlying component . Note that this will not work for ListEditor components . Also note that for a JComboBox The value object must have the same identity as an object in the drop - down . |
22,112 | static void doDifference ( Map < String , String > left , Map < String , String > right , Map < String , String > onlyOnLeft , Map < String , String > onlyOnRight , Map < String , String > updated ) { onlyOnRight . clear ( ) ; onlyOnRight . putAll ( right ) ; for ( Map . Entry < String , String > entry : left . entrySet ( ) ) { String leftKey = entry . getKey ( ) ; String leftValue = entry . getValue ( ) ; if ( right . containsKey ( leftKey ) ) { String rightValue = onlyOnRight . remove ( leftKey ) ; if ( ! leftValue . equals ( rightValue ) ) { updated . put ( leftKey , leftValue ) ; } } else { onlyOnLeft . put ( leftKey , leftValue ) ; } } } | calculate the difference of the two maps so we know what was added removed & updated |
22,113 | public void close ( ) throws IOException { final ManagedBinding binding = this . socketBindingManager . getNamedRegistry ( ) . getManagedBinding ( this . name ) ; if ( binding == null ) { return ; } binding . close ( ) ; } | Closes the outbound socket binding connection . |
22,114 | public static boolean requiresReload ( final Set < Flag > flags ) { return flags . contains ( Flag . RESTART_ALL_SERVICES ) || flags . contains ( Flag . RESTART_RESOURCE_SERVICES ) ; } | Checks to see within the flags if a reload i . e . not a full restart is required . |
22,115 | protected void updateState ( final String name , final InstallationModificationImpl modification , final InstallationModificationImpl . InstallationState state ) { final PatchableTarget . TargetInfo identityInfo = modification . getModifiedState ( ) ; this . identity = new Identity ( ) { public String getVersion ( ) { return modification . getVersion ( ) ; } public String getName ( ) { return name ; } public TargetInfo loadTargetInfo ( ) throws IOException { return identityInfo ; } public DirectoryStructure getDirectoryStructure ( ) { return modification . getDirectoryStructure ( ) ; } } ; this . allPatches = Collections . unmodifiableList ( modification . getAllPatches ( ) ) ; this . layers . clear ( ) ; for ( final Map . Entry < String , MutableTargetImpl > entry : state . getLayers ( ) . entrySet ( ) ) { final String layerName = entry . getKey ( ) ; final MutableTargetImpl target = entry . getValue ( ) ; putLayer ( layerName , new LayerInfo ( layerName , target . getModifiedState ( ) , target . getDirectoryStructure ( ) ) ) ; } this . addOns . clear ( ) ; for ( final Map . Entry < String , MutableTargetImpl > entry : state . getAddOns ( ) . entrySet ( ) ) { final String addOnName = entry . getKey ( ) ; final MutableTargetImpl target = entry . getValue ( ) ; putAddOn ( addOnName , new LayerInfo ( addOnName , target . getModifiedState ( ) , target . getDirectoryStructure ( ) ) ) ; } } | Update the installed identity using the modified state from the modification . |
22,116 | public static Set < String > listAllLinks ( OperationContext context , String overlay ) { Set < String > serverGoupNames = listServerGroupsReferencingOverlay ( context . readResourceFromRoot ( PathAddress . EMPTY_ADDRESS ) , overlay ) ; Set < String > links = new HashSet < > ( ) ; for ( String serverGoupName : serverGoupNames ) { links . addAll ( listLinks ( context , PathAddress . pathAddress ( PathElement . pathElement ( SERVER_GROUP , serverGoupName ) , PathElement . pathElement ( DEPLOYMENT_OVERLAY , overlay ) ) ) ) ; } return links ; } | Returns all the deployment runtime names associated with an overlay accross all server groups . |
22,117 | public static Set < String > listLinks ( OperationContext context , PathAddress overlayAddress ) { Resource overlayResource = context . readResourceFromRoot ( overlayAddress ) ; if ( overlayResource . hasChildren ( DEPLOYMENT ) ) { return overlayResource . getChildrenNames ( DEPLOYMENT ) ; } return Collections . emptySet ( ) ; } | Returns all the deployment runtime names associated with an overlay . |
22,118 | public static void redeployDeployments ( OperationContext context , PathAddress deploymentsRootAddress , Set < String > deploymentNames ) throws OperationFailedException { for ( String deploymentName : deploymentNames ) { PathAddress address = deploymentsRootAddress . append ( DEPLOYMENT , deploymentName ) ; OperationStepHandler handler = context . getRootResourceRegistration ( ) . getOperationHandler ( address , REDEPLOY ) ; ModelNode operation = addRedeployStep ( address ) ; ServerLogger . AS_ROOT_LOGGER . debugf ( "Redeploying %s at address %s with handler %s" , deploymentName , address , handler ) ; assert handler != null ; assert operation . isDefined ( ) ; context . addStep ( operation , handler , OperationContext . Stage . MODEL ) ; } } | We are adding a redeploy operation step for each specified deployment runtime name . |
22,119 | public static void redeployLinksAndTransformOperation ( OperationContext context , ModelNode removeOperation , PathAddress deploymentsRootAddress , Set < String > runtimeNames ) throws OperationFailedException { Set < String > deploymentNames = listDeployments ( context . readResourceFromRoot ( deploymentsRootAddress ) , runtimeNames ) ; Operations . CompositeOperationBuilder opBuilder = Operations . CompositeOperationBuilder . create ( ) ; if ( deploymentNames . isEmpty ( ) ) { for ( String s : runtimeNames ) { ServerLogger . ROOT_LOGGER . debugf ( "We haven't found any deployment for %s in server-group %s" , s , deploymentsRootAddress . getLastElement ( ) . getValue ( ) ) ; } } if ( removeOperation != null ) { opBuilder . addStep ( removeOperation ) ; } for ( String deploymentName : deploymentNames ) { opBuilder . addStep ( addRedeployStep ( deploymentsRootAddress . append ( DEPLOYMENT , deploymentName ) ) ) ; } List < DomainOperationTransmuter > transformers = context . getAttachment ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS ) ; if ( transformers == null ) { context . attach ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS , transformers = new ArrayList < > ( ) ) ; } final ModelNode slave = opBuilder . build ( ) . getOperation ( ) ; transformers . add ( new OverlayOperationTransmuter ( slave , context . getCurrentAddress ( ) ) ) ; } | It will look for all the deployments under the deploymentsRootAddress with a runtimeName in the specified list of runtime names and then transform the operation so that every server having those deployments will redeploy the affected deployments . |
22,120 | public static Set < String > listDeployments ( Resource deploymentRootResource , Set < String > runtimeNames ) { Set < Pattern > set = new HashSet < > ( ) ; for ( String wildcardExpr : runtimeNames ) { Pattern pattern = DeploymentOverlayIndex . getPattern ( wildcardExpr ) ; set . add ( pattern ) ; } return listDeploymentNames ( deploymentRootResource , set ) ; } | Returns the deployment names with the specified runtime names at the specified deploymentRootAddress . |
22,121 | public void execute ( CommandHandler handler , int timeout , TimeUnit unit ) throws CommandLineException , InterruptedException , ExecutionException , TimeoutException { ExecutableBuilder builder = new ExecutableBuilder ( ) { CommandContext c = newTimeoutCommandContext ( ctx ) ; public Executable build ( ) { return ( ) -> { handler . handle ( c ) ; } ; } public CommandContext getCommandContext ( ) { return c ; } } ; execute ( builder , timeout , unit ) ; } | public for testing purpose |
22,122 | void execute ( ExecutableBuilder builder , int timeout , TimeUnit unit ) throws CommandLineException , InterruptedException , ExecutionException , TimeoutException { Future < Void > task = executorService . submit ( ( ) -> { builder . build ( ) . execute ( ) ; return null ; } ) ; try { if ( timeout <= 0 ) { task . get ( ) ; } else { try { task . get ( timeout , unit ) ; } catch ( TimeoutException ex ) { CommandContext c = builder . getCommandContext ( ) ; if ( c instanceof TimeoutCommandContext ) { ( ( TimeoutCommandContext ) c ) . timeout ( ) ; } task . cancel ( true ) ; throw ex ; } } } catch ( InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; cancelTask ( task , builder . getCommandContext ( ) , null ) ; CommandContext c = builder . getCommandContext ( ) ; if ( c instanceof TimeoutCommandContext ) { ( ( TimeoutCommandContext ) c ) . interrupted ( ) ; } throw ex ; } } | The CommandContext can be retrieved thatnks to the ExecutableBuilder . |
22,123 | public String getOriginalValue ( ParsedCommandLine parsedLine , boolean required ) throws CommandFormatException { String value = null ; if ( parsedLine . hasProperties ( ) ) { if ( index >= 0 ) { List < String > others = parsedLine . getOtherProperties ( ) ; if ( others . size ( ) > index ) { return others . get ( index ) ; } } value = parsedLine . getPropertyValue ( fullName ) ; if ( value == null && shortName != null ) { value = parsedLine . getPropertyValue ( shortName ) ; } } if ( required && value == null && ! isPresent ( parsedLine ) ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( "Required argument " ) ; buf . append ( '\'' ) . append ( fullName ) . append ( '\'' ) ; buf . append ( " is missing." ) ; throw new CommandFormatException ( buf . toString ( ) ) ; } return value ; } | Returns value as it appeared on the command line with escape sequences and system properties not resolved . The variables though are resolved during the initial parsing of the command line . |
22,124 | public static void logBeforeExit ( ExitLogger logger ) { try { if ( logged . compareAndSet ( false , true ) ) { logger . logExit ( ) ; } } catch ( Throwable ignored ) { } } | Invokes the exit logger if and only if no ExitLogger was previously invoked . |
22,125 | private String getName ( CommandContext ctx , boolean failInBatch ) throws CommandLineException { final ParsedCommandLine args = ctx . getParsedCommandLine ( ) ; final String name = this . name . getValue ( args , true ) ; if ( name == null ) { throw new CommandFormatException ( this . name + " is missing value." ) ; } if ( ! ctx . isBatchMode ( ) || failInBatch ) { if ( ! Util . isValidPath ( ctx . getModelControllerClient ( ) , Util . DEPLOYMENT_OVERLAY , name ) ) { throw new CommandFormatException ( "Deployment overlay " + name + " does not exist." ) ; } } return name ; } | Validate that the overlay exists . If it doesn t exist throws an exception if not in batch mode or if failInBatch is true . In batch mode we could be in the case that the overlay doesn t exist yet . |
22,126 | public static ServiceName moduleSpecServiceName ( ModuleIdentifier identifier ) { if ( ! isDynamicModule ( identifier ) ) { throw ServerLogger . ROOT_LOGGER . missingModulePrefix ( identifier , MODULE_PREFIX ) ; } return MODULE_SPEC_SERVICE_PREFIX . append ( identifier . getName ( ) ) . append ( identifier . getSlot ( ) ) ; } | Returns the corresponding ModuleSpec service name for the given module . |
22,127 | public static ServiceName moduleResolvedServiceName ( ModuleIdentifier identifier ) { if ( ! isDynamicModule ( identifier ) ) { throw ServerLogger . ROOT_LOGGER . missingModulePrefix ( identifier , MODULE_PREFIX ) ; } return MODULE_RESOLVED_SERVICE_PREFIX . append ( identifier . getName ( ) ) . append ( identifier . getSlot ( ) ) ; } | Returns the corresponding module resolved service name for the given module . |
22,128 | public static ServiceName moduleServiceName ( ModuleIdentifier identifier ) { if ( ! identifier . getName ( ) . startsWith ( MODULE_PREFIX ) ) { throw ServerLogger . ROOT_LOGGER . missingModulePrefix ( identifier , MODULE_PREFIX ) ; } return MODULE_SERVICE_PREFIX . append ( identifier . getName ( ) ) . append ( identifier . getSlot ( ) ) ; } | Returns the corresponding ModuleLoadService service name for the given module . |
22,129 | public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; final ServicesAttachment servicesAttachment = deploymentUnit . getAttachment ( Attachments . SERVICES ) ; if ( servicesAttachment == null || servicesAttachment . getServiceImplementations ( ServiceActivator . class . getName ( ) ) . isEmpty ( ) ) { return ; } final Module module = deploymentUnit . getAttachment ( Attachments . MODULE ) ; if ( module == null ) { return ; } AttachmentList < DeploymentUnit > duList = deploymentUnit . getAttachment ( Attachments . SUB_DEPLOYMENTS ) ; List < String > serviceAcitvatorList = new ArrayList < String > ( ) ; if ( duList != null && ! duList . isEmpty ( ) ) { for ( DeploymentUnit du : duList ) { ServicesAttachment duServicesAttachment = du . getAttachment ( Attachments . SERVICES ) ; for ( String serv : duServicesAttachment . getServiceImplementations ( ServiceActivator . class . getName ( ) ) ) { serviceAcitvatorList . add ( serv ) ; } } } ServiceRegistry serviceRegistry = phaseContext . getServiceRegistry ( ) ; if ( WildFlySecurityManager . isChecking ( ) ) { serviceRegistry = new SecuredServiceRegistry ( serviceRegistry ) ; } final ServiceActivatorContext serviceActivatorContext = new ServiceActivatorContextImpl ( phaseContext . getServiceTarget ( ) , serviceRegistry ) ; final ClassLoader current = WildFlySecurityManager . getCurrentContextClassLoaderPrivileged ( ) ; try { WildFlySecurityManager . setCurrentContextClassLoaderPrivileged ( module . getClassLoader ( ) ) ; for ( ServiceActivator serviceActivator : module . loadService ( ServiceActivator . class ) ) { try { for ( String serv : servicesAttachment . getServiceImplementations ( ServiceActivator . class . getName ( ) ) ) { if ( serv . compareTo ( serviceActivator . getClass ( ) . getName ( ) ) == 0 && ! serviceAcitvatorList . contains ( serv ) ) { serviceActivator . activate ( serviceActivatorContext ) ; break ; } } } catch ( ServiceRegistryException e ) { throw new DeploymentUnitProcessingException ( e ) ; } } } finally { WildFlySecurityManager . setCurrentContextClassLoaderPrivileged ( current ) ; } } | If the deployment has a module attached it will ask the module to load the ServiceActivator services . |
22,130 | synchronized void openConnection ( final ModelController controller , final ActiveOperation . CompletedCallback < ModelNode > callback ) throws Exception { boolean ok = false ; final Connection connection = connectionManager . connect ( ) ; try { channelHandler . executeRequest ( new ServerRegisterRequest ( ) , null , callback ) ; channelHandler . getAttachments ( ) . attach ( TransactionalProtocolClient . SEND_IDENTITY , Boolean . TRUE ) ; channelHandler . getAttachments ( ) . attach ( TransactionalProtocolClient . SEND_IN_VM , Boolean . TRUE ) ; channelHandler . addHandlerFactory ( new TransactionalProtocolOperationHandler ( controller , channelHandler , responseAttachmentSupport ) ) ; ok = true ; } finally { if ( ! ok ) { connection . close ( ) ; } } } | Connect to the HC and retrieve the current model updates . |
22,131 | synchronized void asyncReconnect ( final URI reconnectUri , String authKey , final ReconnectCallback callback ) { if ( getState ( ) != State . OPEN ) { return ; } final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration . copy ( configuration ) ; config . setCallbackHandler ( createClientCallbackHandler ( userName , authKey ) ) ; config . setUri ( reconnectUri ) ; this . configuration = config ; final ReconnectRunner reconnectTask = this . reconnectRunner ; if ( reconnectTask == null ) { final ReconnectRunner task = new ReconnectRunner ( ) ; task . callback = callback ; task . future = executorService . submit ( task ) ; } else { reconnectTask . callback = callback ; } } | This continuously tries to reconnect in a separate thread and will only stop if the connection was established successfully or the server gets shutdown . If there is currently a reconnect task active the connection paramaters and callback will get updated . |
22,132 | synchronized boolean doReConnect ( ) throws IOException { if ( connectionManager . isConnected ( ) ) { try { final Future < Long > result = channelHandler . executeRequest ( ManagementPingRequest . INSTANCE , null ) . getResult ( ) ; result . get ( 15 , TimeUnit . SECONDS ) ; return true ; } catch ( Exception e ) { ServerLogger . AS_ROOT_LOGGER . debugf ( e , "failed to ping the host-controller, going to reconnect" ) ; } final Connection connection = connectionManager . getConnection ( ) ; StreamUtils . safeClose ( connection ) ; if ( connection != null ) { try { connection . awaitClosed ( ) ; } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } } } boolean ok = false ; final Connection connection = connectionManager . connect ( ) ; try { final ActiveOperation < Boolean , Void > result = channelHandler . executeRequest ( new ServerReconnectRequest ( ) , null ) ; try { boolean inSync = result . getResult ( ) . get ( ) ; ok = true ; reconnectRunner = null ; return inSync ; } catch ( ExecutionException e ) { throw new IOException ( e ) ; } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } } finally { if ( ! ok ) { StreamUtils . safeClose ( connection ) ; } } } | Reconnect to the HC . |
22,133 | synchronized void started ( ) { try { if ( isConnected ( ) ) { channelHandler . executeRequest ( new ServerStartedRequest ( ) , null ) . getResult ( ) . await ( ) ; } } catch ( Exception e ) { ServerLogger . AS_ROOT_LOGGER . debugf ( e , "failed to send started notification" ) ; } } | Send the started notification |
22,134 | public int executeTask ( final TransactionalProtocolClient . TransactionalOperationListener < ServerOperation > listener , final ServerUpdateTask task ) { try { return execute ( listener , task . getServerIdentity ( ) , task . getOperation ( ) ) ; } catch ( OperationFailedException e ) { final ServerIdentity identity = task . getServerIdentity ( ) ; final ServerOperation serverOperation = new ServerOperation ( identity , task . getOperation ( ) , null , null , OperationResultTransformer . ORIGINAL_RESULT ) ; final TransactionalProtocolClient . PreparedOperation < ServerOperation > result = BlockingQueueOperationListener . FailedOperation . create ( serverOperation , e ) ; listener . operationPrepared ( result ) ; recordExecutedRequest ( new ExecutedServerRequest ( identity , result . getFinalResult ( ) , OperationResultTransformer . ORIGINAL_RESULT ) ) ; return 1 ; } } | Execute a server task . |
22,135 | protected boolean executeOperation ( final TransactionalProtocolClient . TransactionalOperationListener < ServerOperation > listener , TransactionalProtocolClient client , final ServerIdentity identity , final ModelNode operation , final OperationResultTransformer transformer ) { if ( client == null ) { return false ; } final OperationMessageHandler messageHandler = new DelegatingMessageHandler ( context ) ; final OperationAttachments operationAttachments = new DelegatingOperationAttachments ( context ) ; final ServerOperation serverOperation = new ServerOperation ( identity , operation , messageHandler , operationAttachments , transformer ) ; try { DomainControllerLogger . HOST_CONTROLLER_LOGGER . tracef ( "Sending %s to %s" , operation , identity ) ; final Future < OperationResponse > result = client . execute ( listener , serverOperation ) ; recordExecutedRequest ( new ExecutedServerRequest ( identity , result , transformer ) ) ; } catch ( IOException e ) { final TransactionalProtocolClient . PreparedOperation < ServerOperation > result = BlockingQueueOperationListener . FailedOperation . create ( serverOperation , e ) ; listener . operationPrepared ( result ) ; recordExecutedRequest ( new ExecutedServerRequest ( identity , result . getFinalResult ( ) , transformer ) ) ; } return true ; } | Execute the operation . |
22,136 | void recordPreparedOperation ( final TransactionalProtocolClient . PreparedOperation < ServerTaskExecutor . ServerOperation > preparedOperation ) { recordPreparedTask ( new ServerTaskExecutor . ServerPreparedResponse ( preparedOperation ) ) ; } | Record a prepare operation . |
22,137 | void recordOperationPrepareTimeout ( final BlockingQueueOperationListener . FailedOperation < ServerOperation > failedOperation ) { recordPreparedTask ( new ServerTaskExecutor . ServerPreparedResponse ( failedOperation ) ) ; ServerIdentity identity = failedOperation . getOperation ( ) . getIdentity ( ) ; AsyncFuture < OperationResponse > finalResult = failedOperation . getFinalResult ( ) ; synchronized ( submittedTasks ) { submittedTasks . put ( identity , new ServerTaskExecutor . ExecutedServerRequest ( identity , finalResult ) ) ; } } | Record a prepare operation timeout . |
22,138 | public static ServiceController < InstallationManager > installService ( ServiceTarget serviceTarget ) { final InstallationManagerService service = new InstallationManagerService ( ) ; return serviceTarget . addService ( InstallationManagerService . NAME , service ) . addDependency ( JBOSS_PRODUCT_CONFIG_SERVICE , ProductConfig . class , service . productConfig ) . setInitialMode ( ServiceController . Mode . ACTIVE ) . install ( ) ; } | Install the installation manager service . |
22,139 | public Method getMethod ( Method method ) { return getMethod ( method . getReturnType ( ) , method . getName ( ) , method . getParameterTypes ( ) ) ; } | Get the canonical method declared on this object . |
22,140 | public Collection < Method > getAllMethods ( String name ) { final Map < ParamList , Map < Class < ? > , Method > > nameMap = methods . get ( name ) ; if ( nameMap == null ) { return Collections . emptySet ( ) ; } final Collection < Method > methods = new ArrayList < Method > ( ) ; for ( Map < Class < ? > , Method > map : nameMap . values ( ) ) { methods . addAll ( map . values ( ) ) ; } return methods ; } | Get a collection of methods declared on this object by method name . |
22,141 | public Collection < Method > getAllMethods ( String name , int paramCount ) { final Map < ParamList , Map < Class < ? > , Method > > nameMap = methods . get ( name ) ; if ( nameMap == null ) { return Collections . emptySet ( ) ; } final Collection < Method > methods = new ArrayList < Method > ( ) ; for ( Map < Class < ? > , Method > map : nameMap . values ( ) ) { for ( Method method : map . values ( ) ) { if ( method . getParameterTypes ( ) . length == paramCount ) { methods . add ( method ) ; } } } return methods ; } | Get a collection of methods declared on this object by method name and parameter count . |
22,142 | public static ServiceActivator create ( final ModelNode endpointConfig , final URI managementURI , final String serverName , final String serverProcessName , final String authKey , final boolean managementSubsystemEndpoint , final Supplier < SSLContext > sslContextSupplier ) { return new DomainServerCommunicationServices ( endpointConfig , managementURI , serverName , serverProcessName , authKey , managementSubsystemEndpoint , sslContextSupplier ) ; } | Create a new service activator for the domain server communication services . |
22,143 | public InetSocketAddress getMulticastSocketAddress ( ) { if ( multicastAddress == null ) { throw MESSAGES . noMulticastBinding ( name ) ; } return new InetSocketAddress ( multicastAddress , multicastPort ) ; } | Get the multicast socket address . |
22,144 | public ServerSocket createServerSocket ( ) throws IOException { final ServerSocket socket = getServerSocketFactory ( ) . createServerSocket ( name ) ; socket . bind ( getSocketAddress ( ) ) ; return socket ; } | Create and bind a server socket |
22,145 | public static void registerDeploymentResource ( final DeploymentResourceSupport deploymentResourceSupport , final LoggingConfigurationService service ) { final PathElement base = PathElement . pathElement ( "configuration" , service . getConfiguration ( ) ) ; deploymentResourceSupport . getDeploymentSubModel ( LoggingExtension . SUBSYSTEM_NAME , base ) ; final LogContextConfiguration configuration = service . getValue ( ) ; if ( configuration != null ) { registerDeploymentResource ( deploymentResourceSupport , base , HANDLER , configuration . getHandlerNames ( ) ) ; registerDeploymentResource ( deploymentResourceSupport , base , LOGGER , configuration . getLoggerNames ( ) ) ; registerDeploymentResource ( deploymentResourceSupport , base , FORMATTER , configuration . getFormatterNames ( ) ) ; registerDeploymentResource ( deploymentResourceSupport , base , FILTER , configuration . getFilterNames ( ) ) ; registerDeploymentResource ( deploymentResourceSupport , base , POJO , configuration . getPojoNames ( ) ) ; registerDeploymentResource ( deploymentResourceSupport , base , ERROR_MANAGER , configuration . getErrorManagerNames ( ) ) ; } } | Registers the deployment resources needed . |
22,146 | public static String constructUrl ( final HttpServerExchange exchange , final String path ) { final HeaderMap headers = exchange . getRequestHeaders ( ) ; String host = headers . getFirst ( HOST ) ; String protocol = exchange . getConnection ( ) . getSslSessionInfo ( ) != null ? "https" : "http" ; return protocol + "://" + host + path ; } | Based on the current request represented by the HttpExchange construct a complete URL for the supplied path . |
22,147 | public boolean matches ( Property property ) { return property . getName ( ) . equals ( key ) && ( value == WILDCARD_VALUE || property . getValue ( ) . asString ( ) . equals ( value ) ) ; } | Determine whether the given property matches this element . A property matches this element when property name and this key are equal values are equal or this element value is a wildcard . |
22,148 | public boolean matches ( PathElement pe ) { return pe . key . equals ( key ) && ( isWildcard ( ) || pe . value . equals ( value ) ) ; } | Determine whether the given element matches this element . An element matches this element when keys are equal values are equal or this element value is a wildcard . |
22,149 | public void setAppender ( final Appender appender ) { if ( this . appender != null ) { close ( ) ; } checkAccess ( this ) ; if ( applyLayout && appender != null ) { final Formatter formatter = getFormatter ( ) ; appender . setLayout ( formatter == null ? null : new FormatterLayout ( formatter ) ) ; } appenderUpdater . set ( this , appender ) ; } | Set the Log4j appender . |
22,150 | private ModelNode createOSNode ( ) throws OperationFailedException { String osName = getProperty ( "os.name" ) ; final ModelNode os = new ModelNode ( ) ; if ( osName != null && osName . toLowerCase ( ) . contains ( "linux" ) ) { try { os . set ( GnuLinuxDistribution . discover ( ) ) ; } catch ( IOException ex ) { throw new OperationFailedException ( ex ) ; } } else { os . set ( osName ) ; } return os ; } | Create a ModelNode representing the operating system the instance is running on . |
22,151 | private ModelNode createJVMNode ( ) throws OperationFailedException { ModelNode jvm = new ModelNode ( ) . setEmptyObject ( ) ; jvm . get ( NAME ) . set ( getProperty ( "java.vm.name" ) ) ; jvm . get ( JAVA_VERSION ) . set ( getProperty ( "java.vm.specification.version" ) ) ; jvm . get ( JVM_VERSION ) . set ( getProperty ( "java.version" ) ) ; jvm . get ( JVM_VENDOR ) . set ( getProperty ( "java.vm.vendor" ) ) ; jvm . get ( JVM_HOME ) . set ( getProperty ( "java.home" ) ) ; return jvm ; } | Create a ModelNode representing the JVM the instance is running on . |
22,152 | private ModelNode createCPUNode ( ) throws OperationFailedException { ModelNode cpu = new ModelNode ( ) . setEmptyObject ( ) ; cpu . get ( ARCH ) . set ( getProperty ( "os.arch" ) ) ; cpu . get ( AVAILABLE_PROCESSORS ) . set ( ProcessorInfo . availableProcessors ( ) ) ; return cpu ; } | Create a ModelNode representing the CPU the instance is running on . |
22,153 | private String getProperty ( String name ) { return System . getSecurityManager ( ) == null ? System . getProperty ( name ) : doPrivileged ( new ReadPropertyAction ( name ) ) ; } | Get a System property by its name . |
22,154 | public void explore ( ) { if ( isLeaf ) return ; if ( isGeneric ) return ; removeAllChildren ( ) ; try { String addressPath = addressPath ( ) ; ModelNode resourceDesc = executor . doCommand ( addressPath + ":read-resource-description" ) ; resourceDesc = resourceDesc . get ( "result" ) ; ModelNode response = executor . doCommand ( addressPath + ":read-resource(include-runtime=true,include-defaults=true)" ) ; ModelNode result = response . get ( "result" ) ; if ( ! result . isDefined ( ) ) return ; List < String > childrenTypes = getChildrenTypes ( addressPath ) ; for ( ModelNode node : result . asList ( ) ) { Property prop = node . asProperty ( ) ; if ( childrenTypes . contains ( prop . getName ( ) ) ) { if ( hasGenericOperations ( addressPath , prop . getName ( ) ) ) { add ( new ManagementModelNode ( cliGuiCtx , new UserObject ( node , prop . getName ( ) ) ) ) ; } if ( prop . getValue ( ) . isDefined ( ) ) { for ( ModelNode innerNode : prop . getValue ( ) . asList ( ) ) { UserObject usrObj = new UserObject ( innerNode , prop . getName ( ) , innerNode . asProperty ( ) . getName ( ) ) ; add ( new ManagementModelNode ( cliGuiCtx , usrObj ) ) ; } } } else { UserObject usrObj = new UserObject ( node , resourceDesc , prop . getName ( ) , prop . getValue ( ) . asString ( ) ) ; add ( new ManagementModelNode ( cliGuiCtx , usrObj ) ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Refresh children using read - resource operation . |
22,155 | public String addressPath ( ) { if ( isLeaf ) { ManagementModelNode parent = ( ManagementModelNode ) getParent ( ) ; return parent . addressPath ( ) ; } StringBuilder builder = new StringBuilder ( ) ; for ( Object pathElement : getUserObjectPath ( ) ) { UserObject userObj = ( UserObject ) pathElement ; if ( userObj . isRoot ( ) ) { builder . append ( userObj . getName ( ) ) ; continue ; } builder . append ( userObj . getName ( ) ) ; builder . append ( "=" ) ; builder . append ( userObj . getEscapedValue ( ) ) ; builder . append ( "/" ) ; } return builder . toString ( ) ; } | Get the DMR path for this node . For leaves the DMR path is the path of its parent . |
22,156 | private static boolean mayBeIPv6Address ( String input ) { if ( input == null ) { return false ; } boolean result = false ; int colonsCounter = 0 ; int length = input . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = input . charAt ( i ) ; if ( c == '.' || c == '%' ) { break ; } if ( ! ( ( c >= '0' && c <= '9' ) || ( c >= 'a' && c <= 'f' ) || ( c >= 'A' && c <= 'F' ) || c == ':' ) ) { return false ; } else if ( c == ':' ) { colonsCounter ++ ; } } if ( colonsCounter >= 2 ) { result = true ; } return result ; } | Heuristic check if string might be an IPv6 address . |
22,157 | public static void initializeDomainRegistry ( final TransformerRegistry registry ) { registerRootTransformers ( registry ) ; registerChainedManagementTransformers ( registry ) ; registerChainedServerGroupTransformers ( registry ) ; registerProfileTransformers ( registry ) ; registerSocketBindingGroupTransformers ( registry ) ; registerDeploymentTransformers ( registry ) ; } | Initialize the domain registry . |
22,158 | static boolean killProcess ( final String processName , int id ) { int pid ; try { pid = processUtils . resolveProcessId ( processName , id ) ; if ( pid > 0 ) { try { Runtime . getRuntime ( ) . exec ( processUtils . getKillCommand ( pid ) ) ; return true ; } catch ( Throwable t ) { ProcessLogger . ROOT_LOGGER . debugf ( t , "failed to kill process '%s' with pid '%s'" , processName , pid ) ; } } } catch ( Throwable t ) { ProcessLogger . ROOT_LOGGER . debugf ( t , "failed to resolve pid of process '%s'" , processName ) ; } return false ; } | Try to kill a given process . |
22,159 | public Launcher addEnvironmentVariable ( final String key , final String value ) { env . put ( key , value ) ; return this ; } | Adds an environment variable to the process being created . |
22,160 | private void buildTransformers_3_0 ( ResourceTransformationDescriptionBuilder builder ) { builder . addChildResource ( ConnectorResource . PATH ) . getAttributeBuilder ( ) . setDiscard ( DiscardAttributeChecker . UNDEFINED , ConnectorCommon . SASL_AUTHENTICATION_FACTORY , ConnectorResource . SSL_CONTEXT ) . addRejectCheck ( RejectAttributeChecker . DEFINED , ConnectorCommon . SASL_AUTHENTICATION_FACTORY , ConnectorResource . SSL_CONTEXT ) ; builder . addChildResource ( RemotingEndpointResource . ENDPOINT_PATH ) . getAttributeBuilder ( ) . setValueConverter ( new AttributeConverter . DefaultAttributeConverter ( ) { protected void convertAttribute ( PathAddress address , String attributeName , ModelNode attributeValue , TransformationContext context ) { if ( ! attributeValue . isDefined ( ) ) { attributeValue . set ( "remoting" ) ; } } } , RemotingSubsystemRootResource . SASL_PROTOCOL ) ; builder . addChildResource ( HttpConnectorResource . PATH ) . getAttributeBuilder ( ) . setDiscard ( DiscardAttributeChecker . UNDEFINED , ConnectorCommon . SASL_AUTHENTICATION_FACTORY ) . addRejectCheck ( RejectAttributeChecker . DEFINED , ConnectorCommon . SASL_AUTHENTICATION_FACTORY ) ; builder . addChildResource ( RemoteOutboundConnectionResourceDefinition . ADDRESS ) . getAttributeBuilder ( ) . setDiscard ( DiscardAttributeChecker . UNDEFINED , ConnectorCommon . SASL_AUTHENTICATION_FACTORY ) . addRejectCheck ( RejectAttributeChecker . DEFINED , RemoteOutboundConnectionResourceDefinition . AUTHENTICATION_CONTEXT ) ; } | EAP 7 . 0 |
22,161 | private void buildTransformers_4_0 ( ResourceTransformationDescriptionBuilder builder ) { EndPointWriteTransformer endPointWriteTransformer = new EndPointWriteTransformer ( ) ; builder . getAttributeBuilder ( ) . setDiscard ( DiscardAttributeChecker . ALWAYS , endpointAttrArray ) . end ( ) . addOperationTransformationOverride ( "add" ) . setCustomOperationTransformer ( new EndPointAddTransformer ( ) ) . end ( ) . addOperationTransformationOverride ( "write-attribute" ) . setCustomOperationTransformer ( endPointWriteTransformer ) . end ( ) . addOperationTransformationOverride ( "undefine-attribute" ) . setCustomOperationTransformer ( endPointWriteTransformer ) . end ( ) ; } | EAP 7 . 1 |
22,162 | ServerStatus getState ( ) { final InternalState requiredState = this . requiredState ; final InternalState state = internalState ; if ( requiredState == InternalState . FAILED ) { return ServerStatus . FAILED ; } switch ( state ) { case STOPPED : return ServerStatus . STOPPED ; case SERVER_STARTED : return ServerStatus . STARTED ; default : { if ( requiredState == InternalState . SERVER_STARTED ) { return ServerStatus . STARTING ; } else { return ServerStatus . STOPPING ; } } } } | Determine the current state the server is in . |
22,163 | synchronized boolean reload ( int permit , boolean suspend ) { return internalSetState ( new ReloadTask ( permit , suspend ) , InternalState . SERVER_STARTED , InternalState . RELOADING ) ; } | Reload a managed server . |
22,164 | synchronized void start ( final ManagedServerBootCmdFactory factory ) { final InternalState required = this . requiredState ; if ( required == InternalState . SERVER_STARTED ) { return ; } if ( required != InternalState . FAILED ) { final InternalState current = this . internalState ; if ( current != required ) { throw new IllegalStateException ( ) ; } } operationID = CurrentOperationIdHolder . getCurrentOperationID ( ) ; bootConfiguration = factory . createConfiguration ( ) ; requiredState = InternalState . SERVER_STARTED ; ROOT_LOGGER . startingServer ( serverName ) ; transition ( ) ; } | Start a managed server . |
22,165 | synchronized void stop ( Integer timeout ) { final InternalState required = this . requiredState ; if ( required != InternalState . STOPPED ) { this . requiredState = InternalState . STOPPED ; ROOT_LOGGER . stoppingServer ( serverName ) ; if ( internalState == InternalState . SERVER_STARTED ) { internalSetState ( new ServerStopTask ( timeout ) , internalState , InternalState . PROCESS_STOPPING ) ; } else { transition ( false ) ; } } } | Stop a managed server . |
22,166 | synchronized void reconnectServerProcess ( final ManagedServerBootCmdFactory factory ) { if ( this . requiredState != InternalState . SERVER_STARTED ) { this . bootConfiguration = factory ; this . requiredState = InternalState . SERVER_STARTED ; ROOT_LOGGER . reconnectingServer ( serverName ) ; internalSetState ( new ReconnectTask ( ) , InternalState . STOPPED , InternalState . SEND_STDIN ) ; } } | Try to reconnect to a started server . |
22,167 | synchronized void removeServerProcess ( ) { this . requiredState = InternalState . STOPPED ; internalSetState ( new ProcessRemoveTask ( ) , InternalState . STOPPED , InternalState . PROCESS_REMOVING ) ; } | On host controller reload remove a not running server registered in the process controller declared as down . |
22,168 | synchronized void setServerProcessStopping ( ) { this . requiredState = InternalState . STOPPED ; internalSetState ( null , InternalState . STOPPED , InternalState . PROCESS_STOPPING ) ; } | On host controller reload remove a not running server registered in the process controller declared as stopping . |
22,169 | boolean awaitState ( final InternalState expected ) { synchronized ( this ) { final InternalState initialRequired = this . requiredState ; for ( ; ; ) { final InternalState required = this . requiredState ; if ( required == InternalState . FAILED ) { return false ; } else if ( initialRequired != required ) { return false ; } final InternalState current = this . internalState ; if ( expected == current ) { return true ; } try { wait ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return false ; } } } } | Await a state . |
22,170 | boolean processUnstable ( ) { boolean change = ! unstable ; if ( change ) { unstable = true ; HostControllerLogger . ROOT_LOGGER . managedServerUnstable ( serverName ) ; } return change ; } | Notification that the process has become unstable . |
22,171 | boolean callbackUnregistered ( final TransactionalProtocolClient old , final boolean shuttingDown ) { protocolClient . disconnected ( old ) ; synchronized ( this ) { if ( ! shuttingDown && requiredState == InternalState . SERVER_STARTED ) { final InternalState state = internalState ; if ( state == InternalState . PROCESS_STOPPED || state == InternalState . PROCESS_STOPPING || state == InternalState . STOPPED ) { return true ; } if ( state == InternalState . RELOADING ) { return true ; } try { ROOT_LOGGER . logf ( DEBUG_LEVEL , "trying to reconnect to %s current-state (%s) required-state (%s)" , serverName , state , requiredState ) ; internalSetState ( new ReconnectTask ( ) , state , InternalState . SEND_STDIN ) ; } catch ( Exception e ) { ROOT_LOGGER . logf ( DEBUG_LEVEL , e , "failed to send reconnect task" ) ; } return false ; } else { return true ; } } } | Unregister the mgmt channel . |
22,172 | synchronized void processFinished ( ) { final InternalState required = this . requiredState ; final InternalState state = this . internalState ; if ( required == InternalState . STOPPED && state == InternalState . PROCESS_STOPPING ) { finishTransition ( InternalState . PROCESS_STOPPING , InternalState . PROCESS_STOPPED ) ; } else { this . requiredState = InternalState . STOPPED ; if ( ! ( internalSetState ( getTransitionTask ( InternalState . PROCESS_STOPPING ) , internalState , InternalState . PROCESS_STOPPING ) && internalSetState ( getTransitionTask ( InternalState . PROCESS_REMOVING ) , internalState , InternalState . PROCESS_REMOVING ) && internalSetState ( getTransitionTask ( InternalState . STOPPED ) , internalState , InternalState . STOPPED ) ) ) { this . requiredState = InternalState . FAILED ; internalSetState ( null , internalState , InternalState . PROCESS_STOPPED ) ; } } } | Notification that the server process finished . |
22,173 | synchronized void transitionFailed ( final InternalState state ) { final InternalState current = this . internalState ; if ( state == current ) { switch ( current ) { case PROCESS_ADDING : this . internalState = InternalState . PROCESS_STOPPED ; break ; case PROCESS_STARTED : internalSetState ( getTransitionTask ( InternalState . PROCESS_STOPPING ) , InternalState . PROCESS_STARTED , InternalState . PROCESS_ADDED ) ; break ; case PROCESS_STARTING : this . internalState = InternalState . PROCESS_ADDED ; break ; case SEND_STDIN : case SERVER_STARTING : this . internalState = InternalState . PROCESS_STARTED ; break ; } this . requiredState = InternalState . FAILED ; notifyAll ( ) ; } } | Notification that a state transition failed . |
22,174 | private synchronized void finishTransition ( final InternalState current , final InternalState next ) { internalSetState ( getTransitionTask ( next ) , current , next ) ; transition ( ) ; } | Finish a state transition from a notification . |
22,175 | public void registerCapabilities ( ManagementResourceRegistration resourceRegistration ) { if ( capabilities != null ) { for ( RuntimeCapability c : capabilities ) { resourceRegistration . registerCapability ( c ) ; } } if ( incorporatingCapabilities != null ) { resourceRegistration . registerIncorporatingCapabilities ( incorporatingCapabilities ) ; } assert requirements != null ; resourceRegistration . registerRequirements ( requirements ) ; } | Register capabilities associated with this resource . |
22,176 | @ SuppressWarnings ( "deprecation" ) protected void registerAddOperation ( final ManagementResourceRegistration registration , final OperationStepHandler handler , OperationEntry . Flag ... flags ) { if ( handler instanceof DescriptionProvider ) { registration . registerOperationHandler ( getOperationDefinition ( ModelDescriptionConstants . ADD , ( DescriptionProvider ) handler , OperationEntry . EntryType . PUBLIC , flags ) , handler ) ; } else { registration . registerOperationHandler ( getOperationDefinition ( ModelDescriptionConstants . ADD , new DefaultResourceAddDescriptionProvider ( registration , descriptionResolver , orderedChild ) , OperationEntry . EntryType . PUBLIC , flags ) , handler ) ; } } | Registers add operation |
22,177 | private static void handlePing ( final Channel channel , final ManagementProtocolHeader header ) throws IOException { final ManagementProtocolHeader response = new ManagementPongHeader ( header . getVersion ( ) ) ; final MessageOutputStream output = channel . writeMessage ( ) ; try { writeHeader ( response , output ) ; output . close ( ) ; } finally { StreamUtils . safeClose ( output ) ; } } | Handle a simple ping request . |
22,178 | public static String resolveOrOriginal ( String input ) { try { return resolve ( input , true ) ; } catch ( UnresolvedExpressionException e ) { return input ; } } | Attempts to substitute all the found expressions in the input with their corresponding resolved values . If any of the found expressions failed to resolve or if the input does not contain any expression the input is returned as is . |
22,179 | private OperationResponse executeForResult ( final OperationExecutionContext executionContext ) throws IOException { try { return execute ( executionContext ) . get ( ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } } | Execute for result . |
22,180 | public static LayersConfig getLayersConfig ( final File repoRoot ) throws IOException { final File layersList = new File ( repoRoot , LAYERS_CONF ) ; if ( ! layersList . exists ( ) ) { return new LayersConfig ( ) ; } final Properties properties = PatchUtils . loadProperties ( layersList ) ; return new LayersConfig ( properties ) ; } | Process the layers . conf file . |
22,181 | private boolean parseRemoteDomainControllerAttributes_1_5 ( final XMLExtendedStreamReader reader , final ModelNode address , final List < ModelNode > list , boolean allowDiscoveryOptions ) throws XMLStreamException { final ModelNode update = new ModelNode ( ) ; update . get ( OP_ADDR ) . set ( address ) ; update . get ( OP ) . set ( RemoteDomainControllerAddHandler . OPERATION_NAME ) ; AdminOnlyDomainConfigPolicy adminOnlyPolicy = AdminOnlyDomainConfigPolicy . DEFAULT ; boolean requireDiscoveryOptions = false ; final int count = reader . getAttributeCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final String value = reader . getAttributeValue ( i ) ; if ( ! isNoNamespaceAttribute ( reader , i ) ) { throw unexpectedAttribute ( reader , i ) ; } else { final Attribute attribute = Attribute . forName ( reader . getAttributeLocalName ( i ) ) ; switch ( attribute ) { case HOST : { DomainControllerWriteAttributeHandler . HOST . parseAndSetParameter ( value , update , reader ) ; break ; } case PORT : { DomainControllerWriteAttributeHandler . PORT . parseAndSetParameter ( value , update , reader ) ; break ; } case SECURITY_REALM : { DomainControllerWriteAttributeHandler . SECURITY_REALM . parseAndSetParameter ( value , update , reader ) ; break ; } case USERNAME : { DomainControllerWriteAttributeHandler . USERNAME . parseAndSetParameter ( value , update , reader ) ; break ; } case ADMIN_ONLY_POLICY : { DomainControllerWriteAttributeHandler . ADMIN_ONLY_POLICY . parseAndSetParameter ( value , update , reader ) ; ModelNode nodeValue = update . get ( DomainControllerWriteAttributeHandler . ADMIN_ONLY_POLICY . getName ( ) ) ; if ( nodeValue . getType ( ) != ModelType . EXPRESSION ) { adminOnlyPolicy = AdminOnlyDomainConfigPolicy . getPolicy ( nodeValue . asString ( ) ) ; } break ; } default : throw unexpectedAttribute ( reader , i ) ; } } } if ( ! update . hasDefined ( DomainControllerWriteAttributeHandler . HOST . getName ( ) ) ) { if ( allowDiscoveryOptions ) { requireDiscoveryOptions = isRequireDiscoveryOptions ( adminOnlyPolicy ) ; } else { throw ParseUtils . missingRequired ( reader , Collections . singleton ( Attribute . HOST . getLocalName ( ) ) ) ; } } if ( ! update . hasDefined ( DomainControllerWriteAttributeHandler . PORT . getName ( ) ) ) { if ( allowDiscoveryOptions ) { requireDiscoveryOptions = requireDiscoveryOptions || isRequireDiscoveryOptions ( adminOnlyPolicy ) ; } else { throw ParseUtils . missingRequired ( reader , Collections . singleton ( Attribute . PORT . getLocalName ( ) ) ) ; } } list . add ( update ) ; return requireDiscoveryOptions ; } | The only difference between version 1 . 5 and 1 . 6 of the schema were to make is possible to define discovery options this resulted in the host and port attributes becoming optional - this method also indicates if discovery options are required where the host and port were not supplied . |
22,182 | public static RemoteProxyController create ( final TransactionalProtocolClient client , final PathAddress pathAddress , final ProxyOperationAddressTranslator addressTranslator , final ModelVersion targetKernelVersion ) { return new RemoteProxyController ( client , pathAddress , addressTranslator , targetKernelVersion ) ; } | Create a new remote proxy controller . |
22,183 | public static RemoteProxyController create ( final ManagementChannelHandler channelAssociation , final PathAddress pathAddress , final ProxyOperationAddressTranslator addressTranslator ) { final TransactionalProtocolClient client = TransactionalProtocolHandlers . createClient ( channelAssociation ) ; return create ( client , pathAddress , addressTranslator , ModelVersion . CURRENT ) ; } | Creates a new remote proxy controller using an existing channel . |
22,184 | public ModelNode translateOperationForProxy ( final ModelNode op ) { return translateOperationForProxy ( op , PathAddress . pathAddress ( op . get ( OP_ADDR ) ) ) ; } | Translate the operation address . |
22,185 | private void flush ( final boolean propagate ) throws IOException { final int avail = baseNCodec . available ( context ) ; if ( avail > 0 ) { final byte [ ] buf = new byte [ avail ] ; final int c = baseNCodec . readResults ( buf , 0 , avail , context ) ; if ( c > 0 ) { out . write ( buf , 0 , c ) ; } } if ( propagate ) { out . flush ( ) ; } } | Flushes this output stream and forces any buffered output bytes to be written out to the stream . If propagate is true the wrapped stream will also be flushed . |
22,186 | public void close ( ) throws IOException { if ( doEncode ) { baseNCodec . encode ( singleByte , 0 , EOF , context ) ; } else { baseNCodec . decode ( singleByte , 0 , EOF , context ) ; } flush ( ) ; out . close ( ) ; } | Closes this output stream and releases any system resources associated with the stream . |
22,187 | private ModelNode resolveExpressionsRecursively ( final ModelNode node ) throws OperationFailedException { if ( ! node . isDefined ( ) ) { return node ; } ModelType type = node . getType ( ) ; ModelNode resolved ; if ( type == ModelType . EXPRESSION ) { resolved = resolveExpressionStringRecursively ( node . asExpression ( ) . getExpressionString ( ) , lenient , true ) ; } else if ( type == ModelType . OBJECT ) { resolved = node . clone ( ) ; for ( Property prop : resolved . asPropertyList ( ) ) { resolved . get ( prop . getName ( ) ) . set ( resolveExpressionsRecursively ( prop . getValue ( ) ) ) ; } } else if ( type == ModelType . LIST ) { resolved = node . clone ( ) ; ModelNode list = new ModelNode ( ) ; list . setEmptyList ( ) ; for ( ModelNode current : resolved . asList ( ) ) { list . add ( resolveExpressionsRecursively ( current ) ) ; } resolved = list ; } else if ( type == ModelType . PROPERTY ) { resolved = node . clone ( ) ; resolved . set ( resolved . asProperty ( ) . getName ( ) , resolveExpressionsRecursively ( resolved . asProperty ( ) . getValue ( ) ) ) ; } else { resolved = node ; } return resolved ; } | Examine the given model node resolving any expressions found within including within child nodes . |
22,188 | private ModelNode resolveExpressionStringRecursively ( final String expressionString , final boolean ignoreDMRResolutionFailure , final boolean initial ) throws OperationFailedException { ParseAndResolveResult resolved = parseAndResolve ( expressionString , ignoreDMRResolutionFailure ) ; if ( resolved . recursive ) { return resolveExpressionStringRecursively ( resolved . result , true , false ) ; } else if ( resolved . modified ) { return new ModelNode ( resolved . result ) ; } else if ( initial && EXPRESSION_PATTERN . matcher ( expressionString ) . matches ( ) ) { assert ignoreDMRResolutionFailure ; return new ModelNode ( new ValueExpression ( expressionString ) ) ; } else { return new ModelNode ( expressionString ) ; } } | Attempt to resolve the given expression string recursing if resolution of one string produces another expression . |
22,189 | private String resolveExpressionString ( final String unresolvedString ) throws OperationFailedException { assert unresolvedString . startsWith ( "${" ) && unresolvedString . endsWith ( "}" ) ; String result = unresolvedString ; ModelNode resolveNode = new ModelNode ( new ValueExpression ( unresolvedString ) ) ; resolvePluggableExpression ( resolveNode ) ; if ( resolveNode . getType ( ) == ModelType . EXPRESSION ) { String resolvedString = resolveStandardExpression ( resolveNode ) ; if ( ! unresolvedString . equals ( resolvedString ) ) { result = resolvedString ; } } else { result = resolveNode . asString ( ) ; } return result ; } | Resolve the given string using any plugin and the DMR resolve method |
22,190 | private static XMLStreamException unexpectedElement ( final XMLStreamReader reader ) { return SecurityManagerLogger . ROOT_LOGGER . unexpectedElement ( reader . getName ( ) , reader . getLocation ( ) ) ; } | Gets an exception reporting an unexpected XML element . |
22,191 | private static XMLStreamException unexpectedAttribute ( final XMLStreamReader reader , final int index ) { return SecurityManagerLogger . ROOT_LOGGER . unexpectedAttribute ( reader . getAttributeName ( index ) , reader . getLocation ( ) ) ; } | Gets an exception reporting an unexpected XML attribute . |
22,192 | public static byte [ ] storeContentAndTransformOperation ( OperationContext context , ModelNode operation , ContentRepository contentRepository ) throws IOException , OperationFailedException { if ( ! operation . hasDefined ( CONTENT ) ) { throw createFailureException ( DomainControllerLogger . ROOT_LOGGER . invalidContentDeclaration ( ) ) ; } final ModelNode content = operation . get ( CONTENT ) . get ( 0 ) ; if ( content . hasDefined ( HASH ) ) { throw createFailureException ( DomainControllerLogger . ROOT_LOGGER . invalidContentDeclaration ( ) ) ; } final byte [ ] hash = storeDeploymentContent ( context , operation , contentRepository ) ; final ModelNode slave = operation . clone ( ) ; slave . get ( CONTENT ) . setEmptyList ( ) . add ( ) . get ( HASH ) . set ( hash ) ; List < DomainOperationTransmuter > transformers = context . getAttachment ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS ) ; if ( transformers == null ) { context . attach ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS , transformers = new ArrayList < > ( ) ) ; } transformers . add ( new CompositeOperationAwareTransmuter ( slave ) ) ; return hash ; } | Store the deployment contents and attach a transformed slave operation to the operation context . |
22,193 | public static byte [ ] explodeContentAndTransformOperation ( OperationContext context , ModelNode operation , ContentRepository contentRepository ) throws OperationFailedException , ExplodedContentException { final Resource deploymentResource = context . readResource ( PathAddress . EMPTY_ADDRESS ) ; ModelNode contentItem = getContentItem ( deploymentResource ) ; ModelNode explodedPath = DEPLOYMENT_CONTENT_PATH . resolveModelAttribute ( context , operation ) ; byte [ ] oldHash = CONTENT_HASH . resolveModelAttribute ( context , contentItem ) . asBytes ( ) ; final byte [ ] hash ; if ( explodedPath . isDefined ( ) ) { hash = contentRepository . explodeSubContent ( oldHash , explodedPath . asString ( ) ) ; } else { hash = contentRepository . explodeContent ( oldHash ) ; } final ModelNode slave = operation . clone ( ) ; ModelNode addedContent = new ModelNode ( ) . setEmptyObject ( ) ; addedContent . get ( HASH ) . set ( hash ) ; addedContent . get ( TARGET_PATH . getName ( ) ) . set ( "./" ) ; slave . get ( CONTENT ) . setEmptyList ( ) . add ( addedContent ) ; List < DomainOperationTransmuter > transformers = context . getAttachment ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS ) ; if ( transformers == null ) { context . attach ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS , transformers = new ArrayList < > ( ) ) ; } transformers . add ( new CompositeOperationAwareTransmuter ( slave ) ) ; return hash ; } | Explode the deployment contents and attach a transformed slave operation to the operation context . |
22,194 | public static byte [ ] addContentToExplodedAndTransformOperation ( OperationContext context , ModelNode operation , ContentRepository contentRepository ) throws OperationFailedException , ExplodedContentException { final Resource deploymentResource = context . readResource ( PathAddress . EMPTY_ADDRESS ) ; ModelNode contentItem = getContentItem ( deploymentResource ) ; byte [ ] oldHash = CONTENT_HASH . resolveModelAttribute ( context , contentItem ) . asBytes ( ) ; List < ModelNode > contents = CONTENT_PARAM_ALL_EXPLODED . resolveModelAttribute ( context , operation ) . asList ( ) ; final List < ExplodedContent > addedFiles = new ArrayList < > ( contents . size ( ) ) ; final ModelNode slave = operation . clone ( ) ; ModelNode slaveAddedfiles = slave . get ( UPDATED_PATHS . getName ( ) ) . setEmptyList ( ) ; for ( ModelNode content : contents ) { InputStream in ; if ( hasValidContentAdditionParameterDefined ( content ) ) { in = getInputStream ( context , content ) ; } else { in = null ; } String path = TARGET_PATH . resolveModelAttribute ( context , content ) . asString ( ) ; addedFiles . add ( new ExplodedContent ( path , in ) ) ; slaveAddedfiles . add ( path ) ; } final boolean overwrite = OVERWRITE . resolveModelAttribute ( context , operation ) . asBoolean ( true ) ; final byte [ ] hash = contentRepository . addContentToExploded ( oldHash , addedFiles , overwrite ) ; ModelNode addedContent = new ModelNode ( ) . setEmptyObject ( ) ; addedContent . get ( HASH ) . set ( hash ) ; addedContent . get ( TARGET_PATH . getName ( ) ) . set ( "." ) ; slave . get ( CONTENT ) . setEmptyList ( ) . add ( addedContent ) ; List < DomainOperationTransmuter > transformers = context . getAttachment ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS ) ; if ( transformers == null ) { context . attach ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS , transformers = new ArrayList < > ( ) ) ; } transformers . add ( new CompositeOperationAwareTransmuter ( slave ) ) ; return hash ; } | Add contents to the deployment and attach a transformed slave operation to the operation context . |
22,195 | public static byte [ ] removeContentFromExplodedAndTransformOperation ( OperationContext context , ModelNode operation , ContentRepository contentRepository ) throws OperationFailedException , ExplodedContentException { final Resource deploymentResource = context . readResource ( PathAddress . EMPTY_ADDRESS ) ; ModelNode contentItemNode = getContentItem ( deploymentResource ) ; final byte [ ] oldHash = CONTENT_HASH . resolveModelAttribute ( context , contentItemNode ) . asBytes ( ) ; final List < String > paths = REMOVED_PATHS . unwrap ( context , operation ) ; final byte [ ] hash = contentRepository . removeContentFromExploded ( oldHash , paths ) ; final ModelNode slave = operation . clone ( ) ; slave . get ( CONTENT ) . setEmptyList ( ) . add ( ) . get ( HASH ) . set ( hash ) ; slave . get ( CONTENT ) . add ( ) . get ( ARCHIVE ) . set ( false ) ; List < DomainOperationTransmuter > transformers = context . getAttachment ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS ) ; if ( transformers == null ) { context . attach ( OperationAttachments . SLAVE_SERVER_OPERATION_TRANSMUTERS , transformers = new ArrayList < > ( ) ) ; } transformers . add ( new CompositeOperationAwareTransmuter ( slave ) ) ; return hash ; } | Remove contents from the deployment and attach a transformed slave operation to the operation context . |
22,196 | public static byte [ ] synchronizeSlaveHostController ( ModelNode operation , final PathAddress address , HostFileRepository fileRepository , ContentRepository contentRepository , boolean backup , byte [ ] oldHash ) { ModelNode operationContentItem = operation . get ( DeploymentAttributes . CONTENT_RESOURCE_ALL . getName ( ) ) . get ( 0 ) ; byte [ ] newHash = operationContentItem . require ( CONTENT_HASH . getName ( ) ) . asBytes ( ) ; if ( needRemoteContent ( fileRepository , contentRepository , backup , oldHash ) ) { fileRepository . getDeploymentFiles ( ModelContentReference . fromModelAddress ( address , newHash ) ) ; } return newHash ; } | Synchronize the required files to a slave HC from the master DC if this is required . |
22,197 | public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; for ( ResourceRoot resourceRoot : DeploymentUtils . allResourceRoots ( deploymentUnit ) ) { ResourceRootIndexer . indexResourceRoot ( resourceRoot ) ; } } | Process this deployment for annotations . This will use an annotation indexer to create an index of all annotations found in this deployment and attach it to the deployment unit context . |
22,198 | public static File newFile ( File baseDir , String ... segments ) { File f = baseDir ; for ( String segment : segments ) { f = new File ( f , segment ) ; } return f ; } | Return a new File object based on the baseDir and the segments . |
22,199 | public PasswordCheckResult check ( boolean isAdminitrative , String userName , String password ) { List < PasswordRestriction > passwordValuesRestrictions = getPasswordRestrictions ( ) ; final PasswordStrengthCheckResult strengthResult = this . passwordStrengthChecker . check ( userName , password , passwordValuesRestrictions ) ; final int failedRestrictions = strengthResult . getRestrictionFailures ( ) . size ( ) ; final PasswordStrength strength = strengthResult . getStrength ( ) ; final boolean strongEnough = assertStrength ( strength ) ; PasswordCheckResult . Result resultAction ; String resultMessage = null ; if ( isAdminitrative ) { if ( strongEnough ) { if ( failedRestrictions > 0 ) { resultAction = Result . WARN ; resultMessage = strengthResult . getRestrictionFailures ( ) . get ( 0 ) . getMessage ( ) ; } else { resultAction = Result . ACCEPT ; } } else { resultAction = Result . WARN ; resultMessage = ROOT_LOGGER . passwordNotStrongEnough ( strength . toString ( ) , this . acceptable . toString ( ) ) ; } } else { if ( strongEnough ) { if ( failedRestrictions > 0 ) { resultAction = Result . REJECT ; resultMessage = strengthResult . getRestrictionFailures ( ) . get ( 0 ) . getMessage ( ) ; } else { resultAction = Result . ACCEPT ; } } else { if ( failedRestrictions > 0 ) { resultAction = Result . REJECT ; resultMessage = strengthResult . getRestrictionFailures ( ) . get ( 0 ) . getMessage ( ) ; } else { resultAction = Result . REJECT ; resultMessage = ROOT_LOGGER . passwordNotStrongEnough ( strength . toString ( ) , this . acceptable . toString ( ) ) ; } } } return new PasswordCheckResult ( resultAction , resultMessage ) ; } | Method which performs strength checks on password . It returns outcome which can be used by CLI . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.