Java Code Examples for java.net.UnknownHostException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/util/.

Source file: AmenLibTask.java

  21 
vote

final protected void onPostExecute(Result result){
  if (lastException != null) {
    lastException.printStackTrace();
    String title="Exception";
    String message=lastException.getMessage();
    if (lastException.getCause() != null) {
      message=lastException.getCause().getMessage();
    }
    if (lastException instanceof OutOfMemoryError) {
      title="Error";
      message="OutOfMemoryError";
    }
    if (lastException instanceof UnknownHostException) {
      title="Unknown  Host";
      message=lastException.getMessage();
    }
    if (context.hasWindowFocus()) {
      new AlertDialog.Builder(context).setTitle(title).setMessage(message).setPositiveButton(R.string.dismiss,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialogInterface,        int i){
          Log.e(TAG,"OK clicked");
        }
      }
).setNegativeButton("Crash",new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialogInterface,        int i){
          throw new RuntimeException(lastException);
        }
      }
).show();
      Log.e(TAG,"Dialog shown!");
    }
  }
  wrappedOnPostExecute(result);
  lastException=null;
}
 

Example 2

From project cp-common-utils, under directory /src/com/clarkparsia/common/net/.

Source file: NetUtils.java

  19 
vote

/** 
 * Attempt a reverse look-up with an IP to get a domain name
 * @param theIP the IP to lookup
 * @return the domain name corresponding to the IP
 * @throws UnknownHostException if a machine with the specified IP does not exist, or a domain name cannot be found
 */
public static String reverseLookup(String theIP) throws UnknownHostException {
  String aName=InetAddress.getByName(theIP).getCanonicalHostName();
  if (aName.equals(theIP)) {
    throw new UnknownHostException("Cannot find DN for IP: " + theIP);
  }
 else {
    if (isIP(aName)) {
      throw new UnknownHostException("Invalid DN (" + aName + ") obtained via reverse lookup of: "+ theIP);
    }
    return aName;
  }
}
 

Example 3

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/.

Source file: HotspotManagementSupport.java

  18 
vote

private JMXServiceURL getUrlFrom(String url){
  if (url == null)   return null;
  JMXServiceURL jmxUrl;
  try {
    jmxUrl=new JMXServiceURL(url);
  }
 catch (  MalformedURLException e1) {
    return null;
  }
  String host=null;
  try {
    host=InetAddress.getLocalHost().getHostAddress();
  }
 catch (  UnknownHostException ok) {
  }
  if (host == null) {
    host=jmxUrl.getHost();
  }
  try {
    return new JMXServiceURL(jmxUrl.getProtocol(),host,jmxUrl.getPort(),jmxUrl.getURLPath());
  }
 catch (  MalformedURLException e) {
    return null;
  }
}
 

Example 4

From project des, under directory /daemon/lib/apache-log4j-1.2.16/contribs/KitchingSimon/.

Source file: DatagramStringWriter.java

  18 
vote

/** 
 * This constructor sends messages to the specified host and port, and uses the specified character encoding when converting the message string to a byte sequence; the specified prefix (which may be null) is prepended to each message.
 */
public DatagramStringWriter(String host,int port,String encoding,String prefix){
  this.host=host;
  this.port=port;
  this.encoding=encoding;
  this.prefix=prefix;
  try {
    this.address=InetAddress.getByName(host);
  }
 catch (  UnknownHostException e) {
    LogLog.error("Could not find " + host + ". All logging will FAIL.",e);
  }
  try {
    this.ds=new DatagramSocket();
  }
 catch (  SocketException e) {
    e.printStackTrace();
    LogLog.error("Could not instantiate DatagramSocket to " + host + ". All logging will FAIL.",e);
  }
}
 

Example 5

From project DistCpV2-0.20.203, under directory /src/main/java/org/apache/hadoop/tools/util/.

Source file: DistCpUtils.java

  18 
vote

public static boolean compareFs(FileSystem srcFs,FileSystem destFs){
  URI srcUri=srcFs.getUri();
  URI dstUri=destFs.getUri();
  if (srcUri.getScheme() == null) {
    return false;
  }
  if (!srcUri.getScheme().equals(dstUri.getScheme())) {
    return false;
  }
  String srcHost=srcUri.getHost();
  String dstHost=dstUri.getHost();
  if ((srcHost != null) && (dstHost != null)) {
    try {
      srcHost=InetAddress.getByName(srcHost).getCanonicalHostName();
      dstHost=InetAddress.getByName(dstHost).getCanonicalHostName();
    }
 catch (    UnknownHostException ue) {
      return false;
    }
    if (!srcHost.equals(dstHost)) {
      return false;
    }
  }
 else   if (srcHost == null && dstHost != null) {
    return false;
  }
 else   if (srcHost != null) {
    return false;
  }
  if (srcUri.getPort() != dstUri.getPort()) {
    return false;
  }
  return true;
}
 

Example 6

From project agit, under directory /agit-test-utils/src/main/java/com/madgag/agit/.

Source file: GitTestUtils.java

  17 
vote

public static String gitServerHostAddress() throws IOException, UnknownHostException {
  File hostAddressFile=new File(Environment.getExternalStorageDirectory(),"agit-integration-test.properties");
  Properties properties=new Properties();
  if (hostAddressFile.exists()) {
    properties.load(new FileInputStream(hostAddressFile));
  }
  String[] hostAddresses=properties.getProperty("gitserver.host.address","10.0.2.2").split(",");
  for (  String hostAddress : hostAddresses) {
    if (InetAddress.getByName(hostAddress).isReachable(1000)) {
      Log.d(TAG,"Using git server host : " + hostAddress);
      return hostAddress;
    }
  }
  throw new RuntimeException("No reachable addresses in " + asList(hostAddresses));
}
 

Example 7

From project blog_1, under directory /miniprojects/generic-pojo-mappers/src/test/java/net/jakubholy/blog/genericmappers/.

Source file: XmlToMongoToRestServiceTest.java

  17 
vote

@Before public void setUpMongo() throws UnknownHostException {
  storage=new MongoStorage(new Mongo("127.0.0.1"));
  TestMongoStorageProvider.instance=storage;
  try {
    storage.dropDatabase();
  }
 catch (  MongoException.Network e) {
    e.printStackTrace();
    fail("Failed to communicate with MongoDB, make sure that it is running at localhost " + "at the default port. See System.err for details. E.: " + e.getMessage() + ", cause: "+ e.getCause());
  }
}
 

Example 8

From project cloudify, under directory /esc/src/main/java/org/cloudifysource/esc/util/.

Source file: Utils.java

  17 
vote

/** 
 * Validates a connection can be made to the given address and port, within the given time limit.
 * @param ipAddress The IP address to connect to
 * @param port The port number to use
 * @param timeout The time to wait before timing out, in seconds
 * @throws IOException Reports a failure to connect or resolve the given address.
 */
public static void validateConnection(final String ipAddress,final int port,final int timeout) throws IOException {
  final Socket socket=new Socket();
  try {
    final InetSocketAddress endPoint=new InetSocketAddress(ipAddress,port);
    if (endPoint.isUnresolved()) {
      throw new UnknownHostException(ipAddress);
    }
    socket.connect(endPoint,Utils.safeLongToInt(TimeUnit.SECONDS.toMillis(timeout),true));
  }
  finally {
    try {
      socket.close();
    }
 catch (    final IOException ioe) {
    }
  }
}
 

Example 9

From project cxf-dosgi, under directory /dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/.

Source file: AbstractConfigurationHandler.java

  17 
vote

/** 
 * Utility method that delegates to the methods of NetworkInterface to determine addresses for this machine.
 * @return InetAddress[] - all addresses found from the NetworkInterfaces
 * @throws UnknownHostException - if there is a problem determining addresses
 */
private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
  ArrayList addresses=new ArrayList();
  Enumeration e=null;
  try {
    e=NetworkInterface.getNetworkInterfaces();
  }
 catch (  SocketException ex) {
    throw new UnknownHostException("127.0.0.1");
  }
  while (e.hasMoreElements()) {
    NetworkInterface ni=(NetworkInterface)e.nextElement();
    for (Enumeration e2=ni.getInetAddresses(); e2.hasMoreElements(); ) {
      addresses.add(e2.nextElement());
    }
  }
  InetAddress[] iAddresses=new InetAddress[addresses.size()];
  for (int i=0; i < iAddresses.length; i++) {
    iAddresses[i]=(InetAddress)addresses.get(i);
  }
  return iAddresses;
}
 

Example 10

From project EasyBan, under directory /src/uk/org/whoami/easyban/commands/.

Source file: AlternativeCommand.java

  17 
vote

