HADOOP-10534. KeyProvider getKeysMetadata should take a list of names

rather than returning all keys. (omalley)


Conflicts:
	hadoop-common-project/hadoop-common/CHANGES.txt

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1619517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2014-08-21 18:58:45 +00:00
parent bb0a609e19
commit 91e6a452b5
3 changed files with 15 additions and 16 deletions

View File

@ -111,6 +111,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-10431. Change visibility of KeyStore.Options getter methods to HADOOP-10431. Change visibility of KeyStore.Options getter methods to
public. (tucu) public. (tucu)
HADOOP-10534. KeyProvider getKeysMetadata should take a list of names
rather than returning all keys. (omalley)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-10838. Byte array native checksumming. (James Thomas via todd) HADOOP-10838. Byte array native checksumming. (James Thomas via todd)

View File

@ -312,20 +312,16 @@ public abstract KeyVersion getKeyVersion(String versionName
/** /**
* Get the key metadata for all keys. * Get key metadata in bulk.
* * @param names the names of the keys to get
* @return a Map with all the keys and their metadata
* @throws IOException * @throws IOException
*/ */
public Map<String, Metadata> getKeysMetadata() throws IOException { public Metadata[] getKeysMetadata(String... names) throws IOException {
Map<String, Metadata> keysMetadata = new LinkedHashMap<String, Metadata>(); Metadata[] result = new Metadata[names.length];
for (String key : getKeys()) { for (int i=0; i < names.length; ++i) {
Metadata meta = getMetadata(key); result[i] = getMetadata(names[i]);
if (meta != null) {
keysMetadata.put(key, meta);
}
} }
return keysMetadata; return result;
} }
/** /**

View File

@ -230,16 +230,16 @@ public boolean validate() {
} }
public void execute() throws IOException { public void execute() throws IOException {
List<String> keys;
try { try {
List<String> keys = provider.getKeys();
out.println("Listing keys for KeyProvider: " + provider.toString()); out.println("Listing keys for KeyProvider: " + provider.toString());
if (metadata) { if (metadata) {
Map<String, Metadata> keysMeta = provider.getKeysMetadata(); Metadata[] meta =
for (Map.Entry<String, Metadata> entry : keysMeta.entrySet()) { provider.getKeysMetadata(keys.toArray(new String[keys.size()]));
out.println(entry.getKey() + " : " + entry.getValue()); for(int i=0; i < meta.length; ++i) {
out.println(keys.get(i) + " : " + meta[i]);
} }
} else { } else {
keys = provider.getKeys();
for (String keyName : keys) { for (String keyName : keys) {
out.println(keyName); out.println(keyName);
} }