Tabnine Logo
NetworkAddress
Code IndexAdd Tabnine to your IDE (free)

How to use
NetworkAddress
in
com.netflix.eureka2.registry.instance

Best Java code snippets using com.netflix.eureka2.registry.instance.NetworkAddress (Showing top 18 results out of 315)

origin: com.netflix.eureka/eureka2-core

public String returnNameOrIp(List<NetworkAddress> addresses) {
  Iterator<NetworkAddress> it = applyQuery(addresses.iterator());
  if (it.hasNext()) {
    NetworkAddress address = it.next();
    return address.getHostName() != null ? address.getHostName() : address.getIpAddress();
  }
  return null;
}
origin: com.netflix.eureka/eureka2-core

  public NetworkAddress build() {
    return new NetworkAddress(label, protocolType, ipAddress, hostName);
  }
}
origin: com.netflix.eureka/eureka2-core

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (!(o instanceof AwsDataCenterInfo)) return false;
  AwsDataCenterInfo that = (AwsDataCenterInfo) o;
  if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) return false;
  if (amiId != null ? !amiId.equals(that.amiId) : that.amiId != null) return false;
  if (eth0mac != null ? !eth0mac.equals(that.eth0mac) : that.eth0mac != null) return false;
  if (instanceId != null ? !instanceId.equals(that.instanceId) : that.instanceId != null) return false;
  if (instanceType != null ? !instanceType.equals(that.instanceType) : that.instanceType != null) return false;
  if (name != null ? !name.equals(that.name) : that.name != null) return false;
  if (placementGroup != null ? !placementGroup.equals(that.placementGroup) : that.placementGroup != null)
    return false;
  if (privateAddress != null ? !privateAddress.equals(that.privateAddress) : that.privateAddress != null)
    return false;
  if (publicAddress != null ? !publicAddress.equals(that.publicAddress) : that.publicAddress != null)
    return false;
  if (region != null ? !region.equals(that.region) : that.region != null) return false;
  if (vpcId != null ? !vpcId.equals(that.vpcId) : that.vpcId != null) return false;
  if (zone != null ? !zone.equals(that.zone) : that.zone != null) return false;
  return true;
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(Boolean value, NetworkAddress endpoint) {
    String ipAddress = endpoint.getIpAddress();
    if (ipAddress == null) {
      return false;
    }
    return SystemUtil.isPublic(ipAddress) == value;
  }
}
origin: com.netflix.eureka/eureka2-karyon-admin

public static String extractHostname(InstanceInfo instanceInfo) {
  if (AwsDataCenterInfo.class.isAssignableFrom(instanceInfo.getDataCenterInfo().getClass())) {
    final AwsDataCenterInfo dataCenterInfo = (AwsDataCenterInfo) instanceInfo.getDataCenterInfo();
    return dataCenterInfo.getPublicAddress().getHostName();
  }
  return "";
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(String value, NetworkAddress endpoint) {
    return value.equals(endpoint.getLabel());
  }
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(NetworkAddress.ProtocolType value, NetworkAddress endpoint) {
    return endpoint.getProtocolType() == value;
  }
}
origin: com.netflix.eureka/eureka2-core

/**
 * The order of selection: first public, next private.
 * If there are multiple addresses within a group (for example multiple public IPs), the first in
 * the list is be taken.
 */
@Override
public NetworkAddress getDefaultAddress() {
  if (defaultAddress != null) {
    return defaultAddress;
  }
  if (addresses == null || addresses.isEmpty()) {
    return null;
  }
  NetworkAddress best = null;
  for (NetworkAddress address : addresses) {
    if (best == null) {
      best = address;
      if (best.hasLabel(PUBLIC_ADDRESS)) {
        break;
      }
    } else if (address.hasLabel(PUBLIC_ADDRESS)) {
      best = address;
      break;
    }
  }
  defaultAddress = best;
  return defaultAddress;
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(Boolean value, ServiceEndpoint endpoint) {
    String ipAddress = endpoint.getAddress().getIpAddress();
    if (ipAddress == null) {
      return false;
    }
    return SystemUtil.isPublic(ipAddress) == value;
  }
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(String value, ServiceEndpoint endpoint) {
    return value.equals(endpoint.getAddress().getLabel());
  }
}
origin: com.netflix.eureka/eureka2-core

  @Override
  protected boolean matches(ProtocolType value, ServiceEndpoint endpoint) {
    return endpoint.getAddress().getProtocolType() == value;
  }
}
origin: com.netflix.eureka/eureka2-core

public List<String> returnNameOrIpList(List<NetworkAddress> addresses) {
  Iterator<NetworkAddress> it = applyQuery(addresses.iterator());
  List<String> addressList = new ArrayList<>();
  while (it.hasNext()) {
    NetworkAddress address = it.next();
    addressList.add(address.getHostName() != null ? address.getHostName() : address.getIpAddress());
  }
  return addressList;
}
origin: com.netflix.eureka/eureka2-core

public InetSocketAddress returnServiceAddress(InstanceInfo instanceInfo) {
  ServiceEndpoint endpoint = returnServiceEndpoint(instanceInfo);
  if (endpoint == null) {
    return null;
  }
  String address = endpoint.getAddress().getHostName();
  if (address == null) {
    address = endpoint.getAddress().getIpAddress();
  }
  return new InetSocketAddress(address, endpoint.getServicePort().getPort());
}
origin: com.netflix.eureka/eureka2-testkit