@Override protected void execute(CommandSender cs,Command cmnd,String cmd,String[] args){
  if (args.length == 0) {
    return;
  }
  try {
    InetAddress.getByName(args[0]);
    cs.sendMessage(m._("Users who connected from IP") + args[0]);
    this.sendListToSender(cs,database.getNicks(args[0]));
  }
 catch (  UnknownHostException ex) {
    ArrayList<String> nicks=new ArrayList<String>();
    for (    String ip : database.getHistory(args[0])) {
      Collections.addAll(nicks,database.getNicks(ip));
    }
    cs.sendMessage(m._("Alternative nicks of ") + args[0]);
    this.sendListToSender(cs,nicks.toArray(new String[0]));
  }
}
 

Example 11

From project ACLS-protocol-library, under directory /aclslib/src/main/java/au/edu/uq/cmm/aclslib/config/.

Source file: StaticConfiguration.java

  16 
vote

public void setTrustedAddresses(Set<String> trustedAddresses) throws UnknownHostException {
  this.trustedAddresses=trustedAddresses;
  this.trustedInetAddresses=new HashSet<InetAddress>(trustedAddresses.size());
  for (  String address : trustedAddresses) {
    trustedInetAddresses.add(InetAddress.getByName(address));
  }
}
 

Example 12

From project airlift, under directory /dbpool/src/test/java/io/airlift/dbpool/.

Source file: DatabaseIpAddressUtilTest.java

  15 
vote

private void verifyIpAddressConversion(String ipString,int expectedJavaIpAddress,int expectedDatabaseIpAddress) throws UnknownHostException {
  InetAddress address=InetAddress.getByName(ipString);
  int javaIpAddress=address.hashCode();
  assertEquals(javaIpAddress,expectedJavaIpAddress);
  int databaseIpAddress=toDatabaseIpAddress(javaIpAddress);
  assertEquals(databaseIpAddress,expectedDatabaseIpAddress);
  assertEquals(fromDatabaseIpAddress(databaseIpAddress),javaIpAddress);
}
 

Example 13

From project aksunai, under directory /src/org/androidnerds/app/aksunai/net/.

Source file: ConnectionThread.java

  15 
vote

public void run(){
  try {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"Connecting to... " + mServerDetail.mUrl + ":"+ mServerDetail.mPort);
    mSock=new Socket(mServerDetail.mUrl,mServerDetail.mPort);
  }
 catch (  UnknownHostException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"UnknownHostException caught, terminating connection process");
  }
catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught on socket creation. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  try {
    mWriter=new BufferedWriter(new OutputStreamWriter(mSock.getOutputStream()));
    mReader=new BufferedReader(new InputStreamReader(mSock.getInputStream()));
  }
 catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught grabbing input/output streams. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  mServer.init(mServerDetail.mPass,mServerDetail.mNick,mServerDetail.mUser,mServerDetail.mRealName);
  try {
    while (!shouldKill()) {
      String message=mReader.readLine();
      if (AppConstants.DEBUG)       Log.d(AppConstants.NET_TAG,"Received message: " + message);
      mServer.receiveMessage(message);
    }
  }
 catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught handling messages. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  return;
}
 

Example 14

From project anarchyape, under directory /src/main/java/ape/.

Source file: DenialOfServiceRunner.java

  15 
vote

public void run(){
  long currentTime=System.currentTimeMillis();
  long endTime=currentTime + (duration * 1000);
  while (System.currentTimeMillis() < endTime) {
    try {
      Socket net=new Socket(target,port);
      sendRawLine("GET / HTTP/1.1",net);
    }
 catch (    UnknownHostException e) {
      System.out.println("Could not resolve hostname.");
      e.printStackTrace();
      Main.logger.info("Could not resolve hostname.");
      Main.logger.info(e);
      break;
    }
catch (    ConnectException e) {
      System.out.println("The connection was refused.  Make sure that port " + port + " is open and receiving connections on host "+ target);
      Main.logger.info("The connection was refused.  Make sure that port " + port + " is open and receiving connections on host "+ target);
      e.printStackTrace();
      Main.logger.info(e);
      break;
    }
catch (    SocketException e) {
      if (Main.VERBOSE) {
        System.out.println("VERBOSE: Client says too many files open. This is expected in a DoS attack. Continuing...");
        e.printStackTrace();
      }
    }
catch (    IOException e) {
      e.printStackTrace();
      Main.logger.info(e);
      break;
    }
  }
}
 

Example 15

From project andlytics, under directory /src/com/github/andlyticsproject/admob/.

Source file: AdmobRequest.java

  15 
vote

private static void handleNonJsonException(Exception e,String sb) throws NetworkException, AdmobGenericException, AdmobInvalidTokenException {
  if (e instanceof SocketException || e instanceof UnknownHostException || e instanceof IOException|| e instanceof NetworkException) {
    throw new NetworkException(e);
  }
 else   if (e instanceof AdmobInvalidTokenException) {
    throw (AdmobInvalidTokenException)e;
  }
 else {
    throw new AdmobGenericException(e,sb);
  }
}
 

Example 16

From project android-api_1, under directory /android-lib/src/com/catchnotes/api/.

Source file: CatchAPI.java

  15 
vote

private HttpResponse performGET(String method,List<NameValuePair> httpParams,boolean useToken){
  HttpGet httpget;
  String uri=method;
  if (!uri.startsWith("http")) {
    uri=catchBaseUrl + uri;
  }
  if (httpParams == null || httpParams.isEmpty()) {
    httpget=new HttpGet(uri);
  }
 else {
    httpget=new HttpGet(uri + '?' + URLEncodedUtils.format(httpParams,"UTF-8"));
  }
  HttpResponse response=null;
  try {
    response=useToken ? getHttpClient().execute(httpget) : getHttpClientNoToken().execute(httpget);
  }
 catch (  ClientProtocolException e) {
    log("caught ClientProtocolException performing GET " + httpget.getURI(),e);
    return null;
  }
catch (  UnknownHostException e) {
    log("caught UnknownHostException performing GET " + httpget.getURI(),null);
    return null;
  }
catch (  IOException e) {
    log("caught IOException performing GET " + httpget.getURI(),e);
    return null;
  }
  sync_trace("GET " + httpget.getURI() + " returned "+ response.getStatusLine().getStatusCode()+ ' '+ response.getStatusLine().getReasonPhrase());
  return response;
}
 

Example 17

From project android-async-http, under directory /src/com/loopj/android/http/.

Source file: AsyncHttpRequest.java

  15 
vote

private void makeRequestWithRetries() throws ConnectException {
  boolean retry=true;
  IOException cause=null;
  HttpRequestRetryHandler retryHandler=client.getHttpRequestRetryHandler();
  while (retry) {
    try {
      makeRequest();
      return;
    }
 catch (    UnknownHostException e) {
      if (responseHandler != null) {
        responseHandler.sendFailureMessage(e,"can't resolve host");
      }
      return;
    }
catch (    IOException e) {
      cause=e;
      retry=retryHandler.retryRequest(cause,++executionCount,context);
    }
catch (    NullPointerException e) {
      cause=new IOException("NPE in HttpClient" + e.getMessage());
      retry=retryHandler.retryRequest(cause,++executionCount,context);
    }
  }
  ConnectException ex=new ConnectException();
  ex.initCause(cause);
  throw ex;
}
 

Example 18

From project android-bankdroid, under directory /src/eu/nullbyte/android/urllib/.

Source file: EasySSLSocketFactory.java

  15 
vote

