private static boolean syncWithMaster ( final Resource domain , final PathElement hostElement ) { final Resource host = domain . getChild ( hostElement ) ; assert host != null ; final Set < String > profiles = new HashSet <> ( ) ; final Set < String > serverGroups = new HashSet <> ( ) ; final Set < String > socketBindings = new HashSet <> ( ) ; for ( final Resource . ResourceEntry serverConfig : host . getChildren ( SERVER_CONFIG ) ) { final ModelNode model = serverConfig . getModel ( ) ; final String group = model . require ( GROUP ) . asString ( ) ; if ( ! serverGroups . contains ( group ) ) { serverGroups . add ( group ) ; } if ( model . hasDefined ( SOCKET_BINDING_GROUP ) ) { processSocketBindingGroup ( domain , model . require ( SOCKET_BINDING_GROUP ) . asString ( ) , socketBindings ) ; } } // process referenced server-groups for ( final Resource . ResourceEntry serverGroup : domain . getChildren ( SERVER_GROUP ) ) { // If we have an unreferenced server-group if ( ! serverGroups . remove ( serverGroup . getName ( ) ) ) { return true ; } final ModelNode model = serverGroup . getModel ( ) ; final String profile = model . require ( PROFILE ) . asString ( ) ; // Process the profile processProfile ( domain , profile , profiles ) ; // Process the socket-binding-group processSocketBindingGroup ( domain , model . require ( SOCKET_BINDING_GROUP ) . asString ( ) , socketBindings ) ; } // If we are missing a server group if ( ! serverGroups . isEmpty ( ) ) { return true ; } // Process profiles for ( final Resource . ResourceEntry profile : domain . getChildren ( PROFILE ) ) { // We have an unreferenced profile if ( ! profiles . remove ( profile . getName ( ) ) ) { return true ; } } // We are missing a profile if ( ! profiles . isEmpty ( ) ) { return true ; } // Process socket-binding groups for ( final Resource . ResourceEntry socketBindingGroup : domain . getChildren ( SOCKET_BINDING_GROUP ) ) { // We have an unreferenced socket-binding group if ( ! socketBindings . remove ( socketBindingGroup . getName ( ) ) ) { return true ; } } // We are missing a socket-binding group if ( ! socketBindings . isEmpty ( ) ) { return true ; } // Looks good! return false ; }
Determine whether all references are available locally .