本文整理汇总了Java中org.apache.hadoop.registry.client.types.Endpoint类的典型用法代码示例。如果您正苦于以下问题:Java Endpoint类的具体用法?Java Endpoint怎么用?Java Endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Endpoint类属于org.apache.hadoop.registry.client.types包,在下文中一共展示了Endpoint类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: retrieveAddressesUriType
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Get a single URI endpoint
* @param epr endpoint
* @return the uri of the first entry in the address list. Null if the endpoint
* itself is null
* @throws InvalidRecordException if the type is wrong, there are no addresses
* or the payload ill-formatted
*/
public static List<String> retrieveAddressesUriType(Endpoint epr)
throws InvalidRecordException {
if (epr == null) {
return null;
}
requireAddressType(ADDRESS_URI, epr);
List<Map<String, String>> addresses = epr.addresses;
if (addresses.size() < 1) {
throw new InvalidRecordException(epr.toString(),
"No addresses in endpoint");
}
List<String> results = new ArrayList<String>(addresses.size());
for (Map<String, String> address : addresses) {
results.add(getAddressField(address, ADDRESS_URI));
}
return results;
}
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:RegistryTypeUtils.java
示例2: findEndpoint
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Find an endpoint in a record or fail,
* @param record record
* @param api API
* @param external external?
* @param addressElements expected # of address elements?
* @param addressTupleSize expected size of a type
* @return the endpoint.
*/
public static Endpoint findEndpoint(ServiceRecord record,
String api, boolean external, int addressElements, int addressTupleSize) {
Endpoint epr = external ? record.getExternalEndpoint(api)
: record.getInternalEndpoint(api);
if (epr != null) {
assertEquals("wrong # of addresses",
addressElements, epr.addresses.size());
assertEquals("wrong # of elements in an address tuple",
addressTupleSize, epr.addresses.get(0).size());
return epr;
}
List<Endpoint> endpoints = external ? record.external : record.internal;
StringBuilder builder = new StringBuilder();
for (Endpoint endpoint : endpoints) {
builder.append("\"").append(endpoint).append("\" ");
}
fail("Did not find " + api + " in endpoints " + builder);
// never reached; here to keep the compiler happy
return null;
}
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:RegistryTestHelper.java
示例3: addSampleEndpoints
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Add some endpoints
* @param entry entry
*/
public static void addSampleEndpoints(ServiceRecord entry, String hostname)
throws URISyntaxException {
assertNotNull(hostname);
entry.addExternalEndpoint(webEndpoint(HTTP_API,
new URI("http", hostname + ":80", "/")));
entry.addExternalEndpoint(
restEndpoint(API_WEBHDFS,
new URI("http", hostname + ":8020", "/")));
Endpoint endpoint = ipcEndpoint(API_HDFS, null);
endpoint.addresses.add(RegistryTypeUtils.hostnamePortPair(hostname, 8030));
entry.addInternalEndpoint(endpoint);
InetSocketAddress localhost = new InetSocketAddress("localhost", 8050);
entry.addInternalEndpoint(
inetAddrEndpoint(NNIPC, ProtocolTypes.PROTOCOL_THRIFT, "localhost",
8050));
entry.addInternalEndpoint(
RegistryTypeUtils.ipcEndpoint(
IPC2, localhost));
}
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:RegistryTestHelper.java
示例4: inetAddrEndpoint
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Create an internet address endpoint from a list of URIs
* @param api implemented API
* @param protocolType protocol type
* @param hostname hostname/FQDN
* @param port port
* @return a new endpoint
*/
public static Endpoint inetAddrEndpoint(String api,
String protocolType,
String hostname,
int port) {
Preconditions.checkArgument(api != null, "null API");
Preconditions.checkArgument(protocolType != null, "null protocolType");
Preconditions.checkArgument(hostname != null, "null hostname");
return new Endpoint(api,
ADDRESS_HOSTNAME_AND_PORT,
protocolType,
hostnamePortPair(hostname, port));
}
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:RegistryTypeUtils.java
示例5: ipcEndpoint
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Create an IPC endpoint
* @param api API
* @param address the address as a tuple of (hostname, port)
* @return the new endpoint
*/
public static Endpoint ipcEndpoint(String api, InetSocketAddress address) {
return new Endpoint(api,
ADDRESS_HOSTNAME_AND_PORT,
ProtocolTypes.PROTOCOL_HADOOP_IPC,
address== null ? null: hostnamePortPair(address));
}
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:RegistryTypeUtils.java
示例6: requireAddressType
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Require a specific address type on an endpoint
* @param required required type
* @param epr endpoint
* @throws InvalidRecordException if the type is wrong
*/
public static void requireAddressType(String required, Endpoint epr) throws
InvalidRecordException {
if (!required.equals(epr.addressType)) {
throw new InvalidRecordException(
epr.toString(),
"Address type of " + epr.addressType
+ " does not match required type of "
+ required);
}
}
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:RegistryTypeUtils.java
示例7: retrieveAddressURLs
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Get the address URLs. Guranteed to return at least one address.
* @param epr endpoint
* @return the address as a URL
* @throws InvalidRecordException if the type is wrong, there are no addresses
* or the payload ill-formatted
* @throws MalformedURLException address can't be turned into a URL
*/
public static List<URL> retrieveAddressURLs(Endpoint epr)
throws InvalidRecordException, MalformedURLException {
if (epr == null) {
throw new InvalidRecordException("", "Null endpoint");
}
List<String> addresses = retrieveAddressesUriType(epr);
List<URL> results = new ArrayList<URL>(addresses.size());
for (String address : addresses) {
results.add(new URL(address));
}
return results;
}
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:RegistryTypeUtils.java
示例8: validateEndpoint
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Validate the endpoint by checking for null fields and other invalid
* conditions
* @param path path for exceptions
* @param endpoint endpoint to validate. May be null
* @throws InvalidRecordException on invalid entries
*/
public static void validateEndpoint(String path, Endpoint endpoint)
throws InvalidRecordException {
if (endpoint == null) {
throw new InvalidRecordException(path, "Null endpoint");
}
try {
endpoint.validate();
} catch (RuntimeException e) {
throw new InvalidRecordException(path, e.toString());
}
}
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:RegistryTypeUtils.java
示例9: validateEntry
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* General code to validate bits of a component/service entry built iwth
* {@link #addSampleEndpoints(ServiceRecord, String)}
* @param record instance to check
*/
public static void validateEntry(ServiceRecord record) {
assertNotNull("null service record", record);
List<Endpoint> endpoints = record.external;
assertEquals(2, endpoints.size());
Endpoint webhdfs = findEndpoint(record, API_WEBHDFS, true, 1, 1);
assertEquals(API_WEBHDFS, webhdfs.api);
assertEquals(AddressTypes.ADDRESS_URI, webhdfs.addressType);
assertEquals(ProtocolTypes.PROTOCOL_REST, webhdfs.protocolType);
List<Map<String, String>> addressList = webhdfs.addresses;
Map<String, String> url = addressList.get(0);
String addr = url.get("uri");
assertTrue(addr.contains("http"));
assertTrue(addr.contains(":8020"));
Endpoint nnipc = findEndpoint(record, NNIPC, false, 1,2);
assertEquals("wrong protocol in " + nnipc, ProtocolTypes.PROTOCOL_THRIFT,
nnipc.protocolType);
Endpoint ipc2 = findEndpoint(record, IPC2, false, 1,2);
assertNotNull(ipc2);
Endpoint web = findEndpoint(record, HTTP_API, true, 1, 1);
assertEquals(1, web.addresses.size());
assertEquals(1, web.addresses.get(0).size());
}
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:RegistryTestHelper.java
示例10: assertMatches
import org.apache.hadoop.registry.client.types.Endpoint; //导入依赖的package包/类
/**
* Assert that an endpoint matches the criteria
* @param endpoint endpoint to examine
* @param addressType expected address type
* @param protocolType expected protocol type
* @param api API
*/
public static void assertMatches(Endpoint endpoint,
String addressType,
String protocolType,
String api) {
assertNotNull(endpoint);
assertEquals(addressType, endpoint.addressType);
assertEquals(protocolType, endpoint.protocolType);
assertEquals(api, endpoint.api);
}
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:RegistryTestHelper.java
注:本文中的org.apache.hadoop.registry.client.types.Endpoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论