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");
}
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");
}
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);
}
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);
}
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);
}
Aggregations