当前位置: 首页>>代码示例>>Java>>正文


Java ClientToAMTokenIdentifier类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier的典型用法代码示例。如果您正苦于以下问题:Java ClientToAMTokenIdentifier类的具体用法?Java ClientToAMTokenIdentifier怎么用?Java ClientToAMTokenIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClientToAMTokenIdentifier类属于org.apache.hadoop.yarn.security.client包,在下文中一共展示了ClientToAMTokenIdentifier类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createClientToken

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
@Override
public Token<ClientToAMTokenIdentifier> createClientToken(String client) {
  this.readLock.lock();

  try {
    Token<ClientToAMTokenIdentifier> token = null;
    ClientToAMTokenSecretManagerInRM secretMgr =
        this.rmContext.getClientToAMTokenSecretManager();
    if (client != null &&
        secretMgr.getMasterKey(this.applicationAttemptId) != null) {
      token = new Token<ClientToAMTokenIdentifier>(
          new ClientToAMTokenIdentifier(this.applicationAttemptId, client),
          secretMgr);
    }
    return token;
  } finally {
    this.readLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:RMAppAttemptImpl.java

示例2: verifyNewVersionToken

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
private void verifyNewVersionToken(final Configuration conf, final CustomAM am,
    Token<ClientToAMTokenIdentifier> token, MockRM rm) throws IOException,
    InterruptedException {
  UserGroupInformation ugi;
  ugi = UserGroupInformation.createRemoteUser("me");
  
  Token<ClientToAMTokenIdentifier> newToken = 
      new Token<ClientToAMTokenIdentifier>(
          new ClientToAMTokenIdentifierForTest(token.decodeIdentifier(), "message"),
          am.getClientToAMTokenSecretManager());
  newToken.setService(token.getService());
  
  ugi.addToken(newToken);

  ugi.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      CustomProtocol client =
          (CustomProtocol) RPC.getProxy(CustomProtocol.class, 1L, am.address,
            conf);
      client.ping();
      Assert.assertTrue(am.pinged);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestClientToAMTokens.java

示例3: verifyValidToken

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
private void verifyValidToken(final Configuration conf, final CustomAM am,
    Token<ClientToAMTokenIdentifier> token) throws IOException,
    InterruptedException {
  UserGroupInformation ugi;
  ugi = UserGroupInformation.createRemoteUser("me");
  ugi.addToken(token);

  ugi.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      CustomProtocol client =
          (CustomProtocol) RPC.getProxy(CustomProtocol.class, 1L, am.address,
            conf);
      client.ping();
      Assert.assertTrue(am.pinged);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestClientToAMTokens.java

示例4: storeAttempt

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
ContainerId storeAttempt(RMStateStore store, ApplicationAttemptId attemptId,
    String containerIdStr, Token<AMRMTokenIdentifier> appToken,
    Token<ClientToAMTokenIdentifier> clientToAMToken, TestDispatcher dispatcher)
    throws Exception {

  Container container = new ContainerPBImpl();
  container.setId(ConverterUtils.toContainerId(containerIdStr));
  RMAppAttempt mockAttempt = mock(RMAppAttempt.class);
  when(mockAttempt.getAppAttemptId()).thenReturn(attemptId);
  when(mockAttempt.getMasterContainer()).thenReturn(container);
  when(mockAttempt.getAMRMToken()).thenReturn(appToken);
  when(mockAttempt.getClientToAMToken()).thenReturn(clientToAMToken);
  dispatcher.attemptId = attemptId;
  dispatcher.storedException = null;
  store.storeApplicationAttempt(mockAttempt);
  waitNotify(dispatcher);
  return container.getId();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:19,代码来源:TestRMStateStore.java

示例5: generateTokens

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
private List<Token<?>> generateTokens(ApplicationAttemptId attemptId,
    AMRMTokenSecretManager appTokenMgr,
    ClientToAMTokenSecretManagerInRM clientToAMTokenMgr, Configuration conf) {
  AMRMTokenIdentifier appTokenId =
      new AMRMTokenIdentifier(attemptId);
  Token<AMRMTokenIdentifier> appToken =
      new Token<AMRMTokenIdentifier>(appTokenId, appTokenMgr);
  appToken.setService(new Text("appToken service"));

  ClientToAMTokenIdentifier clientToAMTokenId =
      new ClientToAMTokenIdentifier(attemptId);
  clientToAMTokenMgr.registerApplication(attemptId);
  Token<ClientToAMTokenIdentifier> clientToAMToken =
      new Token<ClientToAMTokenIdentifier>(clientToAMTokenId, clientToAMTokenMgr);
  clientToAMToken.setService(new Text("clientToAMToken service"));
  List<Token<?>> tokenPair = new ArrayList<Token<?>>();
  tokenPair.add(0, appToken);
  tokenPair.add(1, clientToAMToken);
  return tokenPair;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:TestRMStateStore.java

示例6: testClientToAMTokenIdentifier

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
@Test
public void testClientToAMTokenIdentifier() throws IOException {
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(1, 1), 1);
  
  String clientName = "user";

  ClientToAMTokenIdentifier token = new ClientToAMTokenIdentifier(
      appAttemptId, clientName);
  
  ClientToAMTokenIdentifier anotherToken = new ClientToAMTokenIdentifier();
  
  byte[] tokenContent = token.getBytes();
  DataInputBuffer dib = new DataInputBuffer();
  dib.reset(tokenContent, tokenContent.length);
  anotherToken.readFields(dib);
      
  // verify the whole record equals with original record
  Assert.assertEquals("Token is not the same after serialization " +
      "and deserialization.", token, anotherToken);
      
  Assert.assertEquals("ApplicationAttemptId from proto is not the same with original token",
      anotherToken.getApplicationAttemptID(), appAttemptId);
  
  Assert.assertEquals("clientName from proto is not the same with original token",
      anotherToken.getClientName(), clientName);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestYARNTokenIdentifier.java

示例7: verifyTokenWithTamperedID

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
private void verifyTokenWithTamperedID(final Configuration conf,
    final CustomAM am, Token<ClientToAMTokenIdentifier> token)
    throws IOException {
  // Malicious user, messes with appId
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser("me");
  ClientToAMTokenIdentifier maliciousID =
      new ClientToAMTokenIdentifier(BuilderUtils.newApplicationAttemptId(
        BuilderUtils.newApplicationId(am.appAttemptId.getApplicationId()
          .getClusterTimestamp(), 42), 43), UserGroupInformation
        .getCurrentUser().getShortUserName());

  verifyTamperedToken(conf, am, token, ugi, maliciousID);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestClientToAMTokens.java

示例8: verifyTokenWithTamperedUserName

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
private void verifyTokenWithTamperedUserName(final Configuration conf,
    final CustomAM am, Token<ClientToAMTokenIdentifier> token)
    throws IOException {
  // Malicious user, messes with appId
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser("me");
  ClientToAMTokenIdentifier maliciousID =
      new ClientToAMTokenIdentifier(am.appAttemptId, "evilOrc");

  verifyTamperedToken(conf, am, token, ugi, maliciousID);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestClientToAMTokens.java

示例9: ClientToAMTokenIdentifierForTest

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
public ClientToAMTokenIdentifierForTest(
    ClientToAMTokenIdentifier tokenIdentifier, String message) {
  ClientToAMTokenIdentifierForTestProto.Builder builder = 
      ClientToAMTokenIdentifierForTestProto.newBuilder();
  builder.setAppAttemptId(tokenIdentifier.getProto().getAppAttemptId());
  builder.setClientName(tokenIdentifier.getProto().getClientName());
  builder.setMessage(message);
  proto = builder.build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:ClientToAMTokenIdentifierForTest.java

示例10: testGetClientToken

import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; //导入依赖的package包/类
@Test
public void testGetClientToken() throws Exception {
  assumeTrue(isSecurityEnabled);
  Container amContainer = allocateApplicationAttempt();

  // before attempt is launched, can not get ClientToken
  Token<ClientToAMTokenIdentifier> token =
      applicationAttempt.createClientToken(null);
  Assert.assertNull(token);
  token = applicationAttempt.createClientToken("clientuser");
  Assert.assertNull(token);

  launchApplicationAttempt(amContainer);
  // after attempt is launched , can get ClientToken
  token = applicationAttempt.createClientToken(null);
  Assert.assertNull(token);
  token = applicationAttempt.createClientToken("clientuser");
  Assert.assertNotNull(token);

  applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
    .getAppAttemptId(), RMAppAttemptEventType.KILL));
  assertEquals(YarnApplicationAttemptState.LAUNCHED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  // after attempt is killed, can not get Client Token
  token = applicationAttempt.createClientToken(null);
  Assert.assertNull(token);
  token = applicationAttempt.createClientToken("clientuser");
  Assert.assertNull(token);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:TestRMAppAttemptTransitions.java


注:本文中的org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。