/** 
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,java.lang.String,int,java.net.InetAddress,int,org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock,String host,int port,InetAddress localAddress,int localPort,HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  int connTimeout=HttpConnectionParams.getConnectionTimeout(params);
  int soTimeout=HttpConnectionParams.getSoTimeout(params);
  InetSocketAddress remoteAddress=new InetSocketAddress(host,port);
  SSLSocket sslsock=(SSLSocket)((sock != null) ? sock : createSocket());
  if ((localAddress != null) || (localPort > 0)) {
    if (localPort < 0) {
      localPort=0;
    }
    InetSocketAddress isa=new InetSocketAddress(localAddress,localPort);
    sslsock.bind(isa);
  }
  sslsock.connect(remoteAddress,connTimeout);
  sslsock.setSoTimeout(soTimeout);
  return sslsock;
}
 

Example 19

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: TileDownloadMapGenerator.java

  15 
vote

@Override final boolean executeJob(MapGeneratorJob mapGeneratorJob){
  try {
    getTilePath(mapGeneratorJob.tile,this.stringBuilder);
    InputStream inputStream=new URL(this.stringBuilder.toString()).openStream();
    this.decodedBitmap=BitmapFactory.decodeStream(inputStream);
    inputStream.close();
    if (this.decodedBitmap == null) {
      return false;
    }
    this.decodedBitmap.getPixels(this.pixelColors,0,Tile.TILE_SIZE,0,0,Tile.TILE_SIZE,Tile.TILE_SIZE);
    this.decodedBitmap.recycle();
    if (this.tileBitmap != null) {
      this.tileBitmap.setPixels(this.pixelColors,0,Tile.TILE_SIZE,0,0,Tile.TILE_SIZE,Tile.TILE_SIZE);
    }
    return true;
  }
 catch (  UnknownHostException e) {
    Logger.debug(e.getMessage());
    return false;
  }
catch (  IOException e) {
    Logger.exception(e);
    return false;
  }
}
 

Example 20

From project android-rackspacecloud, under directory /main/java/net/elasticgrid/rackspace/cloudservers/.

Source file: Addresses.java

  15 
vote

public Addresses(net.elasticgrid.rackspace.cloudservers.internal.Addresses addresses) throws UnknownHostException {
  Public publicAddresses=addresses.getPublic();
  this.publicAddresses=new ArrayList<InetAddress>(publicAddresses.getAddressLists().size());
  for (  net.elasticgrid.rackspace.cloudservers.internal.Address address : publicAddresses.getAddressLists()) {
    this.publicAddresses.add(InetAddress.getByName(address.getAddr()));
  }
  Private privateAddresses=addresses.getPrivate();
  this.privateAddresses=new ArrayList<InetAddress>(privateAddresses.getAddressLists().size());
  for (  net.elasticgrid.rackspace.cloudservers.internal.Address address : privateAddresses.getAddressLists()) {
    this.privateAddresses.add(InetAddress.getByName(address.getAddr()));
  }
}
 

Example 21

From project android-vpn-server, under directory /src/com/android/server/vpn/.

Source file: VpnService.java

  15 
vote

private void broadcastConnectivity(VpnState s){
  VpnManager m=new VpnManager(mContext);
  Throwable err=mError;
  if ((s == VpnState.IDLE) && (err != null)) {
    if (err instanceof UnknownHostException) {
      m.broadcastConnectivity(mProfile.getName(),s,VpnManager.VPN_ERROR_UNKNOWN_SERVER);
    }
 else     if (err instanceof VpnConnectingError) {
      m.broadcastConnectivity(mProfile.getName(),s,((VpnConnectingError)err).getErrorCode());
    }
 else     if (VPN_IS_UP.equals(SystemProperties.get(VPN_STATUS))) {
      m.broadcastConnectivity(mProfile.getName(),s,VpnManager.VPN_ERROR_CONNECTION_LOST);
    }
 else {
      m.broadcastConnectivity(mProfile.getName(),s,VpnManager.VPN_ERROR_CONNECTION_FAILED);
    }
  }
 else {
    m.broadcastConnectivity(mProfile.getName(),s);
  }
}
 

Example 22

From project android-xbmcremote, under directory /src/org/xbmc/android/util/.

Source file: ClientFactory.java

  15 
vote

/** 
 * Resets the client so it has to re-read the settings and recreate the instance.
 * @param host New host settings, can be null.
 */
public static void resetClient(Host host){
  sApiType=API_TYPE_UNSET;
  if (sHttpClient != null) {
    sHttpClient.setHost(host);
  }
 else {
    Log.w(TAG,"Not updating http client's host because no instance is set yet.");
  }
  Log.i(TAG,"Resetting client to " + (host == null ? "<nullhost>" : host.addr));
  if (sEventClient != null) {
    try {
      if (host != null) {
        InetAddress addr=Inet4Address.getByName(host.addr);
        sEventClient.setHost(addr,host.esPort > 0 ? host.esPort : Host.DEFAULT_EVENTSERVER_PORT);
      }
 else {
        sEventClient.setHost(null,0);
      }
    }
 catch (    UnknownHostException e) {
      Log.e(TAG,"Unknown host: " + (host == null ? "<nullhost>" : host.addr));
    }
  }
 else {
    Log.w(TAG,"Not updating event client's host because no instance is set yet.");
  }
}
 

Example 23

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/zeroconf/.

Source file: DiscoveryService.java

  15 
vote

@Override protected void onHandleIntent(Intent intent){
  try {
    final int ipAddress=mWifiManager.getConnectionInfo().getIpAddress();
    if (ipAddress != 0) {
      mWifiAddress=InetAddress.getByName(android.text.format.Formatter.formatIpAddress(ipAddress));
      Log.i(TAG,"Discovering XBMC hosts through " + mWifiAddress.getHostAddress() + "...");
    }
 else {
      Log.i(TAG,"Discovering XBMC hosts on all interfaces...");
    }
  }
 catch (  UnknownHostException e) {
    Log.e(TAG,"Cannot parse Wifi IP address.",e);
  }
  final ResultReceiver receiver=intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);
  acquireMulticastLock();
  new Thread(){
    @Override public void run(){
      listen(receiver);
    }
  }
.start();
  try {
    Thread.sleep(TIMEOUT);
  }
 catch (  InterruptedException e) {
    Log.e(TAG,"Error sleeping " + TIMEOUT + "ms.",e);
  }
  receiver.send(STATUS_FINISHED,Bundle.EMPTY);
  releaseMulticastLock();
}
 

Example 24

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/util/.

Source file: Geo.java

  15 
vote

