svn merge -c 1379506 FIXES: HADOOP-8684. Deadlock between WritableComparator and WritableComparable. Contributed by Jing Zhao
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1390680 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e619da2136
commit
bde1ba70c1
|
@ -750,6 +750,9 @@ Release 0.23.4 - UNRELEASED
|
||||||
HADOOP-8843. Old trash directories are never deleted on upgrade
|
HADOOP-8843. Old trash directories are never deleted on upgrade
|
||||||
from 1.x (jlowe)
|
from 1.x (jlowe)
|
||||||
|
|
||||||
|
HADOOP-8684. Deadlock between WritableComparator and WritableComparable.
|
||||||
|
(Jing Zhao via suresh)
|
||||||
|
|
||||||
Release 0.23.3 - UNRELEASED
|
Release 0.23.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.io;
|
package org.apache.hadoop.io;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.DataInput;
|
||||||
import java.util.*;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
@ -38,12 +39,11 @@ import org.apache.hadoop.util.ReflectionUtils;
|
||||||
@InterfaceStability.Stable
|
@InterfaceStability.Stable
|
||||||
public class WritableComparator implements RawComparator {
|
public class WritableComparator implements RawComparator {
|
||||||
|
|
||||||
private static HashMap<Class, WritableComparator> comparators =
|
private static final ConcurrentHashMap<Class, WritableComparator> comparators
|
||||||
new HashMap<Class, WritableComparator>(); // registry
|
= new ConcurrentHashMap<Class, WritableComparator>(); // registry
|
||||||
|
|
||||||
/** Get a comparator for a {@link WritableComparable} implementation. */
|
/** Get a comparator for a {@link WritableComparable} implementation. */
|
||||||
public static synchronized
|
public static WritableComparator get(Class<? extends WritableComparable> c) {
|
||||||
WritableComparator get(Class<? extends WritableComparable> c) {
|
|
||||||
WritableComparator comparator = comparators.get(c);
|
WritableComparator comparator = comparators.get(c);
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
// force the static initializers to run
|
// force the static initializers to run
|
||||||
|
@ -76,12 +76,10 @@ public class WritableComparator implements RawComparator {
|
||||||
/** Register an optimized comparator for a {@link WritableComparable}
|
/** Register an optimized comparator for a {@link WritableComparable}
|
||||||
* implementation. Comparators registered with this method must be
|
* implementation. Comparators registered with this method must be
|
||||||
* thread-safe. */
|
* thread-safe. */
|
||||||
public static synchronized void define(Class c,
|
public static void define(Class c, WritableComparator comparator) {
|
||||||
WritableComparator comparator) {
|
|
||||||
comparators.put(c, comparator);
|
comparators.put(c, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final Class<? extends WritableComparable> keyClass;
|
private final Class<? extends WritableComparable> keyClass;
|
||||||
private final WritableComparable key1;
|
private final WritableComparable key1;
|
||||||
private final WritableComparable key2;
|
private final WritableComparable key2;
|
||||||
|
|
Loading…
Reference in New Issue