Tabnine Logo
NetUtils.parseIpPort
Code IndexAdd Tabnine to your IDE (free)

How to use
parseIpPort
method
in
org.apache.servicecomb.foundation.common.net.NetUtils

Best Java code snippets using org.apache.servicecomb.foundation.common.net.NetUtils.parseIpPort (Showing top 12 results out of 315)

origin: apache/servicecomb-java-chassis

/**
 * Parse a {@link URI} into an {@link IpPort}.
 *
 * <p>
 *   A uri without port is allowed, in which case the port will be inferred from the scheme. {@code http} is 80, and
 *   {@code https} is 443.
 * </p>
 * <p>
 *   The host of the {@code uri} should not be null, or it will be treated as an illegal param,
 *   and an {@link IllegalArgumentException} will be thrown.
 * </p>
 */
public static IpPort parseIpPort(URI uri) {
 return parseIpPort(uri, false);
}
origin: apache/servicecomb-java-chassis

public static IpPort parseIpPort(String scheme, String authority) {
 if (authority == null) {
  return null;
 }
 return parseIpPort(URI.create(scheme + "://" + authority));
}
origin: apache/servicecomb-java-chassis

/**
 * The format of address should be {@code IPv4:port} or {@code [IPv6]:port}, or {@code host:port},
 * or you will not get expected result.
 *
 * Note that the IPv6 address should be wrapped by square brackets.
 * @return IpPort parsed from input param, or {@code null} if the param is null.
 */
public static IpPort parseIpPort(String address) {
 if (address == null) {
  return null;
 }
 URI uri = URI.create("http://" + address);
 return parseIpPort(uri, true);
}
origin: apache/servicecomb-java-chassis

/**
 * @param uriAddress the address containing IP and port info.
 * @return IpPort parsed from input param, or {@code null} if the param is null.
 */
public static IpPort parseIpPortFromURI(String uriAddress) {
 if (uriAddress == null) {
  return null;
 }
 try {
  return parseIpPort(new URI(uriAddress));
 } catch (URISyntaxException e) {
  return null;
 }
}
origin: apache/servicecomb-java-chassis

/**
 * 对于配置为0.0.0.0的地址,let it go
 * schema, e.g. http
 * adddress, e.g 0.0.0.0:8080
 * return 实际监听的地址
 */
public static String getRealListenAddress(String schema, String address) {
 if (address == null) {
  return null;
 }
 try {
  URI originalURI = new URI(schema + "://" + address);
  IpPort ipPort = NetUtils.parseIpPort(originalURI);
  if (ipPort == null) {
   LOGGER.error("address {} is not valid.", address);
   return null;
  }
  return originalURI.toString();
 } catch (URISyntaxException e) {
  LOGGER.error("address {} is not valid.", address);
  return null;
 }
}
origin: apache/servicecomb-java-chassis

public ArrayList<IpPort> getIpPort() {
 List<String> uriList = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER).getAccessURL();
 ArrayList<IpPort> ipPortList = new ArrayList<>();
 uriList.forEach(anUriList -> {
  try {
   URI uri = new URI(anUriList.trim());
   this.ssl = "https".equals(uri.getScheme());
   ipPortList.add(NetUtils.parseIpPort(uri));
  } catch (Exception e) {
   LOGGER.error("servicecomb.service.registry.address invalid : {}", anUriList, e);
  }
 });
 return ipPortList;
}
origin: apache/servicecomb-java-chassis

/**
 * In the case that listening address configured as 0.0.0.0, the publish address will be determined
 * by the query result for the net interfaces.
 *
 * @return the publish address, or {@code null} if the param {@code address} is null.
 */
public static String getPublishAddress(String schema, String address) {
 if (address == null) {
  return address;
 }
 try {
  URI originalURI = new URI(schema + "://" + address);
  IpPort ipPort = NetUtils.parseIpPort(originalURI);
  if (ipPort == null) {
   LOGGER.warn("address {} not valid.", address);
   return null;
  }
  IpPort publishIpPort = genPublishIpPort(schema, ipPort);
  URIBuilder builder = new URIBuilder(originalURI);
  return builder.setHost(publishIpPort.getHostOrIp()).setPort(publishIpPort.getPort()).build().toString();
 } catch (URISyntaxException e) {
  LOGGER.warn("address {} not valid.", address);
  return null;
 }
}
origin: org.apache.servicecomb/foundation-common

