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


Java ContainerTokenIdentifier类代码示例

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


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

示例1: handle

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
@Override
public void handle(ContainerAllocatorEvent event) {
  ContainerId cId =
      ContainerId.newContainerId(getContext().getApplicationAttemptId(),
        containerCount++);
  NodeId nodeId = NodeId.newInstance(NM_HOST, NM_PORT);
  Resource resource = Resource.newInstance(1234, 2, 2);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, nodeId.toString(), "user",
      resource, System.currentTimeMillis() + 10000, 42, 42,
      Priority.newInstance(0), 0);
  Token containerToken = newContainerToken(nodeId, "password".getBytes(),
        containerTokenIdentifier);
  Container container = Container.newInstance(cId, nodeId,
      NM_HOST + ":" + NM_HTTP_PORT, resource, null, containerToken);
  JobID id = TypeConverter.fromYarn(applicationId);
  JobId jobId = TypeConverter.toYarn(id);
  getContext().getEventHandler().handle(new JobHistoryEvent(jobId, 
      new NormalizedResourceEvent(
          org.apache.hadoop.mapreduce.TaskType.REDUCE,
      100)));
  getContext().getEventHandler().handle(new JobHistoryEvent(jobId, 
      new NormalizedResourceEvent(
          org.apache.hadoop.mapreduce.TaskType.MAP,
      100)));
  getContext().getEventHandler().handle(
      new TaskAttemptContainerAssignedEvent(event.getAttemptID(),
          container, null));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:MRApp.java

示例2: startContainers

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRPC.java

示例3: startContainerSuccessful

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
/**
 * Container start has gone through. We need to store the containerId in order
 * to block future container start requests with same container token. This
 * container token needs to be saved till its container token expires.
 */