public static URI getLocation(){
  try {
    return URI.create(InetAddress.getLocalHost().getHostAddress());
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 25

From project android_8, under directory /src/com/defuzeme/network/.

Source file: Broadcaster.java

  15 
vote

@Override protected void onPreExecute(){
  DefuzeMe.Gui.showProgress(string.SearchingForClients);
  try {
    this._address=InetAddress.getByName(Settings._BCastSendAddress);
    this._rSocket=new MulticastSocket(Settings._BCastRecvPort);
    this._sSocket=new DatagramSocket();
    this._rSocket.joinGroup(InetAddress.getByName(Settings._BCastRecvAddress));
    this._rSocket.setSoTimeout(Settings._TimeOut);
  }
 catch (  UnknownHostException exception) {
    Log.w(this.getClass().getName(),"Unknown host : " + exception.toString());
  }
catch (  SocketException exception) {
    Log.e(this.getClass().getName(),"Socket exception : " + exception.toString());
  }
catch (  IOException exception) {
    Log.w(this.getClass().getName(),"IO Exception : " + exception.toString());
  }
}
 

Example 26

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: RadioInfo.java

  15 
vote

/** 
 * Ping a host name
 */
private final void pingHostname(){
  try {
    Process p=Runtime.getRuntime().exec("ping -c 1 www.google.com");
    int status=p.waitFor();
    if (status == 0) {
      mPingHostnameResult="Pass";
    }
 else {
      mPingHostnameResult="Fail: Host unreachable";
    }
  }
 catch (  UnknownHostException e) {
    mPingHostnameResult="Fail: Unknown Host";
  }
catch (  IOException e) {
    mPingHostnameResult="Fail: IOException";
  }
catch (  InterruptedException e) {
    mPingHostnameResult="Fail: InterruptedException";
  }
}
 

Example 27

From project apb, under directory /modules/apb-base/src/apb/tasks/.

Source file: DownloadTask.java

  15 
vote

/** 
 * Execute the download task
 */
public void execute(){
  try {
    if (!uptodate()) {
      validateDirectory(dest.getParentFile());
      env.logInfo("Downloading: %s\n",source);
      env.logInfo("         to: %s\n",FileUtils.normalizePath(dest));
      download();
    }
  }
 catch (  UnknownHostException e) {
    env.handle("Unknown Host: " + e.getMessage());
  }
catch (  IOException e) {
    env.logSevere("Error downloading '%s' to '%s'\n",source,dest);
    env.handle(e);
  }
}
 

Example 28

From project apg, under directory /src/org/thialfihar/android/apg/.

Source file: HkpKeyServer.java

  15 
vote

private String query(String request) throws QueryException, HttpError {
  InetAddress ips[];
  try {
    ips=InetAddress.getAllByName(mHost);
  }
 catch (  UnknownHostException e) {
    throw new QueryException(e.toString());
  }
  for (int i=0; i < ips.length; ++i) {
    try {
      String url="http://" + ips[i].getHostAddress() + ":"+ mPort+ request;
      URL realUrl=new URL(url);
      HttpURLConnection conn=(HttpURLConnection)realUrl.openConnection();
      conn.setConnectTimeout(5000);
      conn.setReadTimeout(25000);
      conn.connect();
      int response=conn.getResponseCode();
      if (response >= 200 && response < 300) {
        return readAll(conn.getInputStream(),conn.getContentEncoding());
      }
 else {
        String data=readAll(conn.getErrorStream(),conn.getContentEncoding());
        throw new HttpError(response,data);
      }
    }
 catch (    MalformedURLException e) {
    }
catch (    IOException e) {
    }
  }
  throw new QueryException("querying server(s) for '" + mHost + "' failed");
}
 

Example 29

From project ardverk-commons, under directory /src/main/java/org/ardverk/net/.

Source file: NetworkUtils.java

  15 
vote

/** 
 * Creates and returns an  {@link InetAddress} from the given {@code byte[]}.
 * @see InetAddress#getByAddress(byte[])
 */
public static InetAddress getByAddress(byte[] addr){
  try {
    return InetAddress.getByAddress(addr);
  }
 catch (  UnknownHostException e) {
    throw new IllegalArgumentException("UnknownHostException",e);
  }
}
 

Example 30

From project Arecibo, under directory /alert/src/main/java/com/ning/arecibo/alert/email/.

Source file: EmailManager.java

  15 
vote

@Inject public EmailManager(final AlertServiceConfig alertServiceConfig){
  this.alertServiceConfig=alertServiceConfig;
  String hostName;
  String hostIp;
  try {
    final InetAddress localHost=InetAddress.getLocalHost();
    hostName=localHost.getHostName();
    hostIp=localHost.getHostAddress();
  }
 catch (  UnknownHostException uhEx) {
    log.warn("UnknownHostException: won't be able to append sending host info to outgoing email");
    log.info(uhEx);
    hostName="";
    hostIp="";
  }
  sendingHostSignature=String.format("\n\nSent by Arecibo Alert Service: %s (%s)",hostName,hostIp);
}
 

Example 31

From project asterisk-java, under directory /src/main/java/org/asteriskjava/manager/event/.

Source file: AbstractRtcpEvent.java

  15 
vote

protected InetAddress stringToAddress(String addressWithPort){
  final String address;
  if (addressWithPort == null || addressWithPort.length() == 0) {
    return null;
  }
  if (addressWithPort.lastIndexOf(':') > 0) {
    address=addressWithPort.substring(0,addressWithPort.lastIndexOf(':'));
  }
 else {
    address=addressWithPort;
  }
  try {
    return InetAddress.getByName(address);
  }
 catch (  UnknownHostException e) {
    throw new IllegalArgumentException("Unable to convert " + addressWithPort + " to InetAddress",e);
  }
}
 

Example 32

From project astyanax, under directory /src/main/java/com/netflix/astyanax/connectionpool/.

Source file: Host.java

  15 
vote

/** 
 * Construct a Host from a host:port combination.  The defaultPort is provided in case the hostAndPort2 value does not have a port specified.
 * @param hostAndPort
 * @param defaultPort
 */
public Host(String hostAndPort,int defaultPort){
  String tempHost=parseHostFromHostAndPort(hostAndPort);
  this.port=parsePortFromHostAndPort(hostAndPort,defaultPort);
  Matcher match=ipPattern.matcher(tempHost);
  String workHost;
  String workIpAddress;
  if (match.matches()) {
    workHost=tempHost;
    workIpAddress=tempHost;
  }
 else {
    try {
      InetAddress address=InetAddress.getByName(tempHost);
      workHost=address.getHostName();
      workIpAddress=address.getHostAddress();
    }
 catch (    UnknownHostException e) {
      workHost=tempHost;
      workIpAddress=tempHost;
    }
  }
  this.host=workHost;
  this.ipAddress=workIpAddress;
  this.name=String.format("%s(%s):%d",tempHost,this.ipAddress,this.port);
  this.url=String.format("%s:%d",this.host,this.port);
}
 

Example 33

From project ATHENA, under directory /core/apa/src/main/java/org/fracturedatlas/athena/apa/impl/.

Source file: MongoApaAdapter.java

  15 
vote

public MongoApaAdapter(String host,Integer port,String dbName,String fieldsCollectionName) throws UnknownHostException {
  this.fieldsCollectionName=fieldsCollectionName;
  Mongo m=new Mongo(host,port);
  db=m.getDB(dbName);
  fields=db.getCollection(fieldsCollectionName);
  initializeIndex();
  cacheFields();
}
 

Example 34

From project aws-tasks, under directory /src/main/java/datameer/awstasks/aws/ec2/support/.

Source file: Ec2SocketFactory.java

  15 
vote

@Override public Socket createSocket(String host,int port,InetAddress localHost,int localPort) throws IOException, UnknownHostException {
  Socket socket=createSocket();
  socket.bind(new InetSocketAddress(localHost,localPort));
  socket.connect(new InetSocketAddress(host,port));
  return socket;
}
 

Example 35

From project azkaban, under directory /azkaban/src/java/azkaban/jobs/.

Source file: JobExecutorManager.java

  15 
vote

private void sendSuccessEmail(JobExecution job,Duration duration,String senderAddress,List<String> emailList){
  if ((emailList == null || emailList.isEmpty()) && jobSuccessEmail != null) {
    emailList=Arrays.asList(jobSuccessEmail);
  }
  if (emailList != null && mailman != null) {
    try {
      mailman.sendEmailIfPossible(senderAddress,emailList,"Job '" + job.getId() + "' has completed on "+ InetAddress.getLocalHost().getHostName()+ "!","The job '" + job.getId() + "' completed in "+ PeriodFormat.getDefault().print(duration.toPeriod())+ ".");
    }
 catch (    UnknownHostException uhe) {
      logger.error(uhe);
    }
  }
}
 

Example 36

From project bagheera, under directory /src/main/java/com/mozilla/bagheera/util/.

Source file: HttpUtil.java

  15 
vote

public static byte[] getRemoteAddr(HttpRequest request,InetAddress channelRemoteAddr){
  String forwardedAddr=request.getHeader(X_FORWARDED_FOR);
  byte[] addrBytes=null;
  if (forwardedAddr != null) {
    InetAddress addr;
    try {
      addr=InetAddress.getByName(forwardedAddr);
      addrBytes=addr.getAddress();
    }
 catch (    UnknownHostException e) {
    }
  }
  if (addrBytes == null) {
    addrBytes=channelRemoteAddr.getAddress();
  }
  return addrBytes;
}
 

Example 37

From project bbb-java, under directory /src/main/java/org/transdroid/util/.

Source file: FakeSocketFactory.java

  15 
vote

@Override public Socket connectSocket(Socket sock,String host,int port,InetAddress localAddress,int localPort,HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  int connTimeout=HttpConnectionParams.getConnectionTimeout(params);
  int soTimeout=HttpConnectionParams.getSoTimeout(params);
  InetSocketAddress remoteAddress=new InetSocketAddress(host,port);
  SSLSocket sslsock=(SSLSocket)((sock != null) ? sock : createSocket());
  if ((localAddress != null) || (localPort > 0)) {
    if (localPort < 0) {
      localPort=0;
    }
    InetSocketAddress isa=new InetSocketAddress(localAddress,localPort);
    sslsock.bind(isa);
  }
  sslsock.connect(remoteAddress,connTimeout);
  sslsock.setSoTimeout(soTimeout);
  return sslsock;
}
 

Example 38

From project BeeQueue, under directory /lib/src/hyperic-sigar-1.6.4/bindings/java/examples/.

Source file: Netstat.java

  15 
vote

private String formatAddress(int proto,String ip,long portnum,int max){
  String port=formatPort(proto,portnum);
  String address;
  if (NetFlags.isAnyAddress(ip)) {
    address="*";
  }
 else   if (isNumeric) {
    address=ip;
  }
 else {
    try {
      address=InetAddress.getByName(ip).getHostName();
    }
 catch (    UnknownHostException e) {
      address=ip;
    }
  }
  max-=port.length() + 1;
  if (address.length() > max) {
    address=address.substring(0,max);
  }
  return address + ":" + port;
}
 

Example 39

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/http/.

Source file: RequestHandler.java

  15 
vote

public String post(String link,PostData[] postDataArray,int extraHeaders) throws RequestHandlerException {
  if ("".equals(link)) {
    throw new RequestHandlerException("No link found.");
  }
  HttpPost httpPost=new HttpPost(link);
  if (extraHeaders > 0) {
    if (extraHeaders == 1) {
      httpPost.setHeaders(HttpHeaders.POST_HEADERS.get(extraHeaders));
    }
 else     if (extraHeaders == 2) {
      httpPost.setHeaders(HttpHeaders.POST_HEADERS.get(extraHeaders));
    }
 else     if (extraHeaders == 3) {
      httpPost.setHeaders(HttpHeaders.POST_HEADERS.get(extraHeaders));
    }
  }
  List<BasicNameValuePair> nameValuePairs=new ArrayList<BasicNameValuePair>();
  HttpEntity httpEntity;
  HttpResponse httpResponse;
  for (  PostData data : postDataArray) {
    nameValuePairs.add(new BasicNameValuePair(data.getField(),(data.isHash()) ? this.hash(data.getValue()) : data.getValue()));
  }
  try {
    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8));
    httpResponse=httpClient.execute(httpPost);
    httpEntity=httpResponse.getEntity();
    if (httpEntity != null) {
      return EntityUtils.toString(httpEntity);
    }
  }
 catch (  UnknownHostException ex) {
    throw new RequestHandlerException("Host unreachable - please restart your 3G connection and try again.");
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  return "";
}
 

Example 40

From project big-data-plugin, under directory /src/org/pentaho/di/trans/steps/mongodboutput/.

Source file: MongoDbOutput.java

  15 
vote

@Override public boolean init(StepMetaInterface stepMetaInterface,StepDataInterface stepDataInterface){
  if (super.init(stepMetaInterface,stepDataInterface)) {
    m_meta=(MongoDbOutputMeta)stepMetaInterface;
    m_data=(MongoDbOutputData)stepDataInterface;
    String hostname=environmentSubstitute(m_meta.getHostname());
    int port=Const.toInt(environmentSubstitute(m_meta.getPort()),27017);
    String db=environmentSubstitute(m_meta.getDBName());
    String collection=environmentSubstitute(m_meta.getCollection());
    try {
      m_data.connect(hostname,port);
      m_data.setDB(m_data.getConnection().getDB(db));
      String realUser=environmentSubstitute(m_meta.getUsername());
      String realPass=Encr.decryptPasswordOptionallyEncrypted(environmentSubstitute(m_meta.getPassword()));
      if (!Const.isEmpty(realUser) || !Const.isEmpty(realPass)) {
        if (!m_data.getDB().authenticate(realUser,realPass.toCharArray())) {
          throw new KettleException(BaseMessages.getString(PKG,"MongoDbOutput.Messages.Error.UnableToAuthenticate"));
        }
      }
      if (Const.isEmpty(collection)) {
        throw new KettleException(BaseMessages.getString(PKG,"MongoDbOutput.Messages.Error.NoCollectionSpecified"));
      }
      m_data.createCollection(collection);
      m_data.setCollection(m_data.getDB().getCollection(collection));
      return true;
    }
 catch (    UnknownHostException ex) {
      logError(BaseMessages.getString(PKG,"MongoDbOutput.Messages.Error.UnknownHost",hostname),ex);
      return false;
    }
catch (    Exception e) {
      logError(BaseMessages.getString(PKG,"MongoDbOutput.Messages.Error.ProblemConnecting",hostname,"" + port),e);
      return false;
    }
  }
  return false;
}
 

Example 41

From project BioMAV, under directory /ParrotControl/JavaDroneControl/src/nl/ru/ai/projects/parrot/dronecontrol/javadronecontrol/.

Source file: NavdataChannel.java

  15 
vote

public synchronized void connect(InetAddress remoteAddress) throws SocketException, UnknownHostException {
  disconnect();
  navdataSocket=new DatagramSocket(NAVDATA_PORT);
  navdataSocket.setSoTimeout(500);
  this.remoteAddress=remoteAddress;
  navdataThread=new Thread(this);
  navdataStartTime=System.currentTimeMillis();
  navdataThread.start();
}
 

Example 42

From project blacktie, under directory /blacktie-admin-services/src/main/java/org/jboss/narayana/blacktie/administration/.

Source file: BlacktieStompAdministrationService.java

  15 
vote

private static void initStatic() throws ConfigurationException, UnknownHostException {
synchronized (prop) {
    if (prop.isEmpty()) {
      XMLParser.loadProperties("btconfig.xsd","btconfig.xml",prop);
      beanServerConnection=java.lang.management.ManagementFactory.getPlatformMBeanServer();
      String managementAddress=System.getProperty("jboss.bind.address.management","localhost");
      if (managementAddress.equals("0.0.0.0")) {
        managementAddress="localhost";
      }
      client=ModelControllerClient.Factory.create(InetAddress.getByName(managementAddress),9999,getCallbackHandler());
    }
  }
}
 

Example 43

From project BombusLime, under directory /src/org/bombusim/networking/.

Source file: NetworkSocketDataStream.java

  15 
vote

public NetworkSocketDataStream(String server,int port) throws UnknownHostException, IOException {
  this.host=server;
  this.port=port;
  LimeLog.i("Socket","Connecting to " + host + ":"+ port,null);
  socket=new Socket(server,port);
  socket.setKeepAlive(true);
  istream=socket.getInputStream();
  ostream=socket.getOutputStream();
}
 

Example 44

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: Utils.java

  15 
vote

/** 
 * Utility routine to get the data from a URL. Makes sure timeout is set to avoid application stalling.
 * @param url		URL to retrieve
 * @return
 * @throws UnknownHostException 
 */
static public InputStream getInputStream(URL url) throws UnknownHostException {
synchronized (url) {
    int retries=3;
    while (true) {
      try {
        java.net.URLConnection conn=url.openConnection();
        conn.setConnectTimeout(30000);
        return conn.getInputStream();
      }
 catch (      java.net.UnknownHostException e) {
        Logger.logError(e);
        retries--;
        if (retries-- == 0)         throw e;
        try {
          Thread.sleep(500);
        }
 catch (        Exception junk) {
        }
        ;
      }
catch (      Exception e) {
        Logger.logError(e);
        throw new RuntimeException(e);
      }
    }
  }
}
 

Example 45

From project Cafe, under directory /testrunner/src/com/baidu/cafe/local/.

Source file: LocalLib.java

  15 
vote

/** 
 * config mock server
 * @param filePath
 * @param caseId
 * @return
 * @throws IOException
 * @throws UnknownHostException
 */
public String configMockServer(String filePath,String caseId) throws UnknownHostException, IOException {
  print("startup mock server");
  Intent myIntent=new Intent(MockConstant.MOCK_ACTIVITY_NAME);
  mActivity.startService(myIntent);
  try {
    print("wait 10 seconds");
    Thread.sleep(10000);
  }
 catch (  InterruptedException e) {
    print(e.getMessage());
  }
  print("startup mock server end!");
  MockHelper helper=new MockHelper();
  return helper.config(filePath,caseId);
}
 

Example 46

From project Carnivore, under directory /org/rsg/carnivore/net/.

Source file: IPAddress.java

  15 
vote

/** 
 * Constructor
 * @param s IP address in format 123.45.67.89
 */
public IPAddress(String s){
  try {
    this.ip=InetAddress.getByName(s);
  }
 catch (  UnknownHostException e) {
    Log.debug("[" + this.getClass().getName() + "] getByName: "+ e);
  }
}
 

Example 47

From project cas, under directory /cas-server-support-ldap/src/main/java/org/jasig/cas/adaptors/ldap/remote/.

Source file: RemoteAddressAuthenticationHandler.java

  15 
vote

public boolean authenticate(final Credentials credentials) throws AuthenticationException {
  final RemoteAddressCredentials c=(RemoteAddressCredentials)credentials;
  try {
    final InetAddress inetAddress=InetAddress.getByName(c.getRemoteAddress().trim());
    return containsAddress(this.inetNetwork,this.inetNetmask,inetAddress);
  }
 catch (  final UnknownHostException e) {
    return false;
  }
}
 

Example 48

From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/util/.

Source file: TrustedSSLUtil.java

  15 
vote

public Socket createSocket(final String host,final int port,final InetAddress localAddress,final int localPort,final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  if (params == null) {
    throw new IllegalArgumentException("Parameters may not be null");
  }
  final int timeout=params.getConnectionTimeout();
  final SocketFactory socketfactory=getSSLContext().getSocketFactory();
  if (timeout == 0) {
    return socketfactory.createSocket(host,port,localAddress,localPort);
  }
 else {
    final Socket socket=socketfactory.createSocket();
    final SocketAddress localaddr=new InetSocketAddress(localAddress,localPort);
    final SocketAddress remoteaddr=new InetSocketAddress(host,port);
    socket.bind(localaddr);
    socket.connect(remoteaddr,timeout);
    return socket;
  }
}
 

Example 49

From project ChessCraft, under directory /src/main/java/fr/free/jchecs/core/.

Source file: PGNUtilsTest.java

  15 
vote

/** 
 * Pour que JUnit puisse instancier les tests.
 */
public PGNUtilsTest(){
  String site="?";
  try {
    final InetAddress lh=InetAddress.getLocalHost();
    site=lh.getHostName();
  }
 catch (  final UnknownHostException e) {
  }
  _site=site;
}
 

Example 50

From project chililog-server, under directory /src/main/java/org/chililog/server/data/.

Source file: MongoConnection.java

  15 
vote

/** 
 * <p> Loads our mongoDB connection pool </p> <p> This is a package scope method so that we can use it within our junit test cases. It should not be called from real code. </p>
 * @throws MongoException
 * @throws UnknownHostException
 */
void loadMongo() throws UnknownHostException, MongoException {
  AppProperties appProperties=AppProperties.getInstance();
  ServerAddress addr=new ServerAddress(appProperties.getDbIpAddress(),appProperties.getDbIpPort());
  MongoOptions options=new MongoOptions();
  options.connectionsPerHost=appProperties.getDbConnectionsPerHost();
  _mongo=new Mongo(addr,options);
}
 

Example 51

From project cider, under directory /src/net/yacy/cider/document/.

Source file: URI.java

  15 
vote

public MultiProtocolInputStream(SmbFile sf) throws IOException {
  try {
    this.is=new SmbFileInputStream(sf);
  }
 catch (  SmbException e) {
    throw new IOException(e);
  }
catch (  MalformedURLException e) {
    throw new IOException(e);
  }
catch (  UnknownHostException e) {
    throw new IOException(e);
  }
}
 

Example 52

From project CIShell, under directory /clients/remoting/org.cishell.reference.remoting/src/org/cishell/reference/remoting/server/.

Source file: CIShellFrameworkServer.java

  15 
vote

public CIShellFrameworkServer(BundleContext bContext,CIShellContext ciContext){
  this.bContext=bContext;
  q=new EventQueue(bContext);
  String host="localhost";
  try {
    host=InetAddress.getLocalHost().getHostName();
  }
 catch (  UnknownHostException e) {
  }
  listeners=new ObjectRegistry(host + ":8180-");
  eventAdmin=(EventAdmin)bContext.getService(bContext.getServiceReference(EventAdmin.class.getName()));
}
 

Example 53

From project cloudbees-api-client, under directory /cloudbees-api-client/src/test/java/com/cloudbees/api/util/.

Source file: ProxyServer.java

  15 
vote

private Connector getDefaultConnector(String hostName,int port){
  Connector connector=new SocketConnector();
  if (hostName != null) {
    connector.setHost(hostName);
  }
 else {
    try {
      connector.setHost(InetAddress.getLocalHost().getCanonicalHostName());
    }
 catch (    UnknownHostException e) {
    }
  }
  if (port > 0) {
    connector.setPort(port);
  }
  return connector;
}
 

Example 54

From project cloudhopper-commons-util, under directory /src/main/java/com/cloudhopper/commons/util/.

Source file: EnvironmentUtil.java

  15 
vote

public static String getHostFQDN() throws EnvironmentException {
  try {
    InetAddress addr=InetAddress.getLocalHost();
    byte[] ipAddr=addr.getAddress();
    return addr.getHostName();
  }
 catch (  UnknownHostException e) {
    throw new EnvironmentException("Unable to determine hostname",e);
  }
}
 

Example 55

From project CMM-data-grabber, under directory /eccles/src/main/java/au/edu/uq/cmm/eccles/.

Source file: EcclesProxyConfiguration.java

  15 
vote

public void setTrustedAddresses(Set<String> trustedAddresses) throws UnknownHostException {
  this.trustedAddresses=trustedAddresses;
  this.trustedInetAddresses=new HashSet<InetAddress>(trustedAddresses.size());
  for (  String address : trustedAddresses) {
    trustedInetAddresses.add(InetAddress.getByName(address));
  }
}
 

Example 56

From project cmsandroid, under directory /src/com/zia/freshdocs/net/.

Source file: EasySSLSocketFactory.java

  15 
vote

/** 
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,java.lang.String,int,java.net.InetAddress,int,org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock,String host,int port,InetAddress localAddress,int localPort,HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  int connTimeout=HttpConnectionParams.getConnectionTimeout(params);
  int soTimeout=HttpConnectionParams.getSoTimeout(params);
  InetSocketAddress remoteAddress=new InetSocketAddress(host,port);
  SSLSocket sslsock=(SSLSocket)((sock != null) ? sock : createSocket());
  if ((localAddress != null) || (localPort > 0)) {
    if (localPort < 0) {
      localPort=0;
    }
    InetSocketAddress isa=new InetSocketAddress(localAddress,localPort);
    sslsock.bind(isa);
  }
  sslsock.connect(remoteAddress,connTimeout);
  sslsock.setSoTimeout(soTimeout);
  return sslsock;
}
 

Example 57

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/plugin/.

Source file: DataProcessGuiPlugin.java

  15 
vote

private UserLoginTracker buildUserLoginTracker() throws UnknownHostException {
  InetAddress localhostAddress=Inet4Address.getLocalHost();
  String ip=localhostAddress.getHostAddress();
  String hostname=localhostAddress.getHostName();
  User user=configuration.getUser();
  return new UserLoginTracker(user.getUserName(),user.getCurrentRepository(),ip,hostname,null);
}
 

Example 58

From project cometd, under directory /cometd-java/cometd-java-client/src/test/java/org/cometd/client/.

Source file: BayeuxClientTest.java

  15 
vote

@Test public void testHandshakeFailsBeforeSend() throws Exception {
  LongPollingTransport transport=new LongPollingTransport(null,httpClient){
    @Override protected void customize(    Request request){
      request.listener(new Request.Listener.Empty(){
        @Override public void onBegin(        Request request){
          request.headers().remove(HttpHeader.HOST);
        }
      }
);
    }
  }
;
  final AtomicReference<CountDownLatch> latch=new AtomicReference<>(new CountDownLatch(1));
  BayeuxClient client=new BayeuxClient(cometdURL,transport){
    @Override public void onFailure(    Throwable x,    Message[] messages){
      if (!(x instanceof UnknownHostException))       super.onFailure(x,messages);
    }
  }
;
  client.setDebugEnabled(debugTests());
  client.getChannel(Channel.META_HANDSHAKE).addListener(new ClientSessionChannel.MessageListener(){
    public void onMessage(    ClientSessionChannel channel,    Message message){
      Assert.assertFalse(message.isSuccessful());
      latch.get().countDown();
    }
  }
);
  client.handshake();
  Assert.assertTrue(latch.get().await(5,TimeUnit.SECONDS));
  latch.set(new CountDownLatch(1));
  Assert.assertTrue(latch.get().await(client.getBackoffIncrement() * 2,TimeUnit.MILLISECONDS));
  Assert.assertTrue(client.disconnect(1000));
  latch.set(new CountDownLatch(1));
  Assert.assertFalse(latch.get().await(client.getBackoffIncrement() * 3,TimeUnit.MILLISECONDS));
}
 

Example 59

From project CommitCoin, under directory /src/com/google/bitcoin/core/.

Source file: PeerAddress.java

  15 
vote

@Override protected void parse(){
  if (protocolVersion > 31402)   time=readUint32();
 else   time=-1;
  services=readUint64();
  byte[] addrBytes=readBytes(16);
  try {
    addr=InetAddress.getByAddress(addrBytes);
  }
 catch (  UnknownHostException e) {
    throw new RuntimeException(e);
  }
  port=((0xFF & bytes[cursor++]) << 8) | (0xFF & bytes[cursor++]);
}
 

Example 60

From project commons-j, under directory /src/test/java/nerds/antelax/commons/net/pubsub/.

Source file: PubSubTest.java

  15 
vote

/** 
 * Creates some interesting server configurations to test: <ul> <li>single port</li> <li>two ports</li> <li>three ports</li> <li>random between 5 and 10 ports</li> </ul>
 * @throws UnknownHostException
 */
@DataProvider(name="server-addresses") public Object[][] serverAddresses() throws UnknownHostException {
  final InetAddress loopback=InetAddress.getByName("127.0.0.1");
  final InetAddress local=InetAddress.getLocalHost();
  final Function<Integer,InetSocketAddress> serverAddressBuilder=new Function<Integer,InetSocketAddress>(){
    @Override public InetSocketAddress apply(    final Integer input){
      return new InetSocketAddress(input % 2 == 0 ? loopback : local,PubSubServer.DEFAULT_ADDRESS.getPort() + input);
    }
  }
;
  final int random=new SecureRandom().nextInt(5) + 5;
  final Collection<Integer> randomCount=new ArrayList<Integer>(random);
  for (int pos=0; pos < random; ++pos)   randomCount.add(6 + pos);
  return new Object[][]{new Object[]{Collections2.transform(Arrays.asList(0),serverAddressBuilder)},new Object[]{Collections2.transform(Arrays.asList(1,2),serverAddressBuilder)},new Object[]{Collections2.transform(Arrays.asList(3,4,5),serverAddressBuilder)},new Object[]{Collections2.transform(randomCount,serverAddressBuilder)}};
}
 

Example 61

From project components-ness-mongo, under directory /src/main/java/com/nesscomputing/mongo/.

Source file: MongoWriter.java

  15 
vote

synchronized void start(){
  if (mongoWriterConfig.isEnabled()) {
    try {
      Preconditions.checkState(writerThread.get() == null,"already started, boldly refusing to start twice!");
      Preconditions.checkState(dbCollection.get() == null,"Already have a collection object, something went very wrong!");
      LOG.info("Starting Mongo Writer for collection %s.",collectionName);
      final DBCollection collection=mongoWriterConfig.getMongoUri().connectDB().getCollection(collectionName);
      dbCollection.set(collection);
      final Thread thread=new Thread(this,String.format("mongo-%s-writer",collectionName));
      writerThread.set(thread);
      thread.start();
    }
 catch (    UnknownHostException uhe) {
      LOG.errorDebug(uhe,"Could not connect to mongo URI %s",mongoWriterConfig.getMongoUri());
    }
  }
}
 

Example 62

From project components-ness-pg, under directory /pg-embedded/src/main/java/com/nesscomputing/db/postgres/embedded/.

Source file: EmbeddedPostgreSQL.java

  15 
vote

private void waitForServerStartup(StopWatch watch) throws UnknownHostException, IOException {
  Throwable lastCause=null;
  long start=System.nanoTime();
  long maxWaitNs=TimeUnit.NANOSECONDS.convert(PG_STARTUP_WAIT_MS,TimeUnit.MILLISECONDS);
  while (System.nanoTime() - start < maxWaitNs) {
    try {
      checkReady();
      LOG.info("%s postmaster startup finished in %s",instanceId,watch);
      return;
    }
 catch (    SQLException e) {
      lastCause=e;
      LOG.trace(e);
    }
    try {
      throw new IOException(String.format("%s postmaster exited with value %d, check standard out for more detail!",instanceId,postmaster.exitValue()));
    }
 catch (    IllegalThreadStateException e) {
      LOG.trace(e);
    }
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      Thread.currentThread().interrupt();
      return;
    }
  }
  throw new IOException("Gave up waiting for server to start after " + PG_STARTUP_WAIT_MS + "ms",lastCause);
}
 

