[GitHub] incubator-tephra pull request #67: TEPHRA-272 Add HBase 2.0 compatibility mo...
Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r16679 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/FilteredInternalScanner.java --- @@ -0,0 +1,80 @@ +/* + * 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.tephra.hbase.coprocessor; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.ScannerContext; +import org.apache.tephra.hbase.coprocessor.TransactionProcessor.IncludeInProgressFilter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper of InternalScanner to apply Transaction visibility filter for flush and compact + */ +public class FilteredInternalScanner implements InternalScanner { + + private InternalScanner delegate; + private Filter filter; + + public FilteredInternalScanner(InternalScanner internalScanner, IncludeInProgressFilter filter) { +this.delegate = internalScanner; +this.filter = filter; + } + + @Override + public void close() throws IOException { +this.delegate.close(); + } + + @Override + public boolean next(List result, ScannerContext scannerContext) throws IOException { +List outResult = new ArrayList(); --- End diff -- It would be good to make `outResult` as a private variable, so that it is not created for every `next` call. We can then just clear it for each call. ---
[jira] [Commented] (TEPHRA-272) Add HBase 2.0 compatibility module
[ https://issues.apache.org/jira/browse/TEPHRA-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16368014#comment-16368014 ] ASF GitHub Bot commented on TEPHRA-272: --- Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r168878262 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/TransactionProcessor.java --- @@ -0,0 +1,574 @@ +/* + * 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.tephra.hbase.coprocessor; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellUtil; +import org.apache.hadoop.hbase.CoprocessorEnvironment; +import org.apache.hadoop.hbase.DoNotRetryIOException; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Durability; +import org.apache.hadoop.hbase.client.Get; +import org.apache.hadoop.hbase.client.OperationWithAttributes; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; +import org.apache.hadoop.hbase.coprocessor.RegionObserver; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.FilterBase; +import org.apache.hadoop.hbase.regionserver.HStore; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.Region; +import org.apache.hadoop.hbase.regionserver.ScanOptions; +import org.apache.hadoop.hbase.regionserver.ScanType; +import org.apache.hadoop.hbase.regionserver.Store; +import org.apache.hadoop.hbase.regionserver.StoreFile; +import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker; +import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.wal.WALEdit; +import org.apache.tephra.Transaction; +import org.apache.tephra.TransactionCodec; +import org.apache.tephra.TxConstants; +import org.apache.tephra.coprocessor.CacheSupplier; +import org.apache.tephra.coprocessor.TransactionStateCache; +import org.apache.tephra.coprocessor.TransactionStateCacheSupplier; +import org.apache.tephra.hbase.txprune.CompactionState; +import org.apache.tephra.persist.TransactionVisibilityState; +import org.apache.tephra.util.TxUtils; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.NavigableSet; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +/** + * {@code org.apache.hadoop.hbase.coprocessor.RegionObserver} coprocessor that handles server-side processing + * for transactions: + * + * applies filtering to exclude data from invalid and in-progress transactions + * overrides the scanner returned for flush and compaction to drop data written by invalidated transactions, + * or expired due to TTL. + * + * + * In order to use this coprocessor for transactions, configure the class on any table involved in transactions, + * or on all user tables by adding the following to hbase-site.xml: + * {@code + * + *
[jira] [Commented] (TEPHRA-272) Add HBase 2.0 compatibility module
[ https://issues.apache.org/jira/browse/TEPHRA-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16368016#comment-16368016 ] ASF GitHub Bot commented on TEPHRA-272: --- Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r16679 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/FilteredInternalScanner.java --- @@ -0,0 +1,80 @@ +/* + * 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.tephra.hbase.coprocessor; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.ScannerContext; +import org.apache.tephra.hbase.coprocessor.TransactionProcessor.IncludeInProgressFilter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper of InternalScanner to apply Transaction visibility filter for flush and compact + */ +public class FilteredInternalScanner implements InternalScanner { + + private InternalScanner delegate; + private Filter filter; + + public FilteredInternalScanner(InternalScanner internalScanner, IncludeInProgressFilter filter) { +this.delegate = internalScanner; +this.filter = filter; + } + + @Override + public void close() throws IOException { +this.delegate.close(); + } + + @Override + public boolean next(List result, ScannerContext scannerContext) throws IOException { +List outResult = new ArrayList(); --- End diff -- It would be good to make `outResult` as a private variable, so that it is not created for every `next` call. We can then just clear it for each call. > Add HBase 2.0 compatibility module > -- > > Key: TEPHRA-272 > URL: https://issues.apache.org/jira/browse/TEPHRA-272 > Project: Tephra > Issue Type: Improvement >Reporter: Ankit Singhal >Assignee: Ankit Singhal >Priority: Major > Labels: HBase-2.0 > Fix For: 0.14.0-incubating > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (TEPHRA-272) Add HBase 2.0 compatibility module
[ https://issues.apache.org/jira/browse/TEPHRA-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16368017#comment-16368017 ] ASF GitHub Bot commented on TEPHRA-272: --- Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r16822 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/FilteredInternalScanner.java --- @@ -0,0 +1,80 @@ +/* + * 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.tephra.hbase.coprocessor; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.ScannerContext; +import org.apache.tephra.hbase.coprocessor.TransactionProcessor.IncludeInProgressFilter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper of InternalScanner to apply Transaction visibility filter for flush and compact + */ +public class FilteredInternalScanner implements InternalScanner { + + private InternalScanner delegate; + private Filter filter; --- End diff -- Both the fields can be marked as final since they don't change. > Add HBase 2.0 compatibility module > -- > > Key: TEPHRA-272 > URL: https://issues.apache.org/jira/browse/TEPHRA-272 > Project: Tephra > Issue Type: Improvement >Reporter: Ankit Singhal >Assignee: Ankit Singhal >Priority: Major > Labels: HBase-2.0 > Fix For: 0.14.0-incubating > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (TEPHRA-272) Add HBase 2.0 compatibility module
[ https://issues.apache.org/jira/browse/TEPHRA-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16368015#comment-16368015 ] ASF GitHub Bot commented on TEPHRA-272: --- Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r16423 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/FilteredInternalScanner.java --- @@ -0,0 +1,80 @@ +/* + * 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.tephra.hbase.coprocessor; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.ScannerContext; +import org.apache.tephra.hbase.coprocessor.TransactionProcessor.IncludeInProgressFilter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper of InternalScanner to apply Transaction visibility filter for flush and compact + */ +public class FilteredInternalScanner implements InternalScanner { + + private InternalScanner delegate; + private Filter filter; + + public FilteredInternalScanner(InternalScanner internalScanner, IncludeInProgressFilter filter) { +this.delegate = internalScanner; +this.filter = filter; + } + + @Override + public void close() throws IOException { +this.delegate.close(); + } + + @Override + public boolean next(List result, ScannerContext scannerContext) throws IOException { +List outResult = new ArrayList(); +while (true) { + boolean next = delegate.next(outResult, scannerContext); + for (Cell cell : outResult) { +ReturnCode code = filter.filterKeyValue(cell); +switch (code) { +// included, so we are done +case INCLUDE: +case INCLUDE_AND_NEXT_COL: --- End diff -- When the filter return code is `INCLUDE_AND_NEXT_COL`, this filter needs to skip the remaining cells for that column, right? > Add HBase 2.0 compatibility module > -- > > Key: TEPHRA-272 > URL: https://issues.apache.org/jira/browse/TEPHRA-272 > Project: Tephra > Issue Type: Improvement >Reporter: Ankit Singhal >Assignee: Ankit Singhal >Priority: Major > Labels: HBase-2.0 > Fix For: 0.14.0-incubating > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] incubator-tephra pull request #67: TEPHRA-272 Add HBase 2.0 compatibility mo...
Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/67#discussion_r16822 --- Diff: tephra-hbase-compat-2.0/src/main/java/org/apache/tephra/hbase/coprocessor/FilteredInternalScanner.java --- @@ -0,0 +1,80 @@ +/* + * 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.tephra.hbase.coprocessor; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.filter.Filter; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; +import org.apache.hadoop.hbase.regionserver.InternalScanner; +import org.apache.hadoop.hbase.regionserver.ScannerContext; +import org.apache.tephra.hbase.coprocessor.TransactionProcessor.IncludeInProgressFilter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper of InternalScanner to apply Transaction visibility filter for flush and compact + */ +public class FilteredInternalScanner implements InternalScanner { + + private InternalScanner delegate; + private Filter filter; --- End diff -- Both the fields can be marked as final since they don't change. ---