Skip to content
Closed
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 @@ -76,7 +76,7 @@ public BufferedMutatorParams operationTimeout(final int operationTimeout) {
}

/**
* @deprecated Since 2.3.0, will be removed in 4.0.0. Use {@link #operationTimeout()}
* @deprecated Since 2.3.0, will be removed in 4.0.0. Use {@link #operationTimeout(int)}
*/
@Deprecated
public BufferedMutatorParams opertationTimeout(final int operationTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@ private void waitForRegion() throws InterruptedIOException {
* regions. 3) check the total concurrent tasks. 4) check the concurrent
* tasks for server.
*
* @param loc
* @param heapSizeOfRow
* @return either Include {@link ReturnCode} or Skip {@link ReturnCode}
* @param loc the destination of data
* @param heapSizeOfRow the data size
* @return either Include {@link RequestController.ReturnCode} or skip
* {@link RequestController.ReturnCode}
*/
@Override
public ReturnCode canTakeOperation(HRegionLocation loc, long heapSizeOfRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,63 +41,18 @@ public SnapshotDescription(String name) {
this(name, (TableName)null);
}

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
* instance instead.
* @see #SnapshotDescription(String, TableName)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
*/
@Deprecated
public SnapshotDescription(String name, String table) {
this(name, TableName.valueOf(table));
}

public SnapshotDescription(String name, TableName table) {
this(name, table, SnapshotType.DISABLED, null, -1, -1, null);
}

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
* instance instead.
* @see #SnapshotDescription(String, TableName, SnapshotType)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
*/
@Deprecated
public SnapshotDescription(String name, String table, SnapshotType type) {
this(name, TableName.valueOf(table), type);
}

public SnapshotDescription(String name, TableName table, SnapshotType type) {
this(name, table, type, null, -1, -1, null);
}

/**
* @see #SnapshotDescription(String, TableName, SnapshotType, String)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
* instance instead.
*/
@Deprecated
public SnapshotDescription(String name, String table, SnapshotType type, String owner) {
this(name, TableName.valueOf(table), type, owner);
}

public SnapshotDescription(String name, TableName table, SnapshotType type, String owner) {
this(name, table, type, owner, -1, -1, null);
}

/**
* @see #SnapshotDescription(String, TableName, SnapshotType, String, long, int, Map)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
* instance instead.
*/
@Deprecated
public SnapshotDescription(String name, String table, SnapshotType type, String owner,
long creationTime, int version) {
this(name, TableName.valueOf(table), type, owner, creationTime, version, null);
}

/**
* SnapshotDescription Parameterized Constructor
*
Expand Down Expand Up @@ -141,18 +96,6 @@ public String getName() {
return this.name;
}

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #getTableName()} or
* {@link #getTableNameAsString()} instead.
* @see #getTableName()
* @see #getTableNameAsString()
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
*/
@Deprecated
public String getTable() {
return getTableNameAsString();
}

public String getTableNameAsString() {
return this.table.getNameAsString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ default Result get(Get get) throws IOException {
* @throws IOException if a remote or network exception occurs.
* @since 0.90.0
* @apiNote {@link #put(List)} runs pre-flight validations on the input list on client.
* Currently {@link #get(List)} doesn't run any validations on the client-side, currently there
* is no need, but this may change in the future. An
* {@link IllegalArgumentException} will be thrown in this case.
* Currently {@link #get(List)} doesn't run any validations on the client-side,
* currently there is no need, but this may change in the future. An
* {@link IllegalArgumentException} will be thrown in this case.
*/
default Result[] get(List<Get> gets) throws IOException {
throw new NotImplementedException("Add an implementation!");
Expand Down Expand Up @@ -284,10 +284,10 @@ default void delete(Delete delete) throws IOException {
* that have not be successfully applied.
* @since 0.20.1
* @apiNote In 3.0.0 version, the input list {@code deletes} will no longer be modified. Also,
* {@link #put(List)} runs pre-flight validations on the input list on client. Currently
* {@link #delete(List)} doesn't run validations on the client, there is no need currently,
* but this may change in the future. An * {@link IllegalArgumentException} will be thrown
* in this case.
* {@link #put(List)} runs pre-flight validations on the input list on client. Currently
* {@link #delete(List)} doesn't run validations on the client, there is no need
* currently, but this may change in the future. An * {@link IllegalArgumentException}
* will be thrown in this case.
*/
default void delete(List<Delete> deletes) throws IOException {
throw new NotImplementedException("Add an implementation!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class Batch {
* the implementations {@link Batch.Call#call(Object)} method will be invoked
* with a proxy to each region's coprocessor {@link com.google.protobuf.Service} implementation.
* </p>
* @see org.apache.hadoop.hbase.client.coprocessor
* @see org.apache.hadoop.hbase.client.coprocessor.Batch
* @see org.apache.hadoop.hbase.client.Table#coprocessorService(byte[])
* @see org.apache.hadoop.hbase.client.Table#coprocessorService(Class, byte[], byte[],
* org.apache.hadoop.hbase.client.coprocessor.Batch.Call)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.CallQueueTooBigException;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.MultiActionResultTooLarge;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.RetryImmediatelyException;
Expand All @@ -59,18 +58,23 @@ public static boolean isMetaClearingException(Throwable cur) {
if (cur == null) {
return true;
}
return !isSpecialException(cur) || (cur instanceof RegionMovedException)
|| cur instanceof NotServingRegionException;
return !regionDefinitelyOnTheRegionServerException(cur);
}

public static boolean isSpecialException(Throwable cur) {
return (cur instanceof RegionMovedException || cur instanceof RegionOpeningException
|| cur instanceof RegionTooBusyException || cur instanceof RpcThrottlingException
|| cur instanceof MultiActionResultTooLarge || cur instanceof RetryImmediatelyException
|| cur instanceof CallQueueTooBigException || cur instanceof CallDroppedException
|| cur instanceof NotServingRegionException || cur instanceof RequestTooBigException);
private static boolean regionDefinitelyOnTheRegionServerException(Throwable t) {
return (t instanceof RegionTooBusyException || t instanceof RpcThrottlingException
|| t instanceof RetryImmediatelyException || t instanceof CallQueueTooBigException
|| t instanceof CallDroppedException || t instanceof NotServingRegionException
|| t instanceof RequestTooBigException);
}

/**
* This function is the alias of regionDefinitelyOnTheRegionServerException,
* whose name is confusing in the function findException().
*/
private static boolean matchExceptionWeCare(Throwable t) {
return regionDefinitelyOnTheRegionServerException(t);
}

/**
* Look for an exception we know in the remote exception:
Expand All @@ -87,15 +91,15 @@ public static Throwable findException(Object exception) {
}
Throwable cur = (Throwable) exception;
while (cur != null) {
if (isSpecialException(cur)) {
if (matchExceptionWeCare(cur)) {
return cur;
}
if (cur instanceof RemoteException) {
RemoteException re = (RemoteException) cur;
cur = re.unwrapRemoteException();

// unwrapRemoteException can return the exception given as a parameter when it cannot
// unwrap it. In this case, there is no need to look further
// unwrap it. In this case, there is no need to look further
// noinspection ObjectEquality
if (cur == re) {
return cur;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.util.List;

Expand Down Expand Up @@ -450,10 +451,39 @@ public byte[] toBytes() {
*/
public abstract int read(ReadableByteChannel channel) throws IOException;

/**
* Reads bytes from FileChannel into this ByteBuff
*/
public abstract int read(FileChannel channel, long offset) throws IOException;

/**
* Write this ByteBuff's data into target file
*/
public abstract int write(FileChannel channel, long offset) throws IOException;

/**
* function interface for Channel read
*/
@FunctionalInterface
interface ChannelReader {
int read(ReadableByteChannel channel, ByteBuffer buf, long offset) throws IOException;
}

static final ChannelReader CHANNEL_READER = (channel, buf, offset) -> {
return channel.read(buf);
};

static final ChannelReader FILE_READER = (channel, buf, offset) -> {
return ((FileChannel)channel).read(buf, offset);
};

// static helper methods
public static int channelRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException {
public static int read(ReadableByteChannel channel, ByteBuffer buf, long offset,
ChannelReader reader) throws IOException {
if (buf.remaining() <= NIO_BUFFER_LIMIT) {
return channel.read(buf);
int res = reader.read(channel, buf, offset);
buf.rewind();
return res;
}
int originalLimit = buf.limit();
int initialRemaining = buf.remaining();
Expand All @@ -463,12 +493,14 @@ public static int channelRead(ReadableByteChannel channel, ByteBuffer buf) throw
try {
int ioSize = Math.min(buf.remaining(), NIO_BUFFER_LIMIT);
buf.limit(buf.position() + ioSize);
ret = channel.read(buf);
offset += ret;
ret = reader.read(channel, buf, offset);
if (ret < ioSize) {
break;
}
} finally {
buf.limit(originalLimit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only reset the limit ? should we also reset the position ?

buf.rewind();
}
}
int nBytes = initialRemaining - buf.remaining();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.InvalidMarkException;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;

import org.apache.hadoop.hbase.io.ByteBuffAllocator.Recycler;
Expand Down Expand Up @@ -1064,28 +1065,58 @@ public byte[] toBytes(int offset, int length) {
return output;
}

@Override
public int read(ReadableByteChannel channel) throws IOException {
private int internalRead(ReadableByteChannel channel, long offset,
ChannelReader reader) throws IOException {
checkRefCount();
int total = 0;
while (true) {
// Read max possible into the current BB
int len = channelRead(channel, this.curItem);
if (len > 0)
int len = read(channel, this.curItem, offset, reader);
if (len > 0) {
total += len;
offset += len;
}
if (this.curItem.hasRemaining()) {
// We were not able to read enough to fill the current BB itself. Means there is no point in
// doing more reads from Channel. Only this much there for now.
break;
} else {
if (this.curItemIndex >= this.limitedItemIndex) break;
if (this.curItemIndex >= this.limitedItemIndex) {
break;
}
this.curItemIndex++;
this.curItem = this.items[this.curItemIndex];
}
}
return total;
}

@Override
public int read(ReadableByteChannel channel) throws IOException {
return internalRead(channel, 0, CHANNEL_READER);
}

@Override
public int read(FileChannel channel, long offset) throws IOException {
return internalRead(channel, offset, FILE_READER);
}

@Override
public int write(FileChannel channel, long offset) throws IOException {
checkRefCount();
int total = 0;
while (true) {
while (curItem.hasRemaining()) {
int len = channel.write(curItem, offset);
total += len;
offset += len;
}
if (this.curItemIndex >= this.limitedItemIndex) {
break;
}
this.curItemIndex++;
this.curItem = this.items[this.curItemIndex];
}
return total;
}

@Override
public ByteBuffer[] nioByteBuffers() {
checkRefCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;

import org.apache.hadoop.hbase.io.ByteBuffAllocator.Recycler;
Expand Down Expand Up @@ -371,7 +372,25 @@ public void get(ByteBuffer out, int sourceOffset, int length) {
@Override
public int read(ReadableByteChannel channel) throws IOException {
checkRefCount();
return channelRead(channel, buf);
return read(channel, buf, 0, CHANNEL_READER);
}

@Override
public int read(FileChannel channel, long offset) throws IOException {
checkRefCount();
return read(channel, buf, offset, FILE_READER);
}

@Override
public int write(FileChannel channel, long offset) throws IOException {
checkRefCount();
int total = 0;
while(buf.hasRemaining()) {
int len = channel.write(buf, offset);
total += len;
offset += len;
}
return total;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ protected static class TableRecordWriter implements RecordWriter<ImmutableBytesW
private BufferedMutator m_mutator;
private Connection conn;


/**
* Instantiate a TableRecordWriter with the HBase HClient for writing.
*
* @deprecated since 2.0.0 and will be removed in 3.0.0. Please use
* {@code #TableRecordWriter(JobConf)} instead. This version does not clean up connections and
* will leak connections (removed in 2.0).
* @see <a href="https://issues.apache.org/jira/browse/HBASE-16774">HBASE-16774</a>
*/
@Deprecated
public TableRecordWriter(final BufferedMutator mutator) throws IOException {
this.m_mutator = mutator;
this.conn = null;
}

/**
* Instantiate a TableRecordWriter with a BufferedMutator for batch writing.
*/
Expand Down
Loading