[42/50] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/095fabf1/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index a4c6095..d56def5 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -4362,7 +4362,7 @@ public final class QuotaProtos { * optional .hbase.pb.SpaceQuota space = 3; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> getSpaceFieldBuilder() { if (spaceBuilder_ == null) { spaceBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< @@ -6077,7 +6077,7 @@ public final class QuotaProtos { * optional .hbase.pb.SpaceQuota quota = 1; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> getQuotaFieldBuilder() { if (quotaBuilder_ == null) { quotaBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< @@ -6351,7 +6351,7 @@ public final class QuotaProtos { return memoizedHashCode; } int hash = 41; - hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (19 * hash) + getDescriptor().hashCode(); if (hasPolicy()) { hash = (37 * hash) + POLICY_FIELD_NUMBER; hash = (53 * hash) + policy_; @@ -6978,7 +6978,7 @@ public final class QuotaProtos { return memoizedHashCode; } int hash = 41; - hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (19 * hash) + getDescriptor().hashCode(); if (hasStatus()) { hash = (37 * hash) + STATUS_FIELD_NUMBER; hash = (53 * hash) + getStatus().hashCode(); @@ -7351,7 +7351,7 @@ public final class QuotaProtos { * optional .hbase.pb.SpaceQuotaStatus status = 1; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatus, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatus.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatusOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatus, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatus.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaStatusOrBuilder> getStatusFieldBuilder() { if (statusBuilder_ == null) { statusBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< @@ -7476,163 +7476,5829 @@ public final class QuotaProtos { } - private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor -internal_static_hbase_pb_TimedQuota_descriptor; - private static final - org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_hbase_pb_TimedQuota_fieldAccessorTable; - private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor -internal_static_hbase_pb_Throttle_descriptor; - private static final - org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_hbase_pb_Throttle_fieldAccessorTable; - private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor -
[04/50] [abbrv] hbase git commit: HBASE-17888: Added generic methods for updating metrics on submit and finish of a procedure execution
HBASE-17888: Added generic methods for updating metrics on submit and finish of a procedure execution Signed-off-by: Michael StackProject: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c8461456 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c8461456 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c8461456 Branch: refs/heads/HBASE-16961 Commit: c8461456d0ae81b90d67d36e1e077ae1d01102e5 Parents: e2a7461 Author: Umesh Agashe Authored: Mon Apr 10 15:32:43 2017 -0700 Committer: Michael Stack Committed: Fri Apr 14 11:51:08 2017 -0700 -- .../apache/hadoop/hbase/client/HBaseAdmin.java | 2 +- .../org/apache/hadoop/hbase/ProcedureInfo.java | 20 +- .../master/MetricsAssignmentManagerSource.java | 9 +- .../MetricsAssignmentManagerSourceImpl.java | 9 +- .../hadoop/hbase/procedure2/Procedure.java | 41 +- .../hbase/procedure2/ProcedureExecutor.java | 11 + .../hadoop/hbase/procedure2/ProcedureUtil.java | 10 +- .../hbase/procedure2/TestProcedureMetrics.java | 254 ++ .../procedure2/TestStateMachineProcedure.java | 1 - .../shaded/protobuf/generated/MasterProtos.java | 490 +-- .../protobuf/generated/ProcedureProtos.java | 146 +++--- .../src/main/protobuf/Master.proto | 2 +- .../src/main/protobuf/Procedure.proto | 2 +- .../hadoop/hbase/master/MasterRpcServices.java | 4 +- .../master/procedure/ServerCrashProcedure.java | 2 +- .../hbase-webapps/master/procedures.jsp | 2 +- .../main/ruby/shell/commands/list_procedures.rb | 6 +- 17 files changed, 652 insertions(+), 359 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/c8461456/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 155a272..cadd6cc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -2114,7 +2114,7 @@ public class HBaseAdmin implements Admin { procedureState, procProto.hasParentId() ? procProto.getParentId() : -1, nonceKey, procProto.hasException()? ForeignExceptionUtil.toIOException(procProto.getException()): null, -procProto.getLastUpdate(), procProto.getStartTime(), +procProto.getLastUpdate(), procProto.getSubmittedTime(), procProto.hasResult()? procProto.getResult().toByteArray() : null); } http://git-wip-us.apache.org/repos/asf/hbase/blob/c8461456/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java index bb8bb08..6104c22 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java @@ -39,7 +39,7 @@ public class ProcedureInfo implements Cloneable { private final NonceKey nonceKey; private final IOException exception; private final long lastUpdate; - private final long startTime; + private final long submittedTime; private final byte[] result; private long clientAckTime = -1; @@ -54,7 +54,7 @@ public class ProcedureInfo implements Cloneable { final NonceKey nonceKey, final IOException exception, final long lastUpdate, - final long startTime, + final long submittedTime, final byte[] result) { this.procId = procId; this.procName = procName; @@ -63,7 +63,7 @@ public class ProcedureInfo implements Cloneable { this.parentId = parentId; this.nonceKey = nonceKey; this.lastUpdate = lastUpdate; -this.startTime = startTime; +this.submittedTime = submittedTime; // If the procedure is completed, we should treat exception and result differently this.exception = exception; @@ -74,7 +74,7 @@ public class ProcedureInfo implements Cloneable { justification="Intentional; calling super class clone doesn't make sense here.") public ProcedureInfo clone() { return new ProcedureInfo(procId, procName, procOwner, procState, parentId, nonceKey, - exception, lastUpdate, startTime, result); + exception, lastUpdate, submittedTime, result); } @Override @@ -96,10 +96,10 @@ public class ProcedureInfo implements Cloneable { sb.append(procState);
[09/50] [abbrv] hbase git commit: HBASE-15535 Correct link to Trafodion
HBASE-15535 Correct link to Trafodion Signed-off-by: CHIA-PING TSAIProject: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/363f6275 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/363f6275 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/363f6275 Branch: refs/heads/HBASE-16961 Commit: 363f62751c760cc8056a2b1be40a410281e634f7 Parents: 918aa46 Author: Gábor Lipták Authored: Sat Apr 15 11:43:38 2017 -0400 Committer: CHIA-PING TSAI Committed: Mon Apr 17 10:26:28 2017 +0800 -- src/main/asciidoc/_chapters/sql.adoc | 2 +- src/main/site/xdoc/supportingprojects.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/363f6275/src/main/asciidoc/_chapters/sql.adoc -- diff --git a/src/main/asciidoc/_chapters/sql.adoc b/src/main/asciidoc/_chapters/sql.adoc index b47104c..b1ad063 100644 --- a/src/main/asciidoc/_chapters/sql.adoc +++ b/src/main/asciidoc/_chapters/sql.adoc @@ -37,6 +37,6 @@ link:http://phoenix.apache.org[Apache Phoenix] === Trafodion -link:https://wiki.trafodion.org/[Trafodion: Transactional SQL-on-HBase] +link:http://trafodion.incubator.apache.org/[Trafodion: Transactional SQL-on-HBase] :numbered: http://git-wip-us.apache.org/repos/asf/hbase/blob/363f6275/src/main/site/xdoc/supportingprojects.xml -- diff --git a/src/main/site/xdoc/supportingprojects.xml b/src/main/site/xdoc/supportingprojects.xml index f349c7f..f949a57 100644 --- a/src/main/site/xdoc/supportingprojects.xml +++ b/src/main/site/xdoc/supportingprojects.xml @@ -46,9 +46,9 @@ under the License. for HBase. https://github.com/juwi/HBase-TAggregator;>HBase TAggregator An HBase coprocessor for timeseries-based aggregations. - http://www.trafodion.org;>Trafodion - Trafodion is an HP-sponsored Apache-licensed open source SQL on HBase -DBMS with full-ACID distributed transaction support. + http://trafodion.incubator.apache.org/;>Apache Trafodion + Apache Trafodion is a webscale SQL-on-Hadoop solution enabling +transactional or operational workloads on Hadoop. http://phoenix.apache.org/;>Apache Phoenix Apache Phoenix is a relational database layer over HBase delivered as a client-embedded JDBC driver targeting low latency queries over HBase data.
[43/50] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
HBASE-17428 Implement informational RPCs for space quotas Create some RPCs that can expose the in-memory state that the RegionServers and Master hold to drive the space quota "state machine". Then, create some hbase shell commands to interact with those. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/095fabf1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/095fabf1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/095fabf1 Branch: refs/heads/HBASE-16961 Commit: 095fabf16d91ce0e5c042b657a9f07a548d49a49 Parents: efd6edc Author: Josh ElserAuthored: Tue Feb 21 15:36:39 2017 -0500 Committer: Josh Elser Committed: Mon Apr 17 15:44:00 2017 -0400 -- .../hbase/client/ConnectionImplementation.java |9 + .../hadoop/hbase/client/QuotaStatusCalls.java | 125 + .../client/ShortCircuitMasterConnection.java|7 + .../hadoop/hbase/quotas/QuotaTableUtil.java | 77 + .../hbase/shaded/protobuf/RequestConverter.java | 33 + .../shaded/protobuf/generated/AdminProtos.java | 394 +- .../shaded/protobuf/generated/MasterProtos.java | 92 +- .../shaded/protobuf/generated/QuotaProtos.java | 5986 +- .../generated/RegionServerStatusProtos.java | 28 +- .../src/main/protobuf/Admin.proto |9 + .../src/main/protobuf/Master.proto |4 + .../src/main/protobuf/Quota.proto | 35 + .../hbase/protobuf/generated/QuotaProtos.java |6 +- .../hadoop/hbase/master/MasterRpcServices.java | 40 + .../hbase/quotas/ActivePolicyEnforcement.java |8 + .../hbase/regionserver/RSRpcServices.java | 57 + .../hadoop/hbase/master/MockRegionServer.java | 18 + .../hbase/quotas/TestQuotaStatusRPCs.java | 192 + hbase-shell/src/main/ruby/hbase/quotas.rb | 16 + hbase-shell/src/main/ruby/shell.rb |3 + .../ruby/shell/commands/list_quota_snapshots.rb | 59 + .../shell/commands/list_quota_table_sizes.rb| 47 + .../shell/commands/list_quota_violations.rb | 48 + hbase-shell/src/test/ruby/hbase/quotas_test.rb | 24 - .../test/ruby/hbase/quotas_test_no_cluster.rb | 69 + 25 files changed, 7066 insertions(+), 320 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/095fabf1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java index 99feb14..3f27e1c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java @@ -94,6 +94,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest; @@ -1731,6 +1733,13 @@ class ConnectionImplementation implements ClusterConnection, Closeable { ListReplicationPeersRequest request) throws ServiceException { return stub.listReplicationPeers(controller, request); } + + @Override + public GetSpaceQuotaRegionSizesResponse getSpaceQuotaRegionSizes( + RpcController controller, GetSpaceQuotaRegionSizesRequest request) + throws ServiceException { +return stub.getSpaceQuotaRegionSizes(controller, request); + } }; } http://git-wip-us.apache.org/repos/asf/hbase/blob/095fabf1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java new file mode 100644 index 000..f0f385d ---
[21/50] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
HBASE-17000 Implement computation of online region sizes and report to the Master Includes a trivial implementation of the Master-side collection to avoid. Only enough to write a test to verify RS collection. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2dea6764 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2dea6764 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2dea6764 Branch: refs/heads/HBASE-16961 Commit: 2dea67644982aa18d174de32f454f526354eea5c Parents: a29abe6 Author: Josh ElserAuthored: Mon Nov 7 13:46:42 2016 -0500 Committer: Josh Elser Committed: Mon Apr 17 15:35:31 2017 -0400 -- .../generated/RegionServerStatusProtos.java | 2071 +- .../src/main/protobuf/RegionServerStatus.proto | 22 + .../hadoop/hbase/master/MasterRpcServices.java | 19 + .../quotas/FileSystemUtilizationChore.java | 205 ++ .../hadoop/hbase/quotas/MasterQuotaManager.java | 15 + .../hbase/regionserver/HRegionServer.java | 72 + .../quotas/TestFileSystemUtilizationChore.java | 357 +++ .../hadoop/hbase/quotas/TestRegionSizeUse.java | 194 ++ .../TestRegionServerRegionSpaceUseReport.java | 99 + 9 files changed, 3032 insertions(+), 22 deletions(-) --
[02/50] [abbrv] hbase git commit: HBASE-17906 When a huge amount of data writing to hbase through thrift2, there will be a deadlock error. (Albert Lee)
HBASE-17906 When a huge amount of data writing to hbase through thrift2, there will be a deadlock error. (Albert Lee) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9dd5cda0 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9dd5cda0 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9dd5cda0 Branch: refs/heads/HBASE-16961 Commit: 9dd5cda01747ffb91ac084792fa4a8670859e810 Parents: da5fb27 Author: Michael StackAuthored: Thu Apr 13 21:59:11 2017 -0700 Committer: Michael Stack Committed: Thu Apr 13 21:59:11 2017 -0700 -- .../main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java | 3 --- 1 file changed, 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/9dd5cda0/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java -- diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java index 560ae64..8f56b10 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java @@ -432,9 +432,6 @@ public class ThriftServer extends Configured implements Tool { throw new RuntimeException("Could not parse the value provided for the port option", e); } -// Thrift's implementation uses '0' as a placeholder for 'use the default.' -int backlog = conf.getInt(BACKLOG_CONF_KEY, 0); - // Local hostname and user name, // used only if QOP is configured. String host = null;
[26/54] [abbrv] hbase git commit: HBASE-16999 Implement master and regionserver synchronization of quota state
http://git-wip-us.apache.org/repos/asf/hbase/blob/4a715450/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java new file mode 100644 index 000..4a7000c --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import static org.mockito.Matchers.argThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.Objects; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.mockito.ArgumentMatcher; + +/** + * Test case for {@link TableSpaceQuotaViolationNotifier}. + */ +@Category(SmallTests.class) +public class TestTableSpaceQuotaViolationNotifier { + + private TableSpaceQuotaViolationNotifier notifier; + private Connection conn; + + @Before + public void setup() throws Exception { +notifier = new TableSpaceQuotaViolationNotifier(); +conn = mock(Connection.class); +notifier.initialize(conn); + } + + @Test + public void testToViolation() throws Exception { +final TableName tn = TableName.valueOf("inviolation"); +final SpaceViolationPolicy policy = SpaceViolationPolicy.NO_INSERTS; +final Table quotaTable = mock(Table.class); + when(conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)).thenReturn(quotaTable); + +final Put expectedPut = new Put(Bytes.toBytes("t." + tn.getNameAsString())); +final SpaceQuota protoQuota = SpaceQuota.newBuilder() +.setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(policy)) +.build(); +expectedPut.addColumn(Bytes.toBytes("u"), Bytes.toBytes("v"), protoQuota.toByteArray()); + +notifier.transitionTableToViolation(tn, policy); + +verify(quotaTable).put(argThat(new SingleCellPutMatcher(expectedPut))); + } + + @Test + public void testToObservance() throws Exception { +final TableName tn = TableName.valueOf("notinviolation"); +final Table quotaTable = mock(Table.class); + when(conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)).thenReturn(quotaTable); + +final Delete expectedDelete = new Delete(Bytes.toBytes("t." + tn.getNameAsString())); +expectedDelete.addColumn(Bytes.toBytes("u"), Bytes.toBytes("v")); + +notifier.transitionTableToObservance(tn); + +verify(quotaTable).delete(argThat(new SingleCellDeleteMatcher(expectedDelete))); + } + + /** + * Parameterized for Puts. + */ + private static class SingleCellPutMatcher extends SingleCellMutationMatcher { +private SingleCellPutMatcher(Put expected) { + super(expected); +} + } + + /** + * Parameterized for Deletes. + */ + private static class SingleCellDeleteMatcher extends SingleCellMutationMatcher { +private SingleCellDeleteMatcher(Delete expected) { + super(expected); +} + } + + /** + * Quick hack to verify a Mutation with one column. + */ + private static class SingleCellMutationMatcher extends ArgumentMatcher { +private final Mutation expected; + +private SingleCellMutationMatcher(Mutation expected) { +
[35/54] [abbrv] hbase git commit: HBASE-17259 API to remove space quotas on a table/namespace
HBASE-17259 API to remove space quotas on a table/namespace Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/79bf1888 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/79bf1888 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/79bf1888 Branch: refs/heads/HBASE-16961 Commit: 79bf188818ae32e309433a28f73048558fb3b2db Parents: 7f42b49 Author: Josh ElserAuthored: Wed Jan 11 12:47:06 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 22 +++ .../hadoop/hbase/quotas/QuotaTableUtil.java | 6 +- .../hadoop/hbase/quotas/SpaceLimitSettings.java | 44 - .../hbase/quotas/TestQuotaSettingsFactory.java | 20 +++ .../shaded/protobuf/generated/QuotaProtos.java | 157 +++--- .../src/main/protobuf/Quota.proto | 1 + .../hbase/protobuf/generated/QuotaProtos.java | 159 --- hbase-protocol/src/main/protobuf/Quota.proto| 1 + .../hadoop/hbase/quotas/MasterQuotaManager.java | 9 +- .../hadoop/hbase/quotas/TestQuotaAdmin.java | 49 +- 10 files changed, 423 insertions(+), 45 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/79bf1888/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 7f1c180..184277d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -316,6 +316,17 @@ public class QuotaSettingsFactory { } /** + * Creates a {@link QuotaSettings} object to remove the FileSystem space quota for the given + * table. + * + * @param tableName The name of the table to remove the quota for. + * @return A {@link QuotaSettings} object. + */ + public static QuotaSettings removeTableSpaceLimit(TableName tableName) { +return new SpaceLimitSettings(tableName, true); + } + + /** * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given * namespace to the given size in bytes. When the space usage is exceeded by all tables in the * namespace, the provided {@link SpaceViolationPolicy} is enacted on all tables in the namespace. @@ -329,4 +340,15 @@ public class QuotaSettingsFactory { final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(namespace, sizeLimit, violationPolicy); } + + /** + * Creates a {@link QuotaSettings} object to remove the FileSystem space quota for the given +* namespace. + * + * @param namespace The namespace to remove the quota on. + * @return A {@link QuotaSettings} object. + */ + public static QuotaSettings removeNamespaceSpaceLimit(String namespace) { +return new SpaceLimitSettings(namespace, true); + } } http://git-wip-us.apache.org/repos/asf/hbase/blob/79bf1888/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index 42da811..ca525f0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -390,7 +390,11 @@ public class QuotaTableUtil { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); -hasSettings |= quotas.hasSpace(); +// Only when there is a space quota, make sure there's actually both fields provided +// Otherwise, it's a noop. +if (quotas.hasSpace()) { + hasSettings |= (quotas.getSpace().hasSoftLimit() && quotas.getSpace().hasViolationPolicy()); +} return !hasSettings; } http://git-wip-us.apache.org/repos/asf/hbase/blob/79bf1888/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java index e54882e..8ff7623 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java +++
[06/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes
HBASE-17857 Remove IS annotations from IA.Public classes Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a66d4918 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a66d4918 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a66d4918 Branch: refs/heads/HBASE-16961 Commit: a66d491892514fd4a188d6ca87d6260d8ae46184 Parents: 910b680 Author: zhangduoAuthored: Tue Apr 4 20:30:10 2017 +0800 Committer: zhangduo Committed: Wed Apr 5 15:34:06 2017 +0800 -- .../hbase/classification/InterfaceAudience.java | 1 - .../classification/InterfaceStability.java | 1 - .../hadoop/hbase/CallDroppedException.java | 4 +- .../hadoop/hbase/CallQueueTooBigException.java | 4 +- .../hadoop/hbase/ClockOutOfSyncException.java | 2 - .../org/apache/hadoop/hbase/ClusterStatus.java | 2 - .../hadoop/hbase/DoNotRetryIOException.java | 2 - .../hadoop/hbase/DroppedSnapshotException.java | 2 - .../apache/hadoop/hbase/HColumnDescriptor.java | 2 - .../org/apache/hadoop/hbase/HRegionInfo.java| 2 - .../apache/hadoop/hbase/HRegionLocation.java| 2 - .../apache/hadoop/hbase/HTableDescriptor.java | 2 - .../hbase/InvalidFamilyOperationException.java | 2 - .../apache/hadoop/hbase/KeepDeletedCells.java | 2 - .../hadoop/hbase/MasterNotRunningException.java | 2 - .../hadoop/hbase/MemoryCompactionPolicy.java| 2 - .../hadoop/hbase/MultiActionResultTooLarge.java | 2 - .../hadoop/hbase/NamespaceExistException.java | 2 - .../hbase/NamespaceNotFoundException.java | 2 - .../hbase/NotAllMetaRegionsOnlineException.java | 2 - .../hadoop/hbase/NotServingRegionException.java | 2 - .../hadoop/hbase/PleaseHoldException.java | 2 - .../apache/hadoop/hbase/RegionException.java| 2 - .../org/apache/hadoop/hbase/RegionLoad.java | 2 - .../hadoop/hbase/RegionTooBusyException.java| 2 - .../hbase/ReplicationPeerNotFoundException.java | 4 +- .../hadoop/hbase/RetryImmediatelyException.java | 2 - .../org/apache/hadoop/hbase/ServerLoad.java | 2 - .../hadoop/hbase/TableExistsException.java | 2 - .../hadoop/hbase/TableInfoMissingException.java | 2 - .../hadoop/hbase/TableNotDisabledException.java | 2 - .../hadoop/hbase/TableNotEnabledException.java | 2 - .../hadoop/hbase/TableNotFoundException.java| 2 - .../hadoop/hbase/UnknownRegionException.java| 2 - .../hadoop/hbase/UnknownScannerException.java | 2 - .../hbase/ZooKeeperConnectionException.java | 2 - .../org/apache/hadoop/hbase/client/Admin.java | 2 - .../org/apache/hadoop/hbase/client/Append.java | 2 - .../apache/hadoop/hbase/client/AsyncAdmin.java | 2 - .../hadoop/hbase/client/AsyncConnection.java| 4 +- .../apache/hadoop/hbase/client/AsyncTable.java | 2 - .../hadoop/hbase/client/AsyncTableBase.java | 2 - .../hadoop/hbase/client/AsyncTableBuilder.java | 2 - .../hbase/client/AsyncTableRegionLocator.java | 2 - .../apache/hadoop/hbase/client/Attributes.java | 2 - .../hadoop/hbase/client/BufferedMutator.java| 3 - .../hbase/client/BufferedMutatorParams.java | 2 - .../apache/hadoop/hbase/client/CompactType.java | 4 +- .../hadoop/hbase/client/CompactionState.java| 2 - .../apache/hadoop/hbase/client/Connection.java | 2 - .../hadoop/hbase/client/ConnectionFactory.java | 2 - .../apache/hadoop/hbase/client/Consistency.java | 2 - .../org/apache/hadoop/hbase/client/Delete.java | 2 - .../hbase/client/DoNotRetryRegionException.java | 2 - .../apache/hadoop/hbase/client/Durability.java | 2 - .../org/apache/hadoop/hbase/client/Get.java | 2 - .../hadoop/hbase/client/HTableMultiplexer.java | 3 - .../apache/hadoop/hbase/client/Increment.java | 2 - .../hadoop/hbase/client/IsolationLevel.java | 2 - .../hadoop/hbase/client/MasterSwitchType.java | 4 +- .../hbase/client/MobCompactPartitionPolicy.java | 2 - .../apache/hadoop/hbase/client/Mutation.java| 2 - .../client/NoServerForRegionException.java | 2 - .../apache/hadoop/hbase/client/Operation.java | 2 - .../hbase/client/OperationWithAttributes.java | 2 - .../org/apache/hadoop/hbase/client/Put.java | 2 - .../org/apache/hadoop/hbase/client/Query.java | 4 +- .../hadoop/hbase/client/RawAsyncTable.java | 4 - .../hbase/client/RawScanResultConsumer.java | 6 +- .../hadoop/hbase/client/RegionLoadStats.java| 2 - .../hadoop/hbase/client/RegionLocator.java | 2 - .../hbase/client/RegionOfflineException.java| 2 - .../hadoop/hbase/client/RequestController.java | 4 - .../hbase/client/RequestControllerFactory.java | 2 - .../org/apache/hadoop/hbase/client/Result.java | 2 - .../hadoop/hbase/client/ResultScanner.java | 2 -
[21/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
http://git-wip-us.apache.org/repos/asf/hbase/blob/5def44f5/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index 01ba8f6..71980b1 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -239,12 +239,20 @@ public final class QuotaProtos { * THROTTLE = 1; */ THROTTLE(1), +/** + * SPACE = 2; + */ +SPACE(2), ; /** * THROTTLE = 1; */ public static final int THROTTLE_VALUE = 1; +/** + * SPACE = 2; + */ +public static final int SPACE_VALUE = 2; public final int getNumber() { @@ -262,6 +270,7 @@ public final class QuotaProtos { public static QuotaType forNumber(int value) { switch (value) { case 1: return THROTTLE; +case 2: return SPACE; default: return null; } } @@ -311,6 +320,150 @@ public final class QuotaProtos { // @@protoc_insertion_point(enum_scope:hbase.pb.QuotaType) } + /** + * + * Defines what action should be taken when the SpaceQuota is violated + * + * + * Protobuf enum {@code hbase.pb.SpaceViolationPolicy} + */ + public enum SpaceViolationPolicy + implements org.apache.hadoop.hbase.shaded.com.google.protobuf.ProtocolMessageEnum { +/** + * + * Disable the table(s) + * + * + * DISABLE = 1; + */ +DISABLE(1), +/** + * + * No writes, bulk-loads, or compactions + * + * + * NO_WRITES_COMPACTIONS = 2; + */ +NO_WRITES_COMPACTIONS(2), +/** + * + * No writes or bulk-loads + * + * + * NO_WRITES = 3; + */ +NO_WRITES(3), +/** + * + * No puts or bulk-loads, but deletes are allowed + * + * + * NO_INSERTS = 4; + */ +NO_INSERTS(4), +; + +/** + * + * Disable the table(s) + * + * + * DISABLE = 1; + */ +public static final int DISABLE_VALUE = 1; +/** + * + * No writes, bulk-loads, or compactions + * + * + * NO_WRITES_COMPACTIONS = 2; + */ +public static final int NO_WRITES_COMPACTIONS_VALUE = 2; +/** + * + * No writes or bulk-loads + * + * + * NO_WRITES = 3; + */ +public static final int NO_WRITES_VALUE = 3; +/** + * + * No puts or bulk-loads, but deletes are allowed + * + * + * NO_INSERTS = 4; + */ +public static final int NO_INSERTS_VALUE = 4; + + +public final int getNumber() { + return value; +} + +/** + * @deprecated Use {@link #forNumber(int)} instead. + */ +@java.lang.Deprecated +public static SpaceViolationPolicy valueOf(int value) { + return forNumber(value); +} + +public static SpaceViolationPolicy forNumber(int value) { + switch (value) { +case 1: return DISABLE; +case 2: return NO_WRITES_COMPACTIONS; +case 3: return NO_WRITES; +case 4: return NO_INSERTS; +default: return null; + } +} + +public static org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap +internalGetValueMap() { + return internalValueMap; +} +private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap< +SpaceViolationPolicy> internalValueMap = + new org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap() { +public SpaceViolationPolicy findValueByNumber(int number) { + return SpaceViolationPolicy.forNumber(number); +} + }; + +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor +getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); +} +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumDescriptor +getDescriptorForType() { + return getDescriptor(); +} +public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumDescriptor +getDescriptor() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.getDescriptor().getEnumTypes().get(3); +} + +private static final SpaceViolationPolicy[] VALUES = values(); + +public static SpaceViolationPolicy valueOf( + org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { +throw new
[03/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes
http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java index 05f3556..f6817e7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshotException.java @@ -18,13 +18,11 @@ package org.apache.hadoop.hbase.snapshot; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Thrown when a snapshot could not be exported due to an error during the operation. */ @InterfaceAudience.Public -@InterfaceStability.Stable @SuppressWarnings("serial") public class ExportSnapshotException extends HBaseSnapshotException { http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java index 2fe58ed..bd185a1 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/HBaseSnapshotException.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.snapshot; import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.client.SnapshotDescription; /** @@ -27,7 +26,6 @@ import org.apache.hadoop.hbase.client.SnapshotDescription; */ @SuppressWarnings("serial") @InterfaceAudience.Public -@InterfaceStability.Evolving public class HBaseSnapshotException extends DoNotRetryIOException { private SnapshotDescription description; http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java index 70e8d3b..de58077 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotException.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.snapshot; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.client.SnapshotDescription; /** @@ -27,7 +26,6 @@ import org.apache.hadoop.hbase.client.SnapshotDescription; */ @SuppressWarnings("serial") @InterfaceAudience.Public -@InterfaceStability.Evolving public class RestoreSnapshotException extends HBaseSnapshotException { public RestoreSnapshotException(String msg, SnapshotDescription desc) { super(msg, desc); http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java index 2738b3d..9cfe83a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotCreationException.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.snapshot; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.client.SnapshotDescription; /** @@ -27,7 +26,6 @@ import org.apache.hadoop.hbase.client.SnapshotDescription; */ @SuppressWarnings("serial") @InterfaceAudience.Public -@InterfaceStability.Evolving public class SnapshotCreationException extends HBaseSnapshotException { /** http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDoesNotExistException.java -- diff --git
[52/54] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-protocol-shaded/src/main/protobuf/Admin.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Admin.proto b/hbase-protocol-shaded/src/main/protobuf/Admin.proto index 338c80b..1a085e6 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Admin.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Admin.proto @@ -28,6 +28,7 @@ option optimize_for = SPEED; import "ClusterStatus.proto"; import "HBase.proto"; import "WAL.proto"; +import "Quota.proto"; message GetRegionInfoRequest { required RegionSpecifier region = 1; @@ -314,4 +315,12 @@ service AdminService { rpc GetRegionLoad(GetRegionLoadRequest) returns(GetRegionLoadResponse); + + /** Fetches the RegionServer's view of space quotas */ + rpc GetSpaceQuotaSnapshots(GetSpaceQuotaSnapshotsRequest) +returns(GetSpaceQuotaSnapshotsResponse); + + /** Fetches the RegionServer's space quota active enforcements */ + rpc GetSpaceQuotaEnforcements(GetSpaceQuotaEnforcementsRequest) +returns(GetSpaceQuotaEnforcementsResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-protocol-shaded/src/main/protobuf/Master.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Master.proto b/hbase-protocol-shaded/src/main/protobuf/Master.proto index 4e856c8..58e6f77 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Master.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Master.proto @@ -929,4 +929,8 @@ service MasterService { /** Unmark a list of ServerNames marked as draining. */ rpc removeDrainFromRegionServers(RemoveDrainFromRegionServersRequest) returns(RemoveDrainFromRegionServersResponse); + + /** Fetches the Master's view of space quotas */ + rpc GetSpaceQuotaRegionSizes(GetSpaceQuotaRegionSizesRequest) +returns(GetSpaceQuotaRegionSizesResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-protocol-shaded/src/main/protobuf/Quota.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Quota.proto b/hbase-protocol-shaded/src/main/protobuf/Quota.proto index 597b059..2d7e5f5 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Quota.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Quota.proto @@ -111,3 +111,38 @@ message SpaceQuotaSnapshot { optional uint64 usage = 2; optional uint64 limit = 3; } + +message GetSpaceQuotaRegionSizesRequest { +} + +message GetSpaceQuotaRegionSizesResponse { + message RegionSizes { +optional TableName table_name = 1; +optional uint64 size = 2; + } + repeated RegionSizes sizes = 1; +} + +message GetSpaceQuotaSnapshotsRequest { +} + +message GetSpaceQuotaSnapshotsResponse { + // Cannot use TableName as a map key, do the repeated nested message by hand. + message TableQuotaSnapshot { +optional TableName table_name = 1; +optional SpaceQuotaSnapshot snapshot = 2; + } + repeated TableQuotaSnapshot snapshots = 1; +} + +message GetSpaceQuotaEnforcementsRequest { +} + +message GetSpaceQuotaEnforcementsResponse { + // Cannot use TableName as a map key, do the repeated nested message by hand. + message TableViolationPolicy { +optional TableName table_name = 1; +optional SpaceViolationPolicy violation_policy = 2; + } + repeated TableViolationPolicy violation_policies = 1; +} http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index a7a2f94..53560e9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -21,8 +21,11 @@ package org.apache.hadoop.hbase.master; import java.io.IOException; import java.net.InetAddress; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.apache.commons.logging.Log; @@ -211,6 +214,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest; +import
[23/54] [abbrv] hbase git commit: HBASE-17557 HRegionServer#reportRegionSizesForQuotas() should respond to UnsupportedOperationException
HBASE-17557 HRegionServer#reportRegionSizesForQuotas() should respond to UnsupportedOperationException Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b8c5387f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b8c5387f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b8c5387f Branch: refs/heads/HBASE-16961 Commit: b8c5387fa27e7f6816bacac8e8826085d04bd1a3 Parents: 2a21313 Author: tedyuAuthored: Mon Jan 30 07:47:40 2017 -0800 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../quotas/FileSystemUtilizationChore.java | 20 +--- .../hbase/regionserver/HRegionServer.java | 24 2 files changed, 36 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/b8c5387f/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java index 01540eb..efc17ff 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java @@ -53,6 +53,9 @@ public class FileSystemUtilizationChore extends ScheduledChore { static final String FS_UTILIZATION_MAX_ITERATION_DURATION_KEY = "hbase.regionserver.quotas.fs.utilization.chore.max.iteration.millis"; static final long FS_UTILIZATION_MAX_ITERATION_DURATION_DEFAULT = 5000L; + private int numberOfCyclesToSkip = 0, prevNumberOfCyclesToSkip = 0; + private static final int CYCLE_UPPER_BOUND = 32; + private final HRegionServer rs; private final long maxIterationMillis; private Iterator leftoverRegions; @@ -67,6 +70,10 @@ public class FileSystemUtilizationChore extends ScheduledChore { @Override protected void chore() { +if (numberOfCyclesToSkip > 0) { + numberOfCyclesToSkip--; + return; +} final Map onlineRegionSizes = new HashMap<>(); final Set onlineRegions = new HashSet<>(rs.getOnlineRegions()); // Process the regions from the last run if we have any. If we are somehow having difficulty @@ -126,7 +133,14 @@ public class FileSystemUtilizationChore extends ScheduledChore { + skippedSplitParents + " regions due to being the parent of a split, and" + skippedRegionReplicas + " regions due to being region replicas."); } -reportRegionSizesToMaster(onlineRegionSizes); +if (!reportRegionSizesToMaster(onlineRegionSizes)) { + // backoff reporting + numberOfCyclesToSkip = prevNumberOfCyclesToSkip > 0 ? 2 * prevNumberOfCyclesToSkip : 1; + if (numberOfCyclesToSkip > CYCLE_UPPER_BOUND) { +numberOfCyclesToSkip = CYCLE_UPPER_BOUND; + } + prevNumberOfCyclesToSkip = numberOfCyclesToSkip; +} } /** @@ -166,8 +180,8 @@ public class FileSystemUtilizationChore extends ScheduledChore { * * @param onlineRegionSizes The computed region sizes to report. */ - void reportRegionSizesToMaster(Map onlineRegionSizes) { -this.rs.reportRegionSizesForQuotas(onlineRegionSizes); + boolean reportRegionSizesToMaster(Map onlineRegionSizes) { +return this.rs.reportRegionSizesForQuotas(onlineRegionSizes); } /** http://git-wip-us.apache.org/repos/asf/hbase/blob/b8c5387f/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 9be4131..053e4ac 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -66,6 +66,7 @@ import org.apache.hadoop.hbase.ChoreService; import org.apache.hadoop.hbase.ClockOutOfSyncException; import org.apache.hadoop.hbase.CoordinatedStateManager; import org.apache.hadoop.hbase.CoordinatedStateManagerFactory; +import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.HConstants; @@ -1248,13 +1249,14 @@ public class HRegionServer extends HasThread implements * Reports the given map of Regions and their size on the filesystem to the active Master. * *
[15/54] [abbrv] hbase git commit: HBASE-17836 CellUtil#estimatedSerializedSizeOf is slow when input is ByteBufferCell
HBASE-17836 CellUtil#estimatedSerializedSizeOf is slow when input is ByteBufferCell Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1a701ce4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1a701ce4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1a701ce4 Branch: refs/heads/HBASE-16961 Commit: 1a701ce44484f45a8a07ea9826b84f0df6f1518e Parents: 48b2502 Author: Chia-Ping TsaiAuthored: Sat Apr 1 13:50:01 2017 +0800 Committer: Chia-Ping Tsai Committed: Fri Apr 7 09:30:15 2017 +0800 -- .../src/main/java/org/apache/hadoop/hbase/CellUtil.java | 8 +++- .../src/main/java/org/apache/hadoop/hbase/SplitLogTask.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/1a701ce4/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java index 6585173..e1bc969 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java @@ -1385,12 +1385,10 @@ public final class CellUtil { * @return Estimate of the cell size in bytes. */ public static int estimatedSerializedSizeOf(final Cell cell) { -// If a KeyValue, we can give a good estimate of size. -if (cell instanceof KeyValue) { - return ((KeyValue)cell).getLength() + Bytes.SIZEOF_INT; +if (cell instanceof ExtendedCell) { + return ((ExtendedCell) cell).getSerializedSize(true) + Bytes.SIZEOF_INT; } -// TODO: Should we add to Cell a sizeOf? Would it help? Does it make sense if Cell is -// prefix encoded or compressed? + return getSumOfCellElementLengths(cell) + // Use the KeyValue's infrastructure size presuming that another implementation would have // same basic cost. http://git-wip-us.apache.org/repos/asf/hbase/blob/1a701ce4/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java index 03d5108..3ecaa86 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java @@ -86,7 +86,7 @@ public class SplitLogTask { public ServerName getServerName() { return this.originServer; } - + public ZooKeeperProtos.SplitLogTask.RecoveryMode getMode() { return this.mode; }
[51/54] [abbrv] hbase git commit: HBASE-17447 Implement a MasterObserver for automatically deleting space quotas
HBASE-17447 Implement a MasterObserver for automatically deleting space quotas When a table or namespace is deleted, it would be nice to automatically delete the quota on said table/NS. It's possible that not all people would want this functionality so we can leave it up to the user to configure this Observer. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f46c16aa Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f46c16aa Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f46c16aa Branch: refs/heads/HBASE-16961 Commit: f46c16aa2f03ba07c2585e012e176852bd95 Parents: 59148f6 Author: Josh ElserAuthored: Thu Mar 16 18:54:01 2017 -0400 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../hbase/quotas/MasterSpaceQuotaObserver.java | 85 ++ .../quotas/TestMasterSpaceQuotaObserver.java| 169 +++ src/main/asciidoc/_chapters/ops_mgt.adoc| 17 ++ 3 files changed, 271 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/f46c16aa/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java new file mode 100644 index 000..a3abf32 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import java.io.IOException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.CoprocessorEnvironment; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; +import org.apache.hadoop.hbase.coprocessor.MasterObserver; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.master.MasterServices; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; + +/** + * An observer to automatically delete space quotas when a table/namespace + * are deleted. + */ +@InterfaceAudience.Private +public class MasterSpaceQuotaObserver implements MasterObserver { + private CoprocessorEnvironment cpEnv; + private Configuration conf; + private boolean quotasEnabled = false; + + @Override + public void start(CoprocessorEnvironment ctx) throws IOException { +this.cpEnv = ctx; +this.conf = cpEnv.getConfiguration(); +this.quotasEnabled = QuotaUtil.isQuotaEnabled(conf); + } + + @Override + public void postDeleteTable( + ObserverContext ctx, TableName tableName) throws IOException { +// Do nothing if quotas aren't enabled +if (!quotasEnabled) { + return; +} +final MasterServices master = ctx.getEnvironment().getMasterServices(); +final Connection conn = master.getConnection(); +Quotas quotas = QuotaUtil.getTableQuota(master.getConnection(), tableName); +if (null != quotas && quotas.hasSpace()) { + QuotaSettings settings = QuotaSettingsFactory.removeTableSpaceLimit(tableName); + try (Admin admin = conn.getAdmin()) { +admin.setQuota(settings); + } +} + } + + @Override + public void postDeleteNamespace( + ObserverContext ctx, String namespace) throws IOException { +// Do nothing if quotas aren't enabled +if (!quotasEnabled) { + return; +} +final MasterServices master = ctx.getEnvironment().getMasterServices(); +final Connection conn = master.getConnection(); +Quotas quotas = QuotaUtil.getNamespaceQuota(master.getConnection(), namespace); +if (null != quotas && quotas.hasSpace()) { +
[36/54] [abbrv] hbase git commit: HBASE-17025 Add shell commands for space quotas
HBASE-17025 Add shell commands for space quotas Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/bae29b64 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bae29b64 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bae29b64 Branch: refs/heads/HBASE-16961 Commit: bae29b64a8542f16f392b166ae78ebf3026698dd Parents: 79bf188 Author: Josh ElserAuthored: Wed Jan 11 11:55:29 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- hbase-shell/src/main/ruby/hbase/quotas.rb | 62 - hbase-shell/src/main/ruby/hbase_constants.rb| 1 + .../src/main/ruby/shell/commands/set_quota.rb | 45 +- .../hadoop/hbase/client/AbstractTestShell.java | 1 + hbase-shell/src/test/ruby/hbase/quotas_test.rb | 137 +++ hbase-shell/src/test/ruby/tests_runner.rb | 1 + 6 files changed, 242 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/bae29b64/hbase-shell/src/main/ruby/hbase/quotas.rb -- diff --git a/hbase-shell/src/main/ruby/hbase/quotas.rb b/hbase-shell/src/main/ruby/hbase/quotas.rb index bf2dc63..d99fe72 100644 --- a/hbase-shell/src/main/ruby/hbase/quotas.rb +++ b/hbase-shell/src/main/ruby/hbase/quotas.rb @@ -24,14 +24,22 @@ java_import org.apache.hadoop.hbase.quotas.ThrottleType java_import org.apache.hadoop.hbase.quotas.QuotaFilter java_import org.apache.hadoop.hbase.quotas.QuotaRetriever java_import org.apache.hadoop.hbase.quotas.QuotaSettingsFactory +java_import org.apache.hadoop.hbase.quotas.SpaceViolationPolicy module HBaseQuotasConstants + # RPC Quota constants GLOBAL_BYPASS = 'GLOBAL_BYPASS' THROTTLE_TYPE = 'THROTTLE_TYPE' THROTTLE = 'THROTTLE' REQUEST = 'REQUEST' WRITE = 'WRITE' READ = 'READ' + # Space quota constants + SPACE = 'SPACE' + NO_INSERTS = 'NO_INSERTS' + NO_WRITES = 'NO_WRITES' + NO_WRITES_COMPACTIONS = 'NO_WRITES_COMPACTIONS' + DISABLE = 'DISABLE' end module Hbase @@ -107,6 +115,54 @@ module Hbase @admin.setQuota(settings) end +def limit_space(args) + raise(ArgumentError, 'Argument should be a Hash') unless (not args.nil? and args.kind_of?(Hash)) + # Let the user provide a raw number + if args[LIMIT].is_a?(Numeric) +limit = args[LIMIT] + else +# Parse a string a 1K, 2G, etc. +limit = _parse_size(args[LIMIT]) + end + # Extract the policy, failing if something bogus was provided + policy = SpaceViolationPolicy.valueOf(args[POLICY]) + # Create a table or namespace quota + if args.key?(TABLE) +if args.key?(NAMESPACE) + raise(ArgumentError, "Only one of TABLE or NAMESPACE can be specified.") +end +settings = QuotaSettingsFactory.limitTableSpace(TableName.valueOf(args.delete(TABLE)), limit, policy) + elsif args.key?(NAMESPACE) +if args.key?(TABLE) + raise(ArgumentError, "Only one of TABLE or NAMESPACE can be specified.") +end +settings = QuotaSettingsFactory.limitNamespaceSpace(args.delete(NAMESPACE), limit, policy) + else +raise(ArgumentError, 'One of TABLE or NAMESPACE must be specified.') + end + # Apply the quota + @admin.setQuota(settings) +end + +def remove_space_limit(args) + raise(ArgumentError, 'Argument should be a Hash') unless (not args.nil? and args.kind_of?(Hash)) + if args.key?(TABLE) +if args.key?(NAMESPACE) + raise(ArgumentError, "Only one of TABLE or NAMESPACE can be specified.") +end +table = TableName.valueOf(args.delete(TABLE)) +settings = QuotaSettingsFactory.removeTableSpaceLimit(table) + elsif args.key?(NAMESPACE) +if args.key?(TABLE) + raise(ArgumentError, "Only one of TABLE or NAMESPACE can be specified.") +end +settings = QuotaSettingsFactory.removeNamespaceSpaceLimit(args.delete(NAMESPACE)) + else +raise(ArgumentError, 'One of TABLE or NAMESPACE must be specified.') + end + @admin.setQuota(settings) +end + def set_global_bypass(bypass, args) raise(ArgumentError, "Arguments should be a Hash") unless args.kind_of?(Hash) @@ -171,7 +227,7 @@ module Hbase return _size_from_str(match[1].to_i, match[2]) end else -raise "Invalid size limit syntax" +raise(ArgumentError, "Invalid size limit syntax") end end @@ -188,7 +244,7 @@ module Hbase end if limit <= 0 - raise "Invalid throttle limit, must be greater then 0" + raise(ArgumentError, "Invalid throttle limit, must be greater then 0") end
[40/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
http://git-wip-us.apache.org/repos/asf/hbase/blob/2a21313a/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto b/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto index 1c373ee..23ddd43 100644 --- a/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto +++ b/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto @@ -141,6 +141,22 @@ message SplitTableRegionResponse { optional uint64 proc_id = 1; } +message RegionSpaceUse { + optional RegionInfo region = 1; // A region identifier + optional uint64 size = 2; // The size in bytes of the region +} + +/** + * Reports filesystem usage for regions. + */ +message RegionSpaceUseReportRequest { + repeated RegionSpaceUse space_use = 1; +} + +message RegionSpaceUseReportResponse { + +} + service RegionServerStatusService { /** Called when a region server first starts. */ rpc RegionServerStartup(RegionServerStartupRequest) @@ -182,4 +198,10 @@ service RegionServerStatusService { */ rpc getProcedureResult(GetProcedureResultRequest) returns(GetProcedureResultResponse); + + /** + * Reports Region filesystem space use + */ + rpc ReportRegionSpaceUse(RegionSpaceUseReportRequest) +returns(RegionSpaceUseReportResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/2a21313a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index f86f800..f10d4bb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.mob.MobUtils; import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureUtil; +import org.apache.hadoop.hbase.quotas.MasterQuotaManager; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; @@ -216,6 +217,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse; @@ -2006,4 +2010,19 @@ public class MasterRpcServices extends RSRpcServices throw new ServiceException(e); } } + + @Override + public RegionSpaceUseReportResponse reportRegionSpaceUse(RpcController controller, + RegionSpaceUseReportRequest request) throws ServiceException { +try { + master.checkInitialized(); + MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); + for (RegionSpaceUse report : request.getSpaceUseList()) { +quotaManager.addRegionSize(HRegionInfo.convert(report.getRegion()), report.getSize()); + } + return RegionSpaceUseReportResponse.newBuilder().build(); +} catch (Exception e) { + throw new ServiceException(e); +} + } } http://git-wip-us.apache.org/repos/asf/hbase/blob/2a21313a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java new file mode 100644 index 000..01540eb --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or
[27/54] [abbrv] hbase git commit: HBASE-16999 Implement master and regionserver synchronization of quota state
HBASE-16999 Implement master and regionserver synchronization of quota state * Implement the RegionServer reading violation from the quota table * Implement the Master reporting violations to the quota table * RegionServers need to track its enforced policies Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4a715450 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4a715450 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4a715450 Branch: refs/heads/HBASE-16961 Commit: 4a7154502f8fd28af0fa4480aa3707a0a8459519 Parents: acf2153 Author: Josh ElserAuthored: Fri Nov 18 15:38:19 2016 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hadoop/hbase/quotas/QuotaTableUtil.java | 92 - .../org/apache/hadoop/hbase/master/HMaster.java | 35 +++- .../hadoop/hbase/quotas/QuotaObserverChore.java | 5 +- .../hbase/quotas/RegionServerQuotaManager.java | 200 --- .../quotas/RegionServerRpcQuotaManager.java | 200 +++ .../quotas/RegionServerSpaceQuotaManager.java | 169 .../quotas/SpaceQuotaViolationNotifier.java | 16 +- .../SpaceQuotaViolationNotifierFactory.java | 62 ++ .../SpaceQuotaViolationNotifierForTest.java | 4 + ...SpaceQuotaViolationPolicyRefresherChore.java | 154 ++ .../TableSpaceQuotaViolationNotifier.java | 55 + .../hbase/regionserver/HRegionServer.java | 21 +- .../hbase/regionserver/RSRpcServices.java | 7 +- .../regionserver/RegionServerServices.java | 12 +- .../hadoop/hbase/MockRegionServerServices.java | 10 +- .../hadoop/hbase/master/MockRegionServer.java | 10 +- .../TestQuotaObserverChoreWithMiniCluster.java | 2 + .../hadoop/hbase/quotas/TestQuotaTableUtil.java | 47 + .../hadoop/hbase/quotas/TestQuotaThrottle.java | 4 +- .../TestRegionServerSpaceQuotaManager.java | 127 ...SpaceQuotaViolationPolicyRefresherChore.java | 131 .../TestTableSpaceQuotaViolationNotifier.java | 144 + 22 files changed, 1281 insertions(+), 226 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/4a715450/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index 1640ddc..505e94b 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -23,16 +23,20 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; +import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; @@ -43,7 +47,12 @@ import org.apache.hadoop.hbase.filter.QualifierFilter; import org.apache.hadoop.hbase.filter.RegexStringComparator; import org.apache.hadoop.hbase.filter.RowFilter; import org.apache.hadoop.hbase.protobuf.ProtobufMagic; +import org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString; +import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException; +import org.apache.hadoop.hbase.shaded.com.google.protobuf.UnsafeByteOperations; +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Strings; @@ -52,9 +61,8 @@ import org.apache.hadoop.hbase.util.Strings; * * ROW-KEY FAM/QUALDATA * n.namespace q:s global-quotas - * n.namespace u:dusize in bytes * t.table q:s global-quotas - * t.table u:dusize in bytes + * t.table u:vspace violation policy * u.user q:s
[46/54] [abbrv] hbase git commit: HBASE-17003 Documentation updates for space quotas
HBASE-17003 Documentation updates for space quotas Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/95603567 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/95603567 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/95603567 Branch: refs/heads/HBASE-16961 Commit: 95603567a180f5c9a7d3e126435728cb1b561305 Parents: 51adf1e Author: Josh ElserAuthored: Thu Mar 16 16:21:14 2017 -0400 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- src/main/asciidoc/_chapters/ops_mgt.adoc | 64 ++- 1 file changed, 63 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/95603567/src/main/asciidoc/_chapters/ops_mgt.adoc -- diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc index e4c077f..f9009f3 100644 --- a/src/main/asciidoc/_chapters/ops_mgt.adoc +++ b/src/main/asciidoc/_chapters/ops_mgt.adoc @@ -1705,7 +1705,7 @@ handling multiple workloads: [[quota]] === Quotas -HBASE-11598 introduces quotas, which allow you to throttle requests based on +HBASE-11598 introduces RPC quotas, which allow you to throttle requests based on the following limits: . < > @@ -1885,6 +1885,68 @@ at the same time and that fewer scans can be executed at the same time. A value `0.9` will give more queue/handlers to scans, so the number of scans executed will increase and the number of gets will decrease. +[[space-quotas]] +=== Space Quotas + +link:https://issues.apache.org/jira/browse/HBASE-16961[HBASE-16961] introduces a new type of +quotas for HBase to leverage: filesystem quotas. These "space" quotas limit the amount of space +on the filesystem that HBase namespaces and tables can consume. If a user, malicious or ignorant, +has the ability to write data into HBase, with enough time, that user can effectively crash HBase +(or worse HDFS) by consuming all available space. When there is no filesystem space available, +HBase crashes because it can no longer create/sync data to the write-ahead log. + +This feature allows a for a limit to be set on the size of a table or namespace. When a space quota is set +on a namespace, the quota's limit applies to the sum of usage of all tables in that namespace. +When a table with a quota exists in a namespace with a quota, the table quota takes priority +over the namespace quota. This allows for a scenario where a large limit can be placed on +a collection of tables, but a single table in that collection can have a fine-grained limit set. + +The existing `set_quota` and `list_quota` HBase shell commands can be used to interact with +space quotas. Space quotas are quotas with a `TYPE` of `SPACE` and have `LIMIT` and `POLICY` +attributes. The `LIMIT` is a string that refers to the amount of space on the filesystem +that the quota subject (e.g. the table or namespace) may consume. For example, valid values +of `LIMIT` are `'10G'`, `'2T'`, or `'256M'`. The `POLICY` refers to the action that HBase will +take when the quota subject's usage exceeds the `LIMIT`. The following are valid `POLICY` values. + +* `NO_INSERTS` - No new data may be written (e.g. `Put`, `Increment`, `Append`). +* `NO_WRITES` - Same as `NO_INSERTS` but `Deletes` are also disallowed. +* `NO_WRITES_COMPACTIONS` - Same as `NO_WRITES` but compactions are also disallowed. +* `DISABLE` - The table(s) are disabled, preventing all read/write access. + +.Setting simple space quotas + +# Sets a quota on the table 't1' with a limit of 1GB, disallowing Puts/Increments/Appends when the table exceeds 1GB +hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => '1G', POLICY => NO_INSERTS + +# Sets a quota on the namespace 'ns1' with a limit of 50TB, disallowing Puts/Increments/Appends/Deletes +hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => '50T', POLICY => NO_WRITES + +# Sets a quota on the table 't3' with a limit of 2TB, disallowing any writes and compactions when the table exceeds 2TB. +hbase> set_quota TYPE => SPACE, TABLE => 't3', LIMIT => '2T', POLICY => NO_WRITES_COMPACTIONS + +# Sets a quota on the table 't2' with a limit of 50GB, disabling the table when it exceeds 50GB +hbase> set_quota TYPE => SPACE, TABLE => 't2', LIMIT => '50G', POLICY => DISABLE + + +Consider the following scenario to set up quotas on a namespace, overriding the quota on tables in that namespace + +.Table and Namespace space quotas + +hbase> create_namespace 'ns1' +hbase> create 'ns1:t1' +hbase> create 'ns1:t2' +hbase> create 'ns1:t3' +hbase> set_quota TYPE => SPACE, NAMESPACE =>
[42/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
HBASE-17000 Implement computation of online region sizes and report to the Master Includes a trivial implementation of the Master-side collection to avoid. Only enough to write a test to verify RS collection. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2a21313a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2a21313a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2a21313a Branch: refs/heads/HBASE-16961 Commit: 2a21313aac9a5a9e25b454949b08973bea650291 Parents: 76f3e7f Author: Josh ElserAuthored: Mon Nov 7 13:46:42 2016 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../generated/RegionServerStatusProtos.java | 2071 +- .../src/main/protobuf/RegionServerStatus.proto | 22 + .../hadoop/hbase/master/MasterRpcServices.java | 19 + .../quotas/FileSystemUtilizationChore.java | 205 ++ .../hadoop/hbase/quotas/MasterQuotaManager.java | 15 + .../hbase/regionserver/HRegionServer.java | 72 + .../quotas/TestFileSystemUtilizationChore.java | 357 +++ .../hadoop/hbase/quotas/TestRegionSizeUse.java | 194 ++ .../TestRegionServerRegionSpaceUseReport.java | 99 + 9 files changed, 3032 insertions(+), 22 deletions(-) --
[39/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages - addendum fixes line lengths (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages - addendum fixes line lengths (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/61301c47 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/61301c47 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/61301c47 Branch: refs/heads/HBASE-16961 Commit: 61301c47bc898650a48e7ac8e47930587f515367 Parents: 341b21a Author: tedyuAuthored: Mon Nov 21 13:00:27 2016 -0800 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 20 .../hadoop/hbase/quotas/SpaceLimitSettings.java | 8 .../hbase/shaded/protobuf/ProtobufUtil.java | 9 + 3 files changed, 21 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/61301c47/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 8512e39..7f1c180 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -128,7 +128,8 @@ public class QuotaSettingsFactory { static QuotaSettings fromSpace(TableName table, String namespace, SpaceQuota protoQuota) { if ((null == table && null == namespace) || (null != table && null != namespace)) { - throw new IllegalArgumentException("Can only construct SpaceLimitSettings for a table or namespace."); + throw new IllegalArgumentException( + "Can only construct SpaceLimitSettings for a table or namespace."); } if (null != table) { return SpaceLimitSettings.fromSpaceQuota(table, protoQuota); @@ -300,29 +301,32 @@ public class QuotaSettingsFactory { */ /** - * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table to the given size in bytes. - * When the space usage is exceeded by the table, the provided {@link SpaceViolationPolicy} is enacted on the table. + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table + * to the given size in bytes. When the space usage is exceeded by the table, the provided + * {@link SpaceViolationPolicy} is enacted on the table. * * @param tableName The name of the table on which the quota should be applied. * @param sizeLimit The limit of a table's size in bytes. * @param violationPolicy The action to take when the quota is exceeded. * @return An {@link QuotaSettings} object. */ - public static QuotaSettings limitTableSpace(final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { + public static QuotaSettings limitTableSpace( + final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(tableName, sizeLimit, violationPolicy); } /** - * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given namespace to the given size in bytes. - * When the space usage is exceeded by all tables in the namespace, the provided {@link SpaceViolationPolicy} is enacted on - * all tables in the namespace. + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given + * namespace to the given size in bytes. When the space usage is exceeded by all tables in the + * namespace, the provided {@link SpaceViolationPolicy} is enacted on all tables in the namespace. * * @param namespace The namespace on which the quota should be applied. * @param sizeLimit The limit of the namespace's size in bytes. * @param violationPolicy The action to take when the the quota is exceeded. * @return An {@link QuotaSettings} object. */ - public static QuotaSettings limitNamespaceSpace(final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { + public static QuotaSettings limitNamespaceSpace( + final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(namespace, sizeLimit, violationPolicy); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/61301c47/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java -- diff --git
[14/54] [abbrv] hbase git commit: HBASE-17816 HRegion#mutateRowWithLocks should update writeRequestCount metric (Weizhan Zeng)
HBASE-17816 HRegion#mutateRowWithLocks should update writeRequestCount metric (Weizhan Zeng) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/48b2502a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/48b2502a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/48b2502a Branch: refs/heads/HBASE-16961 Commit: 48b2502a5fcd4d3cd954c3abf6703422da7cdc2f Parents: af604f0 Author: Jerry HeAuthored: Thu Apr 6 16:45:45 2017 -0700 Committer: Jerry He Committed: Thu Apr 6 16:45:45 2017 -0700 -- .../hadoop/hbase/regionserver/HRegion.java | 1 + .../hadoop/hbase/regionserver/TestHRegion.java | 24 2 files changed, 25 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/48b2502a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 7f889ce..a87b679 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -6966,6 +6966,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi @Override public void mutateRowsWithLocks(Collection mutations, Collection rowsToLock, long nonceGroup, long nonce) throws IOException { +writeRequestsCount.add(mutations.size()); MultiRowMutationProcessor proc = new MultiRowMutationProcessor(mutations, rowsToLock); processRowsWithLocks(proc, -1, nonceGroup, nonce); } http://git-wip-us.apache.org/repos/asf/hbase/blob/48b2502a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index eac3c77..d56d6ec 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -6391,4 +6391,28 @@ public class TestHRegion { this.region = null; } } + + @Test + public void testMutateRow_WriteRequestCount() throws Exception { +byte[] row1 = Bytes.toBytes("row1"); +byte[] fam1 = Bytes.toBytes("fam1"); +byte[] qf1 = Bytes.toBytes("qualifier"); +byte[] val1 = Bytes.toBytes("value1"); + +RowMutations rm = new RowMutations(row1); +Put put = new Put(row1); +put.addColumn(fam1, qf1, val1); +rm.add(put); + +this.region = initHRegion(tableName, method, CONF, fam1); +try { + long wrcBeforeMutate = this.region.writeRequestsCount.longValue(); + this.region.mutateRow(rm); + long wrcAfterMutate = this.region.writeRequestsCount.longValue(); + Assert.assertEquals(wrcBeforeMutate + rm.getMutations().size(), wrcAfterMutate); +} finally { + HBaseTestingUtility.closeRegionAndWAL(this.region); + this.region = null; +} + } }
[37/54] [abbrv] hbase git commit: HBASE-16996 Implement storage/retrieval of filesystem-use quotas into quota table (Josh Elser)
HBASE-16996 Implement storage/retrieval of filesystem-use quotas into quota table (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/76f3e7fb Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/76f3e7fb Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/76f3e7fb Branch: refs/heads/HBASE-16961 Commit: 76f3e7fbd07f9db5b352cee28f3b08670cbccc3c Parents: 61301c4 Author: tedyuAuthored: Sat Dec 3 14:30:48 2016 -0800 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hadoop/hbase/quotas/QuotaTableUtil.java | 13 +- .../hadoop/hbase/quotas/MasterQuotaManager.java | 30 + .../hadoop/hbase/quotas/TestQuotaAdmin.java | 125 ++- 3 files changed, 165 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/76f3e7fb/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index 116dd0c..1640ddc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -52,7 +52,9 @@ import org.apache.hadoop.hbase.util.Strings; * * ROW-KEY FAM/QUALDATA * n.namespace q:s global-quotas + * n.namespace u:dusize in bytes * t.table q:s global-quotas + * t.table u:dusize in bytes * u.user q:s global-quotas * u.user q:s.table table-quotas * u.user q:s.ns: namespace-quotas @@ -71,6 +73,7 @@ public class QuotaTableUtil { protected static final byte[] QUOTA_FAMILY_USAGE = Bytes.toBytes("u"); protected static final byte[] QUOTA_QUALIFIER_SETTINGS = Bytes.toBytes("s"); protected static final byte[] QUOTA_QUALIFIER_SETTINGS_PREFIX = Bytes.toBytes("s."); + protected static final byte[] QUOTA_QUALIFIER_DISKUSAGE = Bytes.toBytes("du"); protected static final byte[] QUOTA_USER_ROW_KEY_PREFIX = Bytes.toBytes("u."); protected static final byte[] QUOTA_TABLE_ROW_KEY_PREFIX = Bytes.toBytes("t."); protected static final byte[] QUOTA_NAMESPACE_ROW_KEY_PREFIX = Bytes.toBytes("n."); @@ -298,11 +301,16 @@ public class QuotaTableUtil { * Quotas protobuf helpers */ protected static Quotas quotasFromData(final byte[] data) throws IOException { +return quotasFromData(data, 0, data.length); + } + + protected static Quotas quotasFromData( + final byte[] data, int offset, int length) throws IOException { int magicLen = ProtobufMagic.lengthOfPBMagic(); -if (!ProtobufMagic.isPBMagicPrefix(data, 0, magicLen)) { +if (!ProtobufMagic.isPBMagicPrefix(data, offset, magicLen)) { throw new IOException("Missing pb magic prefix"); } -return Quotas.parseFrom(new ByteArrayInputStream(data, magicLen, data.length - magicLen)); +return Quotas.parseFrom(new ByteArrayInputStream(data, offset + magicLen, length - magicLen)); } protected static byte[] quotasToData(final Quotas data) throws IOException { @@ -316,6 +324,7 @@ public class QuotaTableUtil { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); +hasSettings |= quotas.hasSpace(); return !hasSettings; } http://git-wip-us.apache.org/repos/asf/hbase/blob/76f3e7fb/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java index 5dab2e3..1469268 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java @@ -37,6 +37,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle; import
[01/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes [Forced Update!]
Repository: hbase Updated Branches: refs/heads/HBASE-16961 8271fd53f -> f46c16aa2 (forced update) http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.java index dc2fc0d..3c90b59 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiHFileOutputFormat.java @@ -16,7 +16,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -44,7 +43,6 @@ import com.google.common.annotations.VisibleForTesting; * */ @InterfaceAudience.Public -@InterfaceStability.Evolving @VisibleForTesting public class MultiHFileOutputFormat extends FileOutputFormat{ private static final Log LOG = LogFactory.getLog(MultiHFileOutputFormat.class); http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.java index 3099c0d..a8e6837 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormat.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.Scan; @@ -55,7 +54,6 @@ import org.apache.hadoop.hbase.client.Scan; * */ @InterfaceAudience.Public -@InterfaceStability.Evolving public class MultiTableInputFormat extends MultiTableInputFormatBase implements Configurable { http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java index 25ea047..e18b3aa 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java @@ -25,7 +25,6 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.TableName; @@ -54,7 +53,6 @@ import java.util.Iterator; * filters etc. Subclasses may use other TableRecordReader implementations. */ @InterfaceAudience.Public -@InterfaceStability.Evolving public abstract class MultiTableInputFormatBase extends InputFormat { http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java index 7feb7a9..4cc784f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java @@ -25,7 +25,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import
[10/54] [abbrv] hbase git commit: HBASE-17886 Fix compatibility of ServerSideScanMetrics
HBASE-17886 Fix compatibility of ServerSideScanMetrics Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d7e3116a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d7e3116a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d7e3116a Branch: refs/heads/HBASE-16961 Commit: d7e3116a1744057359ca48d94aa50d7fdf0db974 Parents: 17737b2 Author: Yu LiAuthored: Thu Apr 6 17:29:22 2017 +0800 Committer: Yu Li Committed: Thu Apr 6 17:29:22 2017 +0800 -- .../hadoop/hbase/client/metrics/ServerSideScanMetrics.java | 5 + 1 file changed, 5 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/d7e3116a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java index 8a96aeb..03764ed 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java @@ -49,6 +49,11 @@ public class ServerSideScanMetrics { public static final String COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME = "ROWS_SCANNED"; public static final String COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME = "ROWS_FILTERED"; + /** @deprecated Use {@link #COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME} instead */ + public static final String COUNT_OF_ROWS_SCANNED_KEY = COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME; + /** @deprecated Use {@link #COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME} instead */ + public static final String COUNT_OF_ROWS_FILTERED_KEY = COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME; + /** * number of rows filtered during scan RPC */
[34/54] [abbrv] hbase git commit: HBASE-17478 Avoid reporting FS use when quotas are disabled
HBASE-17478 Avoid reporting FS use when quotas are disabled Also, gracefully produce responses when quotas are disabled. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/376ac5d2 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/376ac5d2 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/376ac5d2 Branch: refs/heads/HBASE-16961 Commit: 376ac5d29b9ac1388256e5387fcbe30492fef13a Parents: bae29b6 Author: Josh ElserAuthored: Tue Jan 17 14:41:45 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hadoop/hbase/master/MasterRpcServices.java | 4 +++ .../hadoop/hbase/quotas/MasterQuotaManager.java | 13 +-- .../hbase/regionserver/HRegionServer.java | 5 ++- .../hbase/quotas/TestMasterQuotaManager.java| 37 4 files changed, 56 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/376ac5d2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index f10d4bb..a7a2f94 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -59,6 +59,7 @@ import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureUtil; import org.apache.hadoop.hbase.quotas.MasterQuotaManager; +import org.apache.hadoop.hbase.quotas.QuotaUtil; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; @@ -2016,6 +2017,9 @@ public class MasterRpcServices extends RSRpcServices RegionSpaceUseReportRequest request) throws ServiceException { try { master.checkInitialized(); + if (!QuotaUtil.isQuotaEnabled(master.getConfiguration())) { +return RegionSpaceUseReportResponse.newBuilder().build(); + } MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); for (RegionSpaceUse report : request.getSpaceUseList()) { quotaManager.addRegionSize(HRegionInfo.convert(report.getRegion()), report.getSize()); http://git-wip-us.apache.org/repos/asf/hbase/blob/376ac5d2/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java index a5832f9..cb614ea 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.quotas; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -58,6 +59,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota; @InterfaceStability.Evolving public class MasterQuotaManager implements RegionStateListener { private static final Log LOG = LogFactory.getLog(MasterQuotaManager.class); + private static final Map EMPTY_MAP = Collections.unmodifiableMap( + new HashMap<>()); private final MasterServices masterServices; private NamedLock namespaceLocks; @@ -529,13 +532,19 @@ public class MasterQuotaManager implements RegionStateListener { } public void addRegionSize(HRegionInfo hri, long size) { -// TODO Make proper API +if (null == regionSizes) { + return; +} +// TODO Make proper API? // TODO Prevent from growing indefinitely regionSizes.put(hri, size); } public Map snapshotRegionSizes() { -// TODO Make proper API +if (null == regionSizes) { + return EMPTY_MAP; +} +// TODO Make proper API? return new HashMap<>(regionSizes); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/376ac5d2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
[16/54] [abbrv] hbase git commit: HBASE-17881 Remove the ByteBufferCellImpl
HBASE-17881 Remove the ByteBufferCellImpl Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/18c5ecf6 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/18c5ecf6 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/18c5ecf6 Branch: refs/heads/HBASE-16961 Commit: 18c5ecf6ed57e80b32568ca1a1a12c7af36bab46 Parents: 1a701ce Author: Chia-Ping TsaiAuthored: Wed Apr 5 21:11:29 2017 +0800 Committer: Chia-Ping Tsai Committed: Fri Apr 7 21:14:19 2017 +0800 -- .../hadoop/hbase/filter/TestComparators.java| 14 +- .../hadoop/hbase/filter/TestKeyOnlyFilter.java | 4 +- .../apache/hadoop/hbase/TestCellComparator.java | 7 +- .../org/apache/hadoop/hbase/TestCellUtil.java | 184 +-- .../filter/TestSingleColumnValueFilter.java | 36 ++-- 5 files changed, 36 insertions(+), 209 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/18c5ecf6/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java -- diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java index d9e4033..0c69ece 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java @@ -21,11 +21,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.nio.ByteBuffer; +import org.apache.hadoop.hbase.ByteBufferKeyValue; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.TestCellUtil.ByteBufferCellImpl; import org.apache.hadoop.hbase.testclassification.MiscTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; @@ -51,18 +51,18 @@ public class TestComparators { // Row compare KeyValue kv = new KeyValue(r1, f, q1, v1); ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer()); -Cell bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); ByteArrayComparable comparable = new BinaryComparator(r1); assertEquals(0, CellComparator.compareRow(bbCell, comparable)); assertEquals(0, CellComparator.compareRow(kv, comparable)); kv = new KeyValue(r0, f, q1, v1); buffer = ByteBuffer.wrap(kv.getBuffer()); -bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); assertTrue(CellComparator.compareRow(bbCell, comparable) > 0); assertTrue(CellComparator.compareRow(kv, comparable) > 0); kv = new KeyValue(r2, f, q1, v1); buffer = ByteBuffer.wrap(kv.getBuffer()); -bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); assertTrue(CellComparator.compareRow(bbCell, comparable) < 0); assertTrue(CellComparator.compareRow(kv, comparable) < 0); // Qualifier compare @@ -71,12 +71,12 @@ public class TestComparators { assertEquals(0, CellComparator.compareQualifier(kv, comparable)); kv = new KeyValue(r2, f, q2, v1); buffer = ByteBuffer.wrap(kv.getBuffer()); -bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); assertEquals(0, CellComparator.compareQualifier(bbCell, comparable)); assertEquals(0, CellComparator.compareQualifier(kv, comparable)); kv = new KeyValue(r2, f, q3, v1); buffer = ByteBuffer.wrap(kv.getBuffer()); -bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); assertTrue(CellComparator.compareQualifier(bbCell, comparable) < 0); assertTrue(CellComparator.compareQualifier(kv, comparable) < 0); // Value compare @@ -85,7 +85,7 @@ public class TestComparators { assertEquals(0, CellComparator.compareValue(kv, comparable)); kv = new KeyValue(r1, f, q1, v2); buffer = ByteBuffer.wrap(kv.getBuffer()); -bbCell = new ByteBufferCellImpl(buffer, 0, buffer.remaining()); +bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); assertTrue(CellComparator.compareValue(bbCell, comparable) < 0); assertTrue(CellComparator.compareValue(kv, comparable) < 0); // Family compare
[48/54] [abbrv] hbase git commit: HBASE-17002 JMX metrics and some UI additions for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index 52e35ab..f71699d 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -13024,6 +13024,3031 @@ public final class QuotaProtos { } + public interface GetQuotaStatesRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:hbase.pb.GetQuotaStatesRequest) + org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code hbase.pb.GetQuotaStatesRequest} + */ + public static final class GetQuotaStatesRequest extends + org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:hbase.pb.GetQuotaStatesRequest) + GetQuotaStatesRequestOrBuilder { +// Use GetQuotaStatesRequest.newBuilder() to construct. +private GetQuotaStatesRequest(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); +} +private GetQuotaStatesRequest() { +} + +@java.lang.Override +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private GetQuotaStatesRequest( +org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input, + org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { + this(); + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.Builder unknownFields = + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} + } +} + } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException( +e).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor +getDescriptor() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetQuotaStatesRequest_descriptor; +} + +protected org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable +internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetQuotaStatesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesRequest.class, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesRequest.Builder.class); +} + +private byte memoizedIsInitialized = -1; +public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; +} + +public void writeTo(org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedOutputStream output) +throws java.io.IOException { + unknownFields.writeTo(output); +} + +public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; +} + +private static final long serialVersionUID = 0L; +@java.lang.Override +public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; +
[38/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages - addendum fixes white spaces (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages - addendum fixes white spaces (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/341b21ad Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/341b21ad Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/341b21ad Branch: refs/heads/HBASE-16961 Commit: 341b21ad7ba60e206868b40be8a73f217606420b Parents: 5def44f Author: tedyuAuthored: Thu Nov 17 10:42:18 2016 -0800 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hbase/quotas/TestQuotaSettingsFactory.java| 2 +- .../shaded/protobuf/generated/MasterProtos.java | 2 +- .../shaded/protobuf/generated/QuotaProtos.java| 18 +- .../hbase/protobuf/generated/QuotaProtos.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/341b21ad/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java -- diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java index 17015d6..e0012a7 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java @@ -44,7 +44,7 @@ import org.junit.experimental.categories.Category; */ @Category(SmallTests.class) public class TestQuotaSettingsFactory { - + @Test public void testAllQuotasAddedToList() { final SpaceQuota spaceQuota = SpaceQuota.newBuilder() http://git-wip-us.apache.org/repos/asf/hbase/blob/341b21ad/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java index 45ff86d..3c78980 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java @@ -63752,7 +63752,7 @@ public final class MasterProtos { * optional .hbase.pb.SpaceLimitRequest space_limit = 8; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequestOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequestOrBuilder> getSpaceLimitFieldBuilder() { if (spaceLimitBuilder_ == null) { spaceLimitBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< http://git-wip-us.apache.org/repos/asf/hbase/blob/341b21ad/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index 71980b1..4ceab07 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -4362,7 +4362,7 @@ public final class QuotaProtos { * optional .hbase.pb.SpaceQuota space = 3; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder,
[13/54] [abbrv] hbase git commit: HBASE-17869 UnsafeAvailChecker wrongly returns false on ppc
HBASE-17869 UnsafeAvailChecker wrongly returns false on ppc Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/af604f0c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/af604f0c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/af604f0c Branch: refs/heads/HBASE-16961 Commit: af604f0c0cf3c40c56746150ffa860aad07f128a Parents: 9109803 Author: Jerry HeAuthored: Thu Apr 6 16:04:47 2017 -0700 Committer: Jerry He Committed: Thu Apr 6 16:04:47 2017 -0700 -- .../hadoop/hbase/util/UnsafeAvailChecker.java | 24 1 file changed, 15 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/af604f0c/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java index 90e6ec8..886cb3c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java @@ -51,15 +51,21 @@ public class UnsafeAvailChecker { }); // When Unsafe itself is not available/accessible consider unaligned as false. if (avail) { - try { -// Using java.nio.Bits#unaligned() to check for unaligned-access capability -Class clazz = Class.forName("java.nio.Bits"); -Method m = clazz.getDeclaredMethod("unaligned"); -m.setAccessible(true); -unaligned = (Boolean) m.invoke(null); - } catch (Exception e) { -LOG.warn("java.nio.Bits#unaligned() check failed." -+ "Unsafe based read/write of primitive types won't be used", e); + String arch = System.getProperty("os.arch"); + if ("ppc64".equals(arch) || "ppc64le".equals(arch)) { +// java.nio.Bits.unaligned() wrongly returns false on ppc (JDK-8165231), +unaligned = true; + } else { +try { + // Using java.nio.Bits#unaligned() to check for unaligned-access capability + Class clazz = Class.forName("java.nio.Bits"); + Method m = clazz.getDeclaredMethod("unaligned"); + m.setAccessible(true); + unaligned = (Boolean) m.invoke(null); +} catch (Exception e) { + LOG.warn("java.nio.Bits#unaligned() check failed." + + "Unsafe based read/write of primitive types won't be used", e); +} } } }
[29/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java index c493b25..943c898 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -22,16 +22,12 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Random; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -40,20 +36,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import org.apache.hadoop.hbase.testclassification.LargeTests; -import org.apache.hadoop.hbase.util.Bytes; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -62,7 +53,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; -import com.google.common.collect.HashMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; @@ -72,11 +62,8 @@ import com.google.common.collect.Multimap; @Category(LargeTests.class) public class TestQuotaObserverChoreWithMiniCluster { private static final Log LOG = LogFactory.getLog(TestQuotaObserverChoreWithMiniCluster.class); - private static final int SIZE_PER_VALUE = 256; - private static final String F1 = "f1"; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final AtomicLong COUNTER = new AtomicLong(0); - private static final long ONE_MEGABYTE = 1024L * 1024L; private static final long DEFAULT_WAIT_MILLIS = 500; @Rule @@ -84,18 +71,19 @@ public class TestQuotaObserverChoreWithMiniCluster { private HMaster master; private QuotaObserverChore chore; - private SpaceQuotaViolationNotifierForTest violationNotifier; + private SpaceQuotaSnapshotNotifierForTest snapshotNotifier; + private SpaceQuotaHelperForTests helper; @BeforeClass public static void setUp() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_DELAY_KEY, 1000); conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_PERIOD_KEY, 1000); -conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_DELAY_KEY, 1000); -conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_PERIOD_KEY, 1000); +conf.setInt(QuotaObserverChore.QUOTA_OBSERVER_CHORE_DELAY_KEY, 1000); +conf.setInt(QuotaObserverChore.QUOTA_OBSERVER_CHORE_PERIOD_KEY, 1000); conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true); -conf.setClass(SpaceQuotaViolationNotifierFactory.VIOLATION_NOTIFIER_KEY, -SpaceQuotaViolationNotifierForTest.class, SpaceQuotaViolationNotifier.class); +conf.setClass(SpaceQuotaSnapshotNotifierFactory.SNAPSHOT_NOTIFIER_KEY, +SpaceQuotaSnapshotNotifierForTest.class, SpaceQuotaSnapshotNotifier.class); TEST_UTIL.startMiniCluster(1); } @@ -131,40 +119,55 @@ public class TestQuotaObserverChoreWithMiniCluster { } master = TEST_UTIL.getMiniHBaseCluster().getMaster(); -violationNotifier = -(SpaceQuotaViolationNotifierForTest) master.getSpaceQuotaViolationNotifier(); -violationNotifier.clearTableViolations(); +snapshotNotifier = +(SpaceQuotaSnapshotNotifierForTest) master.getSpaceQuotaSnapshotNotifier(); +snapshotNotifier.clearSnapshots(); chore = master.getQuotaObserverChore(); +
[49/54] [abbrv] hbase git commit: HBASE-17002 JMX metrics and some UI additions for space quotas
HBASE-17002 JMX metrics and some UI additions for space quotas Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/51adf1e8 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/51adf1e8 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/51adf1e8 Branch: refs/heads/HBASE-16961 Commit: 51adf1e81f56b2e0cf1a25922554cbcb0a9c67cf Parents: 39d1eca Author: Josh ElserAuthored: Wed Feb 15 14:24:57 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../hbase/client/ConnectionImplementation.java |8 + .../hadoop/hbase/client/QuotaStatusCalls.java | 39 +- .../client/ShortCircuitMasterConnection.java|8 + .../hadoop/hbase/quotas/QuotaTableUtil.java | 41 + .../hbase/shaded/protobuf/RequestConverter.java | 11 + .../hbase/master/MetricsMasterQuotaSource.java | 75 + .../master/MetricsMasterQuotaSourceFactory.java | 26 + .../hbase/master/MetricsMasterWrapper.java | 13 + .../MetricsRegionServerQuotaSource.java | 54 + .../MetricsMasterQuotaSourceFactoryImpl.java| 36 + .../master/MetricsMasterQuotaSourceImpl.java| 129 + ...hadoop.hbase.master.MetricsMasterQuotaSource | 18 + ...hbase.master.MetricsMasterQuotaSourceFactory | 18 + .../shaded/protobuf/generated/MasterProtos.java | 93 +- .../shaded/protobuf/generated/QuotaProtos.java | 3099 +- .../src/main/protobuf/Master.proto |6 +- .../src/main/protobuf/Quota.proto | 17 + .../org/apache/hadoop/hbase/master/HMaster.java |2 +- .../hadoop/hbase/master/MasterRpcServices.java | 38 + .../hadoop/hbase/master/MetricsMaster.java | 42 + .../hbase/master/MetricsMasterWrapperImpl.java | 42 +- .../hadoop/hbase/quotas/QuotaObserverChore.java | 92 +- .../resources/hbase-webapps/master/table.jsp| 59 + .../hbase/master/TestMasterMetricsWrapper.java | 17 + .../hbase/quotas/TestQuotaStatusRPCs.java | 83 + 25 files changed, 4032 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java index 3f27e1c..d9219f3 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java @@ -94,6 +94,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest; @@ -1740,6 +1742,12 @@ class ConnectionImplementation implements ClusterConnection, Closeable { throws ServiceException { return stub.getSpaceQuotaRegionSizes(controller, request); } + + @Override + public GetQuotaStatesResponse getQuotaStates( + RpcController controller, GetQuotaStatesRequest request) throws ServiceException { +return stub.getQuotaStates(controller, request); + } }; } http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java index f0f385d..af36d1e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java @@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.ipc.RpcControllerFactory; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import
[31/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 8b127d9..973ac8c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -37,9 +37,8 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.master.HMaster; -import org.apache.hadoop.hbase.quotas.QuotaViolationStore.ViolationState; -import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; -import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import com.google.common.annotations.VisibleForTesting; @@ -54,51 +53,51 @@ import com.google.common.collect.Multimap; @InterfaceAudience.Private public class QuotaObserverChore extends ScheduledChore { private static final Log LOG = LogFactory.getLog(QuotaObserverChore.class); - static final String VIOLATION_OBSERVER_CHORE_PERIOD_KEY = - "hbase.master.quotas.violation.observer.chore.period"; - static final int VIOLATION_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final String QUOTA_OBSERVER_CHORE_PERIOD_KEY = + "hbase.master.quotas.observer.chore.period"; + static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis - static final String VIOLATION_OBSERVER_CHORE_DELAY_KEY = - "hbase.master.quotas.violation.observer.chore.delay"; - static final long VIOLATION_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final String QUOTA_OBSERVER_CHORE_DELAY_KEY = + "hbase.master.quotas.observer.chore.delay"; + static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute - static final String VIOLATION_OBSERVER_CHORE_TIMEUNIT_KEY = - "hbase.master.quotas.violation.observer.chore.timeunit"; - static final String VIOLATION_OBSERVER_CHORE_TIMEUNIT_DEFAULT = TimeUnit.MILLISECONDS.name(); + static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY = + "hbase.master.quotas.observer.chore.timeunit"; + static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_DEFAULT = TimeUnit.MILLISECONDS.name(); - static final String VIOLATION_OBSERVER_CHORE_REPORT_PERCENT_KEY = - "hbase.master.quotas.violation.observer.report.percent"; - static final double VIOLATION_OBSERVER_CHORE_REPORT_PERCENT_DEFAULT= 0.95; + static final String QUOTA_OBSERVER_CHORE_REPORT_PERCENT_KEY = + "hbase.master.quotas.observer.report.percent"; + static final double QUOTA_OBSERVER_CHORE_REPORT_PERCENT_DEFAULT= 0.95; private final Connection conn; private final Configuration conf; private final MasterQuotaManager quotaManager; /* - * Callback that changes in quota violation are passed to. + * Callback that changes in quota snapshots are passed to. */ - private final SpaceQuotaViolationNotifier violationNotifier; + private final SpaceQuotaSnapshotNotifier snapshotNotifier; /* - * Preserves the state of quota violations for tables and namespaces + * Preserves the state of quota snapshots for tables and namespaces */ - private final MaptableQuotaViolationStates; - private final Map namespaceQuotaViolationStates; + private final Map tableQuotaSnapshots; + private final Map namespaceQuotaSnapshots; /* - * Encapsulates logic for moving tables/namespaces into or out of quota violation + * Encapsulates logic for tracking the state of a table/namespace WRT space quotas */ - private QuotaViolationStore tableViolationStore; - private QuotaViolationStore namespaceViolationStore; + private QuotaSnapshotStore tableSnapshotStore; + private QuotaSnapshotStore namespaceSnapshotStore; public QuotaObserverChore(HMaster master) { this( master.getConnection(), master.getConfiguration(), -master.getSpaceQuotaViolationNotifier(), master.getMasterQuotaManager(), +master.getSpaceQuotaSnapshotNotifier(), master.getMasterQuotaManager(), master); } QuotaObserverChore( - Connection conn, Configuration conf, SpaceQuotaViolationNotifier violationNotifier, + Connection conn, Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier,
[44/54] [abbrv] hbase git commit: HBASE-17568 Better handle stale/missing region size reports
HBASE-17568 Better handle stale/missing region size reports * Expire region reports in the master after a timeout. * Move regions in violation out of violation when insufficient region size reports are observed. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/39d1eca0 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/39d1eca0 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/39d1eca0 Branch: refs/heads/HBASE-16961 Commit: 39d1eca0bfc57e6ab720911748315c2a44d2cbac Parents: 10b004b Author: Josh ElserAuthored: Fri Feb 3 16:33:47 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../hadoop/hbase/master/MasterRpcServices.java | 4 +- .../hadoop/hbase/quotas/MasterQuotaManager.java | 86 ++- .../hadoop/hbase/quotas/QuotaObserverChore.java | 53 - .../hbase/quotas/TestMasterQuotaManager.java| 48 +++- .../TestQuotaObserverChoreRegionReports.java| 233 +++ 5 files changed, 412 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/39d1eca0/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index 53560e9..eb2711c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -251,6 +251,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.Updat import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.ForeignExceptionUtil; import org.apache.hadoop.hbase.util.Pair; import org.apache.zookeeper.KeeperException; @@ -2027,8 +2028,9 @@ public class MasterRpcServices extends RSRpcServices return RegionSpaceUseReportResponse.newBuilder().build(); } MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); + final long now = EnvironmentEdgeManager.currentTime(); for (RegionSpaceUse report : request.getSpaceUseList()) { -quotaManager.addRegionSize(HRegionInfo.convert(report.getRegion()), report.getSize()); +quotaManager.addRegionSize(HRegionInfo.convert(report.getRegion()), report.getSize(), now); } return RegionSpaceUseReportResponse.newBuilder().build(); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/hbase/blob/39d1eca0/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java index cb614ea..0622dba 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java @@ -22,9 +22,12 @@ import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.DoNotRetryIOException; @@ -47,6 +50,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.ThrottleRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota; +import com.google.common.annotations.VisibleForTesting; + /** * Master Quota Manager. * It is responsible for initialize the quota table on the first-run and @@ -68,7 +73,7 @@ public class MasterQuotaManager implements RegionStateListener { private NamedLock userLocks; private boolean enabled = false; private NamespaceAuditor namespaceQuotaManager; - private ConcurrentHashMap regionSizes; + private ConcurrentHashMap regionSizes; public MasterQuotaManager(final MasterServices masterServices) { this.masterServices = masterServices; @@ -531,21 +536,88 @@ public class
[53/54] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index 957d261..52e35ab 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -7476,6 +7476,5554 @@ public final class QuotaProtos { } + public interface GetSpaceQuotaRegionSizesRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:hbase.pb.GetSpaceQuotaRegionSizesRequest) + org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code hbase.pb.GetSpaceQuotaRegionSizesRequest} + */ + public static final class GetSpaceQuotaRegionSizesRequest extends + org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:hbase.pb.GetSpaceQuotaRegionSizesRequest) + GetSpaceQuotaRegionSizesRequestOrBuilder { +// Use GetSpaceQuotaRegionSizesRequest.newBuilder() to construct. +private GetSpaceQuotaRegionSizesRequest(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); +} +private GetSpaceQuotaRegionSizesRequest() { +} + +@java.lang.Override +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private GetSpaceQuotaRegionSizesRequest( +org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input, + org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { + this(); + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.Builder unknownFields = + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} + } +} + } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException( +e).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor +getDescriptor() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetSpaceQuotaRegionSizesRequest_descriptor; +} + +protected org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable +internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetSpaceQuotaRegionSizesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest.class, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest.Builder.class); +} + +private byte memoizedIsInitialized = -1; +public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; +} + +public void writeTo(org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedOutputStream output) +throws java.io.IOException { + unknownFields.writeTo(output); +} + +public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; +} + +private static final long serialVersionUID =
[47/54] [abbrv] hbase git commit: HBASE-17002 JMX metrics and some UI additions for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-protocol-shaded/src/main/protobuf/Master.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Master.proto b/hbase-protocol-shaded/src/main/protobuf/Master.proto index 58e6f77..90a7f07 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Master.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Master.proto @@ -930,7 +930,11 @@ service MasterService { rpc removeDrainFromRegionServers(RemoveDrainFromRegionServersRequest) returns(RemoveDrainFromRegionServersResponse); - /** Fetches the Master's view of space quotas */ + /** Fetches the Master's view of space utilization */ rpc GetSpaceQuotaRegionSizes(GetSpaceQuotaRegionSizesRequest) returns(GetSpaceQuotaRegionSizesResponse); + + /** Fetches the Master's view of quotas */ + rpc GetQuotaStates(GetQuotaStatesRequest) +returns(GetQuotaStatesResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-protocol-shaded/src/main/protobuf/Quota.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Quota.proto b/hbase-protocol-shaded/src/main/protobuf/Quota.proto index 2d7e5f5..1a6d5ed 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Quota.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Quota.proto @@ -119,6 +119,7 @@ message GetSpaceQuotaRegionSizesResponse { message RegionSizes { optional TableName table_name = 1; optional uint64 size = 2; + } repeated RegionSizes sizes = 1; } @@ -146,3 +147,19 @@ message GetSpaceQuotaEnforcementsResponse { } repeated TableViolationPolicy violation_policies = 1; } + +message GetQuotaStatesRequest { +} + +message GetQuotaStatesResponse { + message TableQuotaSnapshot { +optional TableName table_name = 1; +optional SpaceQuotaSnapshot snapshot = 2; + } + message NamespaceQuotaSnapshot { +optional string namespace = 1; +optional SpaceQuotaSnapshot snapshot = 2; + } + repeated TableQuotaSnapshot table_snapshots = 1; + repeated NamespaceQuotaSnapshot ns_snapshots = 2; +} http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 0243934..92c1461 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -908,7 +908,7 @@ public class HMaster extends HRegionServer implements MasterServices { // Create the quota snapshot notifier spaceQuotaSnapshotNotifier = createQuotaSnapshotNotifier(); spaceQuotaSnapshotNotifier.initialize(getClusterConnection()); - this.quotaObserverChore = new QuotaObserverChore(this); + this.quotaObserverChore = new QuotaObserverChore(this, getMasterMetrics()); // Start the chore to read the region FS space reports and act on them getChoreService().scheduleChore(quotaObserverChore); } http://git-wip-us.apache.org/repos/asf/hbase/blob/51adf1e8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index eb2711c..1c4abc0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -62,7 +62,9 @@ import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureUtil; import org.apache.hadoop.hbase.quotas.MasterQuotaManager; +import org.apache.hadoop.hbase.quotas.QuotaObserverChore; import org.apache.hadoop.hbase.quotas.QuotaUtil; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; @@ -214,8 +216,12 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse; +import
[54/54] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
HBASE-17428 Implement informational RPCs for space quotas Create some RPCs that can expose the in-memory state that the RegionServers and Master hold to drive the space quota "state machine". Then, create some hbase shell commands to interact with those. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a1ffeea4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a1ffeea4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a1ffeea4 Branch: refs/heads/HBASE-16961 Commit: a1ffeea4aac904f449fc9cdb3a7a3f57c09052b3 Parents: 376ac5d Author: Josh ElserAuthored: Tue Feb 21 15:36:39 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../hbase/client/ConnectionImplementation.java |9 + .../hadoop/hbase/client/QuotaStatusCalls.java | 125 + .../client/ShortCircuitMasterConnection.java|7 + .../hadoop/hbase/quotas/QuotaTableUtil.java | 77 + .../hbase/shaded/protobuf/RequestConverter.java | 33 + .../shaded/protobuf/generated/AdminProtos.java | 394 +- .../shaded/protobuf/generated/MasterProtos.java | 92 +- .../shaded/protobuf/generated/QuotaProtos.java | 5686 +- .../src/main/protobuf/Admin.proto |9 + .../src/main/protobuf/Master.proto |4 + .../src/main/protobuf/Quota.proto | 35 + .../hadoop/hbase/master/MasterRpcServices.java | 40 + .../hbase/quotas/ActivePolicyEnforcement.java |8 + .../hbase/regionserver/RSRpcServices.java | 57 + .../hadoop/hbase/master/MockRegionServer.java | 18 + .../hbase/quotas/TestQuotaStatusRPCs.java | 192 + hbase-shell/src/main/ruby/hbase/quotas.rb | 16 + hbase-shell/src/main/ruby/shell.rb |3 + .../ruby/shell/commands/list_quota_snapshots.rb | 59 + .../shell/commands/list_quota_table_sizes.rb| 47 + .../shell/commands/list_quota_violations.rb | 48 + hbase-shell/src/test/ruby/hbase/quotas_test.rb | 24 - .../test/ruby/hbase/quotas_test_no_cluster.rb | 69 + 23 files changed, 6899 insertions(+), 153 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java index 99feb14..3f27e1c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java @@ -94,6 +94,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest; @@ -1731,6 +1733,13 @@ class ConnectionImplementation implements ClusterConnection, Closeable { ListReplicationPeersRequest request) throws ServiceException { return stub.listReplicationPeers(controller, request); } + + @Override + public GetSpaceQuotaRegionSizesResponse getSpaceQuotaRegionSizes( + RpcController controller, GetSpaceQuotaRegionSizesRequest request) + throws ServiceException { +return stub.getSpaceQuotaRegionSizes(controller, request); + } }; } http://git-wip-us.apache.org/repos/asf/hbase/blob/a1ffeea4/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java new file mode 100644 index 000..f0f385d --- /dev/null +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/QuotaStatusCalls.java @@ -0,0 +1,125 @@ +/* + *
[50/54] [abbrv] hbase git commit: HBASE-17794 Swap "violation" for "snapshot" where appropriate
HBASE-17794 Swap "violation" for "snapshot" where appropriate A couple of variables and comments in which violation is incorrectly used to describe what the code is doing. This was a hold over from early implementation -- need to scrub these out for clarity. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/59148f64 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/59148f64 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/59148f64 Branch: refs/heads/HBASE-16961 Commit: 59148f64e03f6f7f33309a926be9fb3a43125e80 Parents: 9560356 Author: Josh ElserAuthored: Thu Mar 16 19:26:14 2017 -0400 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java| 4 ++-- hbase-protocol-shaded/src/main/protobuf/Quota.proto| 2 +- .../org/apache/hadoop/hbase/quotas/QuotaObserverChore.java | 6 +++--- .../apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.java| 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/59148f64/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index ed5da95..725f170 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -227,7 +227,7 @@ public class QuotaTableUtil { } /** - * Creates a {@link Scan} which returns only quota violations from the quota table. + * Creates a {@link Scan} which returns only quota snapshots from the quota table. */ public static Scan makeQuotaSnapshotScan() { Scan s = new Scan(); @@ -245,7 +245,7 @@ public class QuotaTableUtil { * will throw an {@link IllegalArgumentException}. * * @param result A row from the quota table. - * @param snapshots A map of violations to add the result of this method into. + * @param snapshots A map of snapshots to add the result of this method into. */ public static void extractQuotaSnapshot( Result result, Map snapshots) { http://git-wip-us.apache.org/repos/asf/hbase/blob/59148f64/hbase-protocol-shaded/src/main/protobuf/Quota.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Quota.proto b/hbase-protocol-shaded/src/main/protobuf/Quota.proto index 1a6d5ed..364c58b 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Quota.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Quota.proto @@ -98,7 +98,7 @@ message SpaceLimitRequest { } // Represents the state of a quota on a table. Either the quota is not in violation -// or it is in violatino there is a violation policy which should be in effect. +// or it is in violation there is a violation policy which should be in effect. message SpaceQuotaStatus { optional SpaceViolationPolicy policy = 1; optional bool in_violation = 2; http://git-wip-us.apache.org/repos/asf/hbase/blob/59148f64/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 94c5c87..254f2a1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -532,9 +532,9 @@ public class QuotaObserverChore extends ScheduledChore { } /** - * Stores the quota violation state for the given table. + * Stores the quota state for the given table. */ - void setTableQuotaViolation(TableName table, SpaceQuotaSnapshot snapshot) { + void setTableQuotaSnapshot(TableName table, SpaceQuotaSnapshot snapshot) { this.tableQuotaSnapshots.put(table, snapshot); } @@ -552,7 +552,7 @@ public class QuotaObserverChore extends ScheduledChore { } /** - * Stores the quota violation state for the given namespace. + * Stores the quota state for the given namespace. */ void setNamespaceQuotaSnapshot(String namespace, SpaceQuotaSnapshot snapshot) { this.namespaceQuotaSnapshots.put(namespace, snapshot);
[33/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
HBASE-17001 Enforce quota violation policies in the RegionServer The nuts-and-bolts of filesystem quotas. The Master must inform RegionServers of the violation of a quota by a table. The RegionServer must apply the violation policy as configured. Need to ensure that the proper interfaces exist to satisfy all necessary policies. This required a massive rewrite of the internal tracking by the general space quota feature. Instead of tracking "violations", we need to start tracking "usage". This allows us to make the decision at the RegionServer level as to when the files in a bulk load request should be accept or rejected which ultimately lets us avoid bulk loads dramatically exceeding a configured space quota. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7f42b498 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7f42b498 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7f42b498 Branch: refs/heads/HBASE-16961 Commit: 7f42b498c1cf8108f3eabd5b89b35e83443324f4 Parents: 4a71545 Author: Josh ElserAuthored: Thu Dec 15 13:27:56 2016 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hbase/quotas/QuotaExceededException.java|4 + .../hadoop/hbase/quotas/QuotaTableUtil.java | 47 +- .../hadoop/hbase/quotas/SpaceQuotaSnapshot.java | 192 +++ .../shaded/protobuf/generated/QuotaProtos.java | 1384 +- .../src/main/protobuf/Quota.proto | 15 + .../hbase/protobuf/generated/QuotaProtos.java | 1324 - hbase-protocol/src/main/protobuf/Quota.proto| 15 + .../org/apache/hadoop/hbase/master/HMaster.java | 29 +- .../hbase/quotas/ActivePolicyEnforcement.java | 86 ++ .../quotas/NamespaceQuotaSnapshotStore.java | 127 ++ .../quotas/NamespaceQuotaViolationStore.java| 127 -- .../hadoop/hbase/quotas/QuotaObserverChore.java | 344 +++-- .../hadoop/hbase/quotas/QuotaSnapshotStore.java | 96 ++ .../hbase/quotas/QuotaViolationStore.java | 89 -- .../quotas/RegionServerSpaceQuotaManager.java | 179 ++- .../hbase/quotas/SpaceLimitingException.java| 95 ++ .../hbase/quotas/SpaceQuotaRefresherChore.java | 225 +++ .../quotas/SpaceQuotaSnapshotNotifier.java | 45 + .../SpaceQuotaSnapshotNotifierFactory.java | 62 + .../quotas/SpaceQuotaViolationNotifier.java | 54 - .../SpaceQuotaViolationNotifierFactory.java | 62 - .../SpaceQuotaViolationNotifierForTest.java | 54 - ...SpaceQuotaViolationPolicyRefresherChore.java | 154 -- .../quotas/SpaceViolationPolicyEnforcement.java | 91 ++ .../SpaceViolationPolicyEnforcementFactory.java | 95 ++ .../hbase/quotas/TableQuotaSnapshotStore.java | 127 ++ .../hbase/quotas/TableQuotaViolationStore.java | 127 -- .../quotas/TableSpaceQuotaSnapshotNotifier.java | 52 + .../TableSpaceQuotaViolationNotifier.java | 55 - .../AbstractViolationPolicyEnforcement.java | 118 ++ ...LoadVerifyingViolationPolicyEnforcement.java | 50 + .../DisableTableViolationPolicyEnforcement.java | 80 + .../NoInsertsViolationPolicyEnforcement.java| 55 + ...esCompactionsViolationPolicyEnforcement.java | 64 + .../NoWritesViolationPolicyEnforcement.java | 54 + .../hbase/regionserver/CompactSplitThread.java | 12 + .../hbase/regionserver/RSRpcServices.java | 92 +- .../hbase/quotas/SpaceQuotaHelperForTests.java | 228 +++ .../SpaceQuotaSnapshotNotifierForTest.java | 55 + .../quotas/TestActivePolicyEnforcement.java | 74 + .../quotas/TestFileSystemUtilizationChore.java |3 +- .../TestNamespaceQuotaViolationStore.java | 16 +- .../hbase/quotas/TestQuotaObserverChore.java| 30 +- .../TestQuotaObserverChoreWithMiniCluster.java | 351 ++--- .../hadoop/hbase/quotas/TestQuotaTableUtil.java | 34 +- .../TestRegionServerSpaceQuotaManager.java | 174 ++- ...SpaceQuotaViolationPolicyRefresherChore.java | 193 ++- .../hadoop/hbase/quotas/TestSpaceQuotas.java| 452 ++ .../quotas/TestTableQuotaViolationStore.java| 22 +- .../TestTableSpaceQuotaViolationNotifier.java | 48 +- .../hbase/quotas/TestTablesWithQuotas.java |8 +- .../BaseViolationPolicyEnforcement.java | 31 + ...kLoadCheckingViolationPolicyEnforcement.java | 142 ++ ...tDisableTableViolationPolicyEnforcement.java | 59 + ...TestNoInsertsViolationPolicyEnforcement.java | 57 + ...esCompactionsViolationPolicyEnforcement.java | 58 + .../TestNoWritesViolationPolicyEnforcement.java | 57 + 57 files changed, 6492 insertions(+), 1481 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaExceededException.java
[41/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
http://git-wip-us.apache.org/repos/asf/hbase/blob/2a21313a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java index d7d4db0..e90c934 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java @@ -10164,6 +10164,1912 @@ public final class RegionServerStatusProtos { } + public interface RegionSpaceUseOrBuilder extends + // @@protoc_insertion_point(interface_extends:hbase.pb.RegionSpaceUse) + org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder { + +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ +boolean hasRegion(); +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ +org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo getRegion(); +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ + org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfoOrBuilder getRegionOrBuilder(); + +/** + * + * The size in bytes of the region + * + * + * optional uint64 size = 2; + */ +boolean hasSize(); +/** + * + * The size in bytes of the region + * + * + * optional uint64 size = 2; + */ +long getSize(); + } + /** + * Protobuf type {@code hbase.pb.RegionSpaceUse} + */ + public static final class RegionSpaceUse extends + org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:hbase.pb.RegionSpaceUse) + RegionSpaceUseOrBuilder { +// Use RegionSpaceUse.newBuilder() to construct. +private RegionSpaceUse(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); +} +private RegionSpaceUse() { + size_ = 0L; +} + +@java.lang.Override +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private RegionSpaceUse( +org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input, + org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.Builder unknownFields = + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} +case 10: { + org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo.Builder subBuilder = null; + if (((bitField0_ & 0x0001) == 0x0001)) { +subBuilder = region_.toBuilder(); + } + region_ = input.readMessage(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo.PARSER, extensionRegistry); + if (subBuilder != null) { +subBuilder.mergeFrom(region_); +region_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x0001; + break; +} +case 16: { + bitField0_ |= 0x0002; + size_ = input.readUInt64(); + break; +} + } +} + } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException( +e).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +
[17/54] [abbrv] hbase git commit: HBASE-17863-addendum: Reverted the order of updateStoreOnExec() and store.isRunning() in execProcedure()
HBASE-17863-addendum: Reverted the order of updateStoreOnExec() and store.isRunning() in execProcedure() Change-Id: I1c9d5ee264f4f593a6b2a09011853ab63693f677 Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/59e8b8e2 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/59e8b8e2 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/59e8b8e2 Branch: refs/heads/HBASE-16961 Commit: 59e8b8e2ba4d403d042fe4cc02f8f9f80aad67af Parents: 18c5ecf Author: Umesh AgasheAuthored: Fri Apr 7 14:01:37 2017 -0700 Committer: Apekshit Sharma Committed: Fri Apr 7 16:13:37 2017 -0700 -- .../hadoop/hbase/procedure2/ProcedureExecutor.java | 11 --- .../hadoop/hbase/procedure2/ProcedureTestingUtility.java | 2 +- .../procedure2/store/wal/TestWALProcedureStore.java | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/59e8b8e2/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java -- diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java index 8832637..43f5839 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java @@ -1373,12 +1373,17 @@ public class ProcedureExecutor { return; } - // if the store is not running we are aborting - if (!store.isRunning()) return; - + // TODO: The code here doesn't check if store is running before persisting to the store as + // it relies on the method call below to throw RuntimeException to wind up the stack and + // executor thread to stop. The statement following the method call below seems to check if + // store is not running, to prevent scheduling children procedures, re-execution or yield + // of this procedure. This may need more scrutiny and subsequent cleanup in future // Commit the transaction updateStoreOnExec(procStack, procedure, subprocs); + // if the store is not running we are aborting + if (!store.isRunning()) return; + // if the procedure is kind enough to pass the slot to someone else, yield if (procedure.isRunnable() && !suspended && procedure.isYieldAfterExecutionStep(getEnvironment())) { http://git-wip-us.apache.org/repos/asf/hbase/blob/59e8b8e2/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java -- diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java index 1f4244a..dd3c8f4 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java @@ -408,7 +408,7 @@ public class ProcedureTestingUtility { addStackIndex(index); } -public void setFinishedState() { +public void setSuccessState() { setState(ProcedureState.SUCCESS); } http://git-wip-us.apache.org/repos/asf/hbase/blob/59e8b8e2/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java -- diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java index f8c3486..525a663 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.apache.commons.logging.Log; @@ -785,7 +784,7 @@ public class TestWALProcedureStore { // back to A a.addStackId(5); -a.setFinishedState(); +a.setSuccessState(); procStore.delete(a, new long[] { b.getProcId(), c.getProcId() }); restartAndAssert(3, 0, 1, 0); }
[07/54] [abbrv] hbase git commit: HBASE-17854 Use StealJobQueue in HFileCleaner after HBASE-17215
HBASE-17854 Use StealJobQueue in HFileCleaner after HBASE-17215 Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cbcbcf4d Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cbcbcf4d Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cbcbcf4d Branch: refs/heads/HBASE-16961 Commit: cbcbcf4dcd3401327cc36173f3ca8e5362da1e0c Parents: a66d491 Author: Yu LiAuthored: Wed Apr 5 17:53:21 2017 +0800 Committer: Yu Li Committed: Wed Apr 5 17:53:21 2017 +0800 -- .../hbase/master/cleaner/HFileCleaner.java | 98 +--- .../apache/hadoop/hbase/util/StealJobQueue.java | 22 + .../hbase/master/cleaner/TestHFileCleaner.java | 28 +++--- .../hadoop/hbase/util/TestStealJobQueue.java| 2 +- 4 files changed, 102 insertions(+), 48 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/cbcbcf4d/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java index 3a68252..8b3515a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,6 +34,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Stoppable; import org.apache.hadoop.hbase.io.HFileLink; import org.apache.hadoop.hbase.regionserver.StoreFileInfo; +import org.apache.hadoop.hbase.util.StealJobQueue; import com.google.common.annotations.VisibleForTesting; /** @@ -57,23 +57,23 @@ public class HFileCleaner extends CleanerChore impleme "hbase.regionserver.thread.hfilecleaner.throttle"; public final static int DEFAULT_HFILE_DELETE_THROTTLE_THRESHOLD = 64 * 1024 * 1024;// 64M - // Configuration key for large queue size - public final static String LARGE_HFILE_DELETE_QUEUE_SIZE = + // Configuration key for large queue initial size + public final static String LARGE_HFILE_QUEUE_INIT_SIZE = "hbase.regionserver.hfilecleaner.large.queue.size"; - public final static int DEFAULT_LARGE_HFILE_DELETE_QUEUE_SIZE = 1048576; + public final static int DEFAULT_LARGE_HFILE_QUEUE_INIT_SIZE = 10240; - // Configuration key for small queue size - public final static String SMALL_HFILE_DELETE_QUEUE_SIZE = + // Configuration key for small queue initial size + public final static String SMALL_HFILE_QUEUE_INIT_SIZE = "hbase.regionserver.hfilecleaner.small.queue.size"; - public final static int DEFAULT_SMALL_HFILE_DELETE_QUEUE_SIZE = 1048576; + public final static int DEFAULT_SMALL_HFILE_QUEUE_INIT_SIZE = 10240; private static final Log LOG = LogFactory.getLog(HFileCleaner.class); - BlockingQueue largeFileQueue; + StealJobQueue largeFileQueue; BlockingQueue smallFileQueue; private int throttlePoint; - private int largeQueueSize; - private int smallQueueSize; + private int largeQueueInitSize; + private int smallQueueInitSize; private List threads = new ArrayList(); private boolean running; @@ -94,12 +94,12 @@ public class HFileCleaner extends CleanerChore impleme directory, MASTER_HFILE_CLEANER_PLUGINS, params); throttlePoint = conf.getInt(HFILE_DELETE_THROTTLE_THRESHOLD, DEFAULT_HFILE_DELETE_THROTTLE_THRESHOLD); -largeQueueSize = -conf.getInt(LARGE_HFILE_DELETE_QUEUE_SIZE, DEFAULT_LARGE_HFILE_DELETE_QUEUE_SIZE); -smallQueueSize = -conf.getInt(SMALL_HFILE_DELETE_QUEUE_SIZE, DEFAULT_SMALL_HFILE_DELETE_QUEUE_SIZE); -largeFileQueue = new LinkedBlockingQueue(largeQueueSize); -smallFileQueue = new LinkedBlockingQueue(smallQueueSize); +largeQueueInitSize = +conf.getInt(LARGE_HFILE_QUEUE_INIT_SIZE, DEFAULT_LARGE_HFILE_QUEUE_INIT_SIZE); +smallQueueInitSize = +conf.getInt(SMALL_HFILE_QUEUE_INIT_SIZE, DEFAULT_SMALL_HFILE_QUEUE_INIT_SIZE); +largeFileQueue = new StealJobQueue<>(largeQueueInitSize, smallQueueInitSize); +smallFileQueue = largeFileQueue.getStealFromQueue(); startHFileDeleteThreads(); } @@ -152,6 +152,7 @@ public class HFileCleaner extends CleanerChore impleme private boolean dispatch(HFileDeleteTask task) { if (task.fileLength >= this.throttlePoint) { if (!this.largeFileQueue.offer(task)) { +// should never
[43/54] [abbrv] hbase git commit: HBASE-17516 Correctly handle case where table and NS quotas both apply
HBASE-17516 Correctly handle case where table and NS quotas both apply The logic surrounding when a table and namespace quota both apply to a table was incorrect, leading to a case where a table quota violation which should have fired did not because of the less-strict namespace quota. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/36ee5796 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/36ee5796 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/36ee5796 Branch: refs/heads/HBASE-16961 Commit: 36ee57961bd1d6e10dcd9486e9de1b2c6257ceaf Parents: a1ffeea Author: Josh ElserAuthored: Wed Feb 22 18:32:55 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../hadoop/hbase/quotas/QuotaObserverChore.java | 10 ++- .../TestQuotaObserverChoreWithMiniCluster.java | 66 .../hbase/quotas/TestQuotaStatusRPCs.java | 21 ++- .../hadoop/hbase/quotas/TestSpaceQuotas.java| 32 +- 4 files changed, 97 insertions(+), 32 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/36ee5796/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 973ac8c..b9f4592 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -287,7 +287,8 @@ public class QuotaObserverChore extends ScheduledChore { // We want to have a policy of "NONE", moving out of violation if (!targetStatus.isInViolation()) { for (TableName tableInNS : tablesByNamespace.get(namespace)) { - if (!tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { + // If there is a quota on this table in violation + if (tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { // Table-level quota violation policy is being applied here. if (LOG.isTraceEnabled()) { LOG.trace("Not activating Namespace violation policy because a Table violation" @@ -298,16 +299,21 @@ public class QuotaObserverChore extends ScheduledChore { this.snapshotNotifier.transitionTable(tableInNS, targetSnapshot); } } + // We want to move into violation at the NS level } else { // Moving tables in the namespace into violation or to a different violation policy for (TableName tableInNS : tablesByNamespace.get(namespace)) { - if (tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { + final SpaceQuotaSnapshot tableQuotaSnapshot = +tableSnapshotStore.getCurrentState(tableInNS); + final boolean hasTableQuota = QuotaSnapshotStore.NO_QUOTA != tableQuotaSnapshot; + if (hasTableQuota && tableQuotaSnapshot.getQuotaStatus().isInViolation()) { // Table-level quota violation policy is being applied here. if (LOG.isTraceEnabled()) { LOG.trace("Not activating Namespace violation policy because a Table violation" + " policy is already in effect for " + tableInNS); } } else { +// No table quota present or a table quota present that is not in violation LOG.info(tableInNS + " moving into violation of namespace space quota with policy " + targetStatus.getPolicy()); this.snapshotNotifier.transitionTable(tableInNS, targetSnapshot); } http://git-wip-us.apache.org/repos/asf/hbase/blob/36ee5796/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java index 943c898..63198a8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -193,40 +193,42 @@ public class TestQuotaObserverChoreWithMiniCluster { helper.writeData(tn1, 2L * SpaceQuotaHelperForTests.ONE_MEGABYTE); admin.flush(tn1); -Map violatedQuotas =
[05/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes
http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java index eb1cbc5..179a566 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java @@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.io.TimeRange; import org.apache.hadoop.hbase.security.access.Permission; import org.apache.hadoop.hbase.security.visibility.CellVisibility; @@ -49,7 +48,6 @@ import org.apache.hadoop.hbase.util.ClassSize; * {@link #addColumn(byte[], byte[], long)} method. */ @InterfaceAudience.Public -@InterfaceStability.Stable public class Increment extends Mutation implements Comparable { private static final long HEAP_OVERHEAD = ClassSize.REFERENCE + ClassSize.TIMERANGE; private TimeRange tr = new TimeRange(); http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/client/IsolationLevel.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/IsolationLevel.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/IsolationLevel.java index 01aba6f..ad0897e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/IsolationLevel.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/IsolationLevel.java @@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.client; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Specify Isolation levels in Scan operations. @@ -33,7 +32,6 @@ import org.apache.hadoop.hbase.classification.InterfaceStability; * not have been committed yet. */ @InterfaceAudience.Public -@InterfaceStability.Stable public enum IsolationLevel { READ_COMMITTED(1), http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterSwitchType.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterSwitchType.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterSwitchType.java index 7e31b25..5fa9ec2 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterSwitchType.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterSwitchType.java @@ -17,13 +17,11 @@ */ package org.apache.hadoop.hbase.client; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Represents the master switch type */ @InterfaceAudience.Public -@InterfaceStability.Evolving public enum MasterSwitchType { SPLIT, MERGE -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MobCompactPartitionPolicy.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MobCompactPartitionPolicy.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MobCompactPartitionPolicy.java index f550572..076ab6f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MobCompactPartitionPolicy.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MobCompactPartitionPolicy.java @@ -19,13 +19,11 @@ package org.apache.hadoop.hbase.client; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Enum describing the mob compact partition policy types. */ @InterfaceAudience.Public -@InterfaceStability.Evolving public enum MobCompactPartitionPolicy { /** * Compact daily mob files into one file http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java index fb55fdd..b010c2f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java +++
[12/54] [abbrv] hbase git commit: HBASE-17863: Procedure V2: Some cleanup around Procedure.isFinished() and procedure executor
HBASE-17863: Procedure V2: Some cleanup around Procedure.isFinished() and procedure executor Signed-off-by: Michael StackProject: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/91098038 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/91098038 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/91098038 Branch: refs/heads/HBASE-16961 Commit: 9109803891e256f8c047af72572f07695e604a3f Parents: ec5188d Author: Umesh Agashe Authored: Mon Apr 3 17:37:41 2017 -0700 Committer: Michael Stack Committed: Thu Apr 6 12:05:23 2017 -0700 -- .../org/apache/hadoop/hbase/ProcedureState.java | 2 +- .../hadoop/hbase/procedure2/Procedure.java | 48 .../hbase/procedure2/ProcedureExecutor.java | 32 ++--- .../hadoop/hbase/procedure2/ProcedureUtil.java | 2 +- .../hbase/procedure2/store/ProcedureStore.java | 2 +- .../store/wal/ProcedureWALFormatReader.java | 19 .../procedure2/ProcedureTestingUtility.java | 4 +- ...ProcedureWALLoaderPerformanceEvaluation.java | 2 +- .../protobuf/generated/ProcedureProtos.java | 40 +++- .../src/main/protobuf/Procedure.proto | 3 +- .../master/procedure/TestProcedureAdmin.java| 5 +- 11 files changed, 92 insertions(+), 67 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/91098038/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureState.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureState.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureState.java index 5d95add..0080baa 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureState.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureState.java @@ -24,5 +24,5 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; */ @InterfaceAudience.Public public enum ProcedureState { - INITIALIZING, RUNNABLE, WAITING, WAITING_TIMEOUT, ROLLEDBACK, FINISHED; + INITIALIZING, RUNNABLE, WAITING, WAITING_TIMEOUT, ROLLEDBACK, SUCCESS, FAILED; } http://git-wip-us.apache.org/repos/asf/hbase/blob/91098038/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java -- diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java index 2a7fa6e..761ab3a 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java @@ -216,9 +216,9 @@ public abstract class Procedure implements Comparable { } /** - * By default, the executor will try ro run procedures start to finish. + * By default, the executor will try to run procedures start to finish. * Return true to make the executor yield between each execution step to - * give other procedures time to run their steps. + * give other procedures a chance to run. * @param env the environment passed to the ProcedureExecutor * @return Return true if the executor should yield on completion of an execution step. * Defaults to return false. @@ -271,7 +271,7 @@ public abstract class Procedure implements Comparable { toStringState(sb); if (hasException()) { - sb.append(", failed=" + getException()); + sb.append(", exception=" + getException()); } sb.append(", "); @@ -506,6 +506,25 @@ public abstract class Procedure implements Comparable { // == /** + * Procedure has states which are defined in proto file. At some places in the code, we + * need to determine more about those states. Following Methods help determine: + * + * {@link #isFailed()} - A procedure has executed at least once and has failed. The procedure + * may or may not have rolled back yet. Any procedure in FAILED state + * will be eventually moved to ROLLEDBACK state. + * + * {@link #isSuccess()} - A procedure is completed successfully without any exception. + * + * {@link #isFinished()} - As a procedure in FAILED state will be tried forever for rollback, only + * condition when scheduler/ executor will drop procedure from further + * processing is when procedure state is ROLLEDBACK or isSuccess() + * returns true. This is a terminal state of the procedure. + * + *
[09/54] [abbrv] hbase git commit: HBASE-17858 Update refguide about the IS annotation if necessary
HBASE-17858 Update refguide about the IS annotation if necessary Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/17737b27 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/17737b27 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/17737b27 Branch: refs/heads/HBASE-16961 Commit: 17737b2710a2a1271eb791478eb99f7a573ecac1 Parents: 029fa29 Author: zhangduoAuthored: Fri Mar 31 18:20:45 2017 +0800 Committer: zhangduo Committed: Thu Apr 6 09:48:18 2017 +0800 -- src/main/asciidoc/_chapters/upgrading.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/17737b27/src/main/asciidoc/_chapters/upgrading.adoc -- diff --git a/src/main/asciidoc/_chapters/upgrading.adoc b/src/main/asciidoc/_chapters/upgrading.adoc index df5bbfe..46f637d 100644 --- a/src/main/asciidoc/_chapters/upgrading.adoc +++ b/src/main/asciidoc/_chapters/upgrading.adoc @@ -128,7 +128,7 @@ for warning about incompatible changes). All effort will be made to provide a de HBase has a lot of API points, but for the compatibility matrix above, we differentiate between Client API, Limited Private API, and Private API. HBase uses a version of link:https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Compatibility.html[Hadoop's Interface classification]. HBase's Interface classification classes can be found link:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/classification/package-summary.html[here]. * InterfaceAudience: captures the intended audience, possible values are Public (for end users and external projects), LimitedPrivate (for other Projects, Coprocessors or other plugin points), and Private (for internal use). -* InterfaceStability: describes what types of interface changes are permitted. Possible values are Stable, Evolving, Unstable, and Deprecated. +* InterfaceStability: describes what types of interface changes are permitted. Possible values are Stable, Evolving, Unstable, and Deprecated. Notice that this annotation is only valid for classes which are marked as IA.LimitedPrivate. The stability of IA.Public classes is only related to the upgrade type(major, minor or patch). And for IA.Private classes, there is no guarantee on the stability between releases. Refer to the Compatibility Matrix above for more details. [[hbase.client.api]] HBase Client API::
[08/54] [abbrv] hbase git commit: HBASE-17785 RSGroupBasedLoadBalancer fails to assign new table regions when cloning snapshot
HBASE-17785 RSGroupBasedLoadBalancer fails to assign new table regions when cloning snapshot Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/029fa297 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/029fa297 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/029fa297 Branch: refs/heads/HBASE-16961 Commit: 029fa297129f7ced276d19c4877d19bf32dcfde0 Parents: cbcbcf4 Author: Andrew PurtellAuthored: Wed Apr 5 16:25:56 2017 -0700 Committer: Andrew Purtell Committed: Wed Apr 5 16:25:56 2017 -0700 -- .../hbase/rsgroup/RSGroupAdminEndpoint.java | 28 ++-- .../hadoop/hbase/rsgroup/TestRSGroups.java | 19 + 2 files changed, 39 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/029fa297/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java -- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java index 83389e4..14907ba 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java @@ -67,6 +67,7 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveTablesR import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RSGroupAdminService; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.SnapshotDescription; @InterfaceAudience.Private public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService { @@ -267,14 +268,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService } } - / - // MasterObserver overrides - / - - // Assign table to default RSGroup. - @Override - public void preCreateTable(ObserverContext ctx, - HTableDescriptor desc, HRegionInfo[] regions) throws IOException { + void assignTableToGroup(HTableDescriptor desc) throws IOException { String groupName = master.getClusterSchema().getNamespace(desc.getTableName().getNamespaceAsString()) .getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP); @@ -292,6 +286,17 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService } } + / + // MasterObserver overrides + / + + // Assign table to default RSGroup. + @Override + public void preCreateTable(ObserverContext ctx, + HTableDescriptor desc, HRegionInfo[] regions) throws IOException { +assignTableToGroup(desc); + } + // Remove table from its RSGroup. @Override public void postDeleteTable(ObserverContext ctx, @@ -322,5 +327,12 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService NamespaceDescriptor ns) throws IOException { preCreateNamespace(ctx, ns); } + + @Override + public void preCloneSnapshot(ObserverContext ctx, + SnapshotDescription snapshot, HTableDescriptor desc) throws IOException { +assignTableToGroup(desc); + } + / } http://git-wip-us.apache.org/repos/asf/hbase/blob/029fa297/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java -- diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java index 3886684..d6bd43b 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.master.snapshot.SnapshotManager; import org.apache.hadoop.hbase.net.Address; import
[02/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes
http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawString.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawString.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawString.java index 7e3b350..b70e103 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawString.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawString.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.types; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Order; import org.apache.hadoop.hbase.util.PositionedByteRange; @@ -32,7 +31,6 @@ import org.apache.hadoop.hbase.util.PositionedByteRange; * @see RawStringTerminated */ @InterfaceAudience.Public -@InterfaceStability.Evolving public class RawString implements DataType { public static final RawString ASCENDING = new RawString(Order.ASCENDING); http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringFixedLength.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringFixedLength.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringFixedLength.java index d11bead..24a394c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringFixedLength.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringFixedLength.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.types; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.util.Order; /** @@ -31,7 +30,6 @@ import org.apache.hadoop.hbase.util.Order; * @see RawString */ @InterfaceAudience.Public -@InterfaceStability.Evolving public class RawStringFixedLength extends FixedLengthWrapper { /** http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringTerminated.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringTerminated.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringTerminated.java index 4d89d5b..408b57a 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringTerminated.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/RawStringTerminated.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.types; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.util.Order; /** @@ -33,7 +32,6 @@ import org.apache.hadoop.hbase.util.Order; * @see OrderedString */ @InterfaceAudience.Public -@InterfaceStability.Evolving public class RawStringTerminated extends TerminatedWrapper { /** http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-common/src/main/java/org/apache/hadoop/hbase/types/Struct.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/Struct.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/Struct.java index 550088a..eea64d9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/Struct.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/Struct.java @@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.types; import java.util.Iterator; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.util.Order; import org.apache.hadoop.hbase.util.PositionedByteRange; @@ -78,7 +77,6 @@ import org.apache.hadoop.hbase.util.PositionedByteRange; * @see DataType#isNullable() */ @InterfaceAudience.Public -@InterfaceStability.Evolving public class Struct implements DataType
[24/54] [abbrv] hbase git commit: HBASE-16998 Implement Master-side analysis of region space reports
http://git-wip-us.apache.org/repos/asf/hbase/blob/acf21536/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java new file mode 100644 index 000..98236c2 --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -0,0 +1,596 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.NamespaceNotFoundException; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.master.HMaster; +import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; +import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; + +/** + * Test class for {@link QuotaObserverChore} that uses a live HBase cluster. + */ +@Category(LargeTests.class) +public class TestQuotaObserverChoreWithMiniCluster { + private static final Log LOG = LogFactory.getLog(TestQuotaObserverChoreWithMiniCluster.class); + private static final int SIZE_PER_VALUE = 256; + private static final String F1 = "f1"; + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final AtomicLong COUNTER = new AtomicLong(0); + private static final long ONE_MEGABYTE = 1024L * 1024L; + private static final long DEFAULT_WAIT_MILLIS = 500; + + @Rule + public TestName testName = new TestName(); + + private HMaster master; + private QuotaObserverChore chore; + private SpaceQuotaViolationNotifierForTest violationNotifier; + + @BeforeClass + public static void setUp() throws Exception { +Configuration conf = TEST_UTIL.getConfiguration(); +conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_DELAY_KEY, 1000); +conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_PERIOD_KEY, 1000); +conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_DELAY_KEY, 1000); +conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_PERIOD_KEY, 1000); +conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true); +TEST_UTIL.startMiniCluster(1); + } + + @AfterClass + public static void tearDown() throws Exception { +TEST_UTIL.shutdownMiniCluster(); + } + + @Before + public void removeAllQuotas() throws Exception { +final Connection conn = TEST_UTIL.getConnection(); +
[18/54] [abbrv] hbase git commit: HBASE-17872 The MSLABImpl generates the invaild cells when unsafe is not availble
HBASE-17872 The MSLABImpl generates the invaild cells when unsafe is not availble Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/df96d328 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/df96d328 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/df96d328 Branch: refs/heads/HBASE-16961 Commit: df96d328fb9fa11f04f84607e9a23f254f513202 Parents: 59e8b8e Author: CHIA-PING TSAIAuthored: Sat Apr 8 17:37:37 2017 +0800 Committer: Chia-Ping Tsai Committed: Sun Apr 9 23:28:34 2017 +0800 -- .../hadoop/hbase/util/ByteBufferUtils.java | 30 ++-- .../hadoop/hbase/util/TestByteBufferUtils.java | 165 ++- .../hbase/util/TestFromClientSide3WoUnsafe.java | 43 + 3 files changed, 213 insertions(+), 25 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/df96d328/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java index ff4c843..34a4e02 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java @@ -43,15 +43,14 @@ import sun.nio.ch.DirectBuffer; @SuppressWarnings("restriction") @InterfaceAudience.Public public final class ByteBufferUtils { - // "Compressed integer" serialization helper constants. public final static int VALUE_MASK = 0x7f; public final static int NEXT_BIT_SHIFT = 7; public final static int NEXT_BIT_MASK = 1 << 7; @VisibleForTesting - static boolean UNSAFE_AVAIL = UnsafeAvailChecker.isAvailable(); + final static boolean UNSAFE_AVAIL = UnsafeAvailChecker.isAvailable(); @VisibleForTesting - static boolean UNSAFE_UNALIGNED = UnsafeAvailChecker.unaligned(); + final static boolean UNSAFE_UNALIGNED = UnsafeAvailChecker.unaligned(); private ByteBufferUtils() { } @@ -404,12 +403,11 @@ public final class ByteBufferUtils { } else if (UNSAFE_AVAIL) { UnsafeAccess.copy(in, sourceOffset, out, destinationOffset, length); } else { - int outOldPos = out.position(); - out.position(destinationOffset); + ByteBuffer outDup = out.duplicate(); + outDup.position(destinationOffset); ByteBuffer inDup = in.duplicate(); inDup.position(sourceOffset).limit(sourceOffset + length); - out.put(inDup); - out.position(outOldPos); + outDup.put(inDup); } return destinationOffset + length; } @@ -990,7 +988,7 @@ public final class ByteBufferUtils { /** * Copies bytes from given array's offset to length part into the given buffer. Puts the bytes - * to buffer's given position. + * to buffer's given position. This doesn't affact the position of buffer. * @param out * @param in * @param inOffset @@ -1003,16 +1001,15 @@ public final class ByteBufferUtils { } else if (UNSAFE_AVAIL) { UnsafeAccess.copy(in, inOffset, out, outOffset, length); } else { - int oldPos = out.position(); - out.position(outOffset); - out.put(in, inOffset, length); - out.position(oldPos); + ByteBuffer outDup = out.duplicate(); + outDup.position(outOffset); + outDup.put(in, inOffset, length); } } /** * Copies specified number of bytes from given offset of 'in' ByteBuffer to - * the array. + * the array. This doesn't affact the position of buffer. * @param out * @param in * @param sourceOffset @@ -1026,10 +1023,9 @@ public final class ByteBufferUtils { } else if (UNSAFE_AVAIL) { UnsafeAccess.copy(in, sourceOffset, out, destinationOffset, length); } else { - int oldPos = in.position(); - in.position(sourceOffset); - in.get(out, destinationOffset, length); - in.position(oldPos); + ByteBuffer inDup = in.duplicate(); + inDup.position(sourceOffset); + inDup.get(out, destinationOffset, length); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/df96d328/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java -- diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java index 053fb24..ee03c7b 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java @@ -27,14 +27,22 @@ import
[45/54] [abbrv] hbase git commit: HBASE-17602 Reduce some quota chore periods/delays
HBASE-17602 Reduce some quota chore periods/delays Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/10b004b7 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/10b004b7 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/10b004b7 Branch: refs/heads/HBASE-16961 Commit: 10b004b7240975d663a65a48d67bde386dd451d6 Parents: 36ee579 Author: Josh ElserAuthored: Tue Feb 7 11:21:08 2017 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:03 2017 -0400 -- .../java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java | 4 ++-- .../org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/10b004b7/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index b9f4592..7f894e4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -55,11 +55,11 @@ public class QuotaObserverChore extends ScheduledChore { private static final Log LOG = LogFactory.getLog(QuotaObserverChore.class); static final String QUOTA_OBSERVER_CHORE_PERIOD_KEY = "hbase.master.quotas.observer.chore.period"; - static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 1; // 1 minutes in millis static final String QUOTA_OBSERVER_CHORE_DELAY_KEY = "hbase.master.quotas.observer.chore.delay"; - static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 15L; // 15 seconds in millis static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY = "hbase.master.quotas.observer.chore.timeunit"; http://git-wip-us.apache.org/repos/asf/hbase/blob/10b004b7/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java index e1a2693..8587e79 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java @@ -44,11 +44,11 @@ public class SpaceQuotaRefresherChore extends ScheduledChore { static final String POLICY_REFRESHER_CHORE_PERIOD_KEY = "hbase.regionserver.quotas.policy.refresher.chore.period"; - static final int POLICY_REFRESHER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final int POLICY_REFRESHER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 1; // 1 minute in millis static final String POLICY_REFRESHER_CHORE_DELAY_KEY = "hbase.regionserver.quotas.policy.refresher.chore.delay"; - static final long POLICY_REFRESHER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final long POLICY_REFRESHER_CHORE_DELAY_DEFAULT = 1000L * 15L; // 15 seconds in millis static final String POLICY_REFRESHER_CHORE_TIMEUNIT_KEY = "hbase.regionserver.quotas.policy.refresher.chore.timeunit";
[22/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5def44f5 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5def44f5 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5def44f5 Branch: refs/heads/HBASE-16961 Commit: 5def44f5a187938034de1529060d679285d79edb Parents: 82d554e Author: tedyuAuthored: Thu Nov 17 10:19:52 2016 -0800 Committer: Josh Elser Committed: Tue Apr 11 13:10:01 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 47 + .../apache/hadoop/hbase/quotas/QuotaType.java |1 + .../hadoop/hbase/quotas/SpaceLimitSettings.java | 166 ++ .../hbase/quotas/SpaceViolationPolicy.java | 44 + .../hbase/shaded/protobuf/ProtobufUtil.java | 51 + .../hbase/quotas/TestQuotaSettingsFactory.java | 148 ++ .../hbase/quotas/TestSpaceLimitSettings.java| 119 ++ .../shaded/protobuf/generated/MasterProtos.java | 584 -- .../shaded/protobuf/generated/QuotaProtos.java | 1739 +- .../src/main/protobuf/Master.proto |2 + .../src/main/protobuf/Quota.proto | 21 + .../hbase/protobuf/generated/QuotaProtos.java | 1682 - hbase-protocol/src/main/protobuf/Quota.proto| 21 + 13 files changed, 4291 insertions(+), 334 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/5def44f5/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 3622a32..8512e39 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRe import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; @InterfaceAudience.Public public class QuotaSettingsFactory { @@ -89,6 +90,9 @@ public class QuotaSettingsFactory { if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } +if (quotas.hasSpace()) { + settings.add(fromSpace(tableName, namespace, quotas.getSpace())); +} return settings; } @@ -122,6 +126,18 @@ public class QuotaSettingsFactory { return settings; } + static QuotaSettings fromSpace(TableName table, String namespace, SpaceQuota protoQuota) { +if ((null == table && null == namespace) || (null != table && null != namespace)) { + throw new IllegalArgumentException("Can only construct SpaceLimitSettings for a table or namespace."); +} +if (null != table) { + return SpaceLimitSettings.fromSpaceQuota(table, protoQuota); +} else { + // namespace must be non-null + return SpaceLimitSettings.fromSpaceQuota(namespace, protoQuota); +} + } + /* == * RPC Throttle */ @@ -278,4 +294,35 @@ public class QuotaSettingsFactory { public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, bypassGlobals); } + + /* == + * FileSystem Space Settings + */ + + /** + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table to the given size in bytes. + * When the space usage is exceeded by the table, the provided {@link SpaceViolationPolicy} is enacted on the table. + * + * @param tableName The name of the table on which the quota should be applied. + * @param sizeLimit The limit of a table's size in bytes. + * @param violationPolicy The action to take when the quota is exceeded. + * @return An {@link QuotaSettings} object. + */ + public static QuotaSettings limitTableSpace(final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { +return new SpaceLimitSettings(tableName, sizeLimit, violationPolicy); + } + + /** + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given namespace to the given size in bytes. +
[25/54] [abbrv] hbase git commit: HBASE-16998 Implement Master-side analysis of region space reports
HBASE-16998 Implement Master-side analysis of region space reports Adds a new Chore to the Master that analyzes the reports that are sent by RegionServers. The Master must then, for all tables with quotas, determine the tables that are violating quotas and move those tables into violation. Similarly, tables no longer violating the quota can be moved out of violation. The Chore is the "stateful" bit, managing which tables are and are not in violation. Everything else is just performing computation and informing the Chore on the updated state. Added InterfaceAudience annotations and clean up the QuotaObserverChore constructor. Cleaned up some javadoc and QuotaObserverChore. Reuse the QuotaViolationStore impl objects. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/acf21536 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/acf21536 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/acf21536 Branch: refs/heads/HBASE-16961 Commit: acf215361d6a098184fc5ea8030bde2dfca56cc1 Parents: b8c5387 Author: Josh ElserAuthored: Tue Nov 8 18:55:12 2016 -0500 Committer: Josh Elser Committed: Tue Apr 11 13:10:02 2017 -0400 -- .../hadoop/hbase/quotas/QuotaRetriever.java | 27 +- .../org/apache/hadoop/hbase/master/HMaster.java | 20 + .../hadoop/hbase/quotas/MasterQuotaManager.java | 1 + .../quotas/NamespaceQuotaViolationStore.java| 127 .../hadoop/hbase/quotas/QuotaObserverChore.java | 618 +++ .../hbase/quotas/QuotaViolationStore.java | 89 +++ .../quotas/SpaceQuotaViolationNotifier.java | 44 ++ .../SpaceQuotaViolationNotifierForTest.java | 50 ++ .../hbase/quotas/TableQuotaViolationStore.java | 127 .../TestNamespaceQuotaViolationStore.java | 156 + .../hbase/quotas/TestQuotaObserverChore.java| 106 .../TestQuotaObserverChoreWithMiniCluster.java | 596 ++ .../hadoop/hbase/quotas/TestQuotaTableUtil.java | 4 - .../quotas/TestTableQuotaViolationStore.java| 151 + .../hbase/quotas/TestTablesWithQuotas.java | 198 ++ 15 files changed, 2305 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/acf21536/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java index cba6a24..b011cf4 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java @@ -22,6 +22,7 @@ import java.io.Closeable; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; +import java.util.Objects; import java.util.Queue; import org.apache.commons.logging.Log; @@ -54,11 +55,23 @@ public class QuotaRetriever implements Closeable, Iterable { private Connection connection; private Table table; - private QuotaRetriever() { + /** + * Should QutoaRetriever manage the state of the connection, or leave it be. + */ + private boolean isManagedConnection = false; + + QuotaRetriever() { } void init(final Configuration conf, final Scan scan) throws IOException { -this.connection = ConnectionFactory.createConnection(conf); +// Set this before creating the connection and passing it down to make sure +// it's cleaned up if we fail to construct the Scanner. +this.isManagedConnection = true; +init(ConnectionFactory.createConnection(conf), scan); + } + + void init(final Connection conn, final Scan scan) throws IOException { +this.connection = Objects.requireNonNull(conn); this.table = this.connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME); try { scanner = table.getScanner(scan); @@ -77,10 +90,14 @@ public class QuotaRetriever implements Closeable, Iterable { this.table.close(); this.table = null; } -if (this.connection != null) { - this.connection.close(); - this.connection = null; +// Null out the connection on close() even if we didn't explicitly close it +// to maintain typical semantics. +if (isManagedConnection) { + if (this.connection != null) { +this.connection.close(); + } } +this.connection = null; } public QuotaSettings next() throws IOException { http://git-wip-us.apache.org/repos/asf/hbase/blob/acf21536/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java -- diff --git
[04/54] [abbrv] hbase git commit: HBASE-17857 Remove IS annotations from IA.Public classes
http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java index 7aa807c..ed95a7d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException; import org.apache.hadoop.hbase.shaded.com.google.protobuf.UnsafeByteOperations; @@ -40,7 +39,6 @@ import com.google.common.base.Preconditions; * Use this filter to include the stop row, eg: [A,Z]. */ @InterfaceAudience.Public -@InterfaceStability.Stable public class InclusiveStopFilter extends FilterBase { private byte [] stopRowKey; private boolean done = false; http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/IncompatibleFilterException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/IncompatibleFilterException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/IncompatibleFilterException.java index 8eba03c..6410ab4 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/IncompatibleFilterException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/IncompatibleFilterException.java @@ -19,13 +19,11 @@ package org.apache.hadoop.hbase.filter; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Used to indicate a filter incompatibility */ @InterfaceAudience.Public -@InterfaceStability.Stable public class IncompatibleFilterException extends RuntimeException { private static final long serialVersionUID = 3236763276623198231L; http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InvalidRowFilterException.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InvalidRowFilterException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InvalidRowFilterException.java index 81aae0b..0406058 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InvalidRowFilterException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InvalidRowFilterException.java @@ -19,13 +19,11 @@ package org.apache.hadoop.hbase.filter; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; /** * Used to indicate an invalid RowFilter. */ @InterfaceAudience.Public -@InterfaceStability.Stable public class InvalidRowFilterException extends RuntimeException { private static final long serialVersionUID = 2667894046345657865L; http://git-wip-us.apache.org/repos/asf/hbase/blob/a66d4918/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java index adbf304..b082941 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.ByteBufferCell; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos; import org.apache.hadoop.hbase.util.Bytes; @@ -43,7 +42,6 @@ import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferE * the values. */ @InterfaceAudience.Public -@InterfaceStability.Stable public class KeyOnlyFilter extends FilterBase { boolean lenAsVal;
[32/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java index cc40536..d466e59 100644 --- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java @@ -5778,6 +5778,1284 @@ public final class QuotaProtos { // @@protoc_insertion_point(class_scope:hbase.pb.SpaceLimitRequest) } + public interface SpaceQuotaStatusOrBuilder + extends com.google.protobuf.MessageOrBuilder { + +// optional .hbase.pb.SpaceViolationPolicy policy = 1; +/** + * optional .hbase.pb.SpaceViolationPolicy policy = 1; + */ +boolean hasPolicy(); +/** + * optional .hbase.pb.SpaceViolationPolicy policy = 1; + */ + org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.SpaceViolationPolicy getPolicy(); + +// optional bool in_violation = 2; +/** + * optional bool in_violation = 2; + */ +boolean hasInViolation(); +/** + * optional bool in_violation = 2; + */ +boolean getInViolation(); + } + /** + * Protobuf type {@code hbase.pb.SpaceQuotaStatus} + * + * + * Represents the state of a quota on a table. Either the quota is not in violation + * or it is in violatino there is a violation policy which should be in effect. + * + */ + public static final class SpaceQuotaStatus extends + com.google.protobuf.GeneratedMessage + implements SpaceQuotaStatusOrBuilder { +// Use SpaceQuotaStatus.newBuilder() to construct. +private SpaceQuotaStatus(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); +} +private SpaceQuotaStatus(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + +private static final SpaceQuotaStatus defaultInstance; +public static SpaceQuotaStatus getDefaultInstance() { + return defaultInstance; +} + +public SpaceQuotaStatus getDefaultInstanceForType() { + return defaultInstance; +} + +private final com.google.protobuf.UnknownFieldSet unknownFields; +@java.lang.Override +public final com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private SpaceQuotaStatus( +com.google.protobuf.CodedInputStream input, +com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} +case 8: { + int rawValue = input.readEnum(); + org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.SpaceViolationPolicy value = org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.SpaceViolationPolicy.valueOf(rawValue); + if (value == null) { +unknownFields.mergeVarintField(1, rawValue); + } else { +bitField0_ |= 0x0001; +policy_ = value; + } + break; +} +case 16: { + bitField0_ |= 0x0002; + inViolation_ = input.readBool(); + break; +} + } +} + } catch (com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new com.google.protobuf.InvalidProtocolBufferException( +e.getMessage()).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +public static final com.google.protobuf.Descriptors.Descriptor +getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.internal_static_hbase_pb_SpaceQuotaStatus_descriptor; +} + +protected com.google.protobuf.GeneratedMessage.FieldAccessorTable +internalGetFieldAccessorTable() { + return
[28/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java new file mode 100644 index 000..ec8f1bf --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas.policies; + +import org.apache.hadoop.hbase.client.Append; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Increment; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.util.Bytes; + +public class BaseViolationPolicyEnforcement { + + static final Append APPEND = new Append(Bytes.toBytes("foo")); + static final Delete DELETE = new Delete(Bytes.toBytes("foo")); + static final Increment INCREMENT = new Increment(Bytes.toBytes("foo")); + static final Put PUT = new Put(Bytes.toBytes("foo")); +} http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java new file mode 100644 index 000..abe1b9d --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas.policies; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.quotas.SpaceLimitingException; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; +import org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement; +import org.apache.hadoop.hbase.regionserver.RegionServerServices; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(SmallTests.class) +public class TestBulkLoadCheckingViolationPolicyEnforcement { + + FileSystem fs; + RegionServerServices rss; + TableName tableName; + SpaceViolationPolicyEnforcement policy; + + @Before + public void setup() { +fs = mock(FileSystem.class); +rss = mock(RegionServerServices.class); +tableName = TableName.valueOf("foo"); +policy = new BulkLoadVerifyingViolationPolicyEnforcement(); + } + + @Test + public void testFilesUnderLimit() throws Exception { +final List paths = new ArrayList<>(); +final List
[30/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java new file mode 100644 index 000..6b754b9 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.classification.InterfaceStability; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; +import org.apache.hadoop.hbase.quotas.policies.BulkLoadVerifyingViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.DisableTableViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoInsertsViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoWritesCompactionsViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoWritesViolationPolicyEnforcement; +import org.apache.hadoop.hbase.regionserver.RegionServerServices; + +/** + * A factory class for instantiating {@link SpaceViolationPolicyEnforcement} instances. + */ +@InterfaceAudience.Private +@InterfaceStability.Evolving +public class SpaceViolationPolicyEnforcementFactory { + + private static final SpaceViolationPolicyEnforcementFactory INSTANCE = + new SpaceViolationPolicyEnforcementFactory(); + + private SpaceViolationPolicyEnforcementFactory() {} + + /** + * Returns an instance of this factory. + */ + public static SpaceViolationPolicyEnforcementFactory getInstance() { +return INSTANCE; + } + + /** + * Constructs the appropriate {@link SpaceViolationPolicyEnforcement} for tables that are + * in violation of their space quota. + */ + public SpaceViolationPolicyEnforcement create( + RegionServerServices rss, TableName tableName, SpaceQuotaSnapshot snapshot) { +SpaceViolationPolicyEnforcement enforcement; +SpaceQuotaStatus status = snapshot.getQuotaStatus(); +if (!status.isInViolation()) { + throw new IllegalArgumentException(tableName + " is not in violation. Snapshot=" + snapshot); +} +switch (status.getPolicy()) { + case DISABLE: +enforcement = new DisableTableViolationPolicyEnforcement(); +break; + case NO_WRITES_COMPACTIONS: +enforcement = new NoWritesCompactionsViolationPolicyEnforcement(); +break; + case NO_WRITES: +enforcement = new NoWritesViolationPolicyEnforcement(); +break; + case NO_INSERTS: +enforcement = new NoInsertsViolationPolicyEnforcement(); +break; + default: +throw new IllegalArgumentException("Unhandled SpaceViolationPolicy: " + status.getPolicy()); +} +enforcement.initialize(rss, tableName, snapshot); +return enforcement; + } + + /** + * Creates the "default" {@link SpaceViolationPolicyEnforcement} for a table that isn't in + * violation. This is used to have uniform policy checking for tables in and not quotas. + */ + public SpaceViolationPolicyEnforcement createWithoutViolation( + RegionServerServices rss, TableName tableName, SpaceQuotaSnapshot snapshot) { +SpaceQuotaStatus status = snapshot.getQuotaStatus(); +if (status.isInViolation()) { + throw new IllegalArgumentException( + tableName + " is in violation. Logic error. Snapshot=" + snapshot); +} +BulkLoadVerifyingViolationPolicyEnforcement enforcement = new BulkLoadVerifyingViolationPolicyEnforcement(); +enforcement.initialize(rss, tableName, snapshot); +return enforcement; + } +} http://git-wip-us.apache.org/repos/asf/hbase/blob/7f42b498/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.java
[11/54] [abbrv] hbase git commit: HBASE-17871 scan#setBatch(int) call leads wrong result of VerifyReplication
HBASE-17871 scan#setBatch(int) call leads wrong result of VerifyReplication Signed-off-by: tedyuProject: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ec5188df Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ec5188df Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ec5188df Branch: refs/heads/HBASE-16961 Commit: ec5188df3090d42088b6f4cb8f0c2fd49425f8c1 Parents: d7e3116 Author: Tomu Tsuruhara Authored: Wed Apr 5 21:42:28 2017 +0900 Committer: tedyu Committed: Thu Apr 6 07:00:13 2017 -0700 -- .../mapreduce/replication/VerifyReplication.java | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/ec5188df/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java index ba5966b..3f8317b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/replication/VerifyReplication.java @@ -77,7 +77,7 @@ public class VerifyReplication extends Configured implements Tool { private final static String PEER_CONFIG_PREFIX = NAME + ".peer."; static long startTime = 0; static long endTime = Long.MAX_VALUE; - static int batch = Integer.MAX_VALUE; + static int batch = -1; static int versions = -1; static String tableName = null; static String families = null; @@ -110,6 +110,7 @@ public class VerifyReplication extends Configured implements Tool { private int sleepMsBeforeReCompare; private String delimiter = ""; private boolean verbose = false; +private int batch = -1; /** * Map method that compares every scanned row with the equivalent from @@ -128,8 +129,11 @@ public class VerifyReplication extends Configured implements Tool { sleepMsBeforeReCompare = conf.getInt(NAME +".sleepMsBeforeReCompare", 0); delimiter = conf.get(NAME + ".delimiter", ""); verbose = conf.getBoolean(NAME +".verbose", false); +batch = conf.getInt(NAME + ".batch", -1); final Scan scan = new Scan(); -scan.setBatch(batch); +if (batch > 0) { + scan.setBatch(batch); +} scan.setCacheBlocks(false); scan.setCaching(conf.getInt(TableInputFormat.SCAN_CACHEDROWS, 1)); long startTime = conf.getLong(NAME + ".startTime", 0); @@ -329,6 +333,7 @@ public class VerifyReplication extends Configured implements Tool { conf.setLong(NAME+".endTime", endTime); conf.setInt(NAME +".sleepMsBeforeReCompare", sleepMsBeforeReCompare); conf.set(NAME + ".delimiter", delimiter); +conf.setInt(NAME + ".batch", batch); conf.setBoolean(NAME +".verbose", verbose); conf.setBoolean(NAME +".includeDeletedCells", includeDeletedCells); if (families != null) { @@ -356,6 +361,10 @@ public class VerifyReplication extends Configured implements Tool { Scan scan = new Scan(); scan.setTimeRange(startTime, endTime); scan.setRaw(includeDeletedCells); +scan.setCacheBlocks(false); +if (batch > 0) { + scan.setBatch(batch); +} if (versions >= 0) { scan.setMaxVersions(versions); LOG.info("Number of versions set to " + versions); @@ -503,7 +512,7 @@ public class VerifyReplication extends Configured implements Tool { private static void restoreDefaults() { startTime = 0; endTime = Long.MAX_VALUE; -batch = Integer.MAX_VALUE; +batch = -1; versions = -1; tableName = null; families = null; @@ -521,13 +530,15 @@ public class VerifyReplication extends Configured implements Tool { } System.err.println("Usage: verifyrep [--starttime=X]" + " [--endtime=Y] [--families=A] [--row-prefixes=B] [--delimiter=] [--recomparesleep=] " + -"[--verbose] "); +"[--batch=] [--verbose] "); System.err.println(); System.err.println("Options:"); System.err.println(" starttimebeginning of the time range"); System.err.println(" without endtime means from starttime to forever"); System.err.println(" endtime end of the time range"); System.err.println(" versions number of cell versions to verify"); +System.err.println(" batchbatch count for scan, " + +"note that result row counts will no longer be actual number of rows when you use this option");
[19/54] [abbrv] hbase git commit: HBASE-16477 Remove Writable interface and related code from WALEdit/WALKey
HBASE-16477 Remove Writable interface and related code from WALEdit/WALKey Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/82d554e3 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/82d554e3 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/82d554e3 Branch: refs/heads/HBASE-16961 Commit: 82d554e3783372cc6b05489452c815b57c06f6cd Parents: df96d32 Author: Enis SoztutarAuthored: Mon Apr 10 02:31:42 2017 -0700 Committer: Enis Soztutar Committed: Mon Apr 10 02:31:42 2017 -0700 -- .../regionserver/wal/KeyValueCompression.java | 133 -- .../hadoop/hbase/regionserver/wal/WALEdit.java | 136 +-- .../java/org/apache/hadoop/hbase/wal/WAL.java | 1 - .../org/apache/hadoop/hbase/wal/WALKey.java | 95 ++--- .../wal/TestKeyValueCompression.java| 116 5 files changed, 14 insertions(+), 467 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/82d554e3/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/KeyValueCompression.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/KeyValueCompression.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/KeyValueCompression.java deleted file mode 100644 index a33ff9e..000 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/KeyValueCompression.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hbase.regionserver.wal; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.io.WritableUtils; - -/** - * DO NOT USE. This class is deprecated and should only be used in pre-PB WAL. - * - * Compression class for {@link KeyValue}s written to the WAL. This is not - * synchronized, so synchronization should be handled outside. - * - * Class only compresses and uncompresses row keys, family names, and the - * qualifier. More may be added depending on use patterns. - */ -@Deprecated -@InterfaceAudience.Private -class KeyValueCompression { - /** - * Uncompresses a KeyValue from a DataInput and returns it. - * - * @param in the DataInput - * @param readContext the compressionContext to use. - * @return an uncompressed KeyValue - * @throws IOException - */ - - public static KeyValue readKV(DataInput in, CompressionContext readContext) - throws IOException { -int keylength = WritableUtils.readVInt(in); -int vlength = WritableUtils.readVInt(in); -int tagsLength = WritableUtils.readVInt(in); -int length = (int) KeyValue.getKeyValueDataStructureSize(keylength, vlength, tagsLength); - -byte[] backingArray = new byte[length]; -int pos = 0; -pos = Bytes.putInt(backingArray, pos, keylength); -pos = Bytes.putInt(backingArray, pos, vlength); - -// the row -int elemLen = Compressor.uncompressIntoArray(backingArray, -pos + Bytes.SIZEOF_SHORT, in, readContext.rowDict); -checkLength(elemLen, Short.MAX_VALUE); -pos = Bytes.putShort(backingArray, pos, (short)elemLen); -pos += elemLen; - -// family -elemLen = Compressor.uncompressIntoArray(backingArray, -pos + Bytes.SIZEOF_BYTE, in, readContext.familyDict); -checkLength(elemLen, Byte.MAX_VALUE); -pos = Bytes.putByte(backingArray, pos, (byte)elemLen); -pos += elemLen; - -// qualifier -elemLen = Compressor.uncompressIntoArray(backingArray, pos, in, -readContext.qualifierDict); -pos += elemLen; - -// the rest -in.readFully(backingArray, pos, length - pos); - -return new KeyValue(backingArray, 0, length); - } - - private static void checkLength(int len, int max) throws
[20/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
http://git-wip-us.apache.org/repos/asf/hbase/blob/5def44f5/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java index 05894b9..1925828 100644 --- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java @@ -217,12 +217,20 @@ public final class QuotaProtos { * THROTTLE = 1; */ THROTTLE(0, 1), +/** + * SPACE = 2; + */ +SPACE(1, 2), ; /** * THROTTLE = 1; */ public static final int THROTTLE_VALUE = 1; +/** + * SPACE = 2; + */ +public static final int SPACE_VALUE = 2; public final int getNumber() { return value; } @@ -230,6 +238,7 @@ public final class QuotaProtos { public static QuotaType valueOf(int value) { switch (value) { case 1: return THROTTLE; +case 2: return SPACE; default: return null; } } @@ -281,6 +290,142 @@ public final class QuotaProtos { // @@protoc_insertion_point(enum_scope:hbase.pb.QuotaType) } + /** + * Protobuf enum {@code hbase.pb.SpaceViolationPolicy} + * + * + * Defines what action should be taken when the SpaceQuota is violated + * + */ + public enum SpaceViolationPolicy + implements com.google.protobuf.ProtocolMessageEnum { +/** + * DISABLE = 1; + * + * + * Disable the table(s) + * + */ +DISABLE(0, 1), +/** + * NO_WRITES_COMPACTIONS = 2; + * + * + * No writes, bulk-loads, or compactions + * + */ +NO_WRITES_COMPACTIONS(1, 2), +/** + * NO_WRITES = 3; + * + * + * No writes or bulk-loads + * + */ +NO_WRITES(2, 3), +/** + * NO_INSERTS = 4; + * + * + * No puts or bulk-loads, but deletes are allowed + * + */ +NO_INSERTS(3, 4), +; + +/** + * DISABLE = 1; + * + * + * Disable the table(s) + * + */ +public static final int DISABLE_VALUE = 1; +/** + * NO_WRITES_COMPACTIONS = 2; + * + * + * No writes, bulk-loads, or compactions + * + */ +public static final int NO_WRITES_COMPACTIONS_VALUE = 2; +/** + * NO_WRITES = 3; + * + * + * No writes or bulk-loads + * + */ +public static final int NO_WRITES_VALUE = 3; +/** + * NO_INSERTS = 4; + * + * + * No puts or bulk-loads, but deletes are allowed + * + */ +public static final int NO_INSERTS_VALUE = 4; + + +public final int getNumber() { return value; } + +public static SpaceViolationPolicy valueOf(int value) { + switch (value) { +case 1: return DISABLE; +case 2: return NO_WRITES_COMPACTIONS; +case 3: return NO_WRITES; +case 4: return NO_INSERTS; +default: return null; + } +} + +public static com.google.protobuf.Internal.EnumLiteMap +internalGetValueMap() { + return internalValueMap; +} +private static com.google.protobuf.Internal.EnumLiteMap +internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { +public SpaceViolationPolicy findValueByNumber(int number) { + return SpaceViolationPolicy.valueOf(number); +} + }; + +public final com.google.protobuf.Descriptors.EnumValueDescriptor +getValueDescriptor() { + return getDescriptor().getValues().get(index); +} +public final com.google.protobuf.Descriptors.EnumDescriptor +getDescriptorForType() { + return getDescriptor(); +} +public static final com.google.protobuf.Descriptors.EnumDescriptor +getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.getDescriptor().getEnumTypes().get(3); +} + +private static final SpaceViolationPolicy[] VALUES = values(); + +public static SpaceViolationPolicy valueOf( +com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { +throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; +} + +private final int index; +private final int value; + +private SpaceViolationPolicy(int index, int value) { + this.index = index; + this.value = value; +} + +// @@protoc_insertion_point(enum_scope:hbase.pb.SpaceViolationPolicy) + } + public interface TimedQuotaOrBuilder extends com.google.protobuf.MessageOrBuilder { @@ -3315,6 +3460,20 @@ public final class QuotaProtos {
[12/54] [abbrv] hbase git commit: HBASE-17803 PE always re-creates table when we specify the split policy
HBASE-17803 PE always re-creates table when we specify the split policy Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/23abc900 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/23abc900 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/23abc900 Branch: refs/heads/HBASE-16961 Commit: 23abc90068f0ea75f09c3eecf6ef758f1aee9219 Parents: b299c13 Author: CHIA-PING TSAIAuthored: Sat Mar 18 12:20:07 2017 +0800 Committer: Chia-Ping Tsai Committed: Sun Mar 19 18:27:54 2017 +0800 -- .../test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/23abc900/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index f8345b1..3addb1a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -325,7 +325,7 @@ public class PerformanceEvaluation extends Configured implements Tool { // recreate the table when user has requested presplit or when existing // {RegionSplitPolicy,replica count} does not match requested. if ((exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) - || (!isReadCmd && desc != null && desc.getRegionSplitPolicyClassName() != opts.splitPolicy) + || (!isReadCmd && desc != null && !desc.getRegionSplitPolicyClassName().equals(opts.splitPolicy)) || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas)) { needsDelete = true; // wait, why did it delete my table?!?
[54/54] [abbrv] hbase git commit: HBASE-17447 Implement a MasterObserver for automatically deleting space quotas
HBASE-17447 Implement a MasterObserver for automatically deleting space quotas When a table or namespace is deleted, it would be nice to automatically delete the quota on said table/NS. It's possible that not all people would want this functionality so we can leave it up to the user to configure this Observer. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8271fd53 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8271fd53 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8271fd53 Branch: refs/heads/HBASE-16961 Commit: 8271fd53f81ebba9be9e0f7e8f2cdae6db2a3d71 Parents: 6238590 Author: Josh ElserAuthored: Thu Mar 16 18:54:01 2017 -0400 Committer: Josh Elser Committed: Mon Mar 20 18:48:51 2017 -0400 -- .../hbase/quotas/MasterSpaceQuotaObserver.java | 85 ++ .../quotas/TestMasterSpaceQuotaObserver.java| 169 +++ src/main/asciidoc/_chapters/ops_mgt.adoc| 17 ++ 3 files changed, 271 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/8271fd53/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java new file mode 100644 index 000..a3abf32 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterSpaceQuotaObserver.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import java.io.IOException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.CoprocessorEnvironment; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; +import org.apache.hadoop.hbase.coprocessor.MasterObserver; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.master.MasterServices; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; + +/** + * An observer to automatically delete space quotas when a table/namespace + * are deleted. + */ +@InterfaceAudience.Private +public class MasterSpaceQuotaObserver implements MasterObserver { + private CoprocessorEnvironment cpEnv; + private Configuration conf; + private boolean quotasEnabled = false; + + @Override + public void start(CoprocessorEnvironment ctx) throws IOException { +this.cpEnv = ctx; +this.conf = cpEnv.getConfiguration(); +this.quotasEnabled = QuotaUtil.isQuotaEnabled(conf); + } + + @Override + public void postDeleteTable( + ObserverContext ctx, TableName tableName) throws IOException { +// Do nothing if quotas aren't enabled +if (!quotasEnabled) { + return; +} +final MasterServices master = ctx.getEnvironment().getMasterServices(); +final Connection conn = master.getConnection(); +Quotas quotas = QuotaUtil.getTableQuota(master.getConnection(), tableName); +if (null != quotas && quotas.hasSpace()) { + QuotaSettings settings = QuotaSettingsFactory.removeTableSpaceLimit(tableName); + try (Admin admin = conn.getAdmin()) { +admin.setQuota(settings); + } +} + } + + @Override + public void postDeleteNamespace( + ObserverContext ctx, String namespace) throws IOException { +// Do nothing if quotas aren't enabled +if (!quotasEnabled) { + return; +} +final MasterServices master = ctx.getEnvironment().getMasterServices(); +final Connection conn = master.getConnection(); +Quotas quotas = QuotaUtil.getNamespaceQuota(master.getConnection(), namespace); +if (null != quotas && quotas.hasSpace()) { +
[27/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
http://git-wip-us.apache.org/repos/asf/hbase/blob/6e042231/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java index 8f368e9..899ae9b 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/RegionServerStatusProtos.java @@ -10164,6 +10164,1912 @@ public final class RegionServerStatusProtos { } + public interface RegionSpaceUseOrBuilder extends + // @@protoc_insertion_point(interface_extends:hbase.pb.RegionSpaceUse) + org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder { + +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ +boolean hasRegion(); +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ +org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo getRegion(); +/** + * + * A region identifier + * + * + * optional .hbase.pb.RegionInfo region = 1; + */ + org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfoOrBuilder getRegionOrBuilder(); + +/** + * + * The size in bytes of the region + * + * + * optional uint64 size = 2; + */ +boolean hasSize(); +/** + * + * The size in bytes of the region + * + * + * optional uint64 size = 2; + */ +long getSize(); + } + /** + * Protobuf type {@code hbase.pb.RegionSpaceUse} + */ + public static final class RegionSpaceUse extends + org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:hbase.pb.RegionSpaceUse) + RegionSpaceUseOrBuilder { +// Use RegionSpaceUse.newBuilder() to construct. +private RegionSpaceUse(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); +} +private RegionSpaceUse() { + size_ = 0L; +} + +@java.lang.Override +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private RegionSpaceUse( +org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input, + org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.Builder unknownFields = + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} +case 10: { + org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo.Builder subBuilder = null; + if (((bitField0_ & 0x0001) == 0x0001)) { +subBuilder = region_.toBuilder(); + } + region_ = input.readMessage(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo.PARSER, extensionRegistry); + if (subBuilder != null) { +subBuilder.mergeFrom(region_); +region_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x0001; + break; +} +case 16: { + bitField0_ |= 0x0002; + size_ = input.readUInt64(); + break; +} + } +} + } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException( +e).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +
[14/54] [abbrv] hbase git commit: HBASE-17802 Add note that minor versions can add methods to Interfaces
HBASE-17802 Add note that minor versions can add methods to Interfaces Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7c03a213 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7c03a213 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7c03a213 Branch: refs/heads/HBASE-16961 Commit: 7c03a213ffc074c941333677065031a5c2c12d41 Parents: 261aa94 Author: Michael StackAuthored: Fri Mar 17 16:53:47 2017 -0700 Committer: Michael Stack Committed: Sun Mar 19 14:51:11 2017 -0700 -- src/main/asciidoc/_chapters/upgrading.adoc | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/7c03a213/src/main/asciidoc/_chapters/upgrading.adoc -- diff --git a/src/main/asciidoc/_chapters/upgrading.adoc b/src/main/asciidoc/_chapters/upgrading.adoc index b0a5565..df5bbfe 100644 --- a/src/main/asciidoc/_chapters/upgrading.adoc +++ b/src/main/asciidoc/_chapters/upgrading.adoc @@ -74,12 +74,15 @@ In addition to the usual API versioning considerations HBase has other compatibi * An API needs to be deprecated for a major version before we will change/remove it. * APIs available in a patch version will be available in all later patch versions. However, new APIs may be added which will not be available in earlier patch versions. * New APIs introduced in a patch version will only be added in a source compatible way footnote:[See 'Source Compatibility' https://blogs.oracle.com/darcy/entry/kinds_of_compatibility]: i.e. code that implements public APIs will continue to compile. -* Example: A user using a newly deprecated API does not need to modify application code with HBase API calls until the next major version. +** Example: A user using a newly deprecated API does not need to modify application code with HBase API calls until the next major version. +* .Client Binary compatibility * Client code written to APIs available in a given patch release can run unchanged (no recompilation needed) against the new jars of later patch versions. * Client code written to APIs available in a given patch release might not run against the old jars from an earlier patch version. -* Example: Old compiled client code will work unchanged with the new jars. +** Example: Old compiled client code will work unchanged with the new jars. +* If a Client implements an HBase Interface, a recompile MAY be required upgrading to a newer minor version (See release notes +for warning about incompatible changes). All effort will be made to provide a default implementation so this case should not arise. .Server-Side Limited API compatibility (taken from Hadoop) * Internal APIs are marked as Stable, Evolving, or Unstable
[25/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages - addendum fixes white spaces (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages - addendum fixes white spaces (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d688893c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d688893c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d688893c Branch: refs/heads/HBASE-16961 Commit: d688893c99cf23d826d0832f0ae8bee0c041a660 Parents: 87fa04c Author: tedyuAuthored: Thu Nov 17 10:42:18 2016 -0800 Committer: Josh Elser Committed: Mon Mar 20 17:39:21 2017 -0400 -- .../hbase/quotas/TestQuotaSettingsFactory.java| 2 +- .../shaded/protobuf/generated/MasterProtos.java | 2 +- .../shaded/protobuf/generated/QuotaProtos.java| 18 +- .../hbase/protobuf/generated/QuotaProtos.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/d688893c/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java -- diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java index 17015d6..e0012a7 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaSettingsFactory.java @@ -44,7 +44,7 @@ import org.junit.experimental.categories.Category; */ @Category(SmallTests.class) public class TestQuotaSettingsFactory { - + @Test public void testAllQuotasAddedToList() { final SpaceQuota spaceQuota = SpaceQuota.newBuilder() http://git-wip-us.apache.org/repos/asf/hbase/blob/d688893c/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java index cfa1bf3..668b4f6 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/MasterProtos.java @@ -63752,7 +63752,7 @@ public final class MasterProtos { * optional .hbase.pb.SpaceLimitRequest space_limit = 8; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequestOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequestOrBuilder> getSpaceLimitFieldBuilder() { if (spaceLimitBuilder_ == null) { spaceLimitBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< http://git-wip-us.apache.org/repos/asf/hbase/blob/d688893c/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index a715115..673fb2c 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -4362,7 +4362,7 @@ public final class QuotaProtos { * optional .hbase.pb.SpaceQuota space = 3; */ private org.apache.hadoop.hbase.shaded.com.google.protobuf.SingleFieldBuilderV3< - org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaOrBuilder> + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota.Builder,
[17/54] [abbrv] hbase git commit: HBASE-16084 Cleaned up the stale references in Javadoc
HBASE-16084 Cleaned up the stale references in Javadoc Signed-off-by: tedyuProject: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/55d6dcaf Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/55d6dcaf Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/55d6dcaf Branch: refs/heads/HBASE-16961 Commit: 55d6dcaf877cc5223e679736eb613173229c18be Parents: 4088f82 Author: Jan Hentschel Authored: Sun Mar 19 20:49:28 2017 +0100 Committer: tedyu Committed: Mon Mar 20 10:55:36 2017 -0700 -- .../org/apache/hadoop/hbase/HTableDescriptor.java | 14 +++--- .../apache/hadoop/hbase/client/AsyncProcess.java | 6 +++--- .../hadoop/hbase/client/ConnectionFactory.java | 2 +- .../apache/hadoop/hbase/client/MasterCallable.java | 2 +- .../java/org/apache/hadoop/hbase/client/Query.java | 2 +- .../hbase/client/coprocessor/package-info.java | 8 .../FirstKeyValueMatchingQualifiersFilter.java | 2 +- .../hadoop/hbase/ipc/ServerRpcController.java | 4 ++-- .../hbase/zookeeper/RecoverableZooKeeper.java | 2 +- .../java/org/apache/hadoop/hbase/nio/ByteBuff.java | 2 +- .../org/apache/hadoop/hbase/util/OrderedBytes.java | 2 +- .../hadoop/hbase/HBaseCommonTestingUtility.java| 3 +-- .../codec/prefixtree/scanner/CellSearcher.java | 2 +- .../store/wal/ProcedureWALFormatReader.java| 3 +-- .../apache/hadoop/hbase/backup/HFileArchiver.java | 2 -- .../hbase/backup/example/HFileArchiveManager.java | 3 ++- .../hadoop/hbase/backup/util/RestoreTool.java | 4 ++-- .../apache/hadoop/hbase/constraint/Constraint.java | 8 .../hbase/io/hfile/CompoundBloomFilterWriter.java | 2 +- .../apache/hadoop/hbase/io/hfile/HFileBlock.java | 2 +- .../hadoop/hbase/io/hfile/HFileBlockIndex.java | 2 +- .../apache/hadoop/hbase/mapreduce/RowCounter.java | 3 +-- .../hadoop/hbase/master/TableNamespaceManager.java | 2 +- .../master/balancer/StochasticLoadBalancer.java| 4 ++-- .../regionserver/MiniBatchOperationInProgress.java | 4 ++-- .../hadoop/hbase/regionserver/StoreFileReader.java | 2 +- .../hadoop/hbase/regionserver/wal/FSHLog.java | 8 .../regionserver/wal/SequenceIdAccounting.java | 6 +++--- .../hadoop/hbase/regionserver/wal/SyncFuture.java | 4 ++-- .../access/CoprocessorWhitelistMasterObserver.java | 2 +- .../hbase/security/access/TableAuthManager.java| 2 +- .../apache/hadoop/hbase/HBaseTestingUtility.java | 6 +++--- .../apache/hadoop/hbase/TestMetaTableLocator.java | 8 .../hbase/TestPartialResultsFromClientSide.java| 2 +- .../org/apache/hadoop/hbase/TestSerialization.java | 4 ++-- .../hbase/client/TestMultipleTimestamps.java | 2 +- .../TestFirstKeyValueMatchingQualifiersFilter.java | 2 +- .../apache/hadoop/hbase/io/hfile/TestSeekTo.java | 2 +- .../hbase/mapreduce/TestHFileOutputFormat2.java| 17 +++-- .../hadoop/hbase/mapreduce/TestImportExport.java | 2 +- .../hadoop/hbase/master/MockRegionServer.java | 4 ++-- .../hadoop/hbase/master/TestWarmupRegion.java | 2 +- .../hbase/procedure/TestProcedureMember.java | 4 ++-- .../hbase/regionserver/DataBlockEncodingTool.java | 2 +- .../hbase/regionserver/OOMERegionServer.java | 3 +-- .../TestRegionMergeTransactionOnCluster.java | 6 -- .../org/apache/hadoop/hbase/util/LoadTestTool.java | 2 +- .../hadoop/hbase/util/MultiThreadedAction.java | 4 ++-- 48 files changed, 86 insertions(+), 100 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/55d6dcaf/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index a49cf1c..25fd896 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -723,7 +723,7 @@ public class HTableDescriptor implements Comparable { /** * This sets the class associated with the region split policy which * determines when a region split should occur. The class used by - * default is defined in {@link org.apache.hadoop.hbase.regionserver.RegionSplitPolicy} + * default is defined in org.apache.hadoop.hbase.regionserver.RegionSplitPolicy * @param clazz the class name */ public HTableDescriptor setRegionSplitPolicyClassName(String clazz) { @@ -734,7 +734,7 @@ public class HTableDescriptor implements Comparable { /** * This gets the class associated with
[05/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
http://git-wip-us.apache.org/repos/asf/hbase/blob/75d0f49d/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java new file mode 100644 index 000..0f1453e --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java @@ -0,0 +1,344 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hbase.backup.impl; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.PathFilter; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.backup.BackupInfo; +import org.apache.hadoop.hbase.backup.impl.BackupSystemTable.WALItem; +import org.apache.hadoop.hbase.backup.master.LogRollMasterProcedureManager; +import org.apache.hadoop.hbase.backup.util.BackupUtils; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.util.FSUtils; +import org.apache.hadoop.hbase.wal.AbstractFSWALProvider; + +/** + * After a full backup was created, the incremental backup will only store the changes made after + * the last full or incremental backup. Creating the backup copies the logfiles in .logs and + * .oldlogs since the last backup timestamp. + */ +@InterfaceAudience.Private +public class IncrementalBackupManager extends BackupManager { + public static final Log LOG = LogFactory.getLog(IncrementalBackupManager.class); + + public IncrementalBackupManager(Connection conn, Configuration conf) throws IOException { +super(conn, conf); + } + + /** + * Obtain the list of logs that need to be copied out for this incremental backup. The list is set + * in BackupInfo. + * @param conn the Connection + * @param backupInfo backup info + * @return The new HashMap of RS log timestamps after the log roll for this incremental backup. + * @throws IOException exception + */ + public HashMapgetIncrBackupLogFileList(Connection conn, BackupInfo backupInfo) + throws IOException { +List logList; +HashMap newTimestamps; +HashMap previousTimestampMins; + +String savedStartCode = readBackupStartCode(); + +// key: tableName +// value: +HashMap > previousTimestampMap = readLogTimestampMap(); + +previousTimestampMins = BackupUtils.getRSLogTimestampMins(previousTimestampMap); + +if (LOG.isDebugEnabled()) { + LOG.debug("StartCode " + savedStartCode + "for backupID " + backupInfo.getBackupId()); +} +// get all new log files from .logs and .oldlogs after last TS and before new timestamp +if (savedStartCode == null || previousTimestampMins == null +|| previousTimestampMins.isEmpty()) { + throw new IOException( + "Cannot read any previous back up timestamps from backup system table. " + + "In order to create an incremental backup, at least one full backup is needed."); +} + +LOG.info("Execute roll log procedure for incremental backup ..."); +HashMap props = new HashMap (); +props.put("backupRoot", backupInfo.getBackupRootDir()); + +try (Admin admin = conn.getAdmin();) { + + admin.execProcedure(LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_SIGNATURE, +LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_NAME, props); + +} +newTimestamps = readRegionServerLastLogRollResult();
[20/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
http://git-wip-us.apache.org/repos/asf/hbase/blob/87fa04cc/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java index 05894b9..1925828 100644 --- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/QuotaProtos.java @@ -217,12 +217,20 @@ public final class QuotaProtos { * THROTTLE = 1; */ THROTTLE(0, 1), +/** + * SPACE = 2; + */ +SPACE(1, 2), ; /** * THROTTLE = 1; */ public static final int THROTTLE_VALUE = 1; +/** + * SPACE = 2; + */ +public static final int SPACE_VALUE = 2; public final int getNumber() { return value; } @@ -230,6 +238,7 @@ public final class QuotaProtos { public static QuotaType valueOf(int value) { switch (value) { case 1: return THROTTLE; +case 2: return SPACE; default: return null; } } @@ -281,6 +290,142 @@ public final class QuotaProtos { // @@protoc_insertion_point(enum_scope:hbase.pb.QuotaType) } + /** + * Protobuf enum {@code hbase.pb.SpaceViolationPolicy} + * + * + * Defines what action should be taken when the SpaceQuota is violated + * + */ + public enum SpaceViolationPolicy + implements com.google.protobuf.ProtocolMessageEnum { +/** + * DISABLE = 1; + * + * + * Disable the table(s) + * + */ +DISABLE(0, 1), +/** + * NO_WRITES_COMPACTIONS = 2; + * + * + * No writes, bulk-loads, or compactions + * + */ +NO_WRITES_COMPACTIONS(1, 2), +/** + * NO_WRITES = 3; + * + * + * No writes or bulk-loads + * + */ +NO_WRITES(2, 3), +/** + * NO_INSERTS = 4; + * + * + * No puts or bulk-loads, but deletes are allowed + * + */ +NO_INSERTS(3, 4), +; + +/** + * DISABLE = 1; + * + * + * Disable the table(s) + * + */ +public static final int DISABLE_VALUE = 1; +/** + * NO_WRITES_COMPACTIONS = 2; + * + * + * No writes, bulk-loads, or compactions + * + */ +public static final int NO_WRITES_COMPACTIONS_VALUE = 2; +/** + * NO_WRITES = 3; + * + * + * No writes or bulk-loads + * + */ +public static final int NO_WRITES_VALUE = 3; +/** + * NO_INSERTS = 4; + * + * + * No puts or bulk-loads, but deletes are allowed + * + */ +public static final int NO_INSERTS_VALUE = 4; + + +public final int getNumber() { return value; } + +public static SpaceViolationPolicy valueOf(int value) { + switch (value) { +case 1: return DISABLE; +case 2: return NO_WRITES_COMPACTIONS; +case 3: return NO_WRITES; +case 4: return NO_INSERTS; +default: return null; + } +} + +public static com.google.protobuf.Internal.EnumLiteMap +internalGetValueMap() { + return internalValueMap; +} +private static com.google.protobuf.Internal.EnumLiteMap +internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { +public SpaceViolationPolicy findValueByNumber(int number) { + return SpaceViolationPolicy.valueOf(number); +} + }; + +public final com.google.protobuf.Descriptors.EnumValueDescriptor +getValueDescriptor() { + return getDescriptor().getValues().get(index); +} +public final com.google.protobuf.Descriptors.EnumDescriptor +getDescriptorForType() { + return getDescriptor(); +} +public static final com.google.protobuf.Descriptors.EnumDescriptor +getDescriptor() { + return org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.getDescriptor().getEnumTypes().get(3); +} + +private static final SpaceViolationPolicy[] VALUES = values(); + +public static SpaceViolationPolicy valueOf( +com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { +throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; +} + +private final int index; +private final int value; + +private SpaceViolationPolicy(int index, int value) { + this.index = index; + this.value = value; +} + +// @@protoc_insertion_point(enum_scope:hbase.pb.SpaceViolationPolicy) + } + public interface TimedQuotaOrBuilder extends com.google.protobuf.MessageOrBuilder { @@ -3315,6 +3460,20 @@ public final class QuotaProtos {
[31/54] [abbrv] hbase git commit: HBASE-16998 Implement Master-side analysis of region space reports
HBASE-16998 Implement Master-side analysis of region space reports Adds a new Chore to the Master that analyzes the reports that are sent by RegionServers. The Master must then, for all tables with quotas, determine the tables that are violating quotas and move those tables into violation. Similarly, tables no longer violating the quota can be moved out of violation. The Chore is the "stateful" bit, managing which tables are and are not in violation. Everything else is just performing computation and informing the Chore on the updated state. Added InterfaceAudience annotations and clean up the QuotaObserverChore constructor. Cleaned up some javadoc and QuotaObserverChore. Reuse the QuotaViolationStore impl objects. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a19a95df Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a19a95df Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a19a95df Branch: refs/heads/HBASE-16961 Commit: a19a95dff66fc205efb032185944d910c8ea79b2 Parents: d9ebc1e Author: Josh ElserAuthored: Tue Nov 8 18:55:12 2016 -0500 Committer: Josh Elser Committed: Mon Mar 20 17:46:40 2017 -0400 -- .../hadoop/hbase/quotas/QuotaRetriever.java | 29 +- .../org/apache/hadoop/hbase/master/HMaster.java | 20 + .../hadoop/hbase/quotas/MasterQuotaManager.java | 1 + .../quotas/NamespaceQuotaViolationStore.java| 127 .../hadoop/hbase/quotas/QuotaObserverChore.java | 618 +++ .../hbase/quotas/QuotaViolationStore.java | 89 +++ .../quotas/SpaceQuotaViolationNotifier.java | 44 ++ .../SpaceQuotaViolationNotifierForTest.java | 50 ++ .../hbase/quotas/TableQuotaViolationStore.java | 127 .../TestNamespaceQuotaViolationStore.java | 156 + .../hbase/quotas/TestQuotaObserverChore.java| 106 .../TestQuotaObserverChoreWithMiniCluster.java | 596 ++ .../hadoop/hbase/quotas/TestQuotaTableUtil.java | 4 - .../quotas/TestTableQuotaViolationStore.java| 151 + .../hbase/quotas/TestTablesWithQuotas.java | 198 ++ 15 files changed, 2306 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/a19a95df/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java index fecd2d1..8cd5cf0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java @@ -22,6 +22,7 @@ import java.io.Closeable; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; +import java.util.Objects; import java.util.Queue; import org.apache.commons.logging.Log; @@ -56,11 +57,23 @@ public class QuotaRetriever implements Closeable, Iterable { private Connection connection; private Table table; - private QuotaRetriever() { + /** + * Should QutoaRetriever manage the state of the connection, or leave it be. + */ + private boolean isManagedConnection = false; + + QuotaRetriever() { } void init(final Configuration conf, final Scan scan) throws IOException { -this.connection = ConnectionFactory.createConnection(conf); +// Set this before creating the connection and passing it down to make sure +// it's cleaned up if we fail to construct the Scanner. +this.isManagedConnection = true; +init(ConnectionFactory.createConnection(conf), scan); + } + + void init(final Connection conn, final Scan scan) throws IOException { +this.connection = Objects.requireNonNull(conn); this.table = this.connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME); try { scanner = table.getScanner(scan); @@ -79,10 +92,14 @@ public class QuotaRetriever implements Closeable, Iterable { this.table.close(); this.table = null; } -if (this.connection != null) { - this.connection.close(); - this.connection = null; +// Null out the connection on close() even if we didn't explicitly close it +// to maintain typical semantics. +if (isManagedConnection) { + if (this.connection != null) { +this.connection.close(); + } } +this.connection = null; } public QuotaSettings next() throws IOException { @@ -182,4 +199,4 @@ public class QuotaRetriever implements Closeable, Iterable { scanner.init(conf, scan); return scanner; } -} \ No newline at end of file +}
[04/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
http://git-wip-us.apache.org/repos/asf/hbase/blob/75d0f49d/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/master/LogRollMasterProcedureManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/master/LogRollMasterProcedureManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/master/LogRollMasterProcedureManager.java new file mode 100644 index 000..47e428c --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/master/LogRollMasterProcedureManager.java @@ -0,0 +1,155 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hbase.backup.master; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.CoordinatedStateManagerFactory; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.backup.BackupRestoreConstants; +import org.apache.hadoop.hbase.backup.impl.BackupManager; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager; +import org.apache.hadoop.hbase.errorhandling.ForeignException; +import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; +import org.apache.hadoop.hbase.master.MasterServices; +import org.apache.hadoop.hbase.master.MetricsMaster; +import org.apache.hadoop.hbase.procedure.MasterProcedureManager; +import org.apache.hadoop.hbase.procedure.Procedure; +import org.apache.hadoop.hbase.procedure.ProcedureCoordinator; +import org.apache.hadoop.hbase.procedure.ProcedureCoordinatorRpcs; +import org.apache.hadoop.hbase.procedure.RegionServerProcedureManager; +import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair; +import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription; +import org.apache.zookeeper.KeeperException; + +/** + * Master procedure manager for coordinated cluster-wide WAL roll operation, which is run during + * backup operation, see {@link MasterProcedureManager} and and {@link RegionServerProcedureManager} + */ +@InterfaceAudience.Private +public class LogRollMasterProcedureManager extends MasterProcedureManager { + + public static final String ROLLLOG_PROCEDURE_SIGNATURE = "rolllog-proc"; + public static final String ROLLLOG_PROCEDURE_NAME = "rolllog"; + private static final Log LOG = LogFactory.getLog(LogRollMasterProcedureManager.class); + + private MasterServices master; + private ProcedureCoordinator coordinator; + private boolean done; + + @Override + public void stop(String why) { +LOG.info("stop: " + why); + } + + @Override + public boolean isStopped() { +return false; + } + + @Override + public void initialize(MasterServices master, MetricsMaster metricsMaster) + throws KeeperException, IOException, UnsupportedOperationException { +this.master = master; +this.done = false; + +// setup the default procedure coordinator +String name = master.getServerName().toString(); +ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, 1); +BaseCoordinatedStateManager coordManager = +(BaseCoordinatedStateManager) CoordinatedStateManagerFactory +.getCoordinatedStateManager(master.getConfiguration()); +coordManager.initialize(master); + +ProcedureCoordinatorRpcs comms = +coordManager.getProcedureCoordinatorRpcs(getProcedureSignature(), name); + +this.coordinator = new ProcedureCoordinator(comms, tpool); + } + + @Override + public String getProcedureSignature() { +return ROLLLOG_PROCEDURE_SIGNATURE; + } + + @Override + public void execProcedure(ProcedureDescription desc) throws IOException { +if (!isBackupEnabled()) { + LOG.warn("Backup is not enabled. Check your " + BackupRestoreConstants.BACKUP_ENABLE_KEY + + " setting"); + return; +} +this.done = false; +// start the process on the RS +ForeignExceptionDispatcher monitor = new
[47/54] [abbrv] hbase git commit: HBASE-17602 Reduce some quota chore periods/delays
HBASE-17602 Reduce some quota chore periods/delays Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/517eb828 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/517eb828 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/517eb828 Branch: refs/heads/HBASE-16961 Commit: 517eb828507c1ae07f7521fdf95b3e7fc454027a Parents: a44e50f Author: Josh ElserAuthored: Tue Feb 7 11:21:08 2017 -0500 Committer: Josh Elser Committed: Mon Mar 20 18:19:31 2017 -0400 -- .../java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java | 4 ++-- .../org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/517eb828/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index b9f4592..7f894e4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -55,11 +55,11 @@ public class QuotaObserverChore extends ScheduledChore { private static final Log LOG = LogFactory.getLog(QuotaObserverChore.class); static final String QUOTA_OBSERVER_CHORE_PERIOD_KEY = "hbase.master.quotas.observer.chore.period"; - static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 1; // 1 minutes in millis static final String QUOTA_OBSERVER_CHORE_DELAY_KEY = "hbase.master.quotas.observer.chore.delay"; - static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 15L; // 15 seconds in millis static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY = "hbase.master.quotas.observer.chore.timeunit"; http://git-wip-us.apache.org/repos/asf/hbase/blob/517eb828/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java index e1a2693..8587e79 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java @@ -44,11 +44,11 @@ public class SpaceQuotaRefresherChore extends ScheduledChore { static final String POLICY_REFRESHER_CHORE_PERIOD_KEY = "hbase.regionserver.quotas.policy.refresher.chore.period"; - static final int POLICY_REFRESHER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final int POLICY_REFRESHER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 1; // 1 minute in millis static final String POLICY_REFRESHER_CHORE_DELAY_KEY = "hbase.regionserver.quotas.policy.refresher.chore.delay"; - static final long POLICY_REFRESHER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final long POLICY_REFRESHER_CHORE_DELAY_DEFAULT = 1000L * 15L; // 15 seconds in millis static final String POLICY_REFRESHER_CHORE_TIMEUNIT_KEY = "hbase.regionserver.quotas.policy.refresher.chore.timeunit";
[07/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
http://git-wip-us.apache.org/repos/asf/hbase/blob/75d0f49d/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupAdminImpl.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupAdminImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupAdminImpl.java new file mode 100644 index 000..c1d5258 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupAdminImpl.java @@ -0,0 +1,524 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.backup.impl; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +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.TableName; +import org.apache.hadoop.hbase.backup.BackupAdmin; +import org.apache.hadoop.hbase.backup.BackupInfo; +import org.apache.hadoop.hbase.backup.BackupInfo.BackupState; +import org.apache.hadoop.hbase.backup.BackupRequest; +import org.apache.hadoop.hbase.backup.BackupRestoreConstants; +import org.apache.hadoop.hbase.backup.BackupType; +import org.apache.hadoop.hbase.backup.HBackupFileSystem; +import org.apache.hadoop.hbase.backup.RestoreRequest; +import org.apache.hadoop.hbase.backup.util.BackupSet; +import org.apache.hadoop.hbase.backup.util.BackupUtils; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; + +import com.google.common.collect.Lists; + +@InterfaceAudience.Private +public class BackupAdminImpl implements BackupAdmin { + public final static String CHECK_OK = "Checking backup images: OK"; + public final static String CHECK_FAILED = + "Checking backup images: Failed. Some dependencies are missing for restore"; + private static final Log LOG = LogFactory.getLog(BackupAdminImpl.class); + + private final Connection conn; + + public BackupAdminImpl(Connection conn) { +this.conn = conn; + } + + @Override + public void close() throws IOException { +if (conn != null) { + conn.close(); +} + } + + + @Override + public BackupInfo getBackupInfo(String backupId) throws IOException { +BackupInfo backupInfo = null; +try (final BackupSystemTable table = new BackupSystemTable(conn)) { + if (backupId == null) { +ArrayList recentSessions = table.getBackupInfos(BackupState.RUNNING); +if (recentSessions.isEmpty()) { + LOG.warn("No ongoing sessions found."); + return null; +} +// else show status for ongoing session +// must be one maximum +return recentSessions.get(0); + } else { +backupInfo = table.readBackupInfo(backupId); +return backupInfo; + } +} + } + + @Override + public int deleteBackups(String[] backupIds) throws IOException { +// TODO: requires Fault tolerance support, failure will leave system +// in a non-consistent state +// see HBASE-15227 +int totalDeleted = 0; +MapallTablesMap = new HashMap (); + +try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) { + for (int i = 0; i < backupIds.length; i++) { +BackupInfo info = sysTable.readBackupInfo(backupIds[i]); +if (info != null) { + String rootDir = info.getBackupRootDir(); + HashSet allTables = allTablesMap.get(rootDir); + if (allTables == null) { +allTables = new HashSet(); +allTablesMap.put(rootDir, allTables); + } + allTables.addAll(info.getTableNames()); + totalDeleted += deleteBackup(backupIds[i], sysTable); +} + } + finalizeDelete(allTablesMap, sysTable); +} +
[35/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java new file mode 100644 index 000..ec8f1bf --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/BaseViolationPolicyEnforcement.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas.policies; + +import org.apache.hadoop.hbase.client.Append; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Increment; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.util.Bytes; + +public class BaseViolationPolicyEnforcement { + + static final Append APPEND = new Append(Bytes.toBytes("foo")); + static final Delete DELETE = new Delete(Bytes.toBytes("foo")); + static final Increment INCREMENT = new Increment(Bytes.toBytes("foo")); + static final Put PUT = new Put(Bytes.toBytes("foo")); +} http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java new file mode 100644 index 000..abe1b9d --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas.policies; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.quotas.SpaceLimitingException; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; +import org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement; +import org.apache.hadoop.hbase.regionserver.RegionServerServices; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(SmallTests.class) +public class TestBulkLoadCheckingViolationPolicyEnforcement { + + FileSystem fs; + RegionServerServices rss; + TableName tableName; + SpaceViolationPolicyEnforcement policy; + + @Before + public void setup() { +fs = mock(FileSystem.class); +rss = mock(RegionServerServices.class); +tableName = TableName.valueOf("foo"); +policy = new BulkLoadVerifyingViolationPolicyEnforcement(); + } + + @Test + public void testFilesUnderLimit() throws Exception { +final List paths = new ArrayList<>(); +final List
[52/54] [abbrv] hbase git commit: HBASE-17003 Documentation updates for space quotas
HBASE-17003 Documentation updates for space quotas Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/201da141 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/201da141 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/201da141 Branch: refs/heads/HBASE-16961 Commit: 201da1411c96735cdf6a8f0aa1e8c84894acd417 Parents: 6d1558c Author: Josh ElserAuthored: Thu Mar 16 16:21:14 2017 -0400 Committer: Josh Elser Committed: Mon Mar 20 18:31:30 2017 -0400 -- src/main/asciidoc/_chapters/ops_mgt.adoc | 64 ++- 1 file changed, 63 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/201da141/src/main/asciidoc/_chapters/ops_mgt.adoc -- diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc index e4c077f..f9009f3 100644 --- a/src/main/asciidoc/_chapters/ops_mgt.adoc +++ b/src/main/asciidoc/_chapters/ops_mgt.adoc @@ -1705,7 +1705,7 @@ handling multiple workloads: [[quota]] === Quotas -HBASE-11598 introduces quotas, which allow you to throttle requests based on +HBASE-11598 introduces RPC quotas, which allow you to throttle requests based on the following limits: . < > @@ -1885,6 +1885,68 @@ at the same time and that fewer scans can be executed at the same time. A value `0.9` will give more queue/handlers to scans, so the number of scans executed will increase and the number of gets will decrease. +[[space-quotas]] +=== Space Quotas + +link:https://issues.apache.org/jira/browse/HBASE-16961[HBASE-16961] introduces a new type of +quotas for HBase to leverage: filesystem quotas. These "space" quotas limit the amount of space +on the filesystem that HBase namespaces and tables can consume. If a user, malicious or ignorant, +has the ability to write data into HBase, with enough time, that user can effectively crash HBase +(or worse HDFS) by consuming all available space. When there is no filesystem space available, +HBase crashes because it can no longer create/sync data to the write-ahead log. + +This feature allows a for a limit to be set on the size of a table or namespace. When a space quota is set +on a namespace, the quota's limit applies to the sum of usage of all tables in that namespace. +When a table with a quota exists in a namespace with a quota, the table quota takes priority +over the namespace quota. This allows for a scenario where a large limit can be placed on +a collection of tables, but a single table in that collection can have a fine-grained limit set. + +The existing `set_quota` and `list_quota` HBase shell commands can be used to interact with +space quotas. Space quotas are quotas with a `TYPE` of `SPACE` and have `LIMIT` and `POLICY` +attributes. The `LIMIT` is a string that refers to the amount of space on the filesystem +that the quota subject (e.g. the table or namespace) may consume. For example, valid values +of `LIMIT` are `'10G'`, `'2T'`, or `'256M'`. The `POLICY` refers to the action that HBase will +take when the quota subject's usage exceeds the `LIMIT`. The following are valid `POLICY` values. + +* `NO_INSERTS` - No new data may be written (e.g. `Put`, `Increment`, `Append`). +* `NO_WRITES` - Same as `NO_INSERTS` but `Deletes` are also disallowed. +* `NO_WRITES_COMPACTIONS` - Same as `NO_WRITES` but compactions are also disallowed. +* `DISABLE` - The table(s) are disabled, preventing all read/write access. + +.Setting simple space quotas + +# Sets a quota on the table 't1' with a limit of 1GB, disallowing Puts/Increments/Appends when the table exceeds 1GB +hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => '1G', POLICY => NO_INSERTS + +# Sets a quota on the namespace 'ns1' with a limit of 50TB, disallowing Puts/Increments/Appends/Deletes +hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => '50T', POLICY => NO_WRITES + +# Sets a quota on the table 't3' with a limit of 2TB, disallowing any writes and compactions when the table exceeds 2TB. +hbase> set_quota TYPE => SPACE, TABLE => 't3', LIMIT => '2T', POLICY => NO_WRITES_COMPACTIONS + +# Sets a quota on the table 't2' with a limit of 50GB, disabling the table when it exceeds 50GB +hbase> set_quota TYPE => SPACE, TABLE => 't2', LIMIT => '50G', POLICY => DISABLE + + +Consider the following scenario to set up quotas on a namespace, overriding the quota on tables in that namespace + +.Table and Namespace space quotas + +hbase> create_namespace 'ns1' +hbase> create 'ns1:t1' +hbase> create 'ns1:t2' +hbase> create 'ns1:t3' +hbase> set_quota TYPE => SPACE, NAMESPACE =>
[44/54] [abbrv] hbase git commit: HBASE-17428 Implement informational RPCs for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/341cf7e1/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index d8cd701..f207472 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -7476,6 +7476,5554 @@ public final class QuotaProtos { } + public interface GetSpaceQuotaRegionSizesRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:hbase.pb.GetSpaceQuotaRegionSizesRequest) + org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code hbase.pb.GetSpaceQuotaRegionSizesRequest} + */ + public static final class GetSpaceQuotaRegionSizesRequest extends + org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:hbase.pb.GetSpaceQuotaRegionSizesRequest) + GetSpaceQuotaRegionSizesRequestOrBuilder { +// Use GetSpaceQuotaRegionSizesRequest.newBuilder() to construct. +private GetSpaceQuotaRegionSizesRequest(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); +} +private GetSpaceQuotaRegionSizesRequest() { +} + +@java.lang.Override +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet +getUnknownFields() { + return this.unknownFields; +} +private GetSpaceQuotaRegionSizesRequest( +org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input, + org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry) +throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { + this(); + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.Builder unknownFields = + org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.newBuilder(); + try { +boolean done = false; +while (!done) { + int tag = input.readTag(); + switch (tag) { +case 0: + done = true; + break; +default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { +done = true; + } + break; +} + } +} + } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) { +throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { +throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException( +e).setUnfinishedMessage(this); + } finally { +this.unknownFields = unknownFields.build(); +makeExtensionsImmutable(); + } +} +public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor +getDescriptor() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetSpaceQuotaRegionSizesRequest_descriptor; +} + +protected org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable +internalGetFieldAccessorTable() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.internal_static_hbase_pb_GetSpaceQuotaRegionSizesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest.class, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest.Builder.class); +} + +private byte memoizedIsInitialized = -1; +public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; +} + +public void writeTo(org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedOutputStream output) +throws java.io.IOException { + unknownFields.writeTo(output); +} + +public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; +} + +private static final long serialVersionUID =
[46/54] [abbrv] hbase git commit: HBASE-17516 Correctly handle case where table and NS quotas both apply
HBASE-17516 Correctly handle case where table and NS quotas both apply The logic surrounding when a table and namespace quota both apply to a table was incorrect, leading to a case where a table quota violation which should have fired did not because of the less-strict namespace quota. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a44e50f5 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a44e50f5 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a44e50f5 Branch: refs/heads/HBASE-16961 Commit: a44e50f59f444acd6a87d83c1c3e9b16dc6575f2 Parents: 341cf7e Author: Josh ElserAuthored: Wed Feb 22 18:32:55 2017 -0500 Committer: Josh Elser Committed: Mon Mar 20 18:19:31 2017 -0400 -- .../hadoop/hbase/quotas/QuotaObserverChore.java | 10 ++- .../TestQuotaObserverChoreWithMiniCluster.java | 66 .../hbase/quotas/TestQuotaStatusRPCs.java | 21 ++- .../hadoop/hbase/quotas/TestSpaceQuotas.java| 32 +- 4 files changed, 97 insertions(+), 32 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/a44e50f5/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 973ac8c..b9f4592 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -287,7 +287,8 @@ public class QuotaObserverChore extends ScheduledChore { // We want to have a policy of "NONE", moving out of violation if (!targetStatus.isInViolation()) { for (TableName tableInNS : tablesByNamespace.get(namespace)) { - if (!tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { + // If there is a quota on this table in violation + if (tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { // Table-level quota violation policy is being applied here. if (LOG.isTraceEnabled()) { LOG.trace("Not activating Namespace violation policy because a Table violation" @@ -298,16 +299,21 @@ public class QuotaObserverChore extends ScheduledChore { this.snapshotNotifier.transitionTable(tableInNS, targetSnapshot); } } + // We want to move into violation at the NS level } else { // Moving tables in the namespace into violation or to a different violation policy for (TableName tableInNS : tablesByNamespace.get(namespace)) { - if (tableSnapshotStore.getCurrentState(tableInNS).getQuotaStatus().isInViolation()) { + final SpaceQuotaSnapshot tableQuotaSnapshot = +tableSnapshotStore.getCurrentState(tableInNS); + final boolean hasTableQuota = QuotaSnapshotStore.NO_QUOTA != tableQuotaSnapshot; + if (hasTableQuota && tableQuotaSnapshot.getQuotaStatus().isInViolation()) { // Table-level quota violation policy is being applied here. if (LOG.isTraceEnabled()) { LOG.trace("Not activating Namespace violation policy because a Table violation" + " policy is already in effect for " + tableInNS); } } else { +// No table quota present or a table quota present that is not in violation LOG.info(tableInNS + " moving into violation of namespace space quota with policy " + targetStatus.getPolicy()); this.snapshotNotifier.transitionTable(tableInNS, targetSnapshot); } http://git-wip-us.apache.org/repos/asf/hbase/blob/a44e50f5/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java index 943c898..63198a8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -193,40 +193,42 @@ public class TestQuotaObserverChoreWithMiniCluster { helper.writeData(tn1, 2L * SpaceQuotaHelperForTests.ONE_MEGABYTE); admin.flush(tn1); -Map violatedQuotas =
[30/54] [abbrv] hbase git commit: HBASE-16998 Implement Master-side analysis of region space reports
http://git-wip-us.apache.org/repos/asf/hbase/blob/a19a95df/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java new file mode 100644 index 000..98236c2 --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -0,0 +1,596 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.NamespaceNotFoundException; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.master.HMaster; +import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; +import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; + +/** + * Test class for {@link QuotaObserverChore} that uses a live HBase cluster. + */ +@Category(LargeTests.class) +public class TestQuotaObserverChoreWithMiniCluster { + private static final Log LOG = LogFactory.getLog(TestQuotaObserverChoreWithMiniCluster.class); + private static final int SIZE_PER_VALUE = 256; + private static final String F1 = "f1"; + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final AtomicLong COUNTER = new AtomicLong(0); + private static final long ONE_MEGABYTE = 1024L * 1024L; + private static final long DEFAULT_WAIT_MILLIS = 500; + + @Rule + public TestName testName = new TestName(); + + private HMaster master; + private QuotaObserverChore chore; + private SpaceQuotaViolationNotifierForTest violationNotifier; + + @BeforeClass + public static void setUp() throws Exception { +Configuration conf = TEST_UTIL.getConfiguration(); +conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_DELAY_KEY, 1000); +conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_PERIOD_KEY, 1000); +conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_DELAY_KEY, 1000); +conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_PERIOD_KEY, 1000); +conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true); +TEST_UTIL.startMiniCluster(1); + } + + @AfterClass + public static void tearDown() throws Exception { +TEST_UTIL.shutdownMiniCluster(); + } + + @Before + public void removeAllQuotas() throws Exception { +final Connection conn = TEST_UTIL.getConnection(); +
[02/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
http://git-wip-us.apache.org/repos/asf/hbase/blob/75d0f49d/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java new file mode 100644 index 000..ec88549 --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java @@ -0,0 +1,293 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.backup; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.LocatedFileStatus; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.RemoteIterator; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.backup.BackupInfo.BackupState; +import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl; +import org.apache.hadoop.hbase.backup.impl.BackupManager; +import org.apache.hadoop.hbase.backup.impl.BackupSystemTable; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.ConnectionFactory; +import org.apache.hadoop.hbase.client.Durability; +import org.apache.hadoop.hbase.client.HBaseAdmin; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.wal.WALFactory; +import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * This class is only a base for other integration-level backup tests. Do not add tests here. + * TestBackupSmallTests is where tests that don't require bring machines up/down should go All other + * tests should have their own classes and extend this one + */ +public class TestBackupBase { + + private static final Log LOG = LogFactory.getLog(TestBackupBase.class); + + protected static Configuration conf1; + protected static Configuration conf2; + + protected static HBaseTestingUtility TEST_UTIL; + protected static HBaseTestingUtility TEST_UTIL2; + protected static TableName table1 = TableName.valueOf("table1"); + protected static HTableDescriptor table1Desc; + protected static TableName table2 = TableName.valueOf("table2"); + protected static TableName table3 = TableName.valueOf("table3"); + protected static TableName table4 = TableName.valueOf("table4"); + + protected static TableName table1_restore = TableName.valueOf("ns1:table1_restore"); + protected static TableName table2_restore = TableName.valueOf("ns2:table2_restore"); + protected static TableName table3_restore = TableName.valueOf("ns3:table3_restore"); + protected static TableName table4_restore = TableName.valueOf("ns4:table4_restore"); + + protected static final int NB_ROWS_IN_BATCH = 99; + protected static final byte[] qualName = Bytes.toBytes("q1"); + protected static final byte[] famName = Bytes.toBytes("f"); + + protected static String BACKUP_ROOT_DIR = "/backupUT"; + protected static String BACKUP_REMOTE_ROOT_DIR = "/backupUT"; + protected static String provider = "defaultProvider"; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { +TEST_UTIL = new HBaseTestingUtility(); +conf1 = TEST_UTIL.getConfiguration(); +conf1.setBoolean(BackupRestoreConstants.BACKUP_ENABLE_KEY, true); +
[03/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
http://git-wip-us.apache.org/repos/asf/hbase/blob/75d0f49d/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java new file mode 100644 index 000..e90d5c1 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java @@ -0,0 +1,174 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.mapreduce; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.PathFilter; +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.io.hfile.HFile; +import org.apache.hadoop.hbase.io.hfile.HFile.Reader; +import org.apache.hadoop.hbase.io.hfile.HFileScanner; +import org.apache.hadoop.io.NullWritable; +import org.apache.hadoop.mapreduce.InputSplit; +import org.apache.hadoop.mapreduce.JobContext; +import org.apache.hadoop.mapreduce.RecordReader; +import org.apache.hadoop.mapreduce.TaskAttemptContext; +import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; +import org.apache.hadoop.mapreduce.lib.input.FileSplit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Simple MR input format for HFiles. + * This code was borrowed from Apache Crunch project. + * Updated to the recent version of HBase. + */ +public class HFileInputFormat extends FileInputFormat{ + + private static final Logger LOG = LoggerFactory.getLogger(HFileInputFormat.class); + + /** + * File filter that removes all "hidden" files. This might be something worth removing from + * a more general purpose utility; it accounts for the presence of metadata files created + * in the way we're doing exports. + */ + static final PathFilter HIDDEN_FILE_FILTER = new PathFilter() { +@Override +public boolean accept(Path p) { + String name = p.getName(); + return !name.startsWith("_") && !name.startsWith("."); +} + }; + + /** + * Record reader for HFiles. + */ + private static class HFileRecordReader extends RecordReader { + +private Reader in; +protected Configuration conf; +private HFileScanner scanner; + +/** + * A private cache of the key value so it doesn't need to be loaded twice from the scanner. + */ +private Cell value = null; +private long count; +private boolean seeked = false; + +@Override +public void initialize(InputSplit split, TaskAttemptContext context) +throws IOException, InterruptedException { + FileSplit fileSplit = (FileSplit) split; + conf = context.getConfiguration(); + Path path = fileSplit.getPath(); + FileSystem fs = path.getFileSystem(conf); + LOG.info("Initialize HFileRecordReader for {}", path); + this.in = HFile.createReader(fs, path, conf); + + // The file info must be loaded before the scanner can be used. + // This seems like a bug in HBase, but it's easily worked around. + this.in.loadFileInfo(); + this.scanner = in.getScanner(false, false); + +} + + +@Override +public boolean nextKeyValue() throws IOException, InterruptedException { + boolean hasNext; + if (!seeked) { +LOG.info("Seeking to start"); +hasNext = scanner.seekTo(); +seeked = true; + } else { +hasNext = scanner.next(); + } + if (!hasNext) { +return false; + } + value = scanner.getCell(); + count++; + return true; +} + +@Override +public NullWritable getCurrentKey() throws IOException, InterruptedException { + return NullWritable.get(); +} + +@Override +public Cell getCurrentValue() throws IOException, InterruptedException { + return value; +} + +@Override +public float getProgress()
[32/54] [abbrv] hbase git commit: HBASE-16999 Implement master and regionserver synchronization of quota state
http://git-wip-us.apache.org/repos/asf/hbase/blob/c544ed1f/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java new file mode 100644 index 000..4a7000c --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import static org.mockito.Matchers.argThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.Objects; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.mockito.ArgumentMatcher; + +/** + * Test case for {@link TableSpaceQuotaViolationNotifier}. + */ +@Category(SmallTests.class) +public class TestTableSpaceQuotaViolationNotifier { + + private TableSpaceQuotaViolationNotifier notifier; + private Connection conn; + + @Before + public void setup() throws Exception { +notifier = new TableSpaceQuotaViolationNotifier(); +conn = mock(Connection.class); +notifier.initialize(conn); + } + + @Test + public void testToViolation() throws Exception { +final TableName tn = TableName.valueOf("inviolation"); +final SpaceViolationPolicy policy = SpaceViolationPolicy.NO_INSERTS; +final Table quotaTable = mock(Table.class); + when(conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)).thenReturn(quotaTable); + +final Put expectedPut = new Put(Bytes.toBytes("t." + tn.getNameAsString())); +final SpaceQuota protoQuota = SpaceQuota.newBuilder() +.setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(policy)) +.build(); +expectedPut.addColumn(Bytes.toBytes("u"), Bytes.toBytes("v"), protoQuota.toByteArray()); + +notifier.transitionTableToViolation(tn, policy); + +verify(quotaTable).put(argThat(new SingleCellPutMatcher(expectedPut))); + } + + @Test + public void testToObservance() throws Exception { +final TableName tn = TableName.valueOf("notinviolation"); +final Table quotaTable = mock(Table.class); + when(conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)).thenReturn(quotaTable); + +final Delete expectedDelete = new Delete(Bytes.toBytes("t." + tn.getNameAsString())); +expectedDelete.addColumn(Bytes.toBytes("u"), Bytes.toBytes("v")); + +notifier.transitionTableToObservance(tn); + +verify(quotaTable).delete(argThat(new SingleCellDeleteMatcher(expectedDelete))); + } + + /** + * Parameterized for Puts. + */ + private static class SingleCellPutMatcher extends SingleCellMutationMatcher { +private SingleCellPutMatcher(Put expected) { + super(expected); +} + } + + /** + * Parameterized for Deletes. + */ + private static class SingleCellDeleteMatcher extends SingleCellMutationMatcher { +private SingleCellDeleteMatcher(Delete expected) { + super(expected); +} + } + + /** + * Quick hack to verify a Mutation with one column. + */ + private static class SingleCellMutationMatcher extends ArgumentMatcher { +private final Mutation expected; + +private SingleCellMutationMatcher(Mutation expected) { +
[16/54] [abbrv] hbase git commit: HBASE-17806 TestRSGroups#testMoveServersAndTables is flaky in master branch (Guangxu Cheng)
HBASE-17806 TestRSGroups#testMoveServersAndTables is flaky in master branch (Guangxu Cheng) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4088f822 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4088f822 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4088f822 Branch: refs/heads/HBASE-16961 Commit: 4088f822a449acc39c2408a287f820ec26acabf4 Parents: 5b4bb82 Author: tedyuAuthored: Mon Mar 20 09:26:34 2017 -0700 Committer: tedyu Committed: Mon Mar 20 09:26:34 2017 -0700 -- .../org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java | 3 +++ .../apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java| 11 +-- 2 files changed, 12 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/4088f822/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java index 35563c5..9219c23 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java @@ -132,6 +132,9 @@ public class RSGroupInfo { sb.append(", "); sb.append(" Servers:"); sb.append(this.servers); +sb.append(", "); +sb.append(" Tables:"); +sb.append(this.tables); return sb.toString(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/4088f822/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java -- diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java index e8cdb78..e5c89c3 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java @@ -694,6 +694,7 @@ public abstract class TestRSGroupsBase { @Test public void testMoveServersAndTables() throws Exception { +LOG.info("testMoveServersAndTables"); final RSGroupInfo newGroup = addGroup(getGroupName(name.getMethodName()), 1); //create table final byte[] familyNameBytes = Bytes.toBytes("f"); @@ -718,6 +719,12 @@ public abstract class TestRSGroupsBase { } } +LOG.debug("Print group info : " + rsGroupAdmin.listRSGroups()); +int oldDefaultGroupServerSize = + rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getServers().size(); +int oldDefaultGroupTableSize = + rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables().size(); + //test fail bogus server move try { rsGroupAdmin.moveServersAndTables(Sets.newHashSet(Address.fromString("foo:")), @@ -742,9 +749,9 @@ public abstract class TestRSGroupsBase { } //verify default group info -Assert.assertEquals(3, +Assert.assertEquals(oldDefaultGroupServerSize, rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getServers().size()); -Assert.assertEquals(4, +Assert.assertEquals(oldDefaultGroupTableSize, rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables().size()); //verify new group info
[26/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
http://git-wip-us.apache.org/repos/asf/hbase/blob/6e042231/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto b/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto index 1c373ee..23ddd43 100644 --- a/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto +++ b/hbase-protocol-shaded/src/main/protobuf/RegionServerStatus.proto @@ -141,6 +141,22 @@ message SplitTableRegionResponse { optional uint64 proc_id = 1; } +message RegionSpaceUse { + optional RegionInfo region = 1; // A region identifier + optional uint64 size = 2; // The size in bytes of the region +} + +/** + * Reports filesystem usage for regions. + */ +message RegionSpaceUseReportRequest { + repeated RegionSpaceUse space_use = 1; +} + +message RegionSpaceUseReportResponse { + +} + service RegionServerStatusService { /** Called when a region server first starts. */ rpc RegionServerStartup(RegionServerStartupRequest) @@ -182,4 +198,10 @@ service RegionServerStatusService { */ rpc getProcedureResult(GetProcedureResultRequest) returns(GetProcedureResultResponse); + + /** + * Reports Region filesystem space use + */ + rpc ReportRegionSpaceUse(RegionSpaceUseReportRequest) +returns(RegionSpaceUseReportResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/6e042231/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index f86f800..f10d4bb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.mob.MobUtils; import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureUtil; +import org.apache.hadoop.hbase.quotas.MasterQuotaManager; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; @@ -216,6 +217,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse; @@ -2006,4 +2010,19 @@ public class MasterRpcServices extends RSRpcServices throw new ServiceException(e); } } + + @Override + public RegionSpaceUseReportResponse reportRegionSpaceUse(RpcController controller, + RegionSpaceUseReportRequest request) throws ServiceException { +try { + master.checkInitialized(); + MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); + for (RegionSpaceUse report : request.getSpaceUseList()) { +quotaManager.addRegionSize(HRegionInfo.convert(report.getRegion()), report.getSize()); + } + return RegionSpaceUseReportResponse.newBuilder().build(); +} catch (Exception e) { + throw new ServiceException(e); +} + } } http://git-wip-us.apache.org/repos/asf/hbase/blob/6e042231/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java new file mode 100644 index 000..01540eb --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/FileSystemUtilizationChore.java @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or
[23/54] [abbrv] hbase git commit: HBASE-16996 Implement storage/retrieval of filesystem-use quotas into quota table (Josh Elser)
HBASE-16996 Implement storage/retrieval of filesystem-use quotas into quota table (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/72715494 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/72715494 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/72715494 Branch: refs/heads/HBASE-16961 Commit: 727154949e47d3411f76bc967b0ed687fe672134 Parents: 9684493 Author: tedyuAuthored: Sat Dec 3 14:30:48 2016 -0800 Committer: Josh Elser Committed: Mon Mar 20 17:39:21 2017 -0400 -- .../hadoop/hbase/quotas/QuotaTableUtil.java | 13 +- .../hadoop/hbase/quotas/MasterQuotaManager.java | 30 + .../hadoop/hbase/quotas/TestQuotaAdmin.java | 125 ++- 3 files changed, 165 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/72715494/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index 116dd0c..1640ddc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -52,7 +52,9 @@ import org.apache.hadoop.hbase.util.Strings; * * ROW-KEY FAM/QUALDATA * n.namespace q:s global-quotas + * n.namespace u:dusize in bytes * t.table q:s global-quotas + * t.table u:dusize in bytes * u.user q:s global-quotas * u.user q:s.table table-quotas * u.user q:s.ns: namespace-quotas @@ -71,6 +73,7 @@ public class QuotaTableUtil { protected static final byte[] QUOTA_FAMILY_USAGE = Bytes.toBytes("u"); protected static final byte[] QUOTA_QUALIFIER_SETTINGS = Bytes.toBytes("s"); protected static final byte[] QUOTA_QUALIFIER_SETTINGS_PREFIX = Bytes.toBytes("s."); + protected static final byte[] QUOTA_QUALIFIER_DISKUSAGE = Bytes.toBytes("du"); protected static final byte[] QUOTA_USER_ROW_KEY_PREFIX = Bytes.toBytes("u."); protected static final byte[] QUOTA_TABLE_ROW_KEY_PREFIX = Bytes.toBytes("t."); protected static final byte[] QUOTA_NAMESPACE_ROW_KEY_PREFIX = Bytes.toBytes("n."); @@ -298,11 +301,16 @@ public class QuotaTableUtil { * Quotas protobuf helpers */ protected static Quotas quotasFromData(final byte[] data) throws IOException { +return quotasFromData(data, 0, data.length); + } + + protected static Quotas quotasFromData( + final byte[] data, int offset, int length) throws IOException { int magicLen = ProtobufMagic.lengthOfPBMagic(); -if (!ProtobufMagic.isPBMagicPrefix(data, 0, magicLen)) { +if (!ProtobufMagic.isPBMagicPrefix(data, offset, magicLen)) { throw new IOException("Missing pb magic prefix"); } -return Quotas.parseFrom(new ByteArrayInputStream(data, magicLen, data.length - magicLen)); +return Quotas.parseFrom(new ByteArrayInputStream(data, offset + magicLen, length - magicLen)); } protected static byte[] quotasToData(final Quotas data) throws IOException { @@ -316,6 +324,7 @@ public class QuotaTableUtil { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); +hasSettings |= quotas.hasSpace(); return !hasSettings; } http://git-wip-us.apache.org/repos/asf/hbase/blob/72715494/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java index 5dab2e3..1469268 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java @@ -37,6 +37,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle; import
[22/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/87fa04cc Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/87fa04cc Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/87fa04cc Branch: refs/heads/HBASE-16961 Commit: 87fa04cce2e2701e1a2d425ea89677d97386377c Parents: 16900c8 Author: tedyuAuthored: Thu Nov 17 10:19:52 2016 -0800 Committer: Josh Elser Committed: Mon Mar 20 17:39:17 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 47 + .../apache/hadoop/hbase/quotas/QuotaType.java |1 + .../hadoop/hbase/quotas/SpaceLimitSettings.java | 166 ++ .../hbase/quotas/SpaceViolationPolicy.java | 44 + .../hbase/shaded/protobuf/ProtobufUtil.java | 51 + .../hbase/quotas/TestQuotaSettingsFactory.java | 148 ++ .../hbase/quotas/TestSpaceLimitSettings.java| 119 ++ .../shaded/protobuf/generated/MasterProtos.java | 584 -- .../shaded/protobuf/generated/QuotaProtos.java | 1739 +- .../src/main/protobuf/Master.proto |2 + .../src/main/protobuf/Quota.proto | 21 + .../hbase/protobuf/generated/QuotaProtos.java | 1682 - hbase-protocol/src/main/protobuf/Quota.proto| 21 + 13 files changed, 4291 insertions(+), 334 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/87fa04cc/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 1a8b934..a91163f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRe import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; @InterfaceAudience.Public @InterfaceStability.Evolving @@ -91,6 +92,9 @@ public class QuotaSettingsFactory { if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } +if (quotas.hasSpace()) { + settings.add(fromSpace(tableName, namespace, quotas.getSpace())); +} return settings; } @@ -124,6 +128,18 @@ public class QuotaSettingsFactory { return settings; } + static QuotaSettings fromSpace(TableName table, String namespace, SpaceQuota protoQuota) { +if ((null == table && null == namespace) || (null != table && null != namespace)) { + throw new IllegalArgumentException("Can only construct SpaceLimitSettings for a table or namespace."); +} +if (null != table) { + return SpaceLimitSettings.fromSpaceQuota(table, protoQuota); +} else { + // namespace must be non-null + return SpaceLimitSettings.fromSpaceQuota(namespace, protoQuota); +} + } + /* == * RPC Throttle */ @@ -280,4 +296,35 @@ public class QuotaSettingsFactory { public static QuotaSettings bypassGlobals(final String userName, final boolean bypassGlobals) { return new QuotaGlobalsSettingsBypass(userName, null, null, bypassGlobals); } + + /* == + * FileSystem Space Settings + */ + + /** + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table to the given size in bytes. + * When the space usage is exceeded by the table, the provided {@link SpaceViolationPolicy} is enacted on the table. + * + * @param tableName The name of the table on which the quota should be applied. + * @param sizeLimit The limit of a table's size in bytes. + * @param violationPolicy The action to take when the quota is exceeded. + * @return An {@link QuotaSettings} object. + */ + public static QuotaSettings limitTableSpace(final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { +return new SpaceLimitSettings(tableName, sizeLimit, violationPolicy); + } + + /** + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given namespace to the given size in bytes. + *
[37/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java new file mode 100644 index 000..6b754b9 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceViolationPolicyEnforcementFactory.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.quotas; + +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.classification.InterfaceStability; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; +import org.apache.hadoop.hbase.quotas.policies.BulkLoadVerifyingViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.DisableTableViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoInsertsViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoWritesCompactionsViolationPolicyEnforcement; +import org.apache.hadoop.hbase.quotas.policies.NoWritesViolationPolicyEnforcement; +import org.apache.hadoop.hbase.regionserver.RegionServerServices; + +/** + * A factory class for instantiating {@link SpaceViolationPolicyEnforcement} instances. + */ +@InterfaceAudience.Private +@InterfaceStability.Evolving +public class SpaceViolationPolicyEnforcementFactory { + + private static final SpaceViolationPolicyEnforcementFactory INSTANCE = + new SpaceViolationPolicyEnforcementFactory(); + + private SpaceViolationPolicyEnforcementFactory() {} + + /** + * Returns an instance of this factory. + */ + public static SpaceViolationPolicyEnforcementFactory getInstance() { +return INSTANCE; + } + + /** + * Constructs the appropriate {@link SpaceViolationPolicyEnforcement} for tables that are + * in violation of their space quota. + */ + public SpaceViolationPolicyEnforcement create( + RegionServerServices rss, TableName tableName, SpaceQuotaSnapshot snapshot) { +SpaceViolationPolicyEnforcement enforcement; +SpaceQuotaStatus status = snapshot.getQuotaStatus(); +if (!status.isInViolation()) { + throw new IllegalArgumentException(tableName + " is not in violation. Snapshot=" + snapshot); +} +switch (status.getPolicy()) { + case DISABLE: +enforcement = new DisableTableViolationPolicyEnforcement(); +break; + case NO_WRITES_COMPACTIONS: +enforcement = new NoWritesCompactionsViolationPolicyEnforcement(); +break; + case NO_WRITES: +enforcement = new NoWritesViolationPolicyEnforcement(); +break; + case NO_INSERTS: +enforcement = new NoInsertsViolationPolicyEnforcement(); +break; + default: +throw new IllegalArgumentException("Unhandled SpaceViolationPolicy: " + status.getPolicy()); +} +enforcement.initialize(rss, tableName, snapshot); +return enforcement; + } + + /** + * Creates the "default" {@link SpaceViolationPolicyEnforcement} for a table that isn't in + * violation. This is used to have uniform policy checking for tables in and not quotas. + */ + public SpaceViolationPolicyEnforcement createWithoutViolation( + RegionServerServices rss, TableName tableName, SpaceQuotaSnapshot snapshot) { +SpaceQuotaStatus status = snapshot.getQuotaStatus(); +if (status.isInViolation()) { + throw new IllegalArgumentException( + tableName + " is in violation. Logic error. Snapshot=" + snapshot); +} +BulkLoadVerifyingViolationPolicyEnforcement enforcement = new BulkLoadVerifyingViolationPolicyEnforcement(); +enforcement.initialize(rss, tableName, snapshot); +return enforcement; + } +} http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.java
[10/54] [abbrv] hbase git commit: HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov)
HBASE-14123 HBase Backup/Restore Phase 2 (Vladimir Rodionov) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/75d0f49d Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/75d0f49d Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/75d0f49d Branch: refs/heads/HBASE-16961 Commit: 75d0f49dcd9761d32a8dedfaa169844822a9e7a5 Parents: 8e5eeb4 Author: tedyuAuthored: Sat Mar 18 03:04:19 2017 -0700 Committer: tedyu Committed: Sat Mar 18 03:04:19 2017 -0700 -- bin/hbase |6 + .../apache/hadoop/hbase/client/HBaseAdmin.java |4 +- .../hbase/client/RpcRetryingCallerImpl.java |3 +- .../apache/hadoop/hbase/backup/BackupType.java | 25 + .../hadoop/hbase/util/AbstractHBaseTool.java| 18 +- .../hbase/IntegrationTestBackupRestore.java | 311 + .../shaded/protobuf/generated/BackupProtos.java | 7013 ++ .../shaded/protobuf/generated/MasterProtos.java | 18 +- .../src/main/protobuf/Backup.proto | 117 + hbase-server/pom.xml| 10 + .../apache/hadoop/hbase/backup/BackupAdmin.java | 128 + .../hadoop/hbase/backup/BackupCopyJob.java | 55 + .../hadoop/hbase/backup/BackupDriver.java | 204 + .../apache/hadoop/hbase/backup/BackupInfo.java | 545 ++ .../hadoop/hbase/backup/BackupRequest.java | 139 + .../hbase/backup/BackupRestoreConstants.java| 115 + .../hbase/backup/BackupRestoreFactory.java | 66 + .../hadoop/hbase/backup/BackupTableInfo.java| 82 + .../hadoop/hbase/backup/HBackupFileSystem.java | 141 + .../apache/hadoop/hbase/backup/LogUtils.java| 50 + .../hadoop/hbase/backup/RestoreDriver.java | 265 + .../apache/hadoop/hbase/backup/RestoreJob.java | 46 + .../hadoop/hbase/backup/RestoreRequest.java | 135 + .../hbase/backup/impl/BackupAdminImpl.java | 524 ++ .../hbase/backup/impl/BackupCommands.java | 780 ++ .../hbase/backup/impl/BackupException.java | 84 + .../hadoop/hbase/backup/impl/BackupManager.java | 472 ++ .../hbase/backup/impl/BackupManifest.java | 666 ++ .../hbase/backup/impl/BackupSystemTable.java| 1376 .../backup/impl/FullTableBackupClient.java | 189 + .../backup/impl/IncrementalBackupManager.java | 344 + .../impl/IncrementalTableBackupClient.java | 216 + .../hbase/backup/impl/RestoreTablesClient.java | 237 + .../hbase/backup/impl/TableBackupClient.java| 387 + .../backup/mapreduce/HFileSplitterJob.java | 181 + .../mapreduce/MapReduceBackupCopyJob.java | 344 + .../backup/mapreduce/MapReduceRestoreJob.java | 182 + .../hbase/backup/master/BackupLogCleaner.java | 142 + .../master/LogRollMasterProcedureManager.java | 155 + .../regionserver/LogRollBackupSubprocedure.java | 168 + .../LogRollBackupSubprocedurePool.java | 139 + .../LogRollRegionServerProcedureManager.java| 185 + .../hadoop/hbase/backup/util/BackupSet.java | 58 + .../hadoop/hbase/backup/util/BackupUtils.java | 702 ++ .../hadoop/hbase/backup/util/RestoreTool.java | 610 ++ .../BaseCoordinatedStateManager.java| 20 +- .../coordination/ZkCoordinatedStateManager.java | 23 +- .../hbase/mapreduce/HFileInputFormat.java | 174 + .../hbase/mapreduce/LoadIncrementalHFiles.java | 25 +- .../hadoop/hbase/mapreduce/WALInputFormat.java | 42 +- .../hadoop/hbase/mapreduce/WALPlayer.java | 83 +- .../hadoop/hbase/master/MasterRpcServices.java | 129 +- .../hbase/master/snapshot/SnapshotManager.java |4 +- .../hbase/procedure/ZKProcedureCoordinator.java | 328 + .../procedure/ZKProcedureCoordinatorRpcs.java | 327 - .../flush/MasterFlushTableProcedureManager.java |4 +- .../hbase/regionserver/HRegionServer.java | 17 +- .../hadoop/hbase/wal/AbstractFSWALProvider.java |5 + .../hadoop/hbase/HBaseTestingUtility.java | 41 +- .../hadoop/hbase/backup/TestBackupBase.java | 293 + .../hbase/backup/TestBackupBoundaryTests.java | 97 + .../hbase/backup/TestBackupCommandLineTool.java | 431 ++ .../hadoop/hbase/backup/TestBackupDelete.java | 102 + .../hbase/backup/TestBackupDeleteRestore.java | 70 + .../hadoop/hbase/backup/TestBackupDescribe.java | 110 + .../hbase/backup/TestBackupMultipleDeletes.java | 159 + .../hbase/backup/TestBackupShowHistory.java | 148 + .../hbase/backup/TestBackupStatusProgress.java | 96 + .../hbase/backup/TestBackupSystemTable.java | 511 ++ .../hadoop/hbase/backup/TestFullBackup.java | 59 + .../hadoop/hbase/backup/TestFullBackupSet.java | 103 + .../backup/TestFullBackupSetRestoreSet.java | 128 + .../hadoop/hbase/backup/TestFullRestore.java| 345 + .../hbase/backup/TestIncrementalBackup.java | 200 +
[36/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java index c493b25..943c898 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java @@ -22,16 +22,12 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Random; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -40,20 +36,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.quotas.QuotaObserverChore.TablesWithQuotas; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import org.apache.hadoop.hbase.testclassification.LargeTests; -import org.apache.hadoop.hbase.util.Bytes; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -62,7 +53,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TestName; -import com.google.common.collect.HashMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; @@ -72,11 +62,8 @@ import com.google.common.collect.Multimap; @Category(LargeTests.class) public class TestQuotaObserverChoreWithMiniCluster { private static final Log LOG = LogFactory.getLog(TestQuotaObserverChoreWithMiniCluster.class); - private static final int SIZE_PER_VALUE = 256; - private static final String F1 = "f1"; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final AtomicLong COUNTER = new AtomicLong(0); - private static final long ONE_MEGABYTE = 1024L * 1024L; private static final long DEFAULT_WAIT_MILLIS = 500; @Rule @@ -84,18 +71,19 @@ public class TestQuotaObserverChoreWithMiniCluster { private HMaster master; private QuotaObserverChore chore; - private SpaceQuotaViolationNotifierForTest violationNotifier; + private SpaceQuotaSnapshotNotifierForTest snapshotNotifier; + private SpaceQuotaHelperForTests helper; @BeforeClass public static void setUp() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_DELAY_KEY, 1000); conf.setInt(FileSystemUtilizationChore.FS_UTILIZATION_CHORE_PERIOD_KEY, 1000); -conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_DELAY_KEY, 1000); -conf.setInt(QuotaObserverChore.VIOLATION_OBSERVER_CHORE_PERIOD_KEY, 1000); +conf.setInt(QuotaObserverChore.QUOTA_OBSERVER_CHORE_DELAY_KEY, 1000); +conf.setInt(QuotaObserverChore.QUOTA_OBSERVER_CHORE_PERIOD_KEY, 1000); conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true); -conf.setClass(SpaceQuotaViolationNotifierFactory.VIOLATION_NOTIFIER_KEY, -SpaceQuotaViolationNotifierForTest.class, SpaceQuotaViolationNotifier.class); +conf.setClass(SpaceQuotaSnapshotNotifierFactory.SNAPSHOT_NOTIFIER_KEY, +SpaceQuotaSnapshotNotifierForTest.class, SpaceQuotaSnapshotNotifier.class); TEST_UTIL.startMiniCluster(1); } @@ -131,40 +119,55 @@ public class TestQuotaObserverChoreWithMiniCluster { } master = TEST_UTIL.getMiniHBaseCluster().getMaster(); -violationNotifier = -(SpaceQuotaViolationNotifierForTest) master.getSpaceQuotaViolationNotifier(); -violationNotifier.clearTableViolations(); +snapshotNotifier = +(SpaceQuotaSnapshotNotifierForTest) master.getSpaceQuotaSnapshotNotifier(); +snapshotNotifier.clearSnapshots(); chore = master.getQuotaObserverChore(); +
[38/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 8b127d9..973ac8c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -37,9 +37,8 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.master.HMaster; -import org.apache.hadoop.hbase.quotas.QuotaViolationStore.ViolationState; -import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; -import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus; import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota; import com.google.common.annotations.VisibleForTesting; @@ -54,51 +53,51 @@ import com.google.common.collect.Multimap; @InterfaceAudience.Private public class QuotaObserverChore extends ScheduledChore { private static final Log LOG = LogFactory.getLog(QuotaObserverChore.class); - static final String VIOLATION_OBSERVER_CHORE_PERIOD_KEY = - "hbase.master.quotas.violation.observer.chore.period"; - static final int VIOLATION_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis + static final String QUOTA_OBSERVER_CHORE_PERIOD_KEY = + "hbase.master.quotas.observer.chore.period"; + static final int QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT = 1000 * 60 * 5; // 5 minutes in millis - static final String VIOLATION_OBSERVER_CHORE_DELAY_KEY = - "hbase.master.quotas.violation.observer.chore.delay"; - static final long VIOLATION_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute + static final String QUOTA_OBSERVER_CHORE_DELAY_KEY = + "hbase.master.quotas.observer.chore.delay"; + static final long QUOTA_OBSERVER_CHORE_DELAY_DEFAULT = 1000L * 60L; // 1 minute - static final String VIOLATION_OBSERVER_CHORE_TIMEUNIT_KEY = - "hbase.master.quotas.violation.observer.chore.timeunit"; - static final String VIOLATION_OBSERVER_CHORE_TIMEUNIT_DEFAULT = TimeUnit.MILLISECONDS.name(); + static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY = + "hbase.master.quotas.observer.chore.timeunit"; + static final String QUOTA_OBSERVER_CHORE_TIMEUNIT_DEFAULT = TimeUnit.MILLISECONDS.name(); - static final String VIOLATION_OBSERVER_CHORE_REPORT_PERCENT_KEY = - "hbase.master.quotas.violation.observer.report.percent"; - static final double VIOLATION_OBSERVER_CHORE_REPORT_PERCENT_DEFAULT= 0.95; + static final String QUOTA_OBSERVER_CHORE_REPORT_PERCENT_KEY = + "hbase.master.quotas.observer.report.percent"; + static final double QUOTA_OBSERVER_CHORE_REPORT_PERCENT_DEFAULT= 0.95; private final Connection conn; private final Configuration conf; private final MasterQuotaManager quotaManager; /* - * Callback that changes in quota violation are passed to. + * Callback that changes in quota snapshots are passed to. */ - private final SpaceQuotaViolationNotifier violationNotifier; + private final SpaceQuotaSnapshotNotifier snapshotNotifier; /* - * Preserves the state of quota violations for tables and namespaces + * Preserves the state of quota snapshots for tables and namespaces */ - private final MaptableQuotaViolationStates; - private final Map namespaceQuotaViolationStates; + private final Map tableQuotaSnapshots; + private final Map namespaceQuotaSnapshots; /* - * Encapsulates logic for moving tables/namespaces into or out of quota violation + * Encapsulates logic for tracking the state of a table/namespace WRT space quotas */ - private QuotaViolationStore tableViolationStore; - private QuotaViolationStore namespaceViolationStore; + private QuotaSnapshotStore tableSnapshotStore; + private QuotaSnapshotStore namespaceSnapshotStore; public QuotaObserverChore(HMaster master) { this( master.getConnection(), master.getConfiguration(), -master.getSpaceQuotaViolationNotifier(), master.getMasterQuotaManager(), +master.getSpaceQuotaSnapshotNotifier(), master.getMasterQuotaManager(), master); } QuotaObserverChore( - Connection conn, Configuration conf, SpaceQuotaViolationNotifier violationNotifier, + Connection conn, Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier,
[28/54] [abbrv] hbase git commit: HBASE-17000 Implement computation of online region sizes and report to the Master
HBASE-17000 Implement computation of online region sizes and report to the Master Includes a trivial implementation of the Master-side collection to avoid. Only enough to write a test to verify RS collection. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6e042231 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6e042231 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6e042231 Branch: refs/heads/HBASE-16961 Commit: 6e0422319c570c1d7428d76383e0b54d6f8afc8c Parents: 7271549 Author: Josh ElserAuthored: Mon Nov 7 13:46:42 2016 -0500 Committer: Josh Elser Committed: Mon Mar 20 17:45:33 2017 -0400 -- .../generated/RegionServerStatusProtos.java | 2071 +- .../src/main/protobuf/RegionServerStatus.proto | 22 + .../hadoop/hbase/master/MasterRpcServices.java | 19 + .../quotas/FileSystemUtilizationChore.java | 205 ++ .../hadoop/hbase/quotas/MasterQuotaManager.java | 15 + .../hbase/regionserver/HRegionServer.java | 72 + .../quotas/TestFileSystemUtilizationChore.java | 357 +++ .../hadoop/hbase/quotas/TestRegionSizeUse.java | 194 ++ .../TestRegionServerRegionSpaceUseReport.java | 99 + 9 files changed, 3032 insertions(+), 22 deletions(-) --
[53/54] [abbrv] hbase git commit: HBASE-17794 Swap "violation" for "snapshot" where appropriate
HBASE-17794 Swap "violation" for "snapshot" where appropriate A couple of variables and comments in which violation is incorrectly used to describe what the code is doing. This was a hold over from early implementation -- need to scrub these out for clarity. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6238590a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6238590a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6238590a Branch: refs/heads/HBASE-16961 Commit: 6238590a653153da8928133bba1a8f4e3c5f7a75 Parents: 201da14 Author: Josh ElserAuthored: Thu Mar 16 19:26:14 2017 -0400 Committer: Josh Elser Committed: Mon Mar 20 18:31:30 2017 -0400 -- .../java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java| 4 ++-- hbase-protocol-shaded/src/main/protobuf/Quota.proto| 2 +- .../org/apache/hadoop/hbase/quotas/QuotaObserverChore.java | 6 +++--- .../apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.java| 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/6238590a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index ed5da95..725f170 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -227,7 +227,7 @@ public class QuotaTableUtil { } /** - * Creates a {@link Scan} which returns only quota violations from the quota table. + * Creates a {@link Scan} which returns only quota snapshots from the quota table. */ public static Scan makeQuotaSnapshotScan() { Scan s = new Scan(); @@ -245,7 +245,7 @@ public class QuotaTableUtil { * will throw an {@link IllegalArgumentException}. * * @param result A row from the quota table. - * @param snapshots A map of violations to add the result of this method into. + * @param snapshots A map of snapshots to add the result of this method into. */ public static void extractQuotaSnapshot( Result result, Map snapshots) { http://git-wip-us.apache.org/repos/asf/hbase/blob/6238590a/hbase-protocol-shaded/src/main/protobuf/Quota.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Quota.proto b/hbase-protocol-shaded/src/main/protobuf/Quota.proto index 1a6d5ed..364c58b 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Quota.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Quota.proto @@ -98,7 +98,7 @@ message SpaceLimitRequest { } // Represents the state of a quota on a table. Either the quota is not in violation -// or it is in violatino there is a violation policy which should be in effect. +// or it is in violation there is a violation policy which should be in effect. message SpaceQuotaStatus { optional SpaceViolationPolicy policy = 1; optional bool in_violation = 2; http://git-wip-us.apache.org/repos/asf/hbase/blob/6238590a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java index 94c5c87..254f2a1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java @@ -532,9 +532,9 @@ public class QuotaObserverChore extends ScheduledChore { } /** - * Stores the quota violation state for the given table. + * Stores the quota state for the given table. */ - void setTableQuotaViolation(TableName table, SpaceQuotaSnapshot snapshot) { + void setTableQuotaSnapshot(TableName table, SpaceQuotaSnapshot snapshot) { this.tableQuotaSnapshots.put(table, snapshot); } @@ -552,7 +552,7 @@ public class QuotaObserverChore extends ScheduledChore { } /** - * Stores the quota violation state for the given namespace. + * Stores the quota state for the given namespace. */ void setNamespaceQuotaSnapshot(String namespace, SpaceQuotaSnapshot snapshot) { this.namespaceQuotaSnapshots.put(namespace, snapshot);
[24/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages - addendum fixes line lengths (Josh Elser)
HBASE-16995 Build client Java API and client protobuf messages - addendum fixes line lengths (Josh Elser) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9684493c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9684493c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9684493c Branch: refs/heads/HBASE-16961 Commit: 9684493c6fa9ea302dc7913668ec3d953dd3bfc8 Parents: d688893 Author: tedyuAuthored: Mon Nov 21 13:00:27 2016 -0800 Committer: Josh Elser Committed: Mon Mar 20 17:39:21 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 20 .../hadoop/hbase/quotas/SpaceLimitSettings.java | 8 .../hbase/shaded/protobuf/ProtobufUtil.java | 9 + 3 files changed, 21 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/9684493c/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index a91163f..657554a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -130,7 +130,8 @@ public class QuotaSettingsFactory { static QuotaSettings fromSpace(TableName table, String namespace, SpaceQuota protoQuota) { if ((null == table && null == namespace) || (null != table && null != namespace)) { - throw new IllegalArgumentException("Can only construct SpaceLimitSettings for a table or namespace."); + throw new IllegalArgumentException( + "Can only construct SpaceLimitSettings for a table or namespace."); } if (null != table) { return SpaceLimitSettings.fromSpaceQuota(table, protoQuota); @@ -302,29 +303,32 @@ public class QuotaSettingsFactory { */ /** - * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table to the given size in bytes. - * When the space usage is exceeded by the table, the provided {@link SpaceViolationPolicy} is enacted on the table. + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given table + * to the given size in bytes. When the space usage is exceeded by the table, the provided + * {@link SpaceViolationPolicy} is enacted on the table. * * @param tableName The name of the table on which the quota should be applied. * @param sizeLimit The limit of a table's size in bytes. * @param violationPolicy The action to take when the quota is exceeded. * @return An {@link QuotaSettings} object. */ - public static QuotaSettings limitTableSpace(final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { + public static QuotaSettings limitTableSpace( + final TableName tableName, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(tableName, sizeLimit, violationPolicy); } /** - * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given namespace to the given size in bytes. - * When the space usage is exceeded by all tables in the namespace, the provided {@link SpaceViolationPolicy} is enacted on - * all tables in the namespace. + * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given + * namespace to the given size in bytes. When the space usage is exceeded by all tables in the + * namespace, the provided {@link SpaceViolationPolicy} is enacted on all tables in the namespace. * * @param namespace The namespace on which the quota should be applied. * @param sizeLimit The limit of the namespace's size in bytes. * @param violationPolicy The action to take when the the quota is exceeded. * @return An {@link QuotaSettings} object. */ - public static QuotaSettings limitNamespaceSpace(final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { + public static QuotaSettings limitNamespaceSpace( + final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(namespace, sizeLimit, violationPolicy); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9684493c/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java -- diff --git
[49/54] [abbrv] hbase git commit: HBASE-17002 JMX metrics and some UI additions for space quotas
http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1558c8/hbase-protocol-shaded/src/main/protobuf/Master.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Master.proto b/hbase-protocol-shaded/src/main/protobuf/Master.proto index 58e6f77..90a7f07 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Master.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Master.proto @@ -930,7 +930,11 @@ service MasterService { rpc removeDrainFromRegionServers(RemoveDrainFromRegionServersRequest) returns(RemoveDrainFromRegionServersResponse); - /** Fetches the Master's view of space quotas */ + /** Fetches the Master's view of space utilization */ rpc GetSpaceQuotaRegionSizes(GetSpaceQuotaRegionSizesRequest) returns(GetSpaceQuotaRegionSizesResponse); + + /** Fetches the Master's view of quotas */ + rpc GetQuotaStates(GetQuotaStatesRequest) +returns(GetQuotaStatesResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1558c8/hbase-protocol-shaded/src/main/protobuf/Quota.proto -- diff --git a/hbase-protocol-shaded/src/main/protobuf/Quota.proto b/hbase-protocol-shaded/src/main/protobuf/Quota.proto index 2d7e5f5..1a6d5ed 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Quota.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Quota.proto @@ -119,6 +119,7 @@ message GetSpaceQuotaRegionSizesResponse { message RegionSizes { optional TableName table_name = 1; optional uint64 size = 2; + } repeated RegionSizes sizes = 1; } @@ -146,3 +147,19 @@ message GetSpaceQuotaEnforcementsResponse { } repeated TableViolationPolicy violation_policies = 1; } + +message GetQuotaStatesRequest { +} + +message GetQuotaStatesResponse { + message TableQuotaSnapshot { +optional TableName table_name = 1; +optional SpaceQuotaSnapshot snapshot = 2; + } + message NamespaceQuotaSnapshot { +optional string namespace = 1; +optional SpaceQuotaSnapshot snapshot = 2; + } + repeated TableQuotaSnapshot table_snapshots = 1; + repeated NamespaceQuotaSnapshot ns_snapshots = 2; +} http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1558c8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index bc4987a..6cfddaa 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -907,7 +907,7 @@ public class HMaster extends HRegionServer implements MasterServices { // Create the quota snapshot notifier spaceQuotaSnapshotNotifier = createQuotaSnapshotNotifier(); spaceQuotaSnapshotNotifier.initialize(getClusterConnection()); - this.quotaObserverChore = new QuotaObserverChore(this); + this.quotaObserverChore = new QuotaObserverChore(this, getMasterMetrics()); // Start the chore to read the region FS space reports and act on them getChoreService().scheduleChore(quotaObserverChore); } http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1558c8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index eb2711c..1c4abc0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -62,7 +62,9 @@ import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureUtil; import org.apache.hadoop.hbase.quotas.MasterQuotaManager; +import org.apache.hadoop.hbase.quotas.QuotaObserverChore; import org.apache.hadoop.hbase.quotas.QuotaUtil; +import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; @@ -214,8 +216,12 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTa import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse; +import
[15/54] [abbrv] hbase git commit: HBASE-17691 Add ScanMetrics support for async scan
HBASE-17691 Add ScanMetrics support for async scan Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5b4bb821 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5b4bb821 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5b4bb821 Branch: refs/heads/HBASE-16961 Commit: 5b4bb8217dd4327a89fa29c93ac37bc887d96c2c Parents: 7c03a21 Author: zhangduoAuthored: Mon Mar 20 17:12:53 2017 +0800 Committer: zhangduo Committed: Mon Mar 20 20:54:04 2017 +0800 -- .../hadoop/hbase/client/AsyncClientScanner.java | 34 +++- .../client/AsyncRpcRetryingCallerFactory.java | 24 ++- .../AsyncScanSingleRegionRpcRetryingCaller.java | 35 ++-- .../hadoop/hbase/client/AsyncTableBase.java | 9 +- .../hadoop/hbase/client/AsyncTableImpl.java | 1 + .../hbase/client/AsyncTableResultScanner.java | 9 +- .../hadoop/hbase/client/ClientScanner.java | 8 +- .../hadoop/hbase/client/ConnectionUtils.java| 75 + .../hbase/client/RawScanResultConsumer.java | 10 ++ .../hbase/client/ReversedScannerCallable.java | 10 +- .../hadoop/hbase/client/ScanResultConsumer.java | 9 ++ .../hadoop/hbase/client/ScannerCallable.java| 88 ++ .../client/SimpleRawScanResultConsumer.java | 84 ++ .../hbase/client/SimpleScanResultConsumer.java | 75 + .../hadoop/hbase/client/TestAsyncTableScan.java | 42 - .../hbase/client/TestAsyncTableScanMetrics.java | 159 +++ .../hbase/client/TestRawAsyncTableScan.java | 52 -- 17 files changed, 526 insertions(+), 198 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/5b4bb821/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java index fa7aa81..2c1693d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java @@ -19,8 +19,7 @@ package org.apache.hadoop.hbase.client; import static org.apache.hadoop.hbase.HConstants.EMPTY_END_ROW; import static org.apache.hadoop.hbase.HConstants.EMPTY_START_ROW; -import static org.apache.hadoop.hbase.client.ConnectionUtils.createScanResultCache; -import static org.apache.hadoop.hbase.client.ConnectionUtils.getLocateType; +import static org.apache.hadoop.hbase.client.ConnectionUtils.*; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -29,6 +28,7 @@ import java.util.concurrent.TimeUnit; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.client.metrics.ScanMetrics; import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService; @@ -51,6 +51,8 @@ class AsyncClientScanner { // AsyncScanSingleRegionRpcRetryingCaller will modify this scan object directly. private final Scan scan; + private final ScanMetrics scanMetrics; + private final RawScanResultConsumer consumer; private final TableName tableName; @@ -88,29 +90,46 @@ class AsyncClientScanner { this.rpcTimeoutNs = rpcTimeoutNs; this.startLogErrorsCnt = startLogErrorsCnt; this.resultCache = createScanResultCache(scan); +if (scan.isScanMetricsEnabled()) { + this.scanMetrics = new ScanMetrics(); + consumer.onScanMetricsCreated(scanMetrics); +} else { + this.scanMetrics = null; +} } private static final class OpenScannerResponse { public final HRegionLocation loc; +public final boolean isRegionServerRemote; + public final ClientService.Interface stub; public final HBaseRpcController controller; public final ScanResponse resp; -public OpenScannerResponse(HRegionLocation loc, Interface stub, HBaseRpcController controller, -ScanResponse resp) { +public OpenScannerResponse(HRegionLocation loc, boolean isRegionServerRemote, Interface stub, +HBaseRpcController controller, ScanResponse resp) { this.loc = loc; + this.isRegionServerRemote = isRegionServerRemote; this.stub = stub; this.controller = controller; this.resp = resp; } } + private int openScannerTries; + private CompletableFuture callOpenScanner(HBaseRpcController controller, HRegionLocation loc,
[21/54] [abbrv] hbase git commit: HBASE-16995 Build client Java API and client protobuf messages (Josh Elser)
http://git-wip-us.apache.org/repos/asf/hbase/blob/87fa04cc/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java -- diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java index d14336a..a715115 100644 --- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java +++ b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/generated/QuotaProtos.java @@ -239,12 +239,20 @@ public final class QuotaProtos { * THROTTLE = 1; */ THROTTLE(1), +/** + * SPACE = 2; + */ +SPACE(2), ; /** * THROTTLE = 1; */ public static final int THROTTLE_VALUE = 1; +/** + * SPACE = 2; + */ +public static final int SPACE_VALUE = 2; public final int getNumber() { @@ -262,6 +270,7 @@ public final class QuotaProtos { public static QuotaType forNumber(int value) { switch (value) { case 1: return THROTTLE; +case 2: return SPACE; default: return null; } } @@ -311,6 +320,150 @@ public final class QuotaProtos { // @@protoc_insertion_point(enum_scope:hbase.pb.QuotaType) } + /** + * + * Defines what action should be taken when the SpaceQuota is violated + * + * + * Protobuf enum {@code hbase.pb.SpaceViolationPolicy} + */ + public enum SpaceViolationPolicy + implements org.apache.hadoop.hbase.shaded.com.google.protobuf.ProtocolMessageEnum { +/** + * + * Disable the table(s) + * + * + * DISABLE = 1; + */ +DISABLE(1), +/** + * + * No writes, bulk-loads, or compactions + * + * + * NO_WRITES_COMPACTIONS = 2; + */ +NO_WRITES_COMPACTIONS(2), +/** + * + * No writes or bulk-loads + * + * + * NO_WRITES = 3; + */ +NO_WRITES(3), +/** + * + * No puts or bulk-loads, but deletes are allowed + * + * + * NO_INSERTS = 4; + */ +NO_INSERTS(4), +; + +/** + * + * Disable the table(s) + * + * + * DISABLE = 1; + */ +public static final int DISABLE_VALUE = 1; +/** + * + * No writes, bulk-loads, or compactions + * + * + * NO_WRITES_COMPACTIONS = 2; + */ +public static final int NO_WRITES_COMPACTIONS_VALUE = 2; +/** + * + * No writes or bulk-loads + * + * + * NO_WRITES = 3; + */ +public static final int NO_WRITES_VALUE = 3; +/** + * + * No puts or bulk-loads, but deletes are allowed + * + * + * NO_INSERTS = 4; + */ +public static final int NO_INSERTS_VALUE = 4; + + +public final int getNumber() { + return value; +} + +/** + * @deprecated Use {@link #forNumber(int)} instead. + */ +@java.lang.Deprecated +public static SpaceViolationPolicy valueOf(int value) { + return forNumber(value); +} + +public static SpaceViolationPolicy forNumber(int value) { + switch (value) { +case 1: return DISABLE; +case 2: return NO_WRITES_COMPACTIONS; +case 3: return NO_WRITES; +case 4: return NO_INSERTS; +default: return null; + } +} + +public static org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap +internalGetValueMap() { + return internalValueMap; +} +private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap< +SpaceViolationPolicy> internalValueMap = + new org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLiteMap() { +public SpaceViolationPolicy findValueByNumber(int number) { + return SpaceViolationPolicy.forNumber(number); +} + }; + +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor +getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); +} +public final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumDescriptor +getDescriptorForType() { + return getDescriptor(); +} +public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumDescriptor +getDescriptor() { + return org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.getDescriptor().getEnumTypes().get(3); +} + +private static final SpaceViolationPolicy[] VALUES = values(); + +public static SpaceViolationPolicy valueOf( + org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { +throw new
[13/54] [abbrv] hbase git commit: HBASE-17803 Addendum fix NPE
HBASE-17803 Addendum fix NPE Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/261aa944 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/261aa944 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/261aa944 Branch: refs/heads/HBASE-16961 Commit: 261aa9445c3c52e09c10d06168a77d11d0c9b4b4 Parents: 23abc90 Author: Chia-Ping TsaiAuthored: Sun Mar 19 19:05:25 2017 +0800 Committer: Chia-Ping Tsai Committed: Sun Mar 19 19:05:25 2017 +0800 -- .../test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/261aa944/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 3addb1a..40e50cf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -43,6 +43,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -325,7 +326,8 @@ public class PerformanceEvaluation extends Configured implements Tool { // recreate the table when user has requested presplit or when existing // {RegionSplitPolicy,replica count} does not match requested. if ((exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) - || (!isReadCmd && desc != null && !desc.getRegionSplitPolicyClassName().equals(opts.splitPolicy)) + || (!isReadCmd && desc != null && + !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas)) { needsDelete = true; // wait, why did it delete my table?!?
[11/54] [abbrv] hbase git commit: Add Eshcar Hillel to pom file
Add Eshcar Hillel to pom file Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b299c138 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b299c138 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b299c138 Branch: refs/heads/HBASE-16961 Commit: b299c1388c499b184c06a7b647c649458f6aa1e0 Parents: 75d0f49 Author: eshcarAuthored: Sun Mar 19 09:58:51 2017 +0200 Committer: eshcar Committed: Sun Mar 19 09:58:51 2017 +0200 -- pom.xml | 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/b299c138/pom.xml -- diff --git a/pom.xml b/pom.xml index 34e3102..86c98a2 100644 --- a/pom.xml +++ b/pom.xml @@ -248,6 +248,12 @@ -8 + eshcar + Eshcar Hillel + esh...@apache.org + +2 + + fenghh Honghua Feng fen...@apache.org
[18/54] [abbrv] hbase git commit: HBASE-17582 Fix broken drop page cache hint (broken by HBASE-15236).
HBASE-17582 Fix broken drop page cache hint (broken by HBASE-15236). Change-Id: I2947ab979979f977db7b0c282c4aaf4eb1f26482 Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e39e0e63 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e39e0e63 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e39e0e63 Branch: refs/heads/HBASE-16961 Commit: e39e0e634a2252a352ad799bc2957c72e8d2d2e9 Parents: 55d6dca Author: Apekshit SharmaAuthored: Wed Feb 1 23:23:46 2017 -0800 Committer: Apekshit Sharma Committed: Mon Mar 20 11:19:51 2017 -0700 -- .../org/apache/hadoop/hbase/regionserver/StoreFileScanner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/e39e0e63/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java index ca7dfd4..ab6b0ef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java @@ -129,7 +129,7 @@ public class StoreFileScanner implements KeyValueScanner { List sorted_files = new ArrayList<>(files); Collections.sort(sorted_files, StoreFile.Comparators.SEQ_ID); for (int i = 0; i < sorted_files.size(); i++) { - StoreFileReader r = sorted_files.get(i).createReader(); + StoreFileReader r = sorted_files.get(i).createReader(canUseDrop); r.setReplicaStoreFile(isPrimaryReplica); StoreFileScanner scanner = r.getStoreFileScanner(cacheBlocks, usePread, isCompaction, readPt, i, matcher != null ? !matcher.hasNullColumnInQuery() : false);
[19/54] [abbrv] hbase git commit: Added hbase high performance cookbook to the book resources page on the website
Added hbase high performance cookbook to the book resources page on the website Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/16900c8c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/16900c8c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/16900c8c Branch: refs/heads/HBASE-16961 Commit: 16900c8c25766456aeb624c19d50ee0c203facfa Parents: e39e0e6 Author: Michael StackAuthored: Mon Mar 20 12:01:22 2017 -0700 Committer: Michael Stack Committed: Mon Mar 20 12:01:22 2017 -0700 -- src/main/site/xdoc/resources.xml | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/16900c8c/src/main/site/xdoc/resources.xml -- diff --git a/src/main/site/xdoc/resources.xml b/src/main/site/xdoc/resources.xml index d067c1e..078587c 100644 --- a/src/main/site/xdoc/resources.xml +++ b/src/main/site/xdoc/resources.xml @@ -37,6 +37,10 @@ under the License. http://www.packtpub.com/hbase-administration-for-optimum-database-performance-cookbook/book;>HBase Administration Cookbook by Yifeng Jiang. Publisher: PACKT Publishing, Release: Expected August 2012, Pages: 335. + + https://www.packtpub.com/big-data-and-business-intelligence/hbase-high-performance-cookbook;>HBase High Performance Cookbook by Ruchir Choudhry. Publisher: PACKT Publishing, Release: January 2017, Pages: 350. + +
[40/54] [abbrv] hbase git commit: HBASE-17001 Enforce quota violation policies in the RegionServer
HBASE-17001 Enforce quota violation policies in the RegionServer The nuts-and-bolts of filesystem quotas. The Master must inform RegionServers of the violation of a quota by a table. The RegionServer must apply the violation policy as configured. Need to ensure that the proper interfaces exist to satisfy all necessary policies. This required a massive rewrite of the internal tracking by the general space quota feature. Instead of tracking "violations", we need to start tracking "usage". This allows us to make the decision at the RegionServer level as to when the files in a bulk load request should be accept or rejected which ultimately lets us avoid bulk loads dramatically exceeding a configured space quota. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b99e9cf9 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b99e9cf9 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b99e9cf9 Branch: refs/heads/HBASE-16961 Commit: b99e9cf94d5af3af20f8bedfe9a9a681132f8550 Parents: c544ed1 Author: Josh ElserAuthored: Thu Dec 15 13:27:56 2016 -0500 Committer: Josh Elser Committed: Mon Mar 20 18:02:54 2017 -0400 -- .../hbase/quotas/QuotaExceededException.java|4 + .../hadoop/hbase/quotas/QuotaTableUtil.java | 47 +- .../hadoop/hbase/quotas/SpaceQuotaSnapshot.java | 192 +++ .../shaded/protobuf/generated/QuotaProtos.java | 1384 +- .../src/main/protobuf/Quota.proto | 15 + .../hbase/protobuf/generated/QuotaProtos.java | 1324 - hbase-protocol/src/main/protobuf/Quota.proto| 15 + .../org/apache/hadoop/hbase/master/HMaster.java | 29 +- .../hbase/quotas/ActivePolicyEnforcement.java | 86 ++ .../quotas/NamespaceQuotaSnapshotStore.java | 127 ++ .../quotas/NamespaceQuotaViolationStore.java| 127 -- .../hadoop/hbase/quotas/QuotaObserverChore.java | 344 +++-- .../hadoop/hbase/quotas/QuotaSnapshotStore.java | 96 ++ .../hbase/quotas/QuotaViolationStore.java | 89 -- .../quotas/RegionServerSpaceQuotaManager.java | 179 ++- .../hbase/quotas/SpaceLimitingException.java| 95 ++ .../hbase/quotas/SpaceQuotaRefresherChore.java | 225 +++ .../quotas/SpaceQuotaSnapshotNotifier.java | 45 + .../SpaceQuotaSnapshotNotifierFactory.java | 62 + .../quotas/SpaceQuotaViolationNotifier.java | 54 - .../SpaceQuotaViolationNotifierFactory.java | 62 - .../SpaceQuotaViolationNotifierForTest.java | 54 - ...SpaceQuotaViolationPolicyRefresherChore.java | 154 -- .../quotas/SpaceViolationPolicyEnforcement.java | 91 ++ .../SpaceViolationPolicyEnforcementFactory.java | 95 ++ .../hbase/quotas/TableQuotaSnapshotStore.java | 127 ++ .../hbase/quotas/TableQuotaViolationStore.java | 127 -- .../quotas/TableSpaceQuotaSnapshotNotifier.java | 52 + .../TableSpaceQuotaViolationNotifier.java | 55 - .../AbstractViolationPolicyEnforcement.java | 118 ++ ...LoadVerifyingViolationPolicyEnforcement.java | 50 + .../DisableTableViolationPolicyEnforcement.java | 80 + .../NoInsertsViolationPolicyEnforcement.java| 55 + ...esCompactionsViolationPolicyEnforcement.java | 64 + .../NoWritesViolationPolicyEnforcement.java | 54 + .../hbase/regionserver/CompactSplitThread.java | 12 + .../hbase/regionserver/RSRpcServices.java | 92 +- .../hbase/quotas/SpaceQuotaHelperForTests.java | 228 +++ .../SpaceQuotaSnapshotNotifierForTest.java | 55 + .../quotas/TestActivePolicyEnforcement.java | 74 + .../quotas/TestFileSystemUtilizationChore.java |3 +- .../TestNamespaceQuotaViolationStore.java | 16 +- .../hbase/quotas/TestQuotaObserverChore.java| 30 +- .../TestQuotaObserverChoreWithMiniCluster.java | 351 ++--- .../hadoop/hbase/quotas/TestQuotaTableUtil.java | 34 +- .../TestRegionServerSpaceQuotaManager.java | 174 ++- ...SpaceQuotaViolationPolicyRefresherChore.java | 193 ++- .../hadoop/hbase/quotas/TestSpaceQuotas.java| 452 ++ .../quotas/TestTableQuotaViolationStore.java| 22 +- .../TestTableSpaceQuotaViolationNotifier.java | 48 +- .../hbase/quotas/TestTablesWithQuotas.java |8 +- .../BaseViolationPolicyEnforcement.java | 31 + ...kLoadCheckingViolationPolicyEnforcement.java | 142 ++ ...tDisableTableViolationPolicyEnforcement.java | 59 + ...TestNoInsertsViolationPolicyEnforcement.java | 57 + ...esCompactionsViolationPolicyEnforcement.java | 58 + .../TestNoWritesViolationPolicyEnforcement.java | 57 + 57 files changed, 6492 insertions(+), 1481 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/b99e9cf9/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaExceededException.java
[34/54] [abbrv] hbase git commit: HBASE-17259 API to remove space quotas on a table/namespace
HBASE-17259 API to remove space quotas on a table/namespace Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/187a43f1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/187a43f1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/187a43f1 Branch: refs/heads/HBASE-16961 Commit: 187a43f10a11b2441b89c554cae4508e92c17853 Parents: b99e9cf Author: Josh ElserAuthored: Wed Jan 11 12:47:06 2017 -0500 Committer: Josh Elser Committed: Mon Mar 20 18:02:54 2017 -0400 -- .../hbase/quotas/QuotaSettingsFactory.java | 22 +++ .../hadoop/hbase/quotas/QuotaTableUtil.java | 6 +- .../hadoop/hbase/quotas/SpaceLimitSettings.java | 44 - .../hbase/quotas/TestQuotaSettingsFactory.java | 20 +++ .../shaded/protobuf/generated/QuotaProtos.java | 157 +++--- .../src/main/protobuf/Quota.proto | 1 + .../hbase/protobuf/generated/QuotaProtos.java | 159 --- hbase-protocol/src/main/protobuf/Quota.proto| 1 + .../hadoop/hbase/quotas/MasterQuotaManager.java | 9 +- .../hadoop/hbase/quotas/TestQuotaAdmin.java | 49 +- 10 files changed, 423 insertions(+), 45 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/187a43f1/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 657554a..25ee782 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -318,6 +318,17 @@ public class QuotaSettingsFactory { } /** + * Creates a {@link QuotaSettings} object to remove the FileSystem space quota for the given + * table. + * + * @param tableName The name of the table to remove the quota for. + * @return A {@link QuotaSettings} object. + */ + public static QuotaSettings removeTableSpaceLimit(TableName tableName) { +return new SpaceLimitSettings(tableName, true); + } + + /** * Creates a {@link QuotaSettings} object to limit the FileSystem space usage for the given * namespace to the given size in bytes. When the space usage is exceeded by all tables in the * namespace, the provided {@link SpaceViolationPolicy} is enacted on all tables in the namespace. @@ -331,4 +342,15 @@ public class QuotaSettingsFactory { final String namespace, long sizeLimit, final SpaceViolationPolicy violationPolicy) { return new SpaceLimitSettings(namespace, sizeLimit, violationPolicy); } + + /** + * Creates a {@link QuotaSettings} object to remove the FileSystem space quota for the given +* namespace. + * + * @param namespace The namespace to remove the quota on. + * @return A {@link QuotaSettings} object. + */ + public static QuotaSettings removeNamespaceSpaceLimit(String namespace) { +return new SpaceLimitSettings(namespace, true); + } } http://git-wip-us.apache.org/repos/asf/hbase/blob/187a43f1/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java index 42da811..ca525f0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java @@ -390,7 +390,11 @@ public class QuotaTableUtil { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); -hasSettings |= quotas.hasSpace(); +// Only when there is a space quota, make sure there's actually both fields provided +// Otherwise, it's a noop. +if (quotas.hasSpace()) { + hasSettings |= (quotas.getSpace().hasSoftLimit() && quotas.getSpace().hasViolationPolicy()); +} return !hasSettings; } http://git-wip-us.apache.org/repos/asf/hbase/blob/187a43f1/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java index e54882e..8ff7623 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.java +++