Skip to content
Open
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 @@ -724,6 +724,11 @@ private static BlockTokenSecretManager createBlockTokenSecretManager(
final long lifetimeMin = conf.getLong(
DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY,
DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_DEFAULT);
if (lifetimeMin <= 0) {
throw new HadoopIllegalArgumentException(
DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY + " = '"
+ lifetimeMin + "' is invalid. It should be a positive value.");
}
Comment thread
joseluisll marked this conversation as resolved.
final String encryptionAlgorithm = conf.get(
DFSConfigKeys.DFS_DATA_ENCRYPTION_ALGORITHM_KEY);
LOG.info("{}={} min(s), {}={} min(s), {}={}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.List;
import java.util.Random;

import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.FSDataInputStream;
Expand Down Expand Up @@ -222,6 +224,17 @@ protected Configuration getConf(int numDataNodes) {
return conf;
}

@Test
public void testInvalidBlockTokenLifetime() {
for (long lifetime : new long[] {0, -1}) {
Configuration conf = getConf(1);
conf.setLong(DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY, lifetime);
assertThrows(HadoopIllegalArgumentException.class,
() -> new MiniDFSCluster.Builder(conf).numDataNodes(1).build(),
DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_LIFETIME_KEY);
}
}

/**
* testing that APPEND operation can handle token expiration when
* re-establishing pipeline is needed
Expand Down
Loading