Search in sources :

Example 16 with UnknownHostException

use of java.net.UnknownHostException in project hbase by apache.

the class TestConnectionImplementation method testGetAdminBadHostname.

@Test(expected = UnknownHostException.class)
public void testGetAdminBadHostname() throws Exception {
    // verify that we can get an instance with the cluster hostname
    ServerName master = testUtil.getHBaseCluster().getMaster().getServerName();
    try {
        conn.getAdmin(master);
    } catch (UnknownHostException uhe) {
        fail("Obtaining admin to the cluster master should have succeeded");
    }
    // test that we fail to get a client to an unresolvable hostname, which
    // means it won't be cached
    ServerName badHost = ServerName.valueOf("unknownhost.example.com:" + HConstants.DEFAULT_MASTER_PORT, System.currentTimeMillis());
    conn.getAdmin(badHost);
    fail("Obtaining admin to unresolvable hostname should have failed");
}
Also used : UnknownHostException(java.net.UnknownHostException) ServerName(org.apache.hadoop.hbase.ServerName) Test(org.junit.Test)

Example 17 with UnknownHostException

use of java.net.UnknownHostException in project hbase by apache.

the class TestConnectionImplementation method testGetClientBadHostname.

@Test(expected = UnknownHostException.class)
public void testGetClientBadHostname() throws Exception {
    // verify that we can get an instance with the cluster hostname
    ServerName rs = testUtil.getHBaseCluster().getRegionServer(0).getServerName();
    try {
        conn.getClient(rs);
    } catch (UnknownHostException uhe) {
        fail("Obtaining client to the cluster regionserver should have succeeded");
    }
    // test that we fail to get a client to an unresolvable hostname, which
    // means it won't be cached
    ServerName badHost = ServerName.valueOf("unknownhost.example.com:" + HConstants.DEFAULT_REGIONSERVER_PORT, System.currentTimeMillis());
    conn.getAdmin(badHost);
    fail("Obtaining client to unresolvable hostname should have failed");
}
Also used : UnknownHostException(java.net.UnknownHostException) ServerName(org.apache.hadoop.hbase.ServerName) Test(org.junit.Test)

Example 18 with UnknownHostException

use of java.net.UnknownHostException in project storm by apache.

the class TestSimpleFileNameFormat method testParameters.

@Test
public void testParameters() {
    SimpleFileNameFormat format = new SimpleFileNameFormat().withName("$TIME.$HOST.$COMPONENT.$TASK.$NUM.txt").withPath("/mypath").withTimeFormat("yyyy-MM-dd HH:mm:ss");
    format.prepare(null, createTopologyContext());
    long now = System.currentTimeMillis();
    String path = format.getPath();
    String name = format.getName(1, now);
    Assert.assertEquals("/mypath", path);
    String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now);
    String host = null;
    try {
        host = Utils.localHostname();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    Assert.assertEquals(time + "." + host + ".Xcom.7.1.txt", name);
}
Also used : UnknownHostException(java.net.UnknownHostException) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 19 with UnknownHostException

use of java.net.UnknownHostException in project storm by apache.

the class TestSimpleFileNameFormat method testParameters.

@Test
public void testParameters() {
    SimpleFileNameFormat format = new SimpleFileNameFormat().withName("$TIME.$HOST.$PARTITION.$NUM.txt").withPath("/mypath").withTimeFormat("yyyy-MM-dd HH:mm:ss");
    format.prepare(null, 3, 5);
    long now = System.currentTimeMillis();
    String path = format.getPath();
    String name = format.getName(1, now);
    Assert.assertEquals("/mypath", path);
    String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now);
    String host = null;
    try {
        host = Utils.localHostname();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    Assert.assertEquals(time + "." + host + ".3.1.txt", name);
}
Also used : UnknownHostException(java.net.UnknownHostException) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 20 with UnknownHostException

use of java.net.UnknownHostException in project hive by apache.

the class ThriftCLIService method init.

@Override
public synchronized void init(HiveConf hiveConf) {
    this.hiveConf = hiveConf;
    String hiveHost = System.getenv("HIVE_SERVER2_THRIFT_BIND_HOST");
    if (hiveHost == null) {
        hiveHost = hiveConf.getVar(ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST);
    }
    try {
        serverIPAddress = ServerUtils.getHostAddress(hiveHost);
    } catch (UnknownHostException e) {
        throw new ServiceException(e);
    }
    // Initialize common server configs needed in both binary & http modes
    String portString;
    // HTTP mode
    if (HiveServer2.isHTTPTransportMode(hiveConf)) {
        workerKeepAliveTime = hiveConf.getTimeVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_WORKER_KEEPALIVE_TIME, TimeUnit.SECONDS);
        portString = System.getenv("HIVE_SERVER2_THRIFT_HTTP_PORT");
        if (portString != null) {
            portNum = Integer.parseInt(portString);
        } else {
            portNum = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT);
        }
    } else // Binary mode
    {
        workerKeepAliveTime = hiveConf.getTimeVar(ConfVars.HIVE_SERVER2_THRIFT_WORKER_KEEPALIVE_TIME, TimeUnit.SECONDS);
        portString = System.getenv("HIVE_SERVER2_THRIFT_PORT");
        if (portString != null) {
            portNum = Integer.parseInt(portString);
        } else {
            portNum = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_PORT);
        }
    }
    minWorkerThreads = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MIN_WORKER_THREADS);
    maxWorkerThreads = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_WORKER_THREADS);
    super.init(hiveConf);
}
Also used : UnknownHostException(java.net.UnknownHostException) ServiceException(org.apache.hive.service.ServiceException)

Aggregations

UnknownHostException (java.net.UnknownHostException)780 InetAddress (java.net.InetAddress)319 IOException (java.io.IOException)229 InetSocketAddress (java.net.InetSocketAddress)88 Test (org.junit.Test)74 SocketException (java.net.SocketException)61 ArrayList (java.util.ArrayList)59 Socket (java.net.Socket)48 SocketTimeoutException (java.net.SocketTimeoutException)38 File (java.io.File)34 URL (java.net.URL)32 HashMap (java.util.HashMap)31 MalformedURLException (java.net.MalformedURLException)30 ConnectException (java.net.ConnectException)27 NetworkInterface (java.net.NetworkInterface)25 Properties (java.util.Properties)24 Inet4Address (java.net.Inet4Address)22 InputStream (java.io.InputStream)20 HttpURLConnection (java.net.HttpURLConnection)20 URI (java.net.URI)20