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


Java DelegationKey类代码示例

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


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

示例1: recover

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
public void recover(RMState rmState) throws Exception {

  LOG.info("recovering RMDelegationTokenSecretManager.");
  // recover RMDTMasterKeys
  for (DelegationKey dtKey : rmState.getRMDTSecretManagerState()
    .getMasterKeyState()) {
    addKey(dtKey);
  }

  // recover RMDelegationTokens
  Map<RMDelegationTokenIdentifier, Long> rmDelegationTokens =
      rmState.getRMDTSecretManagerState().getTokenState();
  this.delegationTokenSequenceNumber =
      rmState.getRMDTSecretManagerState().getDTSequenceNumber();
  for (Map.Entry<RMDelegationTokenIdentifier, Long> entry : rmDelegationTokens
    .entrySet()) {
    addPersistedDelegationToken(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:RMDelegationTokenSecretManager.java

示例2: storeRMDTMasterKeyState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
protected void storeRMDTMasterKeyState(DelegationKey masterKey)
    throws IOException {
  String dbKey = getRMDTMasterKeyNodeKey(masterKey);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing token master key to " + dbKey);
  }
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  DataOutputStream out = new DataOutputStream(os);
  try {
    masterKey.write(out);
  } finally {
    out.close();
  }
  try {
    db.put(bytes(dbKey), os.toByteArray());
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:LeveldbRMStateStore.java

示例3: storeRMDTMasterKeyState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
protected synchronized void storeRMDTMasterKeyState(
    DelegationKey delegationKey) throws Exception {
  String nodeCreatePath =
      getNodePath(dtMasterKeysRootPath, DELEGATION_KEY_PREFIX
          + delegationKey.getKeyId());
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  DataOutputStream fsOut = new DataOutputStream(os);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing RMDelegationKey_" + delegationKey.getKeyId());
  }
  delegationKey.write(fsOut);
  try {
    createWithRetries(nodeCreatePath, os.toByteArray(), zkAcl,
        CreateMode.PERSISTENT);
  } finally {
    os.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:ZKRMStateStore.java

示例4: storeRMDTMasterKeyState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
public synchronized void storeRMDTMasterKeyState(DelegationKey delegationKey)
    throws Exception {
  Set<DelegationKey> rmDTMasterKeyState =
      state.rmSecretManagerState.getMasterKeyState();

  if (rmDTMasterKeyState.contains(delegationKey)) {
    IOException e = new IOException("RMDTMasterKey with keyID: "
            + delegationKey.getKeyId() + " is already stored");
    LOG.info("Error storing info for RMDTMasterKey with keyID: "
        + delegationKey.getKeyId(), e);
    throw e;
  }
  state.getRMDTSecretManagerState().getMasterKeyState().add(delegationKey);
  LOG.info("Store RMDT master key with key id: " + delegationKey.getKeyId()
      + ". Currently rmDTMasterKeyState size: " + rmDTMasterKeyState.size());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:MemoryRMStateStore.java

示例5: storeTokenMasterKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
public void storeTokenMasterKey(DelegationKey masterKey)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing master key " + masterKey.getKeyId());
  }

  ByteArrayOutputStream memStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(memStream);
  try {
    masterKey.write(dataStream);
    dataStream.close();
    dataStream = null;
  } finally {
    IOUtils.cleanup(LOG, dataStream);
  }

  String dbKey = getTokenMasterKeyDatabaseKey(masterKey);
  try {
    db.put(bytes(dbKey), memStream.toByteArray());
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:HistoryServerLeveldbStateStoreService.java

示例6: storeTokenMasterKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
public void storeTokenMasterKey(DelegationKey key) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing master key " + key.getKeyId());
  }

  Path keyPath = new Path(tokenKeysStatePath,
      TOKEN_MASTER_KEY_FILE_PREFIX + key.getKeyId());
  if (fs.exists(keyPath)) {
    throw new IOException(keyPath + " already exists");
  }

  ByteArrayOutputStream memStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(memStream);
  try {
    key.write(dataStream);
    dataStream.close();
    dataStream = null;
  } finally {
    IOUtils.cleanup(LOG, dataStream);
  }

  createNewFile(keyPath, memStream.toByteArray());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:HistoryServerFileSystemStateStoreService.java

示例7: loadSecretManagerState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
public synchronized void loadSecretManagerState(SecretManagerState state)
    throws IOException {
  Preconditions.checkState(!running,
      "Can't load state from image in a running SecretManager.");

  currentId = state.section.getCurrentId();
  delegationTokenSequenceNumber = state.section.getTokenSequenceNumber();
  for (SecretManagerSection.DelegationKey k : state.keys) {
    addKey(new DelegationKey(k.getId(), k.getExpiryDate(), k.hasKey() ? k
        .getKey().toByteArray() : null));
  }

  for (SecretManagerSection.PersistToken t : state.tokens) {
    DelegationTokenIdentifier id = new DelegationTokenIdentifier(new Text(
        t.getOwner()), new Text(t.getRenewer()), new Text(t.getRealUser()));
    id.setIssueDate(t.getIssueDate());
    id.setMaxDate(t.getMaxDate());
    id.setSequenceNumber(t.getSequenceNumber());
    id.setMasterKeyId(t.getMasterKeyId());
    addPersistedDelegationToken(id, t.getExpiryDate());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:DelegationTokenSecretManager.java

示例8: logUpdateMasterKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
/**
 * Call namesystem to update editlogs for new master key.
 */
@Override //AbstractDelegationTokenManager
protected void logUpdateMasterKey(DelegationKey key)
    throws IOException {
  synchronized (noInterruptsLock) {
    // The edit logging code will fail catastrophically if it
    // is interrupted during a logSync, since the interrupt
    // closes the edit log files. Doing this inside the
    // above lock and then checking interruption status
    // prevents this bug.
    if (Thread.interrupted()) {
      throw new InterruptedIOException(
          "Interrupted before updating master key");
    }
    namesystem.logUpdateMasterKey(key);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:DelegationTokenSecretManager.java

示例9: loadAllKeys

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
/**
 * Private helper method to load delegation keys from fsimage.
 * @throws IOException on error
 */
private synchronized void loadAllKeys(DataInput in) throws IOException {
  StartupProgress prog = NameNode.getStartupProgress();
  Step step = new Step(StepType.DELEGATION_KEYS);
  prog.beginStep(Phase.LOADING_FSIMAGE, step);
  int numberOfKeys = in.readInt();
  prog.setTotal(Phase.LOADING_FSIMAGE, step, numberOfKeys);
  Counter counter = prog.getCounter(Phase.LOADING_FSIMAGE, step);
  for (int i = 0; i < numberOfKeys; i++) {
    DelegationKey value = new DelegationKey();
    value.readFields(in);
    addKey(value);
    counter.increment();
  }
  prog.endStep(Phase.LOADING_FSIMAGE, step);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:DelegationTokenSecretManager.java

示例10: storeNewMasterKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
protected void storeNewMasterKey(DelegationKey newKey) {
  try {
    LOG.info("storing master key with keyID " + newKey.getKeyId());
    rmContext.getStateStore().storeRMDTMasterKey(newKey);
  } catch (Exception e) {
    LOG.error("Error in storing master key with KeyID: " + newKey.getKeyId());
    ExitUtil.terminate(1, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:RMDelegationTokenSecretManager.java

示例11: removeStoredMasterKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
protected void removeStoredMasterKey(DelegationKey key) {
  try {
    LOG.info("removing master key with keyID " + key.getKeyId());
    rmContext.getStateStore().removeRMDTMasterKey(key);
  } catch (Exception e) {
    LOG.error("Error in removing master key with KeyID: " + key.getKeyId());
    ExitUtil.terminate(1, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:RMDelegationTokenSecretManager.java

示例12: getAllMasterKeys

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Private
@VisibleForTesting
public synchronized Set<DelegationKey> getAllMasterKeys() {
  HashSet<DelegationKey> keySet = new HashSet<DelegationKey>();
  keySet.addAll(allKeys.values());
  return keySet;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:RMDelegationTokenSecretManager.java

示例13: loadDelegationKey

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
private DelegationKey loadDelegationKey(byte[] data) throws IOException {
  DelegationKey key = new DelegationKey();
  DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
  try {
    key.readFields(in);
  } finally {
    IOUtils.cleanup(LOG, in);
  }
  return key;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:LeveldbRMStateStore.java

示例14: removeRMDTMasterKeyState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
@Override
protected void removeRMDTMasterKeyState(DelegationKey masterKey)
    throws IOException {
  String dbKey = getRMDTMasterKeyNodeKey(masterKey);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Removing token master key at " + dbKey);
  }
  try {
    db.delete(bytes(dbKey));
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:LeveldbRMStateStore.java

示例15: loadRMDelegationKeyState

import org.apache.hadoop.security.token.delegation.DelegationKey; //导入依赖的package包/类
private void loadRMDelegationKeyState(RMState rmState) throws Exception {
  List<String> childNodes =
      getChildrenWithRetries(dtMasterKeysRootPath, false);
  for (String childNodeName : childNodes) {
    String childNodePath = getNodePath(dtMasterKeysRootPath, childNodeName);
    byte[] childData = getDataWithRetries(childNodePath, false);

    if (childData == null) {
      LOG.warn("Content of " + childNodePath + " is broken.");
      continue;
    }

    ByteArrayInputStream is = new ByteArrayInputStream(childData);
    DataInputStream fsIn = new DataInputStream(is);

    try {
      if (childNodeName.startsWith(DELEGATION_KEY_PREFIX)) {
        DelegationKey key = new DelegationKey();
        key.readFields(fsIn);
        rmState.rmSecretManagerState.masterKeyState.add(key);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Loaded delegation key: keyId=" + key.getKeyId()
              + ", expirationDate=" + key.getExpiryDate());
        }
      }
    } finally {
      is.close();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:ZKRMStateStore.java


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