@Inject SingularityHostAndPortProvider(final SingularityConfiguration configuration, @Named(HOST_NAME_PROPERTY) String hostname) { checkNotNull(configuration, "configuration is null"); this.hostname = configuration.getHostname().or(hostname); Integer port = null; if (configuration.getServerFactory() instanceof SimpleServerFactory) { SimpleServerFactory simpleServerFactory = (SimpleServerFactory) configuration.getServerFactory(); HttpConnectorFactory httpFactory = (HttpConnectorFactory) simpleServerFactory.getConnector(); port = httpFactory.getPort(); } else { DefaultServerFactory defaultServerFactory = (DefaultServerFactory) configuration.getServerFactory(); for (ConnectorFactory connectorFactory : defaultServerFactory.getApplicationConnectors()) { // Currently we will default to needing an http connector for service -> service communication if (connectorFactory instanceof HttpConnectorFactory && !(connectorFactory instanceof HttpsConnectorFactory)) { HttpConnectorFactory httpFactory = (HttpConnectorFactory) connectorFactory; port = httpFactory.getPort(); } } } if (port == null) { throw new RuntimeException("Could not determine http port"); } this.httpPort = port; }
private static HostAndPort portFromConnectorFactory(ConnectorFactory connectorFactory) { if ( (connectorFactory != null) && HttpConnectorFactory.class.isAssignableFrom(connectorFactory.getClass()) ) { HttpConnectorFactory factory = (HttpConnectorFactory)connectorFactory; String bindHost = MoreObjects.firstNonNull(factory.getBindHost(), "localhost"); return HostAndPort.fromParts(bindHost, factory.getPort()); } return defaultHostAndPort; }
public int getApplicationPort() { AbstractServerFactory sf = serverFactory(); if (sf instanceof SimpleServerFactory) { SimpleServerFactory ssf = (SimpleServerFactory) sf; return ((HttpConnectorFactory)ssf.getConnector()).getPort(); } if (sf instanceof DefaultServerFactory) { DefaultServerFactory dsf = (DefaultServerFactory) sf; return ((HttpConnectorFactory)dsf.getApplicationConnectors().get(0)).getPort(); } throw new IllegalStateException("Unrecognized ServerFactory: "+sf.getClass().getName()); }
public int getAdminPort() { AbstractServerFactory sf = serverFactory(); if (sf instanceof SimpleServerFactory) { SimpleServerFactory ssf = (SimpleServerFactory) sf; return ((HttpConnectorFactory)ssf.getConnector()).getPort(); } if (sf instanceof DefaultServerFactory) { DefaultServerFactory dsf = (DefaultServerFactory) sf; return ((HttpConnectorFactory)dsf.getAdminConnectors().get(0)).getPort(); } throw new IllegalStateException("Unrecognized ServerFactory: "+sf.getClass().getName()); }
private int getHttpPort(Configuration config) { ServerFactory serverFactory = config.getServerFactory(); if (!(serverFactory instanceof DefaultServerFactory)) { throw new IllegalStateException("Server factory is not an instance of DefaultServerFactory"); } List<ConnectorFactory> connectors = ((DefaultServerFactory) serverFactory).getApplicationConnectors(); for (ConnectorFactory connector : connectors) { if (connector instanceof HttpConnectorFactory) { return ((HttpConnectorFactory) connector).getPort(); } } throw new IllegalStateException("Unable to determine HTTP port"); }
private int getHttpPort(Configuration config) { ServerFactory serverFactory = config.getServerFactory(); if (!(serverFactory instanceof DefaultServerFactory)) { throw new IllegalStateException("Server factory is not an instance of DefaultServerFactory"); } List<ConnectorFactory> connectors = ((DefaultServerFactory) serverFactory).getApplicationConnectors(); for (ConnectorFactory connector : connectors) { if (connector instanceof HttpConnectorFactory) { return ((HttpConnectorFactory) connector).getPort(); } } throw new IllegalStateException("Unable to determine HTTP port"); }
private int getPort(Configuration config) { int httpPort = 0; final SimpleServerFactory serverFactory = (SimpleServerFactory) config.getServerFactory(); final HttpConnectorFactory connector = (HttpConnectorFactory) serverFactory.getConnector(); if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) { httpPort = connector.getPort(); } return httpPort; } }
private int getAdminHttpPort(Configuration config) { ServerFactory serverFactory = config.getServerFactory(); if (!(serverFactory instanceof DefaultServerFactory)) { throw new IllegalStateException("Server factory is not an instance of DefaultServerFactory"); } List<ConnectorFactory> connectors = ((DefaultServerFactory) serverFactory).getAdminConnectors(); for (ConnectorFactory connector : connectors) { if (connector instanceof HttpConnectorFactory) { return ((HttpConnectorFactory) connector).getPort(); } } throw new IllegalStateException("Unable to determine admin HTTP port"); }
private int getAdminHttpPort(Configuration config) { ServerFactory serverFactory = config.getServerFactory(); if (!(serverFactory instanceof DefaultServerFactory)) { throw new IllegalStateException("Server factory is not an instance of DefaultServerFactory"); } List<ConnectorFactory> connectors = ((DefaultServerFactory) serverFactory).getAdminConnectors(); for (ConnectorFactory connector : connectors) { if (connector instanceof HttpConnectorFactory) { return ((HttpConnectorFactory) connector).getPort(); } } throw new IllegalStateException("Unable to determine admin HTTP port"); }
private HostAndPort getHostAndPortFromConnectorFactories(List<ConnectorFactory> connectors) { // find the first connector that matches and return it host/port information (in practice there should // be one, and just one, match) try { HttpConnectorFactory httpConnectorFactory = (HttpConnectorFactory) Iterables.find(connectors, Predicates.instanceOf(HttpConnectorFactory.class)); String host = httpConnectorFactory.getBindHost(); if (host == null) { host = getLocalHost().getHostAddress(); } int port = httpConnectorFactory.getPort(); return HostAndPort.fromParts(host, port); } catch (NoSuchElementException ex) { throw new IllegalStateException("Did not find a valid HttpConnector for the server", ex); } }
private HostAndPort getHostAndPortFromConnectorFactories(List<ConnectorFactory> connectors) { // find the first connector that matches and return it host/port information (in practice there should // be one, and just one, match) try { HttpConnectorFactory httpConnectorFactory = (HttpConnectorFactory) Iterables.find(connectors, Predicates.instanceOf(HttpConnectorFactory.class)); String host = httpConnectorFactory.getBindHost(); if (host == null) { host = getLocalHost().getHostAddress(); } int port = httpConnectorFactory.getPort(); return HostAndPort.fromParts(host, port); } catch (NoSuchElementException ex) { throw new IllegalStateException("Did not find a valid HttpConnector for the server", ex); } }
@Inject SingularityHostAndPortProvider(final SingularityConfiguration configuration, @Named(HOST_NAME_PROPERTY) String hostname) { checkNotNull(configuration, "configuration is null"); this.hostname = configuration.getHostname().or(hostname); Integer port = null; if (configuration.getServerFactory() instanceof SimpleServerFactory) { SimpleServerFactory simpleServerFactory = (SimpleServerFactory) configuration.getServerFactory(); HttpConnectorFactory httpFactory = (HttpConnectorFactory) simpleServerFactory.getConnector(); port = httpFactory.getPort(); } else { DefaultServerFactory defaultServerFactory = (DefaultServerFactory) configuration.getServerFactory(); for (ConnectorFactory connectorFactory : defaultServerFactory.getApplicationConnectors()) { // Currently we will default to needing an http connector for service -> service communication if (connectorFactory instanceof HttpConnectorFactory && !(connectorFactory instanceof HttpsConnectorFactory)) { HttpConnectorFactory httpFactory = (HttpConnectorFactory) connectorFactory; port = httpFactory.getPort(); } } } if (port == null) { throw new RuntimeException("Could not determine http port"); } this.httpPort = port; }
LOG.info("Registered streamline entities {}", streamlineEntities); FileStorage fileStorage = this.getJarStorage(configuration, storageManager); int appPort = ((HttpConnectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getApplicationConnectors().get(0)).getPort(); String catalogRootUrl = configuration.getCatalogRootUrl().replaceFirst("8080", appPort + ""); List<ModuleConfiguration> modules = configuration.getModules();