Example 63

From project connectbot, under directory /src/com/trilead/ssh2/.

Source file: KnownHosts.java

  15 
vote

/** 
 * Try to find the preferred order of hostkey algorithms for the given hostname. Based on the type of hostkey that is present in the internal database (i.e., either <code>ssh-rsa</code> or <code>ssh-dss</code>) an ordered list of hostkey algorithms is returned which can be passed to <code>Connection.setServerHostKeyAlgorithms</code>. 
 * @param hostname
 * @return <code>null</code> if no key for the given hostname is present orthere are keys of multiple types present for the given hostname. Otherwise, an array with hostkey algorithms is returned (i.e., an array of length 2).
 */
public String[] getPreferredServerHostkeyAlgorithmOrder(String hostname){
  String[] algos=recommendHostkeyAlgorithms(hostname);
  if (algos != null)   return algos;
  InetAddress[] ipAdresses=null;
  try {
    ipAdresses=InetAddress.getAllByName(hostname);
  }
 catch (  UnknownHostException e) {
    return null;
  }
  for (int i=0; i < ipAdresses.length; i++) {
    algos=recommendHostkeyAlgorithms(ipAdresses[i].getHostAddress());
    if (algos != null)     return algos;
  }
  return null;
}
 

Example 64

From project constretto-core, under directory /constretto-core/src/main/java/org/constretto/internal/converter/.

