Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
package org.apache.tez.runtime.api.events;

import java.nio.ByteBuffer;

import com.google.common.base.Charsets;
import java.nio.charset.StandardCharsets;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -33,7 +32,9 @@ public void testApiPayloadOrPath() {
InputDataInformationEvent.createWithSerializedPayload(0, ByteBuffer.wrap("payload1".getBytes()));
// event created by createWithSerializedPayload should contain serialized payload
// but not a path or a deserialized payload
Assert.assertEquals("payload1", Charsets.UTF_8.decode(eventWithSerializedPayload.getUserPayload()).toString());
Assert.assertEquals(
"payload1",
StandardCharsets.UTF_8.decode(eventWithSerializedPayload.getUserPayload()).toString());
Assert.assertNull(eventWithSerializedPayload.getSerializedPath());
Assert.assertNull(eventWithSerializedPayload.getDeserializedUserPayload());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.net.URI;
import java.net.URL;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -69,8 +70,6 @@
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleHeader;
import org.apache.tez.runtime.library.common.sort.impl.TezIndexRecord;

import com.google.common.base.Charsets;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
Expand Down Expand Up @@ -603,8 +602,7 @@ protected void verifyRequest(String appid, ChannelHandlerContext ctx,
SecureShuffleUtils.verifyReply(urlHashStr, enc_str, tokenSecret);
// verification passed - encode the reply
String reply =
SecureShuffleUtils.generateHash(urlHashStr.getBytes(Charsets.UTF_8),
tokenSecret);
SecureShuffleUtils.generateHash(urlHashStr.getBytes(StandardCharsets.UTF_8), tokenSecret);
response.headers().set(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH, reply);
// Put shuffle version into http header
response.headers().set(ShuffleHeader.HTTP_HEADER_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -101,7 +102,6 @@
import org.apache.tez.runtime.library.common.sort.impl.TezSpillRecord;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Charsets;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand Down Expand Up @@ -1471,8 +1471,7 @@ protected void verifyRequest(String appid, ChannelHandlerContext ctx,
SecureShuffleUtils.verifyReply(urlHashStr, enc_str, tokenSecret);
// verification passed - encode the reply
String reply =
SecureShuffleUtils.generateHash(urlHashStr.getBytes(Charsets.UTF_8),
tokenSecret);
SecureShuffleUtils.generateHash(urlHashStr.getBytes(StandardCharsets.UTF_8), tokenSecret);
response.headers().set(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH, reply);
// Put shuffle version into http header
response.headers().set(ShuffleHeader.HTTP_HEADER_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.tez.common;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import org.apache.tez.runtime.api.events.CompositeDataMovementEvent;
import org.apache.tez.runtime.api.events.CompositeRoutedDataMovementEvent;
Expand All @@ -30,7 +31,6 @@
import org.apache.tez.runtime.api.events.InputInitializerEvent;
import org.apache.tez.runtime.api.events.VertexManagerEvent;

import com.google.common.base.Charsets;
import com.google.protobuf.ByteString;

public final class ProtoConverters {
Expand Down Expand Up @@ -139,7 +139,7 @@ public static VertexManagerEvent convertVertexManagerEventFromProto(
builder.setUserPayload(ByteString.copyFrom(event.getUserPayload()));
}
if (event.getSerializedPath() != null) {
builder.setSerializedPath(ByteString.copyFrom(event.getSerializedPath().getBytes(Charsets.UTF_8)));
builder.setSerializedPath(ByteString.copyFrom(event.getSerializedPath().getBytes(StandardCharsets.UTF_8)));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import javax.crypto.SecretKey;

Expand All @@ -30,8 +31,6 @@
import org.apache.hadoop.io.WritableComparator;
import org.apache.tez.common.security.JobTokenSecretManager;

import com.google.common.base.Charsets;

/**
*
* utilities for generating keys, hashes and verifying them for shuffle
Expand All @@ -49,7 +48,7 @@ private SecureShuffleUtils() {}
* Base64 encoded hash of msg
*/
public static String generateHash(byte[] msg, SecretKey key) {
return new String(Base64.encodeBase64(generateByteHash(msg, key)), Charsets.UTF_8);
return new String(Base64.encodeBase64(generateByteHash(msg, key)), StandardCharsets.UTF_8);
}

/**
Expand Down Expand Up @@ -88,7 +87,9 @@ private static boolean verifyHash(byte[] hash, byte[] msg, JobTokenSecretManager
*
*/
public static String hashFromString(String encStr, JobTokenSecretManager mgr) {
return new String(Base64.encodeBase64(mgr.computeHash(encStr.getBytes(Charsets.UTF_8))), Charsets.UTF_8);
return new String(
Base64.encodeBase64(mgr.computeHash(encStr.getBytes(StandardCharsets.UTF_8))),
StandardCharsets.UTF_8);
}

/**
Expand All @@ -102,8 +103,8 @@ public static String hashFromString(String encStr, JobTokenSecretManager mgr) {
* @param key the key to use to generate the hash from the message
*/
public static void verifyReply(String base64Hash, String msg, SecretKey key) throws IOException {
byte[] hash = Base64.decodeBase64(base64Hash.getBytes(Charsets.UTF_8));
boolean res = verifyHash(hash, msg.getBytes(Charsets.UTF_8), key);
byte[] hash = Base64.decodeBase64(base64Hash.getBytes(StandardCharsets.UTF_8));
boolean res = verifyHash(hash, msg.getBytes(StandardCharsets.UTF_8), key);

if(!res) {
throw new IOException("Verification of the hashReply failed");
Expand All @@ -118,9 +119,9 @@ public static void verifyReply(String base64Hash, String msg, SecretKey key) thr
*/
public static void verifyReply(String base64Hash, String msg, JobTokenSecretManager mgr)
throws IOException {
byte[] hash = Base64.decodeBase64(base64Hash.getBytes(Charsets.UTF_8));
byte[] hash = Base64.decodeBase64(base64Hash.getBytes(StandardCharsets.UTF_8));

boolean res = verifyHash(hash, msg.getBytes(Charsets.UTF_8), mgr);
boolean res = verifyHash(hash, msg.getBytes(StandardCharsets.UTF_8), mgr);

if(!res) {
throw new IOException("Verification of the hashReply failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

Expand All @@ -33,8 +34,6 @@
import org.apache.tez.runtime.api.LogicalOutput;
import org.apache.tez.runtime.api.ProcessorContext;

import com.google.common.base.Charsets;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -115,7 +114,7 @@ public void close() throws Exception {
*/
public static class SleepProcessorConfig {
private int timeToSleepMS;
private final Charset charSet = Charsets.UTF_8;
private final Charset charSet = StandardCharsets.UTF_8;

public SleepProcessorConfig() {
}
Expand Down