本文整理匯總了Java中org.apache.hadoop.net.NetUtils.addStaticResolution方法的典型用法代碼示例。如果您正苦於以下問題:Java NetUtils.addStaticResolution方法的具體用法?Java NetUtils.addStaticResolution怎麽用?Java NetUtils.addStaticResolution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.net.NetUtils
的用法示例。
在下文中一共展示了NetUtils.addStaticResolution方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setConf
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
public void setConf(Configuration conf) {
if (conf instanceof JobConf) {
this.conf = (JobConf) conf;
} else {
this.conf = new JobConf(conf);
}
this.mapOutputFile = ReflectionUtils.newInstance(
conf.getClass(MRConfig.TASK_LOCAL_OUTPUT_CLASS,
MROutputFiles.class, MapOutputFile.class), conf);
this.lDirAlloc = new LocalDirAllocator(MRConfig.LOCAL_DIR);
// add the static resolutions (this is required for the junit to
// work on testcases that simulate multiple nodes on a single physical
// node.
String hostToResolved[] = conf.getStrings(MRConfig.STATIC_RESOLUTIONS);
if (hostToResolved != null) {
for (String str : hostToResolved) {
String name = str.substring(0, str.indexOf('='));
String resolvedName = str.substring(str.indexOf('=') + 1);
NetUtils.addStaticResolution(name, resolvedName);
}
}
}
示例2: testSetSocketAddress
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
public void testSetSocketAddress() {
Configuration conf = new Configuration();
NetUtils.addStaticResolution("host", "127.0.0.1");
final String defaultAddr = "host:1";
InetSocketAddress addr = NetUtils.createSocketAddr(defaultAddr);
conf.setSocketAddr("myAddress", addr);
assertEquals(defaultAddr, NetUtils.getHostPortString(addr));
}
示例3: initializeDummyHostnameResolution
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@BeforeClass
public static void initializeDummyHostnameResolution() throws Exception {
String previousIpAddress;
for (String hostName : dummyHostNames) {
if (null != (previousIpAddress = NetUtils.getStaticResolution(hostName))) {
savedStaticResolution.put(hostName, previousIpAddress);
}
NetUtils.addStaticResolution(hostName, anyIpAddress);
}
}
示例4: setUp
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
super.setUp();
NetUtils.addStaticResolution("host1", "172.0.0.1");
NetUtils.addStaticResolution("host2", "172.0.0.1");
NetUtils.addStaticResolution("host3", "172.0.0.1");
NetUtils.addStaticResolution("host4", "172.0.0.1");
NetUtils.addStaticResolution("host5", "172.0.0.1");
NetUtils.addStaticResolution("host6", "172.0.0.1");
}
示例5: testSetSocketAddress
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
public void testSetSocketAddress() throws IOException {
Configuration conf = new Configuration();
NetUtils.addStaticResolution("host", "127.0.0.1");
final String defaultAddr = "host:1";
InetSocketAddress addr = NetUtils.createSocketAddr(defaultAddr);
conf.setSocketAddr("myAddress", addr);
assertEquals(defaultAddr, NetUtils.getHostPortString(addr));
}
示例6: testSocketAddrWithName
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketAddrWithName() {
String staticHost = "my";
NetUtils.addStaticResolution(staticHost, "localhost");
verifyServiceAddr("LocalHost", "127.0.0.1");
}
示例7: testSocketAddrWithIP
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketAddrWithIP() {
String staticHost = "127.0.0.1";
NetUtils.addStaticResolution(staticHost, "localhost");
verifyServiceAddr(staticHost, "127.0.0.1");
}
示例8: testSocketAddrWithNameToStaticName
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketAddrWithNameToStaticName() {
String staticHost = "host1";
NetUtils.addStaticResolution(staticHost, "localhost");
verifyServiceAddr(staticHost, "127.0.0.1");
}
示例9: testSocketAddrWithNameToStaticIP
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketAddrWithNameToStaticIP() {
String staticHost = "host3";
NetUtils.addStaticResolution(staticHost, "255.255.255.255");
verifyServiceAddr(staticHost, "255.255.255.255");
}
示例10: testSocketAddrWithIPToStaticIP
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketAddrWithIPToStaticIP() {
String staticHost = "1.2.3.4";
NetUtils.addStaticResolution(staticHost, "255.255.255.255");
verifyServiceAddr(staticHost, "255.255.255.255");
}
示例11: restoreDummyHostnameResolution
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@AfterClass
public static void restoreDummyHostnameResolution() throws Exception {
for (Map.Entry<String, String> hostnameToIpEntry : savedStaticResolution.entrySet()) {
NetUtils.addStaticResolution(hostnameToIpEntry.getKey(), hostnameToIpEntry.getValue());
}
}
示例12: setupStaticHostResolution
import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
/**
* Add namenodes to the static resolution list to avoid going
* through DNS which can be really slow in some configurations.
*/
private void setupStaticHostResolution(int nameServiceIdCount) {
for (int i = 0; i < nameServiceIdCount; i++) {
NetUtils.addStaticResolution("nn" + i, "localhost");
}
}