Source file: InetAddressValueConverter.java

  15 
vote

public InetAddress fromString(String value) throws ConstrettoConversionException {
  try {
    return InetAddress.getByName(value);
  }
 catch (  UnknownHostException e) {
    throw new ConstrettoConversionException(value,InetAddress.class,e);
  }
}
 

Example 65

From project Core_2, under directory /shell/src/main/java/org/jboss/forge/shell/plugins/builtin/.

Source file: RunUrlPlugin.java

  15 
vote

@DefaultCommand public void run(@Option(description="url...",required=true) final String url,final PipeOut pipeOut,final String... args) throws Exception {
  String urlPattern="^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
  if (Pattern.matches(urlPattern,url)) {
    URL remote=new URL(url);
    String temporalDir=System.getProperty("java.io.tmpdir");
    File tempFile=new File(temporalDir,"temp" + UUID.randomUUID().toString().replace("-",""));
    tempFile.createNewFile();
    UnknownFileResource tempResource=new UnknownFileResource(factory,tempFile);
    PluginUtil.downloadFromURL(pipeOut,remote,tempResource);
    try {
      shell.execute(tempFile,args);
    }
 catch (    UnknownHostException e) {
      throw e;
    }
catch (    IOException e) {
      throw new RuntimeException("error executing script from url " + url);
    }
  }
 else {
    throw new RuntimeException("resource must be a url: " + url);
  }
}
 

