HBASE-20119 (addendum) revert the removed methods in TableDescriptorBuilder and TableDescriptor

Signed-off-by: Josh Elser <elserj@apache.org>
Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Chia-Ping Tsai 2018-03-19 08:59:24 +08:00
parent 03e7b78260
commit 7ba86d056c
3 changed files with 65 additions and 17 deletions

View File

@ -21,16 +21,15 @@ package org.apache.hadoop.hbase;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.CoprocessorDescriptor; import org.apache.hadoop.hbase.client.CoprocessorDescriptor;
import org.apache.hadoop.hbase.client.CoprocessorDescriptorBuilder; import org.apache.hadoop.hbase.client.CoprocessorDescriptorBuilder;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
@ -38,8 +37,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder.ModifyableTableDesc
import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor;
/** /**
* HTableDescriptor contains the details about an HBase table such as the descriptors of * HTableDescriptor contains the details about an HBase table such as the descriptors of
@ -762,16 +760,6 @@ public class HTableDescriptor implements TableDescriptor, Comparable<HTableDescr
return delegatee.getCoprocessorDescriptors(); return delegatee.getCoprocessorDescriptors();
} }
/**
* Return the list of attached co-processor represented by their name className
*
* @return The list of co-processors classNames
*/
public List<String> getCoprocessors() {
return getCoprocessorDescriptors().stream().map(CoprocessorDescriptor::getClassName)
.collect(Collectors.toList());
}
/** /**
* Remove a coprocessor from those set on the table * Remove a coprocessor from those set on the table
* @param className Class name of the co-processor * @param className Class name of the co-processor

View File

@ -24,7 +24,7 @@ import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -86,6 +86,20 @@ public interface TableDescriptor {
*/ */
Collection<CoprocessorDescriptor> getCoprocessorDescriptors(); Collection<CoprocessorDescriptor> getCoprocessorDescriptors();
/**
* Return the list of attached co-processor represented by their name
* className
* @return The list of co-processors classNames
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #getCoprocessorDescriptors()} instead
*/
@Deprecated
default Collection<String> getCoprocessors() {
return getCoprocessorDescriptors().stream()
.map(CoprocessorDescriptor::getClassName)
.collect(Collectors.toList());
}
/** /**
* Returns the durability setting for the table. * Returns the durability setting for the table.
* *

View File

@ -35,6 +35,7 @@ import java.util.TreeSet;
import java.util.function.Function; import java.util.function.Function;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
@ -232,7 +233,7 @@ public class TableDescriptorBuilder {
private static final Pattern CP_HTD_ATTR_VALUE_PARAM_PATTERN = Pattern.compile( private static final Pattern CP_HTD_ATTR_VALUE_PARAM_PATTERN = Pattern.compile(
"(" + CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN + ")=(" + "(" + CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN + ")=(" +
CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN + "),?"); CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN + "),?");
public static final Pattern CP_HTD_ATTR_KEY_PATTERN = private static final Pattern CP_HTD_ATTR_KEY_PATTERN =
Pattern.compile("^coprocessor\\$([0-9]+)$", Pattern.CASE_INSENSITIVE); Pattern.compile("^coprocessor\\$([0-9]+)$", Pattern.CASE_INSENSITIVE);
/** /**
* Table descriptor for namespace table * Table descriptor for namespace table
@ -302,6 +303,51 @@ public class TableDescriptorBuilder {
this.desc = new ModifyableTableDescriptor(desc); this.desc = new ModifyableTableDescriptor(desc);
} }
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #setCoprocessor(String)} instead
*/
@Deprecated
public TableDescriptorBuilder addCoprocessor(String className) throws IOException {
return addCoprocessor(className, null, Coprocessor.PRIORITY_USER, null);
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #setCoprocessor(CoprocessorDescriptor)} instead
*/
@Deprecated
public TableDescriptorBuilder addCoprocessor(String className, Path jarFilePath,
int priority, final Map<String, String> kvs) throws IOException {
desc.setCoprocessor(
CoprocessorDescriptorBuilder.newBuilder(className)
.setJarPath(jarFilePath == null ? null : jarFilePath.toString())
.setPriority(priority)
.setProperties(kvs == null ? Collections.emptyMap() : kvs)
.build());
return this;
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #setCoprocessor(CoprocessorDescriptor)} instead
*/
@Deprecated
public TableDescriptorBuilder addCoprocessorWithSpec(final String specStr) throws IOException {
desc.setCoprocessorWithSpec(specStr);
return this;
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #setColumnFamily(ColumnFamilyDescriptor)} instead
*/
@Deprecated
public TableDescriptorBuilder addColumnFamily(final ColumnFamilyDescriptor family) {
desc.setColumnFamily(family);
return this;
}
public TableDescriptorBuilder setCoprocessor(String className) throws IOException { public TableDescriptorBuilder setCoprocessor(String className) throws IOException {
return setCoprocessor(CoprocessorDescriptorBuilder.of(className)); return setCoprocessor(CoprocessorDescriptorBuilder.of(className));
} }