public synchronized void startContainerSuccessful(
    ContainerTokenIdentifier tokenId) {

  removeAnyContainerTokenIfExpired();
  
  ContainerId containerId = tokenId.getContainerID();
  Long expTime = tokenId.getExpiryTimeStamp();
  // We might have multiple containers with same expiration time.
  if (!recentlyStartedContainerTracker.containsKey(expTime)) {
    recentlyStartedContainerTracker
      .put(expTime, new ArrayList<ContainerId>());
  }
  recentlyStartedContainerTracker.get(expTime).add(containerId);
  try {
    stateStore.storeContainerToken(containerId, expTime);
  } catch (IOException e) {
    LOG.error("Unable to store token for container " + containerId, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:NMContainerTokenSecretManager.java

示例4: isValidStartContainerRequest

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
/**
 * Container will be remembered based on expiration time of the container
 * token used for starting the container. It is safe to use expiration time
 * as there is one to many mapping between expiration time and containerId.
 * @return true if the current token identifier is not present in cache.
 */
public synchronized boolean isValidStartContainerRequest(
    ContainerTokenIdentifier containerTokenIdentifier) {

  removeAnyContainerTokenIfExpired();

  Long expTime = containerTokenIdentifier.getExpiryTimeStamp();
  List<ContainerId> containers =
      this.recentlyStartedContainerTracker.get(expTime);
  if (containers == null
      || !containers.contains(containerTokenIdentifier.getContainerID())) {
    return true;
  } else {
    return false;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:NMContainerTokenSecretManager.java

示例5: verifyAndGetContainerTokenIdentifier

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
protected ContainerTokenIdentifier verifyAndGetContainerTokenIdentifier(
    org.apache.hadoop.yarn.api.records.Token token,
    ContainerTokenIdentifier containerTokenIdentifier) throws YarnException,
    InvalidToken {
  byte[] password =
      context.getContainerTokenSecretManager().retrievePassword(
        containerTokenIdentifier);
  byte[] tokenPass = token.getPassword().array();
  if (password == null || tokenPass == null
      || !Arrays.equals(password, tokenPass)) {
    throw new InvalidToken(
      "Invalid container token used for starting container on : "
          + context.getNodeId().toString());
  }
  return containerTokenIdentifier;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ContainerManagerImpl.java

示例6: ContainerImpl

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public ContainerImpl(Configuration conf, Dispatcher dispatcher,
    NMStateStoreService stateStore, ContainerLaunchContext launchContext,
    Credentials creds, NodeManagerMetrics metrics,
    ContainerTokenIdentifier containerTokenIdentifier) {
  this.daemonConf = conf;
  this.dispatcher = dispatcher;
  this.stateStore = stateStore;
  this.launchContext = launchContext;
  this.containerTokenIdentifier = containerTokenIdentifier;
  this.containerId = containerTokenIdentifier.getContainerID();
  this.resource = containerTokenIdentifier.getResource();
  this.diagnostics = new StringBuilder();
  this.credentials = creds;
  this.metrics = metrics;
  user = containerTokenIdentifier.getApplicationSubmitter();
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();

  stateMachine = stateMachineFactory.make(this);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ContainerImpl.java

示例7: createContainerToken

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public static Token createContainerToken(ContainerId cId, long rmIdentifier,
    NodeId nodeId, String user,
    NMContainerTokenSecretManager containerTokenSecretManager,
    LogAggregationContext logAggregationContext)
    throws IOException {
  Resource r = BuilderUtils.newResource(1024, 1);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, nodeId.toString(), user, r,
        System.currentTimeMillis() + 100000L, 123, rmIdentifier,
        Priority.newInstance(0), 0, logAggregationContext);
  Token containerToken =
      BuilderUtils
        .newContainerToken(nodeId, containerTokenSecretManager
          .retrievePassword(containerTokenIdentifier),
          containerTokenIdentifier);
  return containerToken;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestContainerManager.java

示例8: getLogAggregationContextFromContainerToken

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
private LogAggregationContext getLogAggregationContextFromContainerToken(
    MockRM rm1, MockNM nm1, LogAggregationContext logAggregationContext)
    throws Exception {
  RMApp app2 = rm1.submitApp(200, logAggregationContext);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
  nm1.nodeHeartbeat(true);
  // request a container.
  am2.allocate("127.0.0.1", 512, 1, new ArrayList<ContainerId>());
  ContainerId containerId =
      ContainerId.newContainerId(am2.getApplicationAttemptId(), 2);
  rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED);

  // acquire the container.
  List<Container> containers =
      am2.allocate(new ArrayList<ResourceRequest>(),
        new ArrayList<ContainerId>()).getAllocatedContainers();
  Assert.assertEquals(containerId, containers.get(0).getId());
  // container token is generated.
  Assert.assertNotNull(containers.get(0).getContainerToken());
  ContainerTokenIdentifier token =
      BuilderUtils.newContainerTokenIdentifier(containers.get(0)
        .getContainerToken());
  return token.getLogAggregationContext();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestContainerAllocation.java

示例9: verifyAndGetContainerTokenIdentifier

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
protected ContainerTokenIdentifier verifyAndGetContainerTokenIdentifier(
    org.apache.hadoop.yarn.api.records.Token token,
    ContainerTokenIdentifier containerTokenIdentifier) throws YarnException,
    InvalidToken {
  byte[] password =
      context.getContainerTokenSecretManager().retrievePassword(
          containerTokenIdentifier);
  byte[] tokenPass = token.getPassword().array();
  if (password == null || tokenPass == null
      || !Arrays.equals(password, tokenPass)) {
    throw new InvalidToken(
      "Invalid container token used for starting container on : "
          + context.getNodeId().toString());
  }
  return containerTokenIdentifier;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:ContainerManagerImpl.java

示例10: ContainerImpl

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public ContainerImpl(Context context,Configuration conf, Dispatcher dispatcher,
    NMStateStoreService stateStore, ContainerLaunchContext launchContext,
    Credentials creds, NodeManagerMetrics metrics,
    ContainerTokenIdentifier containerTokenIdentifier,Set<Integer> cpuCores) {
  this.daemonConf = conf;
  this.dispatcher = dispatcher;
  this.stateStore = stateStore;
  this.launchContext = launchContext;
  this.containerTokenIdentifier = containerTokenIdentifier;
  this.containerId = containerTokenIdentifier.getContainerID();
  this.resource = containerTokenIdentifier.getResource();
  this.currentResource = resource;
  this.diagnostics = new StringBuilder();
  this.credentials = creds;
  this.metrics = metrics;
  user = containerTokenIdentifier.getApplicationSubmitter();
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();
  this.cpuCores  = cpuCores;
  this.context = context;

  stateMachine = stateMachineFactory.make(this);
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:25,代码来源:ContainerImpl.java

示例11: ContainerImpl

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public ContainerImpl(Configuration conf, Dispatcher dispatcher,
    ContainerLaunchContext launchContext, Credentials creds,
    NodeManagerMetrics metrics,
    ContainerTokenIdentifier containerTokenIdentifier, Context context,
    RecoveredContainerState rcs) {
  this(conf, dispatcher, launchContext, creds, metrics,
      containerTokenIdentifier, context);
  this.recoveredStatus = rcs.getStatus();
  this.exitCode = rcs.getExitCode();
  this.recoveredAsKilled = rcs.getKilled();
  this.diagnostics.append(diagnostics);
  Resource recoveredCapability = rcs.getCapability();
  if (recoveredCapability != null
      && !this.resource.equals(recoveredCapability)) {
    // resource capability had been updated before NM was down
    this.resource = Resource.newInstance(recoveredCapability.getMemorySize(),
        recoveredCapability.getVirtualCores());
  }
  this.version = rcs.getVersion();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:ContainerImpl.java

示例12: ContainerImpl

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public ContainerImpl(Configuration conf, Dispatcher dispatcher,
    ContainerLaunchContext launchContext, Credentials creds,
    NodeManagerMetrics metrics,
    ContainerTokenIdentifier containerTokenIdentifier) {
  this.daemonConf = conf;
  this.dispatcher = dispatcher;
  this.launchContext = launchContext;
  this.containerTokenIdentifier = containerTokenIdentifier;
  this.containerId = containerTokenIdentifier.getContainerID();
  this.resource = containerTokenIdentifier.getResource();
  this.diagnostics = new StringBuilder();
  this.credentials = creds;
  this.metrics = metrics;
  user = containerTokenIdentifier.getApplicationSubmitter();
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();

  stateMachine = stateMachineFactory.make(this);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:ContainerImpl.java

示例13: newContainerTokenIdentifier

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public static ContainerTokenIdentifier newContainerTokenIdentifier(
    Token containerToken) throws IOException {
  org.apache.hadoop.security.token.Token<ContainerTokenIdentifier> token =
      new org.apache.hadoop.security.token.Token<ContainerTokenIdentifier>(
          containerToken.getIdentifier()
              .array(), containerToken.getPassword().array(), new Text(
              containerToken.getKind()),
          new Text(containerToken.getService()));
  return token.decodeIdentifier();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRPC.java

示例14: newContainerToken

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
public static Token newContainerToken(NodeId nodeId, byte[] password,
    ContainerTokenIdentifier tokenIdentifier) {
  // RPC layer client expects ip:port as service for tokens
  InetSocketAddress addr =
      NetUtils.createSocketAddrForHost(nodeId.getHost(), nodeId.getPort());
  // NOTE: use SecurityUtil.setTokenService if this becomes a "real" token
  Token containerToken =
      Token.newInstance(tokenIdentifier.getBytes(),
        ContainerTokenIdentifier.KIND.toString(), password, SecurityUtil
          .buildTokenService(addr).toString());
  return containerToken;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestRPC.java

示例15: createPassword

import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; //导入依赖的package包/类
@Override
public byte[] createPassword(ContainerTokenIdentifier identifier) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Creating password for " + identifier.getContainerID()
        + " for user " + identifier.getUser() + " to be run on NM "
        + identifier.getNmHostAddress());
  }
  this.readLock.lock();
  try {
    return createPassword(identifier.getBytes(),
      this.currentMasterKey.getSecretKey());
  } finally {
    this.readLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:BaseContainerTokenSecretManager.java


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