Example 66

From project CouchbaseMock, under directory /src/test/java/org/couchbase/mock/.

Source file: JMembaseTest.java

  15 
vote

private boolean serverIsReady(String host,int port){
  Socket socket=null;
  try {
    socket=new Socket(host,port);
    return true;
  }
 catch (  UnknownHostException ex) {
  }
catch (  IOException ex) {
  }
 finally {
    if (socket != null) {
      try {
        socket.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return false;
}
 

Example 67

From project Cours-3eme-ann-e, under directory /Java/FerryInpres/src/company_server/.

Source file: CheckInApplic.java

  15 
vote

public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException {
  Socket sock=new Socket(Config.COMPANY_SERVER,Config.COMPANY_PORT);
  ObjectOutputStream out=new ObjectOutputStream(sock.getOutputStream());
  ObjectInputStream in=new ObjectInputStream(sock.getInputStream());
  System.out.println("Nom d'utilisateur: ");
  String user=readLine();
  System.out.println("Mot de passe: ");
  String pass=readLine();
  out.writeObject(new Login(user,pass));
  out.flush();
  Protocol response=(Protocol)in.readObject();
  if (response instanceof Ack) {
    int choix;
    do {
      System.out.println("1. Valider une r?servation");
      System.out.println("2. Acheter une travers?e");
      System.out.println("3. Quitter");
      System.out.println("Votre choix: ");
      choix=readInt();
      if (choix == 1)       verifBooking(in,out);
 else       if (choix == 2)       buyTicket(in,out);
    }
 while (choix != 3);
    sock.close();
  }
 else {
    System.out.println("Identifiants invalides");
  }
}
 

Example 68

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: RadioInfo.java

  15 
vote

/** 
 * Ping a host name
 */
private final void pingHostname(){
  try {
    Process p=Runtime.getRuntime().exec("ping -c 1 www.google.com");
    int status=p.waitFor();
    if (status == 0) {
      mPingHostnameResult="Pass";
    }
 else {
      mPingHostnameResult="Fail: Host unreachable";
    }
  }
 catch (  UnknownHostException e) {
    mPingHostnameResult="Fail: Unknown Host";
  }
catch (  IOException e) {
    mPingHostnameResult="Fail: IOException";
  }
catch (  InterruptedException e) {
    mPingHostnameResult="Fail: InterruptedException";
  }
}
 

Example 69

From project curator, under directory /curator-framework/src/main/java/com/netflix/curator/framework/.

Source file: CuratorFrameworkFactory.java

  15 
vote

private static byte[] getLocalAddress(){
  try {
    return InetAddress.getLocalHost().getHostAddress().getBytes();
  }
 catch (  UnknownHostException ignore) {
  }
  return new byte[0];
}
 

Example 70

From project datasalt-utils, under directory /src/contrib/java/org/apache/solr/cloud/.

Source file: SolrZkServer.java

  15 
vote

public void setClientPort(int clientPort){
  if (clientPortAddress != null) {
    try {
      this.clientPortAddress=new InetSocketAddress(InetAddress.getByName(clientPortAddress.getHostName()),clientPort);
    }
 catch (    UnknownHostException e) {
      throw new RuntimeException(e);
    }
  }
 else {
    this.clientPortAddress=new InetSocketAddress(clientPort);
  }
}
 

Example 71

From project dawn-isencia, under directory /com.isencia.passerelle.commons.ume/src/main/java/com/isencia/message/net/.

Source file: DatagramSenderChannel.java

  15 
vote

/** 
 * Sets the remoteHost.
 * @param remoteHost The remoteHost to set
 * @throws ChannelException
 */
public void setRemoteHostName(String remoteHost) throws ChannelException {
  if (logger.isTraceEnabled())   logger.trace("setRemoteHostName() - entry :" + remoteHost);
  if (remoteHost == null || remotePort < 0) {
    throw new ChannelException("Remote host (" + remoteHost + ") not set correctly");
  }
  remoteHostName=remoteHost;
  try {
    this.remoteHost=InetAddress.getByName(remoteHost);
  }
 catch (  UnknownHostException e) {
    throw new ChannelException("Unknown host " + remoteHost);
  }
  if (logger.isTraceEnabled())   logger.trace("setRemoteHostName() - exit");
}
 

Example 72

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model/src/main/java/com/isencia/passerelle/workbench/model/jmx/.

Source file: RemoteManagerAgent.java

  15 
vote

private static final String getHostName() throws UnknownHostException {
  String hostName=System.getProperty("org.dawb.workbench.jmx.host.name");
  if (hostName == null)   hostName=InetAddress.getLocalHost().getHostName();
  if (hostName == null)   hostName=InetAddress.getLocalHost().getHostAddress();
  if (hostName == null)   hostName="localhost";
  return hostName;
}
 

Example 73

From project dawn-workflow, under directory /org.dawb.workbench.jmx/src/org/dawb/workbench/jmx/service/.

Source file: RemoteWorkflow.java

  15 
vote

private static final String getHostName() throws UnknownHostException {
  String hostName=System.getProperty("org.dawb.workbench.jmx.host.name");
  if (hostName == null)   hostName=InetAddress.getLocalHost().getHostName();
  if (hostName == null)   hostName=InetAddress.getLocalHost().getHostAddress();
  if (hostName == null)   hostName="localhost";
  return hostName;
}
 

Example 74

From project dcm4che, under directory /dcm4che-net/src/main/java/org/dcm4che/net/.

Source file: Connection.java

  15 
vote

private List<InetAddress> blacklistAddrs(){
  if (blacklistAddrs == null) {
    blacklistAddrs=new ArrayList<InetAddress>(blacklist.length);
    for (    String hostname : blacklist)     try {
      blacklistAddrs.add(InetAddress.getByName(hostname));
    }
 catch (    UnknownHostException e) {
      LOG.warn("Failed to lookup InetAddress of " + hostname,e);
    }
  }
  return blacklistAddrs;
}
 

Example 75

From project demonstrator-backend, under directory /demonstrator-backend-ejb/src/main/java/org/marssa/demonstrator/beans/.

Source file: DAQBean.java

  15 
vote

@PostConstruct private void init() throws ConfigurationError, NoConnection, UnknownHostException, JAXBException, FileNotFoundException {
  logger.info("Initializing DAQ Bean");
  JAXBContext context=JAXBContext.newInstance(new Class[]{Settings.class});
  Unmarshaller unmarshaller=context.createUnmarshaller();
  InputStream is=this.getClass().getClassLoader().getResourceAsStream("configuration/settings.xml");
  Settings settings=(Settings)unmarshaller.unmarshal(is);
  for (  DAQType daq : settings.getDaqs().getDaq()) {
    AddressType addressElement=daq.getSocket();
    MString address;
    if (addressElement.getHost().getIp() == null || addressElement.getHost().getIp().isEmpty()) {
      String hostname=addressElement.getHost().getHostname();
      address=new MString(Inet4Address.getByName(hostname).getAddress().toString());
    }
 else {
      address=new MString(addressElement.getHost().getIp());
    }
    logger.info("Found configuration for {} connected to {}, port {}",new Object[]{daq.getDAQname(),address,addressElement.getPort()});
    LabJack lj;
switch (daq.getType()) {
case LAB_JACK_U_3:
      lj=LabJackU3.getInstance(address,new MInteger(daq.getSocket().getPort()));
    break;
case LAB_JACK_UE_9:
  lj=LabJackUE9.getInstance(address,new MInteger(daq.getSocket().getPort()));
break;
default :
throw new ConfigurationError("Unknown DAQ type: " + daq.getType());
}
daqs.put(address.toString() + ":" + addressElement.getPort(),lj);
}
logger.info("Initialized DAQ Bean");
}
 

Example 76

From project Dempsy, under directory /lib-dempsyimpl/src/main/java/com/nokia/dempsy/messagetransport/tcp/.

Source file: TcpReceiver.java

  15 
vote

public TcpDestination doGetDestination() throws MessageTransportException {
  try {
    InetAddress inetAddress=useLocalhost ? InetAddress.getLocalHost() : TcpTransport.getFirstNonLocalhostInetAddress();
    if (inetAddress == null)     throw new MessageTransportException("Failed to set the Inet Address for this host. Is there a valid network interface?");
    return new TcpDestination(inetAddress,port);
  }
 catch (  UnknownHostException e) {
    throw new MessageTransportException("Failed to identify the current hostname",e);
  }
catch (  SocketException e) {
    throw new MessageTransportException("Failed to identify the current hostname",e);
  }
}
 

Example 77

From project distributed_loadgen, under directory /src/com/couchbase/loadgen/memcached/.

Source file: SpymemcachedClient.java

  15 
vote

/** 
 * Initialize any state for this DB. Called once per DB instance; there is one DB instance per client thread.
 */
public void init(){
  int membaseport=((Integer)Config.getConfig().get(Config.MEMCACHED_PORT)).intValue();
  String addr=(String)Config.getConfig().get(Config.MEMCACHED_ADDRESS);
  String protocol=(String)Config.getConfig().get(Config.PROTOCOL);
  try {
    InetSocketAddress ia=new InetSocketAddress(InetAddress.getByAddress(ipv4AddressToByte(addr)),membaseport);
    if (protocol.equals(PROTO_BINARY)) {
      client=new MemcachedClient(new BinaryConnectionFactory(),Arrays.asList(ia));
    }
 else     if (protocol.equals(PROTO_ASCII)) {
      client=new MemcachedClient(ia);
    }
 else {
      LOG.info("ERROR: BAD PROTOCOL");
      ClusterManager.getManager().finishedLoadGeneration();
    }
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
catch (  IOException e1) {
    e1.printStackTrace();
  }
}
 

Example 78

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/launching/internal/.

Source file: JavaAgentTraceClient.java

  15 
vote

@Override public void doAttach(ILaunch launch,ILaunchConfiguration configuration,IProgressMonitor monitor) throws CoreException {
  int portNumber=configuration.getAttribute(JavaTraceConfigurationDelegate.TRACE_PORT,0);
  try {
    for (int tries=1; tries <= 5; tries++) {
      try {
        clientSocket=new Socket("localhost",portNumber);
        tries=6;
      }
 catch (      IOException e) {
        clientSocket=null;
        if (tries > 5) {
          throw e;
        }
 else {
          try {
            Thread.sleep(1000);
          }
 catch (          InterruptedException ie) {
            Thread.interrupted();
          }
        }
      }
    }
    handshake(configuration);
    readThread.start();
  }
 catch (  NullPointerException e) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"No port to attach for process"));
  }
catch (  UnknownHostException e) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not connect to host process",e));
  }
catch (  IOException e) {
    throw new CoreException(new Status(Status.ERROR,SketchPlugin.PLUGIN_ID,"Could not connect to host process",e));
  }
}
 

