HBASE-4190 Coprocessors: pull up some cp constants from cp package to o.a.h.h.HConstants
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1158463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f43cb3245c
commit
5b4b4c74e8
|
@ -375,6 +375,8 @@ Release 0.91.0 - Unreleased
|
|||
HBASE-3807 Fix units in RS UI metrics (subramanian raghunathan)
|
||||
HBASE-4193 Enhance RPC debug logging to provide more details on
|
||||
call contents
|
||||
HBASE-4190 Coprocessors: pull up some cp constants from cp package to
|
||||
o.a.h.h.HConstants (Mingjie Lai)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* HConstants holds a bunch of HBase-related constants
|
||||
|
@ -496,6 +497,17 @@ public final class HConstants {
|
|||
CORRUPT_DIR_NAME, Bytes.toString(META_TABLE_NAME),
|
||||
Bytes.toString(ROOT_TABLE_NAME), SPLIT_LOGDIR_NAME }));
|
||||
|
||||
public static final Pattern CP_HTD_ATTR_KEY_PATTERN = Pattern.compile
|
||||
("coprocessor\\$([0-9]+)", Pattern.CASE_INSENSITIVE);
|
||||
public static final Pattern CP_HTD_ATTR_VALUE_PATTERN =
|
||||
Pattern.compile("([^\\|]*)\\|([^\\|]+)\\|[\\s]*([\\d]*)[\\s]*(\\|.*)?");
|
||||
|
||||
public static final String CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN = "[^=,]+";
|
||||
public static final String CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN = "[^,]+";
|
||||
public static final Pattern CP_HTD_ATTR_VALUE_PARAM_PATTERN = Pattern.compile(
|
||||
"(" + CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN + ")=(" +
|
||||
CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN + "),?");
|
||||
|
||||
private HConstants() {
|
||||
// Can't be instantiated with this ctor.
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ import java.util.TreeMap;
|
|||
import java.util.regex.Matcher;
|
||||
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.coprocessor.Coprocessor;
|
||||
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
||||
import org.apache.hadoop.hbase.io.hfile.Compression;
|
||||
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreFile;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.io.WritableComparable;
|
||||
|
@ -705,14 +703,13 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
|
|||
throw new IOException("Coprocessor " + className + " already exists.");
|
||||
}
|
||||
// validate parameter kvs
|
||||
//String kvString = "";
|
||||
StringBuilder kvString = new StringBuilder();
|
||||
if (kvs != null) {
|
||||
for (Map.Entry<String, String> e: kvs.entrySet()) {
|
||||
if (!e.getKey().matches(RegionCoprocessorHost.PARAMETER_KEY_PATTERN)) {
|
||||
if (!e.getKey().matches(HConstants.CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN)) {
|
||||
throw new IOException("Illegal parameter key = " + e.getKey());
|
||||
}
|
||||
if (!e.getValue().matches(RegionCoprocessorHost.PARAMETER_VALUE_PATTERN)) {
|
||||
if (!e.getValue().matches(HConstants.CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN)) {
|
||||
throw new IOException("Illegal parameter (" + e.getKey() +
|
||||
") value = " + e.getValue());
|
||||
}
|
||||
|
@ -731,7 +728,7 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
|
|||
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
|
||||
this.values.entrySet()) {
|
||||
keyMatcher =
|
||||
RegionCoprocessorHost.CP_KEY_PATTERN.matcher(
|
||||
HConstants.CP_HTD_ATTR_KEY_PATTERN.matcher(
|
||||
Bytes.toString(e.getKey().get()));
|
||||
if (!keyMatcher.matches()) {
|
||||
continue;
|
||||
|
@ -754,13 +751,13 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
|
|||
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
|
||||
this.values.entrySet()) {
|
||||
keyMatcher =
|
||||
RegionCoprocessorHost.CP_KEY_PATTERN.matcher(
|
||||
HConstants.CP_HTD_ATTR_KEY_PATTERN.matcher(
|
||||
Bytes.toString(e.getKey().get()));
|
||||
if (!keyMatcher.matches()) {
|
||||
continue;
|
||||
}
|
||||
valueMatcher =
|
||||
RegionCoprocessorHost.CP_VALUE_PATTERN.matcher(
|
||||
HConstants.CP_HTD_ATTR_VALUE_PATTERN.matcher(
|
||||
Bytes.toString(e.getValue().get()));
|
||||
if (!valueMatcher.matches()) {
|
||||
continue;
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.hadoop.hbase.coprocessor;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
|
||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.apache.hadoop.hbase.coprocessor;
|
|||
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HServerInfo;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.coprocessor;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.*;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
|
||||
public interface MasterCoprocessorEnvironment extends CoprocessorEnvironment {
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
|
||||
/**
|
||||
* Carries the execution state for a given invocation of an Observer coprocessor
|
||||
* ({@link RegionObserver}, {@link MasterObserver}, or {@link WALObserver})
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.coprocessor;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
||||
|
||||
public interface WALCoprocessorEnvironment extends CoprocessorEnvironment {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.apache.hadoop.fs.Path;
|
|||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.client.*;
|
||||
import org.apache.hadoop.hbase.coprocessor.*;
|
||||
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
|
||||
|
@ -42,7 +44,6 @@ import org.apache.hadoop.util.StringUtils;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Implements the coprocessor environment and runtime support for coprocessors
|
||||
|
@ -92,16 +93,6 @@ public class RegionCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
public static final Pattern CP_KEY_PATTERN = Pattern.compile
|
||||
("coprocessor\\$([0-9]+)", Pattern.CASE_INSENSITIVE);
|
||||
public static final Pattern CP_VALUE_PATTERN =
|
||||
Pattern.compile("([^\\|]*)\\|([^\\|]+)\\|[\\s]*([\\d]*)[\\s]*(\\|.*)?");
|
||||
|
||||
public static final String PARAMETER_KEY_PATTERN = "[^=,]+";
|
||||
public static final String PARAMETER_VALUE_PATTERN = "[^,]+";
|
||||
public static final Pattern CFG_SPEC_MATCH = Pattern.compile(
|
||||
"(" + PARAMETER_KEY_PATTERN + ")=(" + PARAMETER_VALUE_PATTERN + "),?");
|
||||
|
||||
/** The region server services */
|
||||
RegionServerServices rsServices;
|
||||
/** The region */
|
||||
|
@ -134,10 +125,10 @@ public class RegionCoprocessorHost
|
|||
region.getTableDesc().getValues().entrySet()) {
|
||||
String key = Bytes.toString(e.getKey().get()).trim();
|
||||
String spec = Bytes.toString(e.getValue().get()).trim();
|
||||
if (CP_KEY_PATTERN.matcher(key).matches()) {
|
||||
if (HConstants.CP_HTD_ATTR_KEY_PATTERN.matcher(key).matches()) {
|
||||
// found one
|
||||
try {
|
||||
Matcher matcher = CP_VALUE_PATTERN.matcher(spec);
|
||||
Matcher matcher = HConstants.CP_HTD_ATTR_VALUE_PATTERN.matcher(spec);
|
||||
if (matcher.matches()) {
|
||||
// jar file path can be empty if the cp class can be loaded
|
||||
// from class loader.
|
||||
|
@ -155,7 +146,7 @@ public class RegionCoprocessorHost
|
|||
if (cfgSpec != null) {
|
||||
cfgSpec = cfgSpec.substring(cfgSpec.indexOf('|') + 1);
|
||||
Configuration newConf = HBaseConfiguration.create(conf);
|
||||
Matcher m = CFG_SPEC_MATCH.matcher(cfgSpec);
|
||||
Matcher m = HConstants.CP_HTD_ATTR_VALUE_PARAM_PATTERN.matcher(cfgSpec);
|
||||
while (m.find()) {
|
||||
newConf.set(m.group(1), m.group(2));
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package org.apache.hadoop.hbase.regionserver.wal;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.coprocessor.*;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
|
|||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.apache.hadoop.hbase.HBaseTestCase;
|
|||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Scan;
|
||||
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
|||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||
import org.apache.hadoop.hbase.CoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Arrays;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
|
|||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
|||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.HLogSplitter;
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.apache.hadoop.hbase.*;
|
|||
import org.apache.hadoop.hbase.regionserver.wal.HLog.Reader;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.apache.hadoop.hbase.coprocessor.Coprocessor;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
|
||||
import org.apache.hadoop.hbase.coprocessor.SampleRegionWALObserver;
|
||||
import org.apache.hadoop.hdfs.DFSClient;
|
||||
|
|
Loading…
Reference in New Issue