@Override
public AwsDataCenterInfo next() {
  NetworkAddress publicAddress = publicAddresses.next();
  NetworkAddress privateAddress = privateAddresses.next();
  return new AwsDataCenterInfo.Builder()
      .withAwsDataCenter(template)
      .withInstanceId(String.format("id-%08d", ++instanceId))
      .withPublicHostName(publicAddress.getHostName())
      .withPublicIPv4(publicAddress.getIpAddress())
      .withPrivateHostName(privateAddress.getHostName())
      .withPrivateIPv4(privateAddress.getIpAddress())
      .build();
}
origin: com.netflix.eureka/eureka2-karyon-admin

  @Override
  public JsonElement serialize(InstanceInfo instanceInfo, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    if (AwsDataCenterInfo.class.isAssignableFrom(instanceInfo.getDataCenterInfo().getClass())) {
      final AwsDataCenterInfo dataCenterInfo = (AwsDataCenterInfo) instanceInfo.getDataCenterInfo();
      result.addProperty("instId", dataCenterInfo.getInstanceId());
      if(dataCenterInfo.getPublicAddress() != null) {
        result.addProperty("ip", dataCenterInfo.getPublicAddress().getIpAddress());
        result.addProperty("hostname", dataCenterInfo.getPublicAddress().getHostName());
      }
      result.addProperty("zone", dataCenterInfo.getZone());
      result.addProperty("reg", dataCenterInfo.getRegion());
    }
    result.addProperty("appId", instanceInfo.getApp());
    result.addProperty("status", instanceInfo.getStatus().name());
    result.addProperty("vip", instanceInfo.getVipAddress());
    return result;
  }
}
origin: com.netflix.eureka/eureka2-core

public Builder withAwsDataCenter(AwsDataCenterInfo dataCenter) {
  this.region = dataCenter.getRegion();
  this.zone = dataCenter.getZone();
  this.placementGroup = dataCenter.getPlacementGroup();
  this.amiId = dataCenter.getAmiId();
  this.instanceId = dataCenter.getInstanceId();
  this.instanceType = dataCenter.getInstanceType();
  this.privateIP = dataCenter.getPrivateAddress().getIpAddress();
  this.privateHostName = dataCenter.getPrivateAddress().getHostName();
  this.publicIP = dataCenter.getPublicAddress().getIpAddress();
  this.publicHostName = dataCenter.getPublicAddress().getHostName();
  this.eth0mac = dataCenter.getEth0mac();
  this.vpcId = dataCenter.getVpcId();
  this.accountId = dataCenter.getAccountId();
  return this;
}
origin: com.netflix.eureka/eureka2-eureka1-rest-api

  private static Observable<Void> redirectTo(InstanceInfo readServerInfo,
                        HttpServerRequest<ByteBuf> request,
                        HttpServerResponse<ByteBuf> response) {
    ServiceEndpoint serviceEndpoint = HTTP_PUBLIC_SERVICE_SELECTOR.returnServiceEndpoint(readServerInfo);
    String redirectHost = serviceEndpoint == null ? null : serviceEndpoint.getAddress().getHostName();
    if(redirectHost == null) {
      serviceEndpoint = HTTP_PRIVATE_SERVICE_SELECTOR.returnServiceEndpoint(readServerInfo);
      redirectHost = serviceEndpoint.getAddress().getIpAddress();
    }

    StringBuilder redirectBuilder = new StringBuilder("http://")
        .append(redirectHost)
        .append(':')
        .append(serviceEndpoint.getServicePort().getPort())
        .append(request.getPath());
    if (request.getQueryString() != null) {
      redirectBuilder.append('?').append(request.getQueryString());
    }


    response.getHeaders().add(Names.LOCATION, redirectBuilder.toString());
    response.setStatus(HttpResponseStatus.FOUND);
    return Observable.empty();
  }
}
origin: com.netflix.eureka/eureka2-testkit

@Override
public InstanceInfo next() {
  int cidx = idx.incrementAndGet();
  String name = baseName + '_' + cidx;
  NetworkAddress publicAddress = publicAddresses.next();
  NetworkAddress privateAddress = privateAddresses.next();
  DataCenterInfo dataCenter = new AwsDataCenterInfo.Builder()
      .withAwsDataCenter(templateDataCenter)
      .withInstanceId(String.format("i-%s-%08d", baseName, cidx))
      .withPublicHostName(publicAddress.getHostName())
      .withPublicIPv4(publicAddress.getIpAddress())
      .withPrivateHostName(privateAddress.getHostName())
      .withPrivateIPv4(privateAddress.getIpAddress())
      .build();
  return new InstanceInfo.Builder()
      .withId("id#" + name)
      .withApp(template.getApp())
      .withAppGroup(template.getAppGroup())
      .withAsg(template.getAsg())
      .withHealthCheckUrls(template.getHealthCheckUrls())
      .withHomePageUrl(template.getHomePageUrl())
      .withPorts(template.getPorts())
      .withSecureVipAddress(template.getSecureVipAddress())
      .withStatus(template.getStatus())
      .withStatusPageUrl(template.getStatusPageUrl())
      .withVipAddress(template.getVipAddress())
      .withMetaData(template.getMetaData())
      .withDataCenterInfo(dataCenter)
      .build();
}
com.netflix.eureka2.registry.instanceNetworkAddress

Most used methods

  • getHostName
  • getIpAddress
  • <init>
  • equals
  • getLabel
  • getProtocolType
  • hasLabel
  • hashCode

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best plugins for Eclipse
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