Example 79

From project dmix, under directory /JmDNS/src/javax/jmdns/impl/.

Source file: DNSRecord.java

  15 
vote

protected Address(String name,DNSRecordType type,DNSRecordClass recordClass,boolean unique,int ttl,byte[] rawAddress){
  super(name,type,recordClass,unique,ttl);
  try {
    this._addr=InetAddress.getByAddress(rawAddress);
  }
 catch (  UnknownHostException exception) {
    logger1.log(Level.WARNING,"Address() exception ",exception);
  }
}
 

Example 80

From project dolphin, under directory /dolphinmaple/src/com/tan/util/.

Source file: Site2Ip.java

  15 
vote

private static void getName(String str,int from) throws UnknownHostException {
  String name="";
  String suffix=".com";
  int start=str.indexOf("http://",from);
  int end=str.indexOf(suffix,start);
  if (end == -1) {
    suffix=".cn";
    end=str.indexOf(suffix,start);
  }
  if (start != -1 && end != -1) {
    name=str.substring(start + 7,end + suffix.length());
    if (name.matches("^[\\w\\\56]+$")) {
      result.add(name);
    }
  }
  if ((start=str.indexOf("http://",end)) != -1) {
    getName(str,start);
  }
}
 

Example 81

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/.

Source file: DragonJobRunner.java

  15 
vote

private void configureSubmitHost(Configuration conf) throws UnknownHostException {
  InetAddress ip=InetAddress.getLocalHost();
  if (ip != null) {
    conf.set(DragonJobConfig.JOB_SUBMITHOST,ip.getHostName());
    conf.set(DragonJobConfig.JOB_SUBMITHOSTADDR,ip.getHostAddress());
  }
}
 

Example 82

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/helpers/.

Source file: EasySSLSocketFactory.java

  15 
vote

/** 
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,java.lang.String,int,java.net.InetAddress,int,org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock,String host,int port,InetAddress localAddress,int localPort,HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  int connTimeout=HttpConnectionParams.getConnectionTimeout(params);
  int soTimeout=HttpConnectionParams.getSoTimeout(params);
  InetSocketAddress remoteAddress=new InetSocketAddress(host,port);
  SSLSocket sslsock=(SSLSocket)((sock != null) ? sock : createSocket());
  if ((localAddress != null) || (localPort > 0)) {
    if (localPort < 0) {
      localPort=0;
    }
    InetSocketAddress isa=new InetSocketAddress(localAddress,localPort);
    sslsock.bind(isa);
  }
  sslsock.connect(remoteAddress,connTimeout);
  sslsock.setSoTimeout(soTimeout);
  return sslsock;
}
 

Example 83

From project droid-fu, under directory /src/main/java/com/github/droidfu/http/ssl/.

Source file: EasySSLSocketFactory.java

  15 
vote

/** 
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,java.lang.String,int,java.net.InetAddress,int,org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock,String host,int port,InetAddress localAddress,int localPort,HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  int connTimeout=HttpConnectionParams.getConnectionTimeout(params);
  int soTimeout=HttpConnectionParams.getSoTimeout(params);
  InetSocketAddress remoteAddress=new InetSocketAddress(host,port);
  SSLSocket sslsock=(SSLSocket)((sock != null) ? sock : createSocket());
  if ((localAddress != null) || (localPort > 0)) {
    if (localPort < 0) {
      localPort=0;
    }
    InetSocketAddress isa=new InetSocketAddress(localAddress,localPort);
    sslsock.bind(isa);
  }
  sslsock.connect(remoteAddress,connTimeout);
  sslsock.setSoTimeout(soTimeout);
  return sslsock;
}
 

Example 84

From project droolsjbpm-integration, under directory /drools-grid/drools-grid-impl/src/test/java/org/drools/grid/local/.

Source file: LocalGridNodeTest.java

  15 
vote

private InetAddress getLocalAddress(){
  try {
    return InetAddress.getLocalHost();
  }
 catch (  UnknownHostException e) {
    throw new RuntimeException("Unable to lookup local address",e);
  }
}