public static IpPort parseIpPortFromURI(String uriAddress) {
 if (uriAddress == null) {
  return null;
 }
 try {
  URI uri = new URI(uriAddress);
  String authority = uri.getAuthority();
  return parseIpPort(uri.getScheme(), authority);
 } catch (URISyntaxException e) {
  return null;
 }
}
origin: org.apache.servicecomb/foundation-common

/**
 * 对于配置为0.0.0.0的地址,let it go
 * schema, e.g. http
 * adddress, e.g 0.0.0.0:8080
 * return 实际监听的地址
 */
public static String getRealListenAddress(String schema, String address) {
 if (address == null) {
  return null;
 }
 try {
  URI originalURI = new URI(schema + "://" + address);
  IpPort ipPort = NetUtils.parseIpPort(originalURI.getAuthority());
  if (ipPort == null) {
   LOGGER.error("address {} is not valid.", address);
   return null;
  }
  return originalURI.toString();
 } catch (URISyntaxException e) {
  LOGGER.error("address {} is not valid.", address);
  return null;
 }
}
origin: org.apache.servicecomb/foundation-common

public static IpPort parseIpPort(String scheme, String authority) {
 if (authority == null) {
  return null;
 }
 int idx = authority.indexOf(':');
 if (idx != -1) {
  return parseIpPort(authority);
 }
 if (scheme.equals("http")) {
  return new IpPort(authority, 80);
 }
 if (scheme.equals("https")) {
  return new IpPort(authority, 443);
 }
 return null;
}
origin: org.apache.servicecomb/service-registry

public ArrayList<IpPort> getIpPort() {
 DynamicStringProperty property =
   DynamicPropertyFactory.getInstance()
     .getStringProperty("servicecomb.service.registry.address", "https://127.0.0.1:30100");
 List<String> uriList = Arrays.asList(property.get().split(","));
 ArrayList<IpPort> ipPortList = new ArrayList<>();
 uriList.forEach(anUriList -> {
  try {
   URI uri = new URI(anUriList.trim());
   this.ssl = "https".equals(uri.getScheme());
   ipPortList.add(NetUtils.parseIpPort(uri.getScheme(), uri.getAuthority()));
  } catch (Exception e) {
   LOGGER.error("servicecomb.service.registry.address invalid : {}", anUriList, e);
  }
 });
 return ipPortList;
}
origin: org.apache.servicecomb/service-registry

/**
 * 对于配置为0.0.0.0的地址,通过查询网卡地址,转换为实际监听的地址。
 */
public static String getPublishAddress(String schema, String address) {
 if (address == null) {
  return address;
 }
 try {
  URI originalURI = new URI(schema + "://" + address);
  IpPort ipPort = NetUtils.parseIpPort(originalURI.getAuthority());
  if (ipPort == null) {
   LOGGER.warn("address {} not valid.", address);
   return null;
  }
  IpPort publishIpPort = genPublishIpPort(schema, ipPort);
  URIBuilder builder = new URIBuilder(originalURI);
  return builder.setHost(publishIpPort.getHostOrIp()).setPort(publishIpPort.getPort()).build().toString();
 } catch (URISyntaxException e) {
  LOGGER.warn("address {} not valid.", address);
  return null;
 }
}
org.apache.servicecomb.foundation.common.netNetUtilsparseIpPort

Javadoc

The format of address should be IPv4:port or [IPv6]:port, or host:port, or you will not get expected result. Note that the IPv6 address should be wrapped by square brackets.

Popular methods of NetUtils

  • parseIpPortFromURI
  • canTcpListen
  • doGetHostNameAndHostAddress
  • doGetIpv4AddressFromNetworkInterface
    docker环境中,有时无法通过InetAddress.getLocalHost()获取 ,会报unknown host Exception, system error 此时,通过遍历网卡接口的方式规
  • ensureGetInterfaceAddress
  • getHostAddress
  • getHostName
  • getRealListenAddress
    对于配置为0.0.0.0的地址,let it go schema, e.g. http adddress, e.g 0.0.0.0:8080 return 实际监听的地址
  • humanReadableBytes

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now