本文整理汇总了Java中org.apache.hadoop.yarn.api.records.Token类的典型用法代码示例。如果您正苦于以下问题:Java Token类的具体用法?Java Token怎么用?Java Token使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Token类属于org.apache.hadoop.yarn.api.records包,在下文中一共展示了Token类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startContainers
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@Override
public StartContainersResponse startContainers(
StartContainersRequest requests) throws YarnException {
StartContainersResponse response =
recordFactory.newRecordInstance(StartContainersResponse.class);
for (StartContainerRequest request : requests.getStartContainerRequests()) {
Token containerToken = request.getContainerToken();
ContainerTokenIdentifier tokenId = null;
try {
tokenId = newContainerTokenIdentifier(containerToken);
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
}
ContainerStatus status =
recordFactory.newRecordInstance(ContainerStatus.class);
status.setState(ContainerState.RUNNING);
status.setContainerId(tokenId.getContainerID());
status.setExitStatus(0);
statuses.add(status);
}
return response;
}
示例2: newContainerInstance
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private Container newContainerInstance(int id, Priority priority,
Resource capability, String hostName) throws IOException {
HPCCommandExecutor.setJobState(id, "assigned", conf);
NodeId nodeId = NodeId.newInstance(hostName, 0);
Container container = Records.newRecord(Container.class);
container.setNodeId(nodeId);
container.setPriority(priority);
container.setResource(capability);
container.setId(ContainerId.newInstance(appAttemptId, ++containerId));
Token token = Token.newInstance(nodeId.toString().getBytes(),
nodeId.toString(), nodeId.toString().getBytes(), nodeId.toString());
byte[] bytes = container.getId().toString().getBytes();
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.put(bytes);
token.setIdentifier(buffer);
container.setContainerToken(token);
container.setNodeHttpAddress(hostName + ":0");
LOG.info("Allocated container " + container.getId() + " for Job id:" + id);
return container;
}
示例3: testStopContainer
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private String testStopContainer(YarnRPC rpc,
ApplicationAttemptId appAttemptId, NodeId nodeId,
ContainerId containerId, Token nmToken, boolean isExceptionExpected) {
try {
stopContainer(rpc, nmToken,
Arrays.asList(new ContainerId[] { containerId }), appAttemptId,
nodeId);
if (isExceptionExpected) {
fail("Exception was expected!!");
}
return "";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
示例4: testStartContainer
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private String testStartContainer(YarnRPC rpc,
ApplicationAttemptId appAttemptId, NodeId nodeId,
org.apache.hadoop.yarn.api.records.Token containerToken,
org.apache.hadoop.yarn.api.records.Token nmToken,
boolean isExceptionExpected) {
try {
startContainer(rpc, nmToken, containerToken, nodeId,
appAttemptId.toString());
if (isExceptionExpected){
fail("Exception was expected!!");
}
return "";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
示例5: stopContainer
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private void stopContainer(YarnRPC rpc, Token nmToken,
List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
NodeId nodeId) throws Exception {
StopContainersRequest request =
StopContainersRequest.newInstance(containerId);
ContainerManagementProtocol proxy = null;
try {
proxy =
getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
appAttemptId.toString());
StopContainersResponse response = proxy.stopContainers(request);
if (response.getFailedRequests() != null &&
response.getFailedRequests().containsKey(containerId)) {
parseAndThrowException(response.getFailedRequests().get(containerId)
.deSerialize());
}
} catch (Exception e) {
if (proxy != null) {
rpc.stopProxy(proxy, conf);
}
}
}
示例6: startContainer
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private void startContainer(final YarnRPC rpc,
org.apache.hadoop.yarn.api.records.Token nmToken,
org.apache.hadoop.yarn.api.records.Token containerToken,
NodeId nodeId, String user) throws Exception {
ContainerLaunchContext context =
Records.newRecord(ContainerLaunchContext.class);
StartContainerRequest scRequest =
StartContainerRequest.newInstance(context,containerToken);
List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
list.add(scRequest);
StartContainersRequest allRequests =
StartContainersRequest.newInstance(list);
ContainerManagementProtocol proxy = null;
try {
proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
StartContainersResponse response = proxy.startContainers(allRequests);
for(SerializedException ex : response.getFailedRequests().values()){
parseAndThrowException(ex.deSerialize());
}
} finally {
if (proxy != null) {
rpc.stopProxy(proxy, conf);
}
}
}
示例7: getDelegationToken
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private Token getDelegationToken(
final UserGroupInformation loggedInUser,
final MRClientProtocol hsService, final String renewerString)
throws IOException, InterruptedException {
// Get the delegation token directly as it is a little difficult to setup
// the kerberos based rpc.
Token token = loggedInUser
.doAs(new PrivilegedExceptionAction<Token>() {
@Override
public Token run() throws IOException {
GetDelegationTokenRequest request = Records
.newRecord(GetDelegationTokenRequest.class);
request.setRenewer(renewerString);
return hsService.getDelegationToken(request).getDelegationToken();
}
});
return token;
}
示例8: createAndGetNMToken
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
public NMToken createAndGetNMToken(String applicationSubmitter,
ApplicationAttemptId appAttemptId, Container container) {
try {
this.readLock.lock();
HashSet<NodeId> nodeSet = this.appAttemptToNodeKeyMap.get(appAttemptId);
NMToken nmToken = null;
if (nodeSet != null) {
if (!nodeSet.contains(container.getNodeId())) {
LOG.info("Sending NMToken for nodeId : " + container.getNodeId()
+ " for container : " + container.getId());
Token token =
createNMToken(container.getId().getApplicationAttemptId(),
container.getNodeId(), applicationSubmitter);
nmToken = NMToken.newInstance(container.getNodeId(), token);
nodeSet.add(container.getNodeId());
}
}
return nmToken;
} finally {
this.readLock.unlock();
}
}
示例9: newContainerInstance
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
private Container newContainerInstance(int id, Priority priority,
Resource capability, String hostName) throws IOException {
NodeId nodeId = NodeId.newInstance(hostName, 0);
Container container = Records.newRecord(Container.class);
container.setNodeId(nodeId);
container.setPriority(priority);
container.setResource(capability);
container.setId(ContainerId.newContainerId(appAttemptId, ++containerId));
Token token = Token.newInstance(nodeId.toString().getBytes(),
nodeId.toString(), nodeId.toString().getBytes(), nodeId.toString());
byte[] bytes = container.getId().toString().getBytes();
ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
buffer.put(bytes);
token.setIdentifier(buffer);
container.setContainerToken(token);
container.setNodeHttpAddress(hostName + ":0");
return container;
}
示例10: testCancelDelegationTokenRequestPBImpl
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
/**
* Test CancelDelegationTokenRequestPBImpl.
* Test a transformation to prototype and back
*/
@Test
public void testCancelDelegationTokenRequestPBImpl() {
Token token = getDelegationToken();
CancelDelegationTokenRequestPBImpl original = new CancelDelegationTokenRequestPBImpl();
original.setDelegationToken(token);
CancelDelegationTokenRequestProto protoType = original.getProto();
CancelDelegationTokenRequestPBImpl copy = new CancelDelegationTokenRequestPBImpl(protoType);
assertNotNull(copy.getDelegationToken());
//compare source and converted
assertEquals(token, copy.getDelegationToken());
}
示例11: testRenewDelegationTokenRequestPBImpl
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
/**
* Test RenewDelegationTokenRequestPBImpl.
* Test a transformation to prototype and back
*/
@Test
public void testRenewDelegationTokenRequestPBImpl() {
Token token = getDelegationToken();
RenewDelegationTokenRequestPBImpl original = new RenewDelegationTokenRequestPBImpl();
original.setDelegationToken(token);
RenewDelegationTokenRequestProto protoType = original.getProto();
RenewDelegationTokenRequestPBImpl copy = new RenewDelegationTokenRequestPBImpl(protoType);
assertNotNull(copy.getDelegationToken());
//compare source and converted
assertEquals(token, copy.getDelegationToken());
}
示例12: newInstance
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@Private
@Unstable
public static AllocateResponse newInstance(int responseId,
List<ContainerStatus> completedContainers,
List<Container> allocatedContainers, List<NodeReport> updatedNodes,
Resource availResources, AMCommand command, int numClusterNodes,
PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken,
List<ContainerResourceIncrease> increasedContainers,
List<ContainerResourceDecrease> decreasedContainers) {
AllocateResponse response =
newInstance(responseId, completedContainers, allocatedContainers,
updatedNodes, availResources, command, numClusterNodes, preempt,
nmTokens, increasedContainers, decreasedContainers);
response.setAMRMToken(amRMToken);
return response;
}
示例13: getDelegationToken
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@Override
public Token getDelegationToken() {
CancelDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder;
if (this.token != null) {
return this.token;
}
this.token = convertFromProtoFormat(p.getToken());
return this.token;
}
示例14: setDelegationToken
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@Override
public void setDelegationToken(Token token) {
maybeInitBuilder();
if (token == null)
builder.clearToken();
this.token = token;
}
示例15: getRMDelegationToken
import org.apache.hadoop.yarn.api.records.Token; //导入依赖的package包/类
@Override
public Token getRMDelegationToken() {
GetDelegationTokenResponseProtoOrBuilder p = viaProto ? proto : builder;
if (this.appToken != null) {
return this.appToken;
}
if (!p.hasToken()) {
return null;
}
this.appToken = convertFromProtoFormat(p.getToken());
return this.appToken;
}