HADOOP-10534. KeyProvider getKeysMetadata should take a list of names
rather than returning all keys. (omalley) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1589773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24d1cf9ac6
commit
f9a9c1ee63
|
@ -23,8 +23,8 @@ Trunk (Unreleased)
|
|||
if the override value is same as the final parameter value.
|
||||
(Ravi Prakash via suresh)
|
||||
|
||||
HADOOP-8078. Add capability to turn on security in unit tests. (Jaimin Jetly
|
||||
via jitendra)
|
||||
HADOOP-8078. Add capability to turn on security in unit tests. (Jaimin
|
||||
Jetly via jitendra)
|
||||
|
||||
HADOOP-7757. Test file reference count is at least 3x actual value (Jon
|
||||
Eagles via bobby)
|
||||
|
@ -141,6 +141,9 @@ Trunk (Unreleased)
|
|||
HADOOP-10430. KeyProvider Metadata should have an optional description,
|
||||
there should be a method to retrieve the metadata from all keys. (tucu)
|
||||
|
||||
HADOOP-10534. KeyProvider getKeysMetadata should take a list of names
|
||||
rather than returning all keys. (omalley)
|
||||
|
||||
BUG FIXES
|
||||
|
||||
HADOOP-9451. Fault single-layer config if node group topology is enabled.
|
||||
|
|
|
@ -312,20 +312,16 @@ public abstract class KeyProvider {
|
|||
|
||||
|
||||
/**
|
||||
* Get the key metadata for all keys.
|
||||
*
|
||||
* @return a Map with all the keys and their metadata
|
||||
* Get key metadata in bulk.
|
||||
* @param names the names of the keys to get
|
||||
* @throws IOException
|
||||
*/
|
||||
public Map<String, Metadata> getKeysMetadata() throws IOException {
|
||||
Map<String, Metadata> keysMetadata = new LinkedHashMap<String, Metadata>();
|
||||
for (String key : getKeys()) {
|
||||
Metadata meta = getMetadata(key);
|
||||
if (meta != null) {
|
||||
keysMetadata.put(key, meta);
|
||||
}
|
||||
public Metadata[] getKeysMetadata(String... names) throws IOException {
|
||||
Metadata[] result = new Metadata[names.length];
|
||||
for (int i=0; i < names.length; ++i) {
|
||||
result[i] = getMetadata(names[i]);
|
||||
}
|
||||
return keysMetadata;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -230,16 +230,16 @@ public class KeyShell extends Configured implements Tool {
|
|||
}
|
||||
|
||||
public void execute() throws IOException {
|
||||
List<String> keys;
|
||||
try {
|
||||
List<String> keys = provider.getKeys();
|
||||
out.println("Listing keys for KeyProvider: " + provider.toString());
|
||||
if (metadata) {
|
||||
Map<String, Metadata> keysMeta = provider.getKeysMetadata();
|
||||
for (Map.Entry<String, Metadata> entry : keysMeta.entrySet()) {
|
||||
out.println(entry.getKey() + " : " + entry.getValue());
|
||||
Metadata[] meta =
|
||||
provider.getKeysMetadata(keys.toArray(new String[keys.size()]));
|
||||
for(int i=0; i < meta.length; ++i) {
|
||||
out.println(keys.get(i) + " : " + meta[i]);
|
||||
}
|
||||
} else {
|
||||
keys = provider.getKeys();
|
||||
for (String keyName : keys) {
|
||||
out.println(keyName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue