@Override public Set<? extends NodePropertiesConfiguration> getNodeConfigurations() throws AppClusterConfigurationException { Set<String> ids = getUniqueStrings("appcluster.nodes", true); Set<NodePropertiesConfiguration> nodes = new LinkedHashSet<NodePropertiesConfiguration>(ids.size()*4/3+1); for(String id : ids) { if( !nodes.add(new NodePropertiesConfiguration(this, id)) ) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(nodes); }
private ServiceSet( Service template, Set<Service> services ) { this.template = template; this.services = AoCollections.optimalUnmodifiableSet(services); SortedSet<Target> newTargets = new TreeSet<Target>(); for(Service service : services) { newTargets.addAll(service.getTargets()); } this.targets = AoCollections.optimalUnmodifiableSortedSet(newTargets); }
@Override public Set<? extends JdbcResourceNodePropertiesConfiguration> getResourceNodeConfigurations() throws AppClusterConfigurationException { String resourceId = getId(); Set<String> nodeIds = properties.getUniqueStrings("appcluster.resource."+id+".nodes", true); Set<JdbcResourceNodePropertiesConfiguration> resourceNodes = new LinkedHashSet<JdbcResourceNodePropertiesConfiguration>(nodeIds.size()*4/3+1); for(String nodeId : nodeIds) { if(!resourceNodes.add(new JdbcResourceNodePropertiesConfiguration(properties, resourceId, nodeId, type))) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(resourceNodes); }
@Override public Set<Table> getVertices() throws SQLException { Set<Table> vertices = new LinkedHashSet<>(); for(Schema schema : getSchemas().values()) { for(Table table : schema.getTables().values()) { if(tableTypes==null || tableTypes.contains(table.getTableType())) vertices.add(table); } } return AoCollections.optimalUnmodifiableSet(vertices); }
@Override public Set<? extends ImapResourceNodePropertiesConfiguration> getResourceNodeConfigurations() throws AppClusterConfigurationException { String resourceId = getId(); Set<String> nodeIds = properties.getUniqueStrings("appcluster.resource."+id+".nodes", true); Set<ImapResourceNodePropertiesConfiguration> resourceNodes = new LinkedHashSet<ImapResourceNodePropertiesConfiguration>(nodeIds.size()*4/3+1); for(String nodeId : nodeIds) { if(!resourceNodes.add(new ImapResourceNodePropertiesConfiguration(properties, resourceId, nodeId, type))) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(resourceNodes); }
@Override public Set<? extends Csync2ResourceNodePropertiesConfiguration> getResourceNodeConfigurations() throws AppClusterConfigurationException { String resourceId = getId(); Set<String> nodeIds = properties.getUniqueStrings("appcluster.resource."+id+".nodes", true); Set<Csync2ResourceNodePropertiesConfiguration> resourceNodes = new LinkedHashSet<Csync2ResourceNodePropertiesConfiguration>(nodeIds.size()*4/3+1); for(String nodeId : nodeIds) { if(!resourceNodes.add(new Csync2ResourceNodePropertiesConfiguration(properties, resourceId, nodeId, type))) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(resourceNodes); }
@Override public Set<? extends DnsOnlyResourceNodePropertiesConfiguration> getResourceNodeConfigurations() throws AppClusterConfigurationException { String resourceId = getId(); Set<String> nodeIds = properties.getUniqueStrings("appcluster.resource."+id+".nodes", true); Set<DnsOnlyResourceNodePropertiesConfiguration> resourceNodes = new LinkedHashSet<DnsOnlyResourceNodePropertiesConfiguration>(nodeIds.size()*4/3+1); for(String nodeId : nodeIds) { if(!resourceNodes.add(new DnsOnlyResourceNodePropertiesConfiguration(properties, resourceId, nodeId, type))) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(resourceNodes); }
@Override public Set<Edge<Table>> getEdgesFrom(Table from) throws SQLException { Set<? extends Table> tos = from.getImportedTables(); Set<Edge<Table>> edges = new LinkedHashSet<>(tos.size()*4/3+1); for(Table to : tos) { if( tableTypes==null || tableTypes.contains(from.getTableType()) || tableTypes.contains(to.getTableType()) ) edges.add(new Edge<>(from, to)); } return AoCollections.optimalUnmodifiableSet(edges); }
@Override public Set<Edge<Table>> getEdgesTo(Table to) throws SQLException { Set<? extends Table> froms = to.getExportedTables(); Set<Edge<Table>> edges = new LinkedHashSet<>(froms.size()*4/3+1); for(Table from : froms) { if( tableTypes==null || tableTypes.contains(from.getTableType()) || tableTypes.contains(to.getTableType()) ) edges.add(new Edge<>(from, to)); } return AoCollections.optimalUnmodifiableSet(edges); } };
allServices.put( currentZone, AoCollections.optimalUnmodifiableSet(zoneServices) ) != null ) {
/** * Gets a unique set of trimmed strings. Must have at least one value when required. */ public Set<String> getUniqueStrings(String propertyName, boolean required) throws AppClusterConfigurationException { String paramValue = getString(propertyName, required); if(paramValue==null) return Collections.emptySet(); List<String> values = StringUtility.splitStringCommaSpace(paramValue); Set<String> set = new LinkedHashSet<String>(values.size()*4/3+1); for(String value : values) { value = value.trim(); if(value.length()>0 && !set.add(value)) { throw new AppClusterConfigurationException( ApplicationResources.accessor.getMessage("AppClusterPropertiesConfiguration.getStrings.duplicate", propertyName, value) ); } } if(required && set.isEmpty()) throw new AppClusterConfigurationException(ApplicationResources.accessor.getMessage("AppClusterPropertiesConfiguration.getString.missingValue", propertyName)); return AoCollections.optimalUnmodifiableSet(set); }
@Override public Set<? extends ResourceConfiguration<?,?>> getResourceConfigurations() throws AppClusterConfigurationException { // Get all of the resource types Set<String> types = getUniqueStrings("appcluster.resourceTypes", true); Map<String,ResourcePropertiesConfigurationFactory<?,?>> factories = new HashMap<String,ResourcePropertiesConfigurationFactory<?,?>>(types.size()*4/3+1); for(String type : types) { factories.put(type, getResourcePropertiesConfigurationFactory(getString("appcluster.resourceType."+type+".factory", true))); } Set<String> ids = getUniqueStrings("appcluster.resources", true); Set<ResourceConfiguration<?,?>> resources = new LinkedHashSet<ResourceConfiguration<?,?>>(ids.size()*4/3+1); for(String id : ids) { String propertyName = "appcluster.resource."+id+".type"; String type = getString(propertyName, true); ResourcePropertiesConfigurationFactory<?,?> factory = factories.get(type); if(factory==null) throw new AppClusterConfigurationException(ApplicationResources.accessor.getMessage("AppClusterPropertiesConfiguration.getResourceConfigurations.unexpectedType", propertyName, type)); if(!resources.add(factory.newResourcePropertiesConfiguration(this, id))) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(resources); } }
/** * Gets all the parents of the given page that are not in missing books * and are applicable to the given view. * * @return The filtered set of parents, in the order declared by the page. */ public static Set<Page> getApplicableParents( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, View view, Page page ) throws ServletException, IOException { Collection<Page> parents = CapturePage.capturePages( servletContext, request, response, filterNotMissingBook(page.getParentRefs()), CaptureLevel.META // TODO: View provide capture level required for isApplicable check, might be PAGE or (null for none) for some views. ).values(); Set<Page> applicableParents = new LinkedHashSet<Page>(parents.size() *4/3+1); for(Page parent : parents) { if(view.isApplicable(servletContext, request, response, parent)) { applicableParents.add(parent); } } return AoCollections.optimalUnmodifiableSet(applicableParents); }
Node(AppCluster cluster, NodeConfiguration nodeConfiguration) { this.cluster = cluster; this.id = nodeConfiguration.getId(); this.enabled = cluster.isEnabled() && nodeConfiguration.isEnabled(); this.display = nodeConfiguration.getDisplay(); this.hostname = nodeConfiguration.getHostname(); this.username = nodeConfiguration.getUsername(); Set<? extends Name> configNameservers = nodeConfiguration.getNameservers(); Set<Nameserver> newNameservers = new LinkedHashSet<Nameserver>(configNameservers.size()*4/3+1); for(Name nameserver : configNameservers) newNameservers.add(new Nameserver(cluster, nameserver)); this.nameservers = AoCollections.optimalUnmodifiableSet(newNameservers); }
/** * Gets a unique set of trimmed names. Must have at least one value. */ public Set<? extends Name> getUniqueNames(String propertyName) throws AppClusterConfigurationException { try { List<String> values = StringUtility.splitStringCommaSpace(getString(propertyName, true)); Set<Name> set = new LinkedHashSet<Name>(values.size()*4/3+1); for(String value : values) { value = value.trim(); if(value.length()>0 && !set.add(Name.fromString(value))) { throw new AppClusterConfigurationException( ApplicationResources.accessor.getMessage("AppClusterPropertiesConfiguration.getStrings.duplicate", propertyName, value) ); } } if(set.isEmpty()) throw new AppClusterConfigurationException(ApplicationResources.accessor.getMessage("AppClusterPropertiesConfiguration.getString.missingValue", propertyName)); return AoCollections.optimalUnmodifiableSet(set); } catch(TextParseException exc) { throw new AppClusterConfigurationException(exc); } }
/** * Gets the set of tables that this table depends on. * * This is based on getImportedKeys */ public Set<? extends Table> getImportedTables() throws SQLException { synchronized(getImportedTablesLock) { if(getImportedTablesCache==null) { Set<Table> newImportedTables = new LinkedHashSet<>(); Catalog catalog = schema.getCatalog(); DatabaseMetaData metaData = catalog.getMetaData(); try (ResultSet results = schema.getCatalog().getMetaData().getMetaData().getImportedKeys(schema.getCatalog().getName(), schema.getName(), name)) { while(results.next()) { String pkCat = results.getString("PKTABLE_CAT"); Catalog pkCatalog = pkCat==null ? catalog : metaData.getCatalog(pkCat); newImportedTables.add( pkCatalog .getSchema(results.getString("PKTABLE_SCHEM")) .getTable(results.getString("PKTABLE_NAME")) ); } } getImportedTablesCache = AoCollections.optimalUnmodifiableSet(newImportedTables); } return getImportedTablesCache; } }
/** * Gets the set of tables that depend on this table. * * This is based on getExportedKeys */ public Set<? extends Table> getExportedTables() throws SQLException { synchronized(getExportedTablesLock) { if(getExportedTablesCache==null) { Set<Table> newExportedTables = new LinkedHashSet<>(); Catalog catalog = schema.getCatalog(); DatabaseMetaData metaData = catalog.getMetaData(); try (ResultSet results = schema.getCatalog().getMetaData().getMetaData().getExportedKeys(schema.getCatalog().getName(), schema.getName(), name)) { while(results.next()) { String fkCat = results.getString("FKTABLE_CAT"); Catalog fkCatalog = fkCat==null ? catalog : metaData.getCatalog(fkCat); newExportedTables.add( fkCatalog .getSchema(results.getString("FKTABLE_SCHEM")) .getTable(results.getString("FKTABLE_NAME")) ); } } getExportedTablesCache = AoCollections.optimalUnmodifiableSet(newExportedTables); } return getExportedTablesCache; } } }
newNodes.add(new Node(this, nodeConfiguration)); nodes = AoCollections.optimalUnmodifiableSet(newNodes); resource.start(); resources = AoCollections.optimalUnmodifiableSet(newResources); } catch(TextParseException exc) { throw new AppClusterConfigurationException(exc);
newResourceNodes.add(rn); this.resourceNodes = AoCollections.optimalUnmodifiableSet(newResourceNodes); final Set<Nameserver> newEnabledNameservers = new LinkedHashSet<Nameserver>(); for(ResourceNode<?,?> resourceNode : resourceNodes) { if(node.isEnabled()) newEnabledNameservers.addAll(node.getNameservers()); this.enabledNameservers = AoCollections.optimalUnmodifiableSet(newEnabledNameservers);