Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-22279 Add a getRegionLocator method in Table/AsyncTable interface #175

Merged
merged 1 commit into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public interface AsyncTable<C extends ScanResultConsumerBase> {
*/
Configuration getConfiguration();

/**
* Gets the {@link TableDescriptor} for this table.
*/
CompletableFuture<TableDescriptor> getDescriptor();

/**
* Gets the {@link AsyncTableRegionLocator} for this table.
*/
AsyncTableRegionLocator getRegionLocator();
/**
* Get timeout of each rpc request in this Table instance. It will be overridden by a more
* specific rpc timeout config such as readRpcTimeout or writeRpcTimeout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public Configuration getConfiguration() {
return rawTable.getConfiguration();
}

@Override
public CompletableFuture<TableDescriptor> getDescriptor() {
return wrap(rawTable.getDescriptor());
}

@Override
public AsyncTableRegionLocator getRegionLocator() {
return rawTable.getRegionLocator();
}

@Override
public long getRpcTimeout(TimeUnit unit) {
return rawTable.getRpcTimeout(unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ public <R extends Message> void batchCoprocessorService(
}
}

@Override
public RegionLocator getRegionLocator() {
return this.locator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public Configuration getConfiguration() {
return conn.getConfiguration();
}

@Override
public CompletableFuture<TableDescriptor> getDescriptor() {
return conn.getAdmin().getDescriptor(tableName);
}

@Override
public AsyncTableRegionLocator getRegionLocator() {
return conn.getRegionLocator(tableName);
}

@FunctionalInterface
private interface Converter<D, I, S> {
D convert(I info, S src) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@
*/
package org.apache.hadoop.hbase.client;

import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
import com.google.protobuf.Service;
import com.google.protobuf.ServiceException;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.yetus.audience.InterfaceAudience;

import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.util.Bytes;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
import com.google.protobuf.Service;
import com.google.protobuf.ServiceException;
import org.apache.yetus.audience.InterfaceAudience;

/**
* Used to communicate with a single HBase table.
Expand Down Expand Up @@ -92,6 +90,11 @@ default HTableDescriptor getTableDescriptor() throws IOException {
*/
TableDescriptor getDescriptor() throws IOException;

/**
* Gets the {@link RegionLocator} for this table.
*/
RegionLocator getRegionLocator() throws IOException;

/**
* Test for the existence of columns in the table, as specified by the Get.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Row;
Expand Down Expand Up @@ -1022,4 +1023,9 @@ public boolean thenMutate(RowMutations mutation) throws IOException {
throw new UnsupportedOperationException("thenMutate not implemented");
}
}

@Override
public RegionLocator getRegionLocator() throws IOException {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@
*/
package org.apache.hadoop.hbase.regionserver;

import com.google.protobuf.Descriptors.MethodDescriptor;
import com.google.protobuf.Message;
import com.google.protobuf.Service;
import com.google.protobuf.ServiceException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.client.Append;
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.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Row;
Expand All @@ -48,11 +52,6 @@
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;

import com.google.protobuf.Descriptors.MethodDescriptor;
import com.google.protobuf.Message;
import com.google.protobuf.Service;
import com.google.protobuf.ServiceException;

/**
* An implementation of {@link Table} that sits directly on a Region; it decorates the passed in
* Region instance with the Table API. Some API is not implemented yet (throws
Expand Down Expand Up @@ -412,9 +411,18 @@ public long getRpcTimeout(TimeUnit unit) {

@Override
@Deprecated
public int getWriteRpcTimeout() { throw new UnsupportedOperationException(); }
public int getWriteRpcTimeout() {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
public int getReadRpcTimeout() { throw new UnsupportedOperationException(); }
public int getReadRpcTimeout() {
throw new UnsupportedOperationException();
}

@Override
public RegionLocator getRegionLocator() throws IOException {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,11 @@ public int getOperationTimeout() {

@Override
public void setOperationTimeout(int operationTimeout) {
}

@Override
public RegionLocator getRegionLocator() throws IOException {
return null;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Row;
Expand Down Expand Up @@ -489,4 +490,8 @@ public CoprocessorRpcChannel coprocessorService(byte[] row) {
throw new NotImplementedException("coprocessorService not supported in ThriftTable");
}

@Override
public RegionLocator getRegionLocator() throws IOException {
throw new NotImplementedException("getRegionLocator not supported in ThriftTable");
}
}