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


Java SecureShuffleUtils.hashFromString方法代码示例

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


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

示例1: getShuffleResponseCode

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private static int getShuffleResponseCode(ShuffleHandler shuffle,
    Token<JobTokenIdentifier> jt) throws IOException {
  URL url = new URL("http://127.0.0.1:"
      + shuffle.getConfig().get(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY)
      + "/mapOutput?job=job_12345_0001&reduce=0&map=attempt_12345_1_m_1_0");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  String encHash = SecureShuffleUtils.hashFromString(
      SecureShuffleUtils.buildMsgFrom(url),
      JobTokenSecretManager.createSecretKey(jt.getPassword()));
  conn.addRequestProperty(
      SecureShuffleUtils.HTTP_HEADER_URL_HASH, encHash);
  conn.setRequestProperty(ShuffleHeader.HTTP_HEADER_NAME,
      ShuffleHeader.DEFAULT_HTTP_HEADER_NAME);
  conn.setRequestProperty(ShuffleHeader.HTTP_HEADER_VERSION,
      ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION);
  conn.connect();
  int rc = conn.getResponseCode();
  conn.disconnect();
  return rc;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestShuffleHandler.java

示例2: setupConnectionsWithRetry

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private void setupConnectionsWithRetry(MapHost host,
    Set<TaskAttemptID> remaining, URL url) throws IOException {
  openConnectionWithRetry(host, remaining, url);
  if (stopped) {
    return;
  }
    
  // generate hash of the url
  String msgToEncode = SecureShuffleUtils.buildMsgFrom(url);
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode,
      shuffleSecretKey);
  
  setupShuffleConnection(encHash);
  connect(connection, connectionTimeout);
  // verify that the thread wasn't stopped during calls to connect
  if (stopped) {
    return;
  }
  
  verifyConnection(url, msgToEncode, encHash);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:Fetcher.java

示例3: setupConnectionsWithRetry

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private void setupConnectionsWithRetry(URL url) throws IOException {
  openConnectionWithRetry(url);
  if (stopped) {
    return;
  }
    
  // generate hash of the url
  String msgToEncode = SecureShuffleUtils.buildMsgFrom(url);
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode,
      shuffleSecretKey);
  
  setupShuffleConnection(encHash);
  connect(connection, connectionTimeout);
  // verify that the thread wasn't stopped during calls to connect
  if (stopped) {
    return;
  }
  
  verifyConnection(url, msgToEncode, encHash);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:Fetcher.java

示例4: setupSecureConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
public InputStream setupSecureConnection(MapOutputLocation mapOutputLoc, 
    URLConnection connection) throws IOException {

  // generate hash of the url
  String msgToEncode = 
    SecureShuffleUtils.buildMsgFrom(connection.getURL());
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode, 
      jobTokenSecret);

  // put url hash into http header
  connection.setRequestProperty(
      SecureShuffleUtils.HTTP_HEADER_URL_HASH, encHash);
  
  InputStream input = getInputStream(connection, shuffleConnectionTimeout,
                                     shuffleReadTimeout); 

  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(
      SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  if (LOG.isDebugEnabled())
    LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="
        +replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecret);
  if (LOG.isDebugEnabled())
    LOG.debug("for url="+msgToEncode+" sent hash and receievd reply");
  return input;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:32,代码来源:ReduceTask.java

示例5: setupSecureConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private InputStream setupSecureConnection(MapOutputLocation mapOutputLoc, 
    URLConnection connection) throws IOException {

  // generate hash of the url
  String msgToEncode = 
    SecureShuffleUtils.buildMsgFrom(connection.getURL());
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode, 
      jobTokenSecret);

  // put url hash into http header
  connection.setRequestProperty(
      SecureShuffleUtils.HTTP_HEADER_URL_HASH, encHash);
  
  InputStream input = getInputStream(connection, shuffleConnectionTimeout,
                                     shuffleReadTimeout); 

  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(
      SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  if (LOG.isDebugEnabled())
    LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="
        +replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecret);
  if (LOG.isDebugEnabled())
    LOG.debug("for url="+msgToEncode+" sent hash and receievd reply");
  return input;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:32,代码来源:ReduceTask.java

示例6: createDigest

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
public static String createDigest(byte[] password, String data)
    throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);
  return SecureShuffleUtils.hashFromString(data, key);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:Application.java

示例7: createDigest

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
protected String createDigest(byte[] password, String data) throws IOException {
  SecretKey key = JobTokenSecretManager.createSecretKey(password);

  return SecureShuffleUtils.hashFromString(data, key);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:CommonStub.java


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