public void startContext(URI uri) throws GroupInitializationException { if (RuntimeMode.NODE == info.getRuntimeMode() && discoveryAgent == null) { return; } else if (RuntimeMode.NODE == info.getRuntimeMode() && !discoveryAgent.isLeader()) { // defer instantiation until this node becomes zone leader synchronized (deferredContexts) { deferredContexts.add(uri); } return; } activated = true; super.startContext(uri); }
public void startContext(URI uri) throws GroupInitializationException { if (RuntimeMode.NODE == info.getRuntimeMode() && discoveryAgent == null) { return; } else if (RuntimeMode.NODE == info.getRuntimeMode() && !discoveryAgent.isLeader()) { // defer instantiation until this node becomes zone leader synchronized (deferredContexts) { deferredContexts.add(uri); } return; } activated = true; super.startContext(uri); }
public URL resolveUrl(LogicalBinding<WsBinding> binding) throws Fabric3Exception { try { URL targetUrl; String path = binding.getDefinition().getTargetUri().toString(); if (path == null) { path = binding.getParent().getUri().getFragment(); } boolean https = false; if (RuntimeMode.VM == hostInfo.getRuntimeMode()) { // single VM if (https) { targetUrl = new URL("https://localhost:" + servletHost.getHttpsPort() + "/" + path); } else { targetUrl = new URL("http://localhost:" + servletHost.getHttpPort() + "/" + path); } } else { throw new Fabric3Exception("Resolve URL not supported in distributed configuration"); } return targetUrl; } catch (MalformedURLException e) { throw new Fabric3Exception(e); } }
public URL resolveUrl(LogicalBinding<WsBindingDefinition> serviceBinding, EffectivePolicy policy) throws GenerationException { try { URL targetUrl; String path = serviceBinding.getDefinition().getTargetUri().toString(); if (path == null) { path = serviceBinding.getParent().getUri().getFragment(); } boolean https = requiresHttps(policy); if (RuntimeMode.VM == hostInfo.getRuntimeMode()) { // single VM if (https) { targetUrl = new URL("https://localhost:" + servletHost.getHttpsPort() + "/" + path); } else { targetUrl = new URL("http://localhost:" + servletHost.getHttpPort() + "/" + path); } } else { throw new GenerationException("Resolve URL not supported in distributed configuration"); } return targetUrl; } catch (MalformedURLException e) { throw new GenerationException(e); } }
public List<Composite> getDeployables(Set<Contribution> contributions) { List<Composite> deployables = new ArrayList<>(); for (Contribution contribution : contributions) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof Composite)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, Composite> element = (ResourceElement<QNameSymbol, Composite>) entry; QName name = element.getSymbol().getKey(); Composite composite = element.getValue(); for (Deployable deployable : contribution.getManifest().getDeployables()) { if (deployable.getName().equals(name)) { List<RuntimeMode> deployableModes = deployable.getRuntimeModes(); // only add deployables that are set to boot in the current runtime mode and where the environment matches if (deployableModes.contains(hostInfo.getRuntimeMode())) { List<String> environments = deployable.getEnvironments(); if (environments.isEmpty() || environments.contains(hostInfo.getEnvironment())) { deployables.add(composite); } } break; } } } } } return deployables; }
public List<Composite> getDeployables(Set<Contribution> contributions) { List<Composite> deployables = new ArrayList<>(); for (Contribution contribution : contributions) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof Composite)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, Composite> element = (ResourceElement<QNameSymbol, Composite>) entry; QName name = element.getSymbol().getKey(); Composite composite = element.getValue(); for (Deployable deployable : contribution.getManifest().getDeployables()) { if (deployable.getName().equals(name)) { List<RuntimeMode> deployableModes = deployable.getRuntimeModes(); // only add deployables that are set to boot in the current runtime mode and where the environment matches if (deployableModes.contains(hostInfo.getRuntimeMode())) { List<String> environments = deployable.getEnvironments(); if (environments.isEmpty() || environments.contains(hostInfo.getEnvironment())) { deployables.add(composite); } } break; } } } } } return deployables; }
/** * Instantiates and optionally deploys deployables from a set of contributions. Deployment is performed if recovery mode is false or the runtime is * operating in single VM mode. When recovering in a distributed domain, the components contained in the deployables will be instantiated but not deployed * to zones. This is because the domain can run headless (i.e. without a controller) and may already be hosting deployed components. * * @param deployables the deployables * @param contributions the contributions to deploy * @param recover true if recovery mode is enabled * @throws Fabric3Exception if an error occurs during instantiation or deployment */ private void instantiateAndDeploy(List<Composite> deployables, Set<Contribution> contributions, boolean recover) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); for (Contribution contribution : contributions) { if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } } InstantiationContext context = logicalModelInstantiator.include(deployables, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { // in single VM mode, recovery includes deployment deploy(domain); } else { collector.markAsProvisioned(domain); } contributions.forEach(Contribution::deploy); }
/** * Instantiates and optionally deploys deployables from a set of contributions. Deployment is performed if recovery mode is false or the runtime is * operating in single VM mode. When recovering in a distributed domain, the components contained in the deployables will be instantiated but not deployed * to zones. This is because the domain can run headless (i.e. without a controller) and may already be hosting deployed components. * * @param deployables the deployables * @param contributions the contributions to deploy * @param recover true if recovery mode is enabled * @throws Fabric3Exception if an error occurs during instantiation or deployment */ private void instantiateAndDeploy(List<Composite> deployables, Set<Contribution> contributions, boolean recover) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); for (Contribution contribution : contributions) { if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } } InstantiationContext context = logicalModelInstantiator.include(deployables, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { // in single VM mode, recovery includes deployment deploy(domain); } else { collector.markAsProvisioned(domain); } contributions.forEach(Contribution::deploy); }
/** * Registers HTTP and HTTPS socket information with the topology service if it is available. */ private void registerSockets() { if (RuntimeMode.VM != hostInfo.getRuntimeMode() && discoveryAgent != null) { try { String host = httpConnector.getHost(); if (host == null) { host = InetAddress.getLocalHost().getHostAddress(); } ServiceEntry httpEntry = new ServiceEntry(); httpEntry.setAddress(host); httpEntry.setPort(selectedHttp.getNumber()); httpEntry.setName("f3.HTTP"); httpEntry.setTransport("http"); discoveryAgent.register(httpEntry); if (isHttpsEnabled()) { ServiceEntry httpsEntry = new ServiceEntry(); httpsEntry.setAddress(host); httpsEntry.setPort(selectedHttps.getNumber()); httpsEntry.setName("f3.HTTPS"); httpsEntry.setTransport("https"); discoveryAgent.register(httpsEntry); } } catch (UnknownHostException e) { monitor.exception("Error registering sockets", e); } } }