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


Java MasterKey.getKeyId方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.api.records.MasterKey.getKeyId方法的典型用法代码示例。如果您正苦于以下问题:Java MasterKey.getKeyId方法的具体用法?Java MasterKey.getKeyId怎么用?Java MasterKey.getKeyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.api.records.MasterKey的用法示例。


在下文中一共展示了MasterKey.getKeyId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: equals

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (!(obj instanceof MasterKey)) {
    return false;
  }
  MasterKey other = (MasterKey) obj;
  if (this.getKeyId() != other.getKeyId()) {
    return false;
  }
  if (!this.getBytes().equals(other.getBytes())) {
    return false;
  }
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:MasterKeyPBImpl.java

示例2: populateKeys

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
private void populateKeys(NodeHeartbeatRequest request,
    NodeHeartbeatResponse nodeHeartBeatResponse) {

  // Check if node's masterKey needs to be updated and if the currentKey has
  // roller over, send it across

  // ContainerTokenMasterKey

  MasterKey nextMasterKeyForNode =
      this.containerTokenSecretManager.getNextKey();
  if (nextMasterKeyForNode != null
      && (request.getLastKnownContainerTokenMasterKey().getKeyId()
          != nextMasterKeyForNode.getKeyId())) {
    nodeHeartBeatResponse.setContainerTokenMasterKey(nextMasterKeyForNode);
  }

  // NMTokenMasterKey

  nextMasterKeyForNode = this.nmTokenSecretManager.getNextKey();
  if (nextMasterKeyForNode != null
      && (request.getLastKnownNMTokenMasterKey().getKeyId() 
          != nextMasterKeyForNode.getKeyId())) {
    nodeHeartBeatResponse.setNMTokenMasterKey(nextMasterKeyForNode);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:ResourceTrackerService.java

示例3: setMasterKey

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
/**
 * Used by NodeManagers to create a token-secret-manager with the key obtained
 * from the RM. This can happen during registration or when the RM rolls the
 * master-key and signals the NM.
 * 
 * @param masterKeyRecord
 */
@Private
public synchronized void setMasterKey(MasterKey masterKeyRecord) {
  // Update keys only if the key has changed.
  if (super.currentMasterKey == null || super.currentMasterKey.getMasterKey()
        .getKeyId() != masterKeyRecord.getKeyId()) {
    LOG.info("Rolling master-key for container-tokens, got key with id "
        + masterKeyRecord.getKeyId());
    if (super.currentMasterKey != null) {
      updatePreviousMasterKey(super.currentMasterKey);
    }
    updateCurrentMasterKey(new MasterKeyData(masterKeyRecord,
        createSecretKey(masterKeyRecord.getBytes().array())));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:NMContainerTokenSecretManager.java

示例4: setMasterKey

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
/**
 * Used by NodeManagers to create a token-secret-manager with the key
 * obtained from the RM. This can happen during registration or when the RM
 * rolls the master-key and signal the NM.
 */
@Private
public synchronized void setMasterKey(MasterKey masterKey) {
  // Update keys only if the key has changed.
  if (super.currentMasterKey == null || super.currentMasterKey.getMasterKey()
        .getKeyId() != masterKey.getKeyId()) {
    LOG.info("Rolling master-key for container-tokens, got key with id "
        + masterKey.getKeyId());
    if (super.currentMasterKey != null) {
      updatePreviousMasterKey(super.currentMasterKey);
    }
    updateCurrentMasterKey(new MasterKeyData(masterKey,
        createSecretKey(masterKey.getBytes().array())));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:NMTokenSecretManagerInNM.java

示例5: nodeHeartbeat

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
public NodeHeartbeatResponse nodeHeartbeat(Map<ApplicationId,
    List<ContainerStatus>> conts, boolean isHealthy, int resId) throws Exception {
  NodeHeartbeatRequest req = Records.newRecord(NodeHeartbeatRequest.class);
  NodeStatus status = Records.newRecord(NodeStatus.class);
  status.setResponseId(resId);
  status.setNodeId(nodeId);
  for (Map.Entry<ApplicationId, List<ContainerStatus>> entry : conts.entrySet()) {
    Log.info("entry.getValue() " + entry.getValue());
    status.setContainersStatuses(entry.getValue());
  }
  NodeHealthStatus healthStatus = Records.newRecord(NodeHealthStatus.class);
  healthStatus.setHealthReport("");
  healthStatus.setIsNodeHealthy(isHealthy);
  healthStatus.setLastHealthReportTime(1);
  status.setNodeHealthStatus(healthStatus);
  req.setNodeStatus(status);
  req.setLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey);
  req.setLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey);
  NodeHeartbeatResponse heartbeatResponse =
      resourceTracker.nodeHeartbeat(req);
  
  MasterKey masterKeyFromRM = heartbeatResponse.getContainerTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentContainerTokenMasterKey
          .getKeyId()) {
    this.currentContainerTokenMasterKey = masterKeyFromRM;
  }

  masterKeyFromRM = heartbeatResponse.getNMTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentNMTokenMasterKey
          .getKeyId()) {
    this.currentNMTokenMasterKey = masterKeyFromRM;
  }
  
  return heartbeatResponse;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:MockNM.java

示例6: WrappedApplication

import org.apache.hadoop.yarn.server.api.records.MasterKey; //导入方法依赖的package包/类
WrappedApplication(int id, long timestamp, String user, int numContainers) {
  Configuration conf = new Configuration();
  
  dispatcher = new DrainDispatcher();
  containerTokenIdentifierMap =
      new HashMap<ContainerId, ContainerTokenIdentifier>();
  dispatcher.init(conf);

  localizerBus = mock(EventHandler.class);
  launcherBus = mock(EventHandler.class);
  monitorBus = mock(EventHandler.class);
  auxBus = mock(EventHandler.class);
  containerBus = mock(EventHandler.class);
  logAggregationBus = mock(EventHandler.class);

  dispatcher.register(LocalizationEventType.class, localizerBus);
  dispatcher.register(ContainersLauncherEventType.class, launcherBus);
  dispatcher.register(ContainersMonitorEventType.class, monitorBus);
  dispatcher.register(AuxServicesEventType.class, auxBus);
  dispatcher.register(ContainerEventType.class, containerBus);
  dispatcher.register(LogHandlerEventType.class, logAggregationBus);

  nmTokenSecretMgr = mock(NMTokenSecretManagerInNM.class);

  context = mock(Context.class);
  
  when(context.getContainerTokenSecretManager()).thenReturn(
    new NMContainerTokenSecretManager(conf));
  when(context.getApplicationACLsManager()).thenReturn(
    new ApplicationACLsManager(conf));
  when(context.getNMTokenSecretManager()).thenReturn(nmTokenSecretMgr);
  
  // Setting master key
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { (new Integer(123)
    .byteValue()) }));
  context.getContainerTokenSecretManager().setMasterKey(masterKey);
  
  this.user = user;
  this.appId = BuilderUtils.newApplicationId(timestamp, id);

  app = new ApplicationImpl(dispatcher, this.user, appId, null, context);
  containers = new ArrayList<Container>();
  for (int i = 0; i < numContainers; i++) {
    Container container = createMockedContainer(this.appId, i);
    containers.add(container);
    long currentTime = System.currentTimeMillis();
    ContainerTokenIdentifier identifier =
        new ContainerTokenIdentifier(container.getContainerId(), "", "",
          null, currentTime + 2000, masterKey.getKeyId(), currentTime,
          Priority.newInstance(0), 0);
    containerTokenIdentifierMap
      .put(identifier.getContainerID(), identifier);
    context.getContainerTokenSecretManager().startContainerSuccessful(
      identifier);
    Assert.assertFalse(context.getContainerTokenSecretManager()
      .isValidStartContainerRequest(identifier));
  }

  dispatcher.start();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:TestApplication.java


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