本文整理了Java中org.mortbay.jetty.Connector.getPort()
方法的一些代码示例,展示了Connector.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector.getPort()
方法的具体详情如下:
包路径:org.mortbay.jetty.Connector
类名称:Connector
方法名:getPort
暂无
代码示例来源:origin: azkaban/azkaban
@Override
public int getPort() {
return this.connector.getPort();
}
代码示例来源:origin: com.linkedin.azkaban/azkaban-common
@Override
public int getPort() {
return this.connector.getPort();
}
代码示例来源:origin: com.linkedin.azkaban/azkaban
@Override
public int getPort() {
return connector.getPort();
}
代码示例来源:origin: net.disy.legato/legato-testing
public int getPort() {
return connector.getPort();
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
@Override
public String toString() {
Preconditions.checkState(!listeners.isEmpty());
StringBuilder sb = new StringBuilder("HttpServer (")
.append(isAlive() ? STATE_DESCRIPTION_ALIVE
: STATE_DESCRIPTION_NOT_LIVE)
.append("), listening at:");
for (Connector l : listeners) {
sb.append(l.getHost()).append(":").append(l.getPort()).append("/,");
}
return sb.toString();
}
代码示例来源:origin: io.hops/hadoop-common
@Override
public String toString() {
Preconditions.checkState(!listeners.isEmpty());
StringBuilder sb = new StringBuilder("HttpServer (")
.append(isAlive() ? STATE_DESCRIPTION_ALIVE
: STATE_DESCRIPTION_NOT_LIVE)
.append("), listening at:");
for (Connector l : listeners) {
sb.append(l.getHost()).append(":").append(l.getPort()).append("/,");
}
return sb.toString();
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
@Override
public String toString() {
Preconditions.checkState(!listeners.isEmpty());
StringBuilder sb = new StringBuilder("HttpServer (")
.append(isAlive() ? STATE_DESCRIPTION_ALIVE
: STATE_DESCRIPTION_NOT_LIVE)
.append("), listening at:");
for (Connector l : listeners) {
sb.append(l.getHost()).append(":").append(l.getPort()).append("/,");
}
return sb.toString();
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
/**
* {@inheritDoc}
*
* @see net.sourceforge.eclipsejetty.starter.common.ServerAdapter#getPorts()
*/
public Collection<Integer> getPorts()
{
Collection<Integer> results = new LinkedHashSet<Integer>();
Connector[] connectors = server.getConnectors();
if (connectors != null)
{
for (Connector connector : connectors)
{
if (!connector.getClass().getSimpleName().toLowerCase().contains("ssl"))
{
results.add(connector.getPort());
}
}
}
return results;
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Return the bind address of the listener.
* @return InetSocketAddress of the listener
*/
public InetSocketAddress getListenerAddress() {
int port = listener.getLocalPort();
if (port == -1) { // not bound, return requested port
port = listener.getPort();
}
return new InetSocketAddress(listener.getHost(), port);
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Return the host and port of the HttpServer3, if live
* @return the classname and any HTTP URL
*/
@Override
public String toString() {
if (listeners.size() == 0) {
return "Inactive HttpServer";
} else {
StringBuilder sb = new StringBuilder("HttpServer (")
.append(isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE).append("), listening at:");
for (ListenerInfo li : listeners) {
Connector l = li.listener;
sb.append(l.getHost()).append(":").append(l.getPort()).append("/,");
}
return sb.toString();
}
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
/**
* {@inheritDoc}
*
* @see net.sourceforge.eclipsejetty.starter.common.ServerAdapter#getSecurePorts()
*/
public Collection<Integer> getSecurePorts()
{
Collection<Integer> results = new LinkedHashSet<Integer>();
Connector[] connectors = server.getConnectors();
if (connectors != null)
{
for (Connector connector : connectors)
{
if (connector.getClass().getSimpleName().toLowerCase().contains("ssl"))
{
results.add(connector.getPort());
}
}
}
return results;
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Return the bind address of the listener.
* @return InetSocketAddress of the listener
*/
public InetSocketAddress getListenerAddress() {
int port = listener.getLocalPort();
if (port == -1) { // not bound, return requested port
port = listener.getPort();
}
return new InetSocketAddress(listener.getHost(), port);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Return the bind address of the listener.
* @return InetSocketAddress of the listener
*/
public InetSocketAddress getListenerAddress() {
int port = listener.getLocalPort();
if (port == -1) { // not bound, return requested port
port = listener.getPort();
}
return new InetSocketAddress(listener.getHost(), port);
}
代码示例来源:origin: org.apache.isis.runtimes.dflt/webserver
private String baseFor(final Server jettyServer) {
final Connector connector = jettyServer.getConnectors()[0];
final String scheme = "http";
final String host = StringUtils.coalesce(connector.getHost(), "localhost");
final int port = connector.getPort();
final WebAppContext handler = (WebAppContext) jettyServer.getHandler();
final String contextPath = handler.getContextPath();
final StringBuilder buf = new StringBuilder();
final Formatter formatter = new Formatter(buf);
formatter.format("%s://%s:%d/%s", scheme, host, port, contextPath);
return appendSlashIfRequired(buf).toString();
}
代码示例来源:origin: ch.cern.hadoop/hadoop-kms
private static URL getJettyURL(Server server) {
boolean ssl = server.getConnectors()[0].getClass()
== SslSelectChannelConnectorSecure.class;
try {
String scheme = (ssl) ? "https" : "http";
return new URL(scheme + "://" +
server.getConnectors()[0].getHost() + ":" +
server.getConnectors()[0].getPort());
} catch (MalformedURLException ex) {
throw new RuntimeException("It should never happen, " + ex.getMessage(),
ex);
}
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
protected String getJettyURL() {
Connector c = jetty.getConnectors()[0];
return "http://" + c.getHost() + ":" + c.getPort();
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
protected String getJettyURL() {
Connector c = jetty.getConnectors()[0];
return "http://" + c.getHost() + ":" + c.getPort();
}
代码示例来源:origin: org.apache.slider/slider-core
private void openListeners() throws Exception {
// from HttpServer2.openListeners()
for (Connector listener : agentServer.getConnectors()) {
if (listener.getLocalPort() != -1) {
// This listener is either started externally or has been bound
continue;
}
int port = listener.getPort();
while (true) {
// jetty has a bug where you can't reopen a listener that previously
// failed to open w/o issuing a close first, even if the port is changed
try {
listener.close();
listener.open();
LOG.info("Jetty bound to port " + listener.getLocalPort());
break;
} catch (BindException ex) {
if (port == 0) {
BindException be = new BindException("Port in use: "
+ listener.getHost() + ":" + listener.getPort());
be.initCause(ex);
throw be;
}
}
// try the next port number
listener.setPort(++port);
Thread.sleep(100);
}
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
private HttpServer2 checkBindAddress(String host, int port, boolean findPort)
throws Exception {
HttpServer2 server = createServer(host, port);
try {
// not bound, ephemeral should return requested port (0 for ephemeral)
List<?> listeners = (List<?>) Whitebox.getInternalState(server,
"listeners");
Connector listener = (Connector) listeners.get(0);
assertEquals(port, listener.getPort());
// verify hostname is what was given
server.openListeners();
assertEquals(host, server.getConnectorAddress(0).getHostName());
int boundPort = server.getConnectorAddress(0).getPort();
if (port == 0) {
assertTrue(boundPort != 0); // ephemeral should now return bound port
} else if (findPort) {
assertTrue(boundPort > port);
// allow a little wiggle room to prevent random test failures if
// some consecutive ports are already in use
assertTrue(boundPort - port < 8);
}
} catch (Exception e) {
server.stop();
throw e;
}
return server;
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
private HttpServer2 checkBindAddress(String host, int port, boolean findPort)
throws Exception {
HttpServer2 server = createServer(host, port);
try {
// not bound, ephemeral should return requested port (0 for ephemeral)
List<?> listeners = (List<?>) Whitebox.getInternalState(server,
"listeners");
Connector listener = (Connector) listeners.get(0);
assertEquals(port, listener.getPort());
// verify hostname is what was given
server.openListeners();
assertEquals(host, server.getConnectorAddress(0).getHostName());
int boundPort = server.getConnectorAddress(0).getPort();
if (port == 0) {
assertTrue(boundPort != 0); // ephemeral should now return bound port
} else if (findPort) {
assertTrue(boundPort > port);
// allow a little wiggle room to prevent random test failures if
// some consecutive ports are already in use
assertTrue(boundPort - port < 8);
}
} catch (Exception e) {
server.stop();
throw e;
}
return server;
}
内容来源于网络,如有侵权,请联系作者删除!