本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}