HADOOP-16222. Fix new deprecations after guava 27.0 update in trunk. Contributed by Gabor Bota.
This commit is contained in:
parent
e1c5ddf2aa
commit
a703dae25e
|
@ -58,7 +58,7 @@ public class ArrayWritable implements Writable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayWritable(String[] strings) {
|
public ArrayWritable(String[] strings) {
|
||||||
this(UTF8.class, new Writable[strings.length]);
|
this(Text.class, new Writable[strings.length]);
|
||||||
for (int i = 0; i < strings.length; i++) {
|
for (int i = 0; i < strings.length; i++) {
|
||||||
values[i] = new UTF8(strings[i]);
|
values[i] = new UTF8(strings[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class SemaphoredDelegatingExecutor extends
|
||||||
queueingPermits.acquire();
|
queueingPermits.acquire();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return Futures.immediateFailedCheckedFuture(e);
|
return Futures.immediateFailedFuture(e);
|
||||||
}
|
}
|
||||||
return super.submit(new CallableWithPermitRelease<>(task));
|
return super.submit(new CallableWithPermitRelease<>(task));
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class SemaphoredDelegatingExecutor extends
|
||||||
queueingPermits.acquire();
|
queueingPermits.acquire();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return Futures.immediateFailedCheckedFuture(e);
|
return Futures.immediateFailedFuture(e);
|
||||||
}
|
}
|
||||||
return super.submit(new RunnableWithPermitRelease(task), result);
|
return super.submit(new RunnableWithPermitRelease(task), result);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class SemaphoredDelegatingExecutor extends
|
||||||
queueingPermits.acquire();
|
queueingPermits.acquire();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return Futures.immediateFailedCheckedFuture(e);
|
return Futures.immediateFailedFuture(e);
|
||||||
}
|
}
|
||||||
return super.submit(new RunnableWithPermitRelease(task));
|
return super.submit(new RunnableWithPermitRelease(task));
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class ZKUtil {
|
||||||
return valInConf;
|
return valInConf;
|
||||||
}
|
}
|
||||||
String path = valInConf.substring(1).trim();
|
String path = valInConf.substring(1).trim();
|
||||||
return Files.toString(new File(path), Charsets.UTF_8).trim();
|
return Files.asCharSource(new File(path), Charsets.UTF_8).read().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class TestArrayWritable {
|
||||||
String[] original = { "test1", "test2", "test3" };
|
String[] original = { "test1", "test2", "test3" };
|
||||||
ArrayWritable arrayWritable = new ArrayWritable(original);
|
ArrayWritable arrayWritable = new ArrayWritable(original);
|
||||||
assertEquals("testArrayWritableStringConstructor class error!!!",
|
assertEquals("testArrayWritableStringConstructor class error!!!",
|
||||||
UTF8.class, arrayWritable.getValueClass());
|
Text.class, arrayWritable.getValueClass());
|
||||||
assertArrayEquals("testArrayWritableStringConstructor toString error!!!",
|
assertArrayEquals("testArrayWritableStringConstructor toString error!!!",
|
||||||
original, arrayWritable.toStrings());
|
original, arrayWritable.toStrings());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class TestTableMapping {
|
||||||
public void testResolve() throws IOException {
|
public void testResolve() throws IOException {
|
||||||
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
||||||
".testResolve", ".txt");
|
".testResolve", ".txt");
|
||||||
Files.write(hostName1 + " /rack1\n" +
|
Files.asCharSink(mapFile, Charsets.UTF_8).write(
|
||||||
hostName2 + "\t/rack2\n", mapFile, Charsets.UTF_8);
|
hostName1 + " /rack1\n" + hostName2 + "\t/rack2\n");
|
||||||
mapFile.deleteOnExit();
|
mapFile.deleteOnExit();
|
||||||
TableMapping mapping = new TableMapping();
|
TableMapping mapping = new TableMapping();
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ public class TestTableMapping {
|
||||||
public void testTableCaching() throws IOException {
|
public void testTableCaching() throws IOException {
|
||||||
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
||||||
".testTableCaching", ".txt");
|
".testTableCaching", ".txt");
|
||||||
Files.write(hostName1 + " /rack1\n" +
|
Files.asCharSink(mapFile, Charsets.UTF_8).write(
|
||||||
hostName2 + "\t/rack2\n", mapFile, Charsets.UTF_8);
|
hostName1 + " /rack1\n" + hostName2 + "\t/rack2\n");
|
||||||
mapFile.deleteOnExit();
|
mapFile.deleteOnExit();
|
||||||
TableMapping mapping = new TableMapping();
|
TableMapping mapping = new TableMapping();
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ public class TestTableMapping {
|
||||||
public void testClearingCachedMappings() throws IOException {
|
public void testClearingCachedMappings() throws IOException {
|
||||||
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
||||||
".testClearingCachedMappings", ".txt");
|
".testClearingCachedMappings", ".txt");
|
||||||
Files.write(hostName1 + " /rack1\n" +
|
Files.asCharSink(mapFile, Charsets.UTF_8).write(
|
||||||
hostName2 + "\t/rack2\n", mapFile, Charsets.UTF_8);
|
hostName1 + " /rack1\n" + hostName2 + "\t/rack2\n");
|
||||||
mapFile.deleteOnExit();
|
mapFile.deleteOnExit();
|
||||||
|
|
||||||
TableMapping mapping = new TableMapping();
|
TableMapping mapping = new TableMapping();
|
||||||
|
@ -147,7 +147,7 @@ public class TestTableMapping {
|
||||||
assertEquals("/rack1", result.get(0));
|
assertEquals("/rack1", result.get(0));
|
||||||
assertEquals("/rack2", result.get(1));
|
assertEquals("/rack2", result.get(1));
|
||||||
|
|
||||||
Files.write("", mapFile, Charsets.UTF_8);
|
Files.asCharSink(mapFile, Charsets.UTF_8).write("");
|
||||||
|
|
||||||
mapping.reloadCachedMappings();
|
mapping.reloadCachedMappings();
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public class TestTableMapping {
|
||||||
public void testBadFile() throws IOException {
|
public void testBadFile() throws IOException {
|
||||||
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
File mapFile = File.createTempFile(getClass().getSimpleName() +
|
||||||
".testBadFile", ".txt");
|
".testBadFile", ".txt");
|
||||||
Files.write("bad contents", mapFile, Charsets.UTF_8);
|
Files.asCharSink(mapFile, Charsets.UTF_8).write("bad contents");
|
||||||
mapFile.deleteOnExit();
|
mapFile.deleteOnExit();
|
||||||
TableMapping mapping = new TableMapping();
|
TableMapping mapping = new TableMapping();
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,8 @@ public class TestSecurityUtil {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
File passwordTxtFile = File.createTempFile(
|
File passwordTxtFile = File.createTempFile(
|
||||||
getClass().getSimpleName() + ".testAuthAtPathNotation-", ".txt");
|
getClass().getSimpleName() + ".testAuthAtPathNotation-", ".txt");
|
||||||
Files.write(ZK_AUTH_VALUE, passwordTxtFile, StandardCharsets.UTF_8);
|
Files.asCharSink(passwordTxtFile, StandardCharsets.UTF_8)
|
||||||
|
.write(ZK_AUTH_VALUE);
|
||||||
try {
|
try {
|
||||||
conf.set(CommonConfigurationKeys.ZK_AUTH,
|
conf.set(CommonConfigurationKeys.ZK_AUTH,
|
||||||
"@" + passwordTxtFile.getAbsolutePath());
|
"@" + passwordTxtFile.getAbsolutePath());
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class TestZKUtil {
|
||||||
assertEquals("x", ZKUtil.resolveConfIndirection("x"));
|
assertEquals("x", ZKUtil.resolveConfIndirection("x"));
|
||||||
|
|
||||||
TEST_FILE.getParentFile().mkdirs();
|
TEST_FILE.getParentFile().mkdirs();
|
||||||
Files.write("hello world", TEST_FILE, Charsets.UTF_8);
|
Files.asCharSink(TEST_FILE, Charsets.UTF_8).write("hello world");
|
||||||
assertEquals("hello world", ZKUtil.resolveConfIndirection(
|
assertEquals("hello world", ZKUtil.resolveConfIndirection(
|
||||||
"@" + TEST_FILE.getAbsolutePath()));
|
"@" + TEST_FILE.getAbsolutePath()));
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class TestDFSHAAdminMiniCluster {
|
||||||
assertEquals(0, runTool("-ns", "minidfs-ns", "-failover", "nn2", "nn1"));
|
assertEquals(0, runTool("-ns", "minidfs-ns", "-failover", "nn2", "nn1"));
|
||||||
|
|
||||||
// Fencer has not run yet, since none of the above required fencing
|
// Fencer has not run yet, since none of the above required fencing
|
||||||
assertEquals("", Files.toString(tmpFile, Charsets.UTF_8));
|
assertEquals("", Files.asCharSource(tmpFile, Charsets.UTF_8).read());
|
||||||
|
|
||||||
// Test failover with fencer and forcefence option
|
// Test failover with fencer and forcefence option
|
||||||
assertEquals(0, runTool("-failover", "nn1", "nn2", "--forcefence"));
|
assertEquals(0, runTool("-failover", "nn1", "nn2", "--forcefence"));
|
||||||
|
@ -216,8 +216,8 @@ public class TestDFSHAAdminMiniCluster {
|
||||||
// The fence script should run with the configuration from the target
|
// The fence script should run with the configuration from the target
|
||||||
// node, rather than the configuration from the fencing node. Strip
|
// node, rather than the configuration from the fencing node. Strip
|
||||||
// out any trailing spaces and CR/LFs which may be present on Windows.
|
// out any trailing spaces and CR/LFs which may be present on Windows.
|
||||||
String fenceCommandOutput =Files.toString(tmpFile, Charsets.UTF_8).
|
String fenceCommandOutput = Files.asCharSource(tmpFile, Charsets.UTF_8)
|
||||||
replaceAll(" *[\r\n]+", "");
|
.read().replaceAll(" *[\r\n]+", "");
|
||||||
assertEquals("minidfs-ns.nn1 " + nn1Port + " nn1", fenceCommandOutput);
|
assertEquals("minidfs-ns.nn1 " + nn1Port + " nn1", fenceCommandOutput);
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,8 @@ public class ServiceTestUtils {
|
||||||
fs = new SliderFileSystem(conf);
|
fs = new SliderFileSystem(conf);
|
||||||
fs.setAppDir(new Path(serviceBasePath.toString()));
|
fs.setAppDir(new Path(serviceBasePath.toString()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
Throwables.throwIfUnchecked(e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
import com.google.common.io.FileWriteMode;
|
||||||
|
|
||||||
public class TestFpgaResourceHandler {
|
public class TestFpgaResourceHandler {
|
||||||
@Rule
|
@Rule
|
||||||
|
@ -133,7 +134,8 @@ public class TestFpgaResourceHandler {
|
||||||
dummyAocx = new File(aocxPath);
|
dummyAocx = new File(aocxPath);
|
||||||
Files.createParentDirs(dummyAocx);
|
Files.createParentDirs(dummyAocx);
|
||||||
Files.touch(dummyAocx);
|
Files.touch(dummyAocx);
|
||||||
Files.append(HASHABLE_STRING, dummyAocx, StandardCharsets.UTF_8);
|
Files.asCharSink(dummyAocx, StandardCharsets.UTF_8, FileWriteMode.APPEND)
|
||||||
|
.write(HASHABLE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -358,7 +360,8 @@ public class TestFpgaResourceHandler {
|
||||||
|
|
||||||
// Case 2. id-2 container request preStart, with 1 plugin.configureIP called
|
// Case 2. id-2 container request preStart, with 1 plugin.configureIP called
|
||||||
// Add some characters to the dummy file to have its hash changed
|
// Add some characters to the dummy file to have its hash changed
|
||||||
Files.append("12345", dummyAocx, StandardCharsets.UTF_8);
|
Files.asCharSink(dummyAocx, StandardCharsets.UTF_8, FileWriteMode.APPEND)
|
||||||
|
.write("12345");
|
||||||
fpgaResourceHandler.preStart(mockContainer(1, 1, "GZIP"));
|
fpgaResourceHandler.preStart(mockContainer(1, 1, "GZIP"));
|
||||||
// we should have 4 times invocation
|
// we should have 4 times invocation
|
||||||
verify(mockVendorPlugin, times(4)).configureIP(anyString(),
|
verify(mockVendorPlugin, times(4)).configureIP(anyString(),
|
||||||
|
|
|
@ -1172,7 +1172,8 @@ public class TestAMRestart extends ParameterizedSchedulerTestBase {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.throwIfUnchecked(e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, 2000, 200000);
|
}, 2000, 200000);
|
||||||
|
|
Loading…
Reference in New Issue