http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java index 813f02b..8f9e75b 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/client/TabletClient.java @@ -26,17 +26,16 @@ package org.apache.kudu.client; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.atomic.AtomicInteger; +import javax.security.sasl.SaslException; + import com.google.common.annotations.VisibleForTesting; import com.stumbleupon.async.Deferred; - -import org.jboss.netty.handler.timeout.ReadTimeoutException; -import org.apache.kudu.WireProtocol; -import org.apache.kudu.annotations.InterfaceAudience; -import org.apache.kudu.master.Master; -import org.apache.kudu.rpc.RpcHeader; -import org.apache.kudu.tserver.Tserver; -import org.apache.kudu.util.Pair; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -49,17 +48,16 @@ import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.handler.codec.replay.ReplayingDecoder; import org.jboss.netty.handler.codec.replay.VoidEnum; +import org.jboss.netty.handler.timeout.ReadTimeoutException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.security.sasl.SaslException; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.atomic.AtomicInteger; +import org.apache.kudu.WireProtocol; +import org.apache.kudu.annotations.InterfaceAudience; +import org.apache.kudu.master.Master; +import org.apache.kudu.rpc.RpcHeader; +import org.apache.kudu.tserver.Tserver; +import org.apache.kudu.util.Pair; /** * Stateful handler that manages a connection to a specific TabletServer. @@ -85,7 +83,7 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { public static final Logger LOG = LoggerFactory.getLogger(TabletClient.class); - private ArrayList<KuduRpc<?>> pending_rpcs; + private ArrayList<KuduRpc<?>> pendingRpcs; public static final byte RPC_CURRENT_VERSION = 9; /** Initial part of the header for 0.95 and up. */ @@ -129,7 +127,7 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { * Maps an RPC ID to the in-flight RPC that was given this ID. * RPCs can be sent out from any thread, so we need a concurrent map. */ - private final ConcurrentHashMap<Integer, KuduRpc<?>> rpcs_inflight = new ConcurrentHashMap<>(); + private final ConcurrentHashMap<Integer, KuduRpc<?>> rpcsInflight = new ConcurrentHashMap<>(); private final AsyncKuduClient kuduClient; @@ -190,21 +188,20 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { // Check if we got connected while entering this synchronized block. if (chan != null) { tryAgain = true; - // Check if we got disconnected. } else if (dead) { // We got disconnected during the process of encoding this rpc, but we need to check if // cleanup() already took care of calling failOrRetryRpc() for us. If it did, the entry we - // added in rpcs_inflight will be missing. If not, we have to call failOrRetryRpc() + // added in rpcsInflight will be missing. If not, we have to call failOrRetryRpc() // ourselves after this synchronized block. // `encodedRpcAndId` is null iff `chan` is null. - if (encodedRpcAndId == null || rpcs_inflight.containsKey(encodedRpcAndId.getSecond())) { + if (encodedRpcAndId == null || rpcsInflight.containsKey(encodedRpcAndId.getSecond())) { failRpc = true; } } else { - if (pending_rpcs == null) { - pending_rpcs = new ArrayList<>(); + if (pendingRpcs == null) { + pendingRpcs = new ArrayList<>(); } - pending_rpcs.add(rpc); + pendingRpcs.add(rpc); } } @@ -264,16 +261,16 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { payload = rpc.serialize(headerBuilder.build()); } catch (Exception e) { - LOG.error("Uncaught exception while serializing RPC: " + rpc, e); - rpc.errback(e); // Make the RPC fail with the exception. - return null; + LOG.error("Uncaught exception while serializing RPC: " + rpc, e); + rpc.errback(e); // Make the RPC fail with the exception. + return null; } - final KuduRpc<?> oldrpc = rpcs_inflight.put(rpcid, rpc); + final KuduRpc<?> oldrpc = rpcsInflight.put(rpcid, rpc); if (oldrpc != null) { final String wtf = getPeerUuidLoggingString() + - "WTF? There was already an RPC in flight with" - + " rpcid=" + rpcid + ": " + oldrpc - + ". This happened when sending out: " + rpc; + "WTF? There was already an RPC in flight with" + + " rpcid=" + rpcid + ": " + oldrpc + + ". This happened when sending out: " + rpc; LOG.error(wtf); Status statusIllegalState = Status.IllegalState(wtf); // Make it fail. This isn't an expected failure mode. @@ -281,8 +278,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { } if (LOG.isDebugEnabled()) { - LOG.debug(getPeerUuidLoggingString() + chan + " Sending RPC #" + rpcid - + ", payload=" + payload + ' ' + Bytes.pretty(payload)); + LOG.debug(getPeerUuidLoggingString() + chan + " Sending RPC #" + rpcid + + ", payload=" + payload + ' ' + Bytes.pretty(payload)); } payload = secureRpcHelper.wrap(payload); @@ -311,7 +308,7 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { Status.NetworkError(getPeerUuidLoggingString() + "Client is shutting down"); NonRecoverableException exception = new NonRecoverableException(statusNetworkError); // First, check whether we have RPCs in flight and cancel them. - for (Iterator<KuduRpc<?>> ite = rpcs_inflight.values().iterator(); ite + for (Iterator<KuduRpc<?>> ite = rpcsInflight.values().iterator(); ite .hasNext();) { ite.next().errback(exception); ite.remove(); @@ -319,8 +316,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { // Same for the pending RPCs. synchronized (this) { - if (pending_rpcs != null) { - for (Iterator<KuduRpc<?>> ite = pending_rpcs.iterator(); ite.hasNext();) { + if (pendingRpcs != null) { + for (Iterator<KuduRpc<?>> ite = pendingRpcs.iterator(); ite.hasNext();) { ite.next().errback(exception); ite.remove(); } @@ -401,8 +398,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { RpcHeader.ResponseHeader header = response.getHeader(); if (!header.hasCallId()) { final int size = response.getTotalResponseSize(); - final String msg = getPeerUuidLoggingString() + "RPC response (size: " + size + ") doesn't" - + " have a call ID: " + header + ", buf=" + Bytes.pretty(buf); + final String msg = getPeerUuidLoggingString() + "RPC response (size: " + size + ") doesn't" + + " have a call ID: " + header + ", buf=" + Bytes.pretty(buf); LOG.error(msg); Status statusIncomplete = Status.Incomplete(msg); throw new NonRecoverableException(statusIncomplete); @@ -410,11 +407,11 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { final int rpcid = header.getCallId(); @SuppressWarnings("rawtypes") - final KuduRpc rpc = rpcs_inflight.get(rpcid); + final KuduRpc rpc = rpcsInflight.get(rpcid); if (rpc == null) { - final String msg = getPeerUuidLoggingString() + "Invalid rpcid: " + rpcid + " found in " - + buf + '=' + Bytes.pretty(buf); + final String msg = getPeerUuidLoggingString() + "Invalid rpcid: " + rpcid + " found in " + + buf + '=' + Bytes.pretty(buf); LOG.error(msg); Status statusIllegalState = Status.IllegalState(msg); // The problem here is that we don't know which Deferred corresponds to @@ -442,7 +439,7 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { KuduRpc.readProtobuf(response.getPBMessage(), errorBuilder); RpcHeader.ErrorStatusPB error = errorBuilder.build(); if (error.getCode().equals(RpcHeader.ErrorStatusPB.RpcErrorCodePB.ERROR_SERVER_TOO_BUSY)) { - // We can't return right away, we still need to remove ourselves from 'rpcs_inflight', so we + // We can't return right away, we still need to remove ourselves from 'rpcsInflight', so we // populate 'retryableHeaderError'. retryableHeaderError = Status.ServiceUnavailable(error.getMessage()); } else { @@ -460,14 +457,14 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { } } if (LOG.isDebugEnabled()) { - LOG.debug(getPeerUuidLoggingString() + "rpcid=" + rpcid - + ", response size=" + (buf.readerIndex() - rdx) + " bytes" - + ", " + actualReadableBytes() + " readable bytes left" - + ", rpc=" + rpc); + LOG.debug(getPeerUuidLoggingString() + "rpcid=" + rpcid + + ", response size=" + (buf.readerIndex() - rdx) + " bytes" + + ", " + actualReadableBytes() + " readable bytes left" + + ", rpc=" + rpc); } { - final KuduRpc<?> removed = rpcs_inflight.remove(rpcid); + final KuduRpc<?> removed = rpcsInflight.remove(rpcid); if (removed == null) { // The RPC we were decoding was cleaned up already, give up. Status statusIllegalState = Status.IllegalState("RPC not found"); @@ -525,12 +522,12 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { rpc.errback(exception); } } catch (Exception e) { - LOG.debug(getPeerUuidLoggingString() + "Unexpected exception while handling RPC #" + rpcid - + ", rpc=" + rpc + ", buf=" + Bytes.pretty(buf), e); + LOG.debug(getPeerUuidLoggingString() + "Unexpected exception while handling RPC #" + rpcid + + ", rpc=" + rpc + ", buf=" + Bytes.pretty(buf), e); } if (LOG.isDebugEnabled()) { - LOG.debug("------------------<< LEAVING DECODE <<------------------" - + " time elapsed: " + ((System.nanoTime() - start) / 1000) + "us"); + LOG.debug("------------------<< LEAVING DECODE <<------------------" + + " time elapsed: " + ((System.nanoTime() - start) / 1000) + "us"); } return null; // Stop processing here. The Deferred does everything else. } @@ -620,10 +617,10 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { return decode(ctx, chan, buf, unused); } finally { if (buf.readable()) { - LOG.error(getPeerUuidLoggingString() + "After decoding the last message on " + chan - + ", there was still some undecoded bytes in the channel's" - + " buffer (which are going to be lost): " - + buf + '=' + Bytes.pretty(buf)); + LOG.error(getPeerUuidLoggingString() + "After decoding the last message on " + chan + + ", there was still some undecoded bytes in the channel's" + + " buffer (which are going to be lost): " + + buf + '=' + Bytes.pretty(buf)); } } } else { @@ -708,26 +705,26 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { final ArrayList<KuduRpc<?>> rpcs; // The timing of this block is critical. If this TabletClient is 'dead' then it means that - // rpcs_inflight was emptied and that anything added to it after won't be handled and needs + // rpcsInflight was emptied and that anything added to it after won't be handled and needs // to be sent to failOrRetryRpc. synchronized (this) { // Cleanup can be called multiple times, but we only want to run it once so that we don't - // clear up rpcs_inflight multiple times. + // clear up rpcsInflight multiple times. if (dead) { return; } dead = true; - rpcs = pending_rpcs == null ? new ArrayList<KuduRpc<?>>(rpcs_inflight.size()) : pending_rpcs; + rpcs = pendingRpcs == null ? new ArrayList<KuduRpc<?>>(rpcsInflight.size()) : pendingRpcs; - for (Iterator<KuduRpc<?>> iterator = rpcs_inflight.values().iterator(); iterator.hasNext();) { + for (Iterator<KuduRpc<?>> iterator = rpcsInflight.values().iterator(); iterator.hasNext();) { KuduRpc<?> rpc = iterator.next(); rpcs.add(rpc); iterator.remove(); } - // After this, rpcs_inflight might still have entries since they could have been added + // After this, rpcsInflight might still have entries since they could have been added // concurrently, and those RPCs will be handled by their caller in sendRpc. - pending_rpcs = null; + pendingRpcs = null; } Status statusNetworkError = Status.NetworkError(getPeerUuidLoggingString() + "Connection reset"); @@ -787,8 +784,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { final Channel c = event.getChannel(); if (e instanceof RejectedExecutionException) { - LOG.warn(getPeerUuidLoggingString() + "RPC rejected by the executor," - + " ignore this if we're shutting down", e); + LOG.warn(getPeerUuidLoggingString() + "RPC rejected by the executor," + + " ignore this if we're shutting down", e); } else if (e instanceof ReadTimeoutException) { LOG.debug(getPeerUuidLoggingString() + "Encountered a read timeout, will close the channel"); } else { @@ -822,8 +819,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { private void sendQueuedRpcs() { ArrayList<KuduRpc<?>> rpcs; synchronized (this) { - rpcs = pending_rpcs; - pending_rpcs = null; + rpcs = pendingRpcs; + pendingRpcs = null; } if (rpcs != null) { for (final KuduRpc<?> rpc : rpcs) { @@ -847,8 +844,8 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { userBuilder.setRealUser(SecureRpcHelper.USER_AND_PASSWORD); builder.setDEPRECATEDUserInfo(userBuilder.build()); RpcHeader.ConnectionContextPB pb = builder.build(); - RpcHeader.RequestHeader header = RpcHeader.RequestHeader.newBuilder().setCallId - (CONNECTION_CTX_CALL_ID).build(); + RpcHeader.RequestHeader header = RpcHeader.RequestHeader.newBuilder() + .setCallId(CONNECTION_CTX_CALL_ID).build(); return KuduRpc.toChannelBuffer(header, pb); } @@ -869,13 +866,13 @@ public class TabletClient extends ReplayingDecoder<VoidEnum> { .append(", uuid=") // = 7 .append(serverInfo.getUuid()) // = 32 .append(", #pending_rpcs="); // =16 - int npending_rpcs; + int npendingRpcs; synchronized (this) { - npending_rpcs = pending_rpcs == null ? 0 : pending_rpcs.size(); + npendingRpcs = pendingRpcs == null ? 0 : pendingRpcs.size(); } - buf.append(npending_rpcs); // = 1 + buf.append(npendingRpcs); // = 1 buf.append(", #rpcs_inflight=") // =17 - .append(rpcs_inflight.size()) // ~ 2 + .append(rpcsInflight.size()) // ~ 2 .append(')'); // = 1 return buf.toString(); }
http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/client/Update.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Update.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Update.java index 5f12dff..9b4dc20 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/client/Update.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Update.java @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.client; import org.apache.kudu.annotations.InterfaceAudience; http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/client/Upsert.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Upsert.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Upsert.java index 3f7bcb5..7e7a66c 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/client/Upsert.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Upsert.java @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.client; import org.apache.kudu.annotations.InterfaceAudience; http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/AsyncUtil.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/AsyncUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/AsyncUtil.java index c69ec3f..7289bd5 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/AsyncUtil.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/AsyncUtil.java @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.util; import com.stumbleupon.async.Callback; @@ -42,9 +43,9 @@ public class AsyncUtil { */ @SuppressWarnings("unchecked") public static <T, R, D extends Deferred<R>, E> - Deferred<R> addCallbacksDeferring(final Deferred<T> d, - final Callback<D, T> cb, - final Callback<D, E> eb) { + Deferred<R> addCallbacksDeferring(final Deferred<T> d, + final Callback<D, T> cb, + final Callback<D, E> eb) { return d.addCallbacks((Callback<R, T>) cb, eb); } http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/ByteVec.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/ByteVec.java b/java/kudu-client/src/main/java/org/apache/kudu/util/ByteVec.java index 274840c..398c9d9 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/ByteVec.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/ByteVec.java @@ -14,8 +14,13 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.util; +import java.util.Arrays; +import java.util.List; +import javax.annotation.concurrent.NotThreadSafe; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; @@ -23,10 +28,6 @@ import com.google.common.primitives.Bytes; import org.apache.kudu.annotations.InterfaceAudience; -import java.util.Arrays; -import java.util.List; -import javax.annotation.concurrent.NotThreadSafe; - /** * A vector of primitive bytes. * @@ -115,7 +116,9 @@ public final class ByteVec { */ public void reserveAdditional(int additional) { Preconditions.checkArgument(additional >= 0, "negative additional"); - if (data.length - len >= additional) return; + if (data.length - len >= additional) { + return; + } // Use a 1.5x growth factor. According to // https://stackoverflow.com/questions/1100311/what-is-the-ideal-growth-rate-for-a-dynamically-allocated-array // this is close to the ideal ratio, although it isn't clear if that holds @@ -134,7 +137,9 @@ public final class ByteVec { */ public void reserveExact(int additional) { Preconditions.checkArgument(additional >= 0, "negative additional"); - if (data.length - len >= additional) return; + if (data.length - len >= additional) { + return; + } data = Arrays.copyOf(data, len + additional); } @@ -142,7 +147,9 @@ public final class ByteVec { * Shrink the capacity of the vector to match the length. */ public void shrinkToFit() { - if (len < data.length) data = Arrays.copyOf(data, len); + if (len < data.length) { + data = Arrays.copyOf(data, len); + } } /** @@ -234,7 +241,9 @@ public final class ByteVec { */ public List<Byte> asList() { List<Byte> list = Bytes.asList(data); - if (len < data.length) return list.subList(0, len); + if (len < data.length) { + return list.subList(0, len); + } return list; } @@ -262,11 +271,21 @@ public final class ByteVec { /** {@inheritDoc} */ @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } ByteVec other = (ByteVec) o; - if (len != other.len) return false; - for (int i = 0; i < len; i++) if (data[i] != other.data[i]) return false; + if (len != other.len) { + return false; + } + for (int i = 0; i < len; i++) { + if (data[i] != other.data[i]) { + return false; + } + } return true; } @@ -274,7 +293,9 @@ public final class ByteVec { @Override public int hashCode() { int result = len; - for (int i = 0; i < len; i++) result = 31 * result + data[i]; + for (int i = 0; i < len; i++) { + result = 31 * result + data[i]; + } return result; } http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/HybridTimeUtil.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/HybridTimeUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/HybridTimeUtil.java index 2ee68f4..d250257 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/HybridTimeUtil.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/HybridTimeUtil.java @@ -14,12 +14,13 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package org.apache.kudu.util; -import org.apache.kudu.annotations.InterfaceAudience; +package org.apache.kudu.util; import java.util.concurrent.TimeUnit; +import org.apache.kudu.annotations.InterfaceAudience; + /** * Set of common utility methods to handle HybridTime and related timestamps. */ @@ -51,7 +52,9 @@ public class HybridTimeUtil { * @param htTimestamp the encoded HT timestamp * @return a pair of {physical, logical} long values in an array */ + //CHECKSTYLE:OFF public static long[] HTTimestampToPhysicalAndLogical(long htTimestamp) { + //CHECKSTYLE:ON long timestampInMicros = htTimestamp >> hybridTimeNumBitsToShift; long logicalValues = htTimestamp & hybridTimeLogicalBitsMask; return new long[] {timestampInMicros, logicalValues}; http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/NetUtil.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/NetUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/NetUtil.java index 4ca6d8c..92d39a4 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/NetUtil.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/NetUtil.java @@ -14,23 +14,25 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.util; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.List; + import com.google.common.base.Functions; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.net.HostAndPort; -import org.apache.kudu.annotations.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.List; +import org.apache.kudu.annotations.InterfaceAudience; /** * Networking related methods. @@ -125,6 +127,7 @@ public class NetUtil { try { local = NetworkInterface.getByInetAddress(addr) != null; } catch (SocketException e) { + // Pass. } } return local; http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/Pair.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/Pair.java b/java/kudu-client/src/main/java/org/apache/kudu/util/Pair.java index c2a0944..c2d8d94 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/Pair.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/Pair.java @@ -14,9 +14,11 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + package org.apache.kudu.util; import com.google.common.base.Objects; + import org.apache.kudu.annotations.InterfaceAudience; @InterfaceAudience.Private @@ -39,13 +41,21 @@ public class Pair<A, B> { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Pair<?, ?> pair = (Pair<?, ?>) o; - if (first != null ? !first.equals(pair.first) : pair.first != null) return false; - if (second != null ? !second.equals(pair.second) : pair.second != null) return false; + if (first != null ? !first.equals(pair.first) : pair.first != null) { + return false; + } + if (second != null ? !second.equals(pair.second) : pair.second != null) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/Slice.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/Slice.java b/java/kudu-client/src/main/java/org/apache/kudu/util/Slice.java index 7a3dcae..4a4e045 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/Slice.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/Slice.java @@ -16,13 +16,10 @@ * Copyright 2011 Dain Sundstrom <d...@iq80.com> * Copyright 2011 FuseSource Corp. http://fusesource.com */ + package org.apache.kudu.util; -import com.google.common.base.Preconditions; -import com.google.common.primitives.Ints; -import com.google.common.primitives.Longs; -import com.google.common.primitives.Shorts; -import org.apache.kudu.annotations.InterfaceAudience; +import static java.nio.ByteOrder.LITTLE_ENDIAN; import java.io.IOException; import java.io.InputStream; @@ -35,37 +32,38 @@ import java.nio.channels.ScatteringByteChannel; import java.nio.charset.Charset; import java.util.Arrays; -import static java.nio.ByteOrder.LITTLE_ENDIAN; +import com.google.common.base.Preconditions; +import com.google.common.primitives.Ints; +import com.google.common.primitives.Longs; +import com.google.common.primitives.Shorts; + +import org.apache.kudu.annotations.InterfaceAudience; /** * Little Endian slice of a byte array. */ @InterfaceAudience.Private -public final class Slice implements Comparable<Slice> -{ +public final class Slice implements Comparable<Slice> { private final byte[] data; private final int offset; private final int length; private int hash; - public Slice(int length) - { + public Slice(int length) { data = new byte[length]; this.offset = 0; this.length = length; } - public Slice(byte[] data) - { + public Slice(byte[] data) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = 0; this.length = data.length; } - public Slice(byte[] data, int offset, int length) - { + public Slice(byte[] data, int offset, int length) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = offset; @@ -75,24 +73,21 @@ public final class Slice implements Comparable<Slice> /** * Length of this slice. */ - public int length() - { + public int length() { return length; } /** * Gets the array underlying this slice. */ - public byte[] getRawArray() - { + public byte[] getRawArray() { return data; } /** * Gets the offset of this slice in the underlying array. */ - public int getRawOffset() - { + public int getRawOffset() { return offset; } @@ -102,8 +97,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} */ - public byte getByte(int index) - { + public byte getByte(int index) { Preconditions.checkPositionIndexes(index, index + 1, this.length); index += offset; return data[index]; @@ -116,8 +110,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} */ - public short getUnsignedByte(int index) - { + public short getUnsignedByte(int index) { return (short) (getByte(index) & 0xFF); } @@ -128,8 +121,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 2} is greater than {@code this.capacity} */ - public short getShort(int index) - { + public short getShort(int index) { Preconditions.checkPositionIndexes(index, index + Shorts.BYTES, this.length); index += offset; return (short) (data[index] & 0xFF | data[index + 1] << 8); @@ -142,8 +134,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 4} is greater than {@code this.capacity} */ - public int getInt(int index) - { + public int getInt(int index) { Preconditions.checkPositionIndexes(index, index + Ints.BYTES, this.length); index += offset; return (data[index] & 0xff) | @@ -159,8 +150,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 8} is greater than {@code this.capacity} */ - public long getLong(int index) - { + public long getLong(int index) { Preconditions.checkPositionIndexes(index, index + Longs.BYTES, this.length); index += offset; return ((long) data[index] & 0xff) | @@ -186,8 +176,7 @@ public final class Slice implements Comparable<Slice> * if {@code dstIndex + length} is greater than * {@code dst.capacity} */ - public void getBytes(int index, Slice dst, int dstIndex, int length) - { + public void getBytes(int index, Slice dst, int dstIndex, int length) { getBytes(index, dst.data, dstIndex, length); } @@ -204,21 +193,19 @@ public final class Slice implements Comparable<Slice> * if {@code dstIndex + length} is greater than * {@code dst.length} */ - public void getBytes(int index, byte[] destination, int destinationIndex, int length) - { + public void getBytes(int index, byte[] destination, int destinationIndex, int length) { Preconditions.checkPositionIndexes(index, index + length, this.length); - Preconditions.checkPositionIndexes(destinationIndex, destinationIndex + length, destination.length); + Preconditions.checkPositionIndexes(destinationIndex, + destinationIndex + length, destination.length); index += offset; System.arraycopy(data, index, destination, destinationIndex, length); } - public byte[] getBytes() - { + public byte[] getBytes() { return getBytes(0, length); } - public byte[] getBytes(int index, int length) - { + public byte[] getBytes(int index, int length) { index += offset; if (index == 0) { return Arrays.copyOf(data, length); @@ -238,8 +225,7 @@ public final class Slice implements Comparable<Slice> * if {@code index + dst.remaining()} is greater than * {@code this.capacity} */ - public void getBytes(int index, ByteBuffer destination) - { + public void getBytes(int index, ByteBuffer destination) { Preconditions.checkPositionIndex(index, this.length); index += offset; destination.put(data, index, Math.min(length, destination.remaining())); @@ -256,8 +242,7 @@ public final class Slice implements Comparable<Slice> * @throws java.io.IOException if the specified stream threw an exception during I/O */ public void getBytes(int index, OutputStream out, int length) - throws IOException - { + throws IOException { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; out.write(data, index, length); @@ -275,8 +260,7 @@ public final class Slice implements Comparable<Slice> * @throws java.io.IOException if the specified channel threw an exception during I/O */ public int getBytes(int index, GatheringByteChannel out, int length) - throws IOException - { + throws IOException { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; return out.write(ByteBuffer.wrap(data, index, length)); @@ -290,8 +274,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 2} is greater than {@code this.capacity} */ - public void setShort(int index, int value) - { + public void setShort(int index, int value) { Preconditions.checkPositionIndexes(index, index + Shorts.BYTES, this.length); index += offset; data[index] = (byte) (value); @@ -305,8 +288,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 4} is greater than {@code this.capacity} */ - public void setInt(int index, int value) - { + public void setInt(int index, int value) { Preconditions.checkPositionIndexes(index, index + Ints.BYTES, this.length); index += offset; data[index] = (byte) (value); @@ -322,8 +304,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 8} is greater than {@code this.capacity} */ - public void setLong(int index, long value) - { + public void setLong(int index, long value) { Preconditions.checkPositionIndexes(index, index + Longs.BYTES, this.length); index += offset; data[index] = (byte) (value); @@ -343,8 +324,7 @@ public final class Slice implements Comparable<Slice> * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} */ - public void setByte(int index, int value) - { + public void setByte(int index, int value) { Preconditions.checkPositionIndexes(index, index + 1, this.length); index += offset; data[index] = (byte) value; @@ -363,8 +343,7 @@ public final class Slice implements Comparable<Slice> * if {@code srcIndex + length} is greater than * {@code src.capacity} */ - public void setBytes(int index, Slice src, int srcIndex, int length) - { + public void setBytes(int index, Slice src, int srcIndex, int length) { setBytes(index, src.data, src.offset + srcIndex, length); } @@ -378,8 +357,7 @@ public final class Slice implements Comparable<Slice> * {@code this.capacity}, or * if {@code srcIndex + length} is greater than {@code src.length} */ - public void setBytes(int index, byte[] source, int sourceIndex, int length) - { + public void setBytes(int index, byte[] source, int sourceIndex, int length) { Preconditions.checkPositionIndexes(index, index + length, this.length); Preconditions.checkPositionIndexes(sourceIndex, sourceIndex + length, source.length); index += offset; @@ -395,8 +373,7 @@ public final class Slice implements Comparable<Slice> * if {@code index + src.remaining()} is greater than * {@code this.capacity} */ - public void setBytes(int index, ByteBuffer source) - { + public void setBytes(int index, ByteBuffer source) { Preconditions.checkPositionIndexes(index, index + source.remaining(), this.length); index += offset; source.get(data, index, source.remaining()); @@ -414,8 +391,7 @@ public final class Slice implements Comparable<Slice> * @throws java.io.IOException if the specified stream threw an exception during I/O */ public int setBytes(int index, InputStream in, int length) - throws IOException - { + throws IOException { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; int readBytes = 0; @@ -424,8 +400,7 @@ public final class Slice implements Comparable<Slice> if (localReadBytes < 0) { if (readBytes == 0) { return -1; - } - else { + } else { break; } } @@ -449,8 +424,7 @@ public final class Slice implements Comparable<Slice> * @throws java.io.IOException if the specified channel threw an exception during I/O */ public int setBytes(int index, ScatteringByteChannel in, int length) - throws IOException - { + throws IOException { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; ByteBuffer buf = ByteBuffer.wrap(data, index, length); @@ -460,19 +434,16 @@ public final class Slice implements Comparable<Slice> int localReadBytes; try { localReadBytes = in.read(buf); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { localReadBytes = -1; } if (localReadBytes < 0) { if (readBytes == 0) { return -1; - } - else { + } else { break; } - } - else if (localReadBytes == 0) { + } else if (localReadBytes == 0) { break; } readBytes += localReadBytes; @@ -482,8 +453,7 @@ public final class Slice implements Comparable<Slice> } public int setBytes(int index, FileChannel in, int position, int length) - throws IOException - { + throws IOException { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; ByteBuffer buf = ByteBuffer.wrap(data, index, length); @@ -493,19 +463,16 @@ public final class Slice implements Comparable<Slice> int localReadBytes; try { localReadBytes = in.read(buf, position + readBytes); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { localReadBytes = -1; } if (localReadBytes < 0) { if (readBytes == 0) { return -1; - } - else { + } else { break; } - } - else if (localReadBytes == 0) { + } else if (localReadBytes == 0) { break; } readBytes += localReadBytes; @@ -514,8 +481,7 @@ public final class Slice implements Comparable<Slice> return readBytes; } - public Slice copySlice() - { + public Slice copySlice() { return copySlice(0, length); } @@ -523,8 +489,7 @@ public final class Slice implements Comparable<Slice> * Returns a copy of this buffer's sub-region. Modifying the content of * the returned buffer or this buffer does not affect each other at all. */ - public Slice copySlice(int index, int length) - { + public Slice copySlice(int index, int length) { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; @@ -533,13 +498,11 @@ public final class Slice implements Comparable<Slice> return new Slice(copiedArray); } - public byte[] copyBytes() - { + public byte[] copyBytes() { return copyBytes(0, length); } - public byte[] copyBytes(int index, int length) - { + public byte[] copyBytes(int index, int length) { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; if (index == 0) { @@ -556,8 +519,7 @@ public final class Slice implements Comparable<Slice> * of the returned buffer or this buffer affects each other's content * while they maintain separate indexes and marks. */ - public Slice slice() - { + public Slice slice() { return slice(0, length); } @@ -566,8 +528,7 @@ public final class Slice implements Comparable<Slice> * the returned buffer or this buffer affects each other's content while * they maintain separate indexes and marks. */ - public Slice slice(int index, int length) - { + public Slice slice(int index, int length) { if (index == 0 && length == this.length) { return this; } @@ -583,8 +544,7 @@ public final class Slice implements Comparable<Slice> * Converts this buffer's readable bytes into a NIO buffer. The returned * buffer shares the content with this buffer. */ - public ByteBuffer toByteBuffer() - { + public ByteBuffer toByteBuffer() { return toByteBuffer(0, length); } @@ -592,16 +552,14 @@ public final class Slice implements Comparable<Slice> * Converts this buffer's sub-region into a NIO buffer. The returned * buffer shares the content with this buffer. */ - public ByteBuffer toByteBuffer(int index, int length) - { + public ByteBuffer toByteBuffer(int index, int length) { Preconditions.checkPositionIndexes(index, index + length, this.length); index += offset; return ByteBuffer.wrap(data, index, length).order(LITTLE_ENDIAN); } @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { if (this == o) { return true; } @@ -629,8 +587,7 @@ public final class Slice implements Comparable<Slice> } @Override - public int hashCode() - { + public int hashCode() { if (hash != 0) { return hash; } @@ -651,8 +608,7 @@ public final class Slice implements Comparable<Slice> * buffer. This comparison is performed byte by byte using an unsigned * comparison. */ - public int compareTo(Slice that) - { + public int compareTo(Slice that) { if (this == that) { return 0; } @@ -675,8 +631,7 @@ public final class Slice implements Comparable<Slice> * Decodes this buffer's readable bytes into a string with the specified * character set name. */ - public String toString(Charset charset) - { + public String toString(Charset charset) { return toString(0, length, charset); } @@ -684,8 +639,7 @@ public final class Slice implements Comparable<Slice> * Decodes this buffer's sub-region into a string with the specified * character set. */ - public String toString(int index, int length, Charset charset) - { + public String toString(int index, int length, Charset charset) { if (length == 0) { return ""; } @@ -693,8 +647,7 @@ public final class Slice implements Comparable<Slice> return Slices.decodeString(toByteBuffer(index, length), charset); } - public String toString() - { + public String toString() { return getClass().getSimpleName() + '(' + "length=" + length() + ')'; http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java b/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java index 2fc6555..5cd3abe 100644 --- a/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java +++ b/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java @@ -19,10 +19,8 @@ * Copyright 2011 Dain Sundstrom <d...@iq80.com> * Copyright 2011 FuseSource Corp. http://fusesource.com */ -package org.apache.kudu.util; -import com.google.common.base.Preconditions; -import org.apache.kudu.annotations.InterfaceAudience; +package org.apache.kudu.util; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -36,20 +34,20 @@ import java.nio.charset.CodingErrorAction; import java.util.IdentityHashMap; import java.util.Map; +import com.google.common.base.Preconditions; + +import org.apache.kudu.annotations.InterfaceAudience; + @InterfaceAudience.Private -public final class Slices -{ +public final class Slices { /** * A buffer whose capacity is {@code 0}. */ public static final Slice EMPTY_SLICE = new Slice(0); - private Slices() - { - } + private Slices() {} - public static Slice ensureSize(Slice existingSlice, int minWritableBytes) - { + public static Slice ensureSize(Slice existingSlice, int minWritableBytes) { if (existingSlice == null) { existingSlice = EMPTY_SLICE; } @@ -61,8 +59,7 @@ public final class Slices int newCapacity; if (existingSlice.length() == 0) { newCapacity = 1; - } - else { + } else { newCapacity = existingSlice.length(); } int minNewCapacity = existingSlice.length() + minWritableBytes; @@ -75,47 +72,42 @@ public final class Slices return newSlice; } - public static Slice allocate(int capacity) - { + public static Slice allocate(int capacity) { if (capacity == 0) { return EMPTY_SLICE; } return new Slice(capacity); } - public static Slice wrappedBuffer(byte[] array) - { + public static Slice wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_SLICE; } return new Slice(array); } - public static Slice copiedBuffer(ByteBuffer source, int sourceOffset, int length) - { + public static Slice copiedBuffer(ByteBuffer source, int sourceOffset, int length) { Preconditions.checkNotNull(source, "source is null"); int newPosition = source.position() + sourceOffset; - return copiedBuffer((ByteBuffer) source.duplicate().order(ByteOrder.LITTLE_ENDIAN).clear().limit(newPosition + length).position(newPosition)); + return copiedBuffer((ByteBuffer) source.duplicate().order(ByteOrder.LITTLE_ENDIAN).clear() + .limit(newPosition + length).position(newPosition)); } - public static Slice copiedBuffer(ByteBuffer source) - { + public static Slice copiedBuffer(ByteBuffer source) { Preconditions.checkNotNull(source, "source is null"); Slice copy = allocate(source.limit() - source.position()); copy.setBytes(0, source.duplicate().order(ByteOrder.LITTLE_ENDIAN)); return copy; } - public static Slice copiedBuffer(String string, Charset charset) - { + public static Slice copiedBuffer(String string, Charset charset) { Preconditions.checkNotNull(string, "string is null"); Preconditions.checkNotNull(charset, "charset is null"); return wrappedBuffer(string.getBytes(charset)); } - public static ByteBuffer encodeString(CharBuffer src, Charset charset) - { + public static ByteBuffer encodeString(CharBuffer src, Charset charset) { final CharsetEncoder encoder = getEncoder(charset); final ByteBuffer dst = ByteBuffer.allocate( (int) ((double) src.remaining() * encoder.maxBytesPerChar())); @@ -128,16 +120,14 @@ public final class Slices if (!cr.isUnderflow()) { cr.throwException(); } - } - catch (CharacterCodingException x) { + } catch (CharacterCodingException x) { throw new IllegalStateException(x); } dst.flip(); return dst; } - public static String decodeString(ByteBuffer src, Charset charset) - { + public static String decodeString(ByteBuffer src, Charset charset) { final CharsetDecoder decoder = getDecoder(charset); final CharBuffer dst = CharBuffer.allocate( (int) ((double) src.remaining() * decoder.maxCharsPerByte())); @@ -150,8 +140,7 @@ public final class Slices if (!cr.isUnderflow()) { cr.throwException(); } - } - catch (CharacterCodingException x) { + } catch (CharacterCodingException x) { throw new IllegalStateException(x); } return dst.flip().toString(); @@ -160,16 +149,14 @@ public final class Slices /** * Toggles the endianness of the specified 16-bit short integer. */ - public static short swapShort(short value) - { + public static short swapShort(short value) { return (short) (value << 8 | value >>> 8 & 0xff); } /** * Toggles the endianness of the specified 32-bit integer. */ - public static int swapInt(int value) - { + public static int swapInt(int value) { return swapShort((short) value) << 16 | swapShort((short) (value >>> 16)) & 0xffff; } @@ -177,28 +164,23 @@ public final class Slices /** * Toggles the endianness of the specified 64-bit long integer. */ - public static long swapLong(long value) - { + public static long swapLong(long value) { return (long) swapInt((int) value) << 32 | swapInt((int) (value >>> 32)) & 0xffffffffL; } private static final ThreadLocal<Map<Charset, CharsetEncoder>> encoders = - new ThreadLocal<Map<Charset, CharsetEncoder>>() - { + new ThreadLocal<Map<Charset, CharsetEncoder>>() { @Override - protected Map<Charset, CharsetEncoder> initialValue() - { + protected Map<Charset, CharsetEncoder> initialValue() { return new IdentityHashMap<Charset, CharsetEncoder>(); } }; private static final ThreadLocal<Map<Charset, CharsetDecoder>> decoders = - new ThreadLocal<Map<Charset, CharsetDecoder>>() - { + new ThreadLocal<Map<Charset, CharsetDecoder>>() { @Override - protected Map<Charset, CharsetDecoder> initialValue() - { + protected Map<Charset, CharsetDecoder> initialValue() { return new IdentityHashMap<Charset, CharsetDecoder>(); } }; @@ -207,8 +189,7 @@ public final class Slices * Returns a cached thread-local {@link CharsetEncoder} for the specified * <tt>charset</tt>. */ - private static CharsetEncoder getEncoder(Charset charset) - { + private static CharsetEncoder getEncoder(Charset charset) { if (charset == null) { throw new NullPointerException("charset"); } @@ -234,8 +215,7 @@ public final class Slices * Returns a cached thread-local {@link CharsetDecoder} for the specified * <tt>charset</tt>. */ - private static CharsetDecoder getDecoder(Charset charset) - { + private static CharsetDecoder getDecoder(Charset charset) { if (charset == null) { throw new NullPointerException("charset"); } http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java index d30762c..fdc74dd 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java @@ -16,6 +16,15 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -24,21 +33,13 @@ import com.stumbleupon.async.Callback; import com.stumbleupon.async.Deferred; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.kudu.ColumnSchema; import org.apache.kudu.Schema; import org.apache.kudu.Type; import org.apache.kudu.master.Master; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.Assert.fail; public class BaseKuduTest { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java index 13fae25..d542f1e 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java @@ -16,6 +16,12 @@ // under the License. package org.apache.kudu.client; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import com.google.common.collect.ImmutableList; import org.junit.Assert; import org.junit.BeforeClass; @@ -23,12 +29,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * Integration test for the client. RPCs are sent to Kudu from multiple threads while processes * are restarted and failures are injected. http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java index 0253ce0..63931e2 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java @@ -16,15 +16,16 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Random; + import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; -import org.apache.kudu.Schema; -import java.util.Random; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.kudu.Schema; /** * Integration test that inserts enough data to trigger flushes and getting multiple data http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java index 53ae002..6239b25 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java @@ -16,19 +16,6 @@ // under the License. package org.apache.kudu.client; -import com.google.common.base.Charsets; -import com.google.common.base.Joiner; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.io.CharStreams; - -import org.apache.commons.io.FileUtils; -import org.apache.kudu.annotations.InterfaceAudience; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.BufferedReader; import java.io.Closeable; import java.io.File; @@ -43,6 +30,19 @@ import java.util.List; import java.util.Map; import javax.annotation.concurrent.NotThreadSafe; +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.io.CharStreams; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.kudu.annotations.InterfaceAudience; + /** * A managed Kerberos Key Distribution Center. * http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java index 37690d9..28b1bf7 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java @@ -13,6 +13,18 @@ */ package org.apache.kudu.client; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; @@ -21,23 +33,11 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.net.HostAndPort; - import org.apache.commons.io.FileUtils; -import org.apache.kudu.util.NetUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; +import org.apache.kudu.util.NetUtil; /** * Utility class to start and manipulate Kudu clusters. Relies on being IN the Kudu source code with http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java index 8041f2b..ebb8bb8 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java @@ -16,22 +16,24 @@ // under the License. package org.apache.kudu.client; -import com.google.common.collect.ImmutableList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.apache.kudu.ColumnSchema; -import org.apache.kudu.Schema; -import org.apache.kudu.Type; -import org.apache.kudu.util.Pair; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.common.collect.ImmutableList; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.*; +import org.apache.kudu.ColumnSchema; +import org.apache.kudu.Schema; +import org.apache.kudu.Type; +import org.apache.kudu.util.Pair; public class TestAlterTable extends BaseKuduTest { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java index 815f767..302b2cc 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java @@ -16,25 +16,27 @@ // under the License. package org.apache.kudu.client; -import com.google.common.base.Charsets; -import com.google.common.base.Stopwatch; -import com.google.protobuf.ByteString; -import com.stumbleupon.async.Deferred; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import org.apache.kudu.util.Pair; +import com.google.common.base.Charsets; +import com.google.common.base.Stopwatch; +import com.google.protobuf.ByteString; +import com.stumbleupon.async.Deferred; import org.junit.BeforeClass; import org.junit.Test; -import org.apache.kudu.Common; -import org.apache.kudu.consensus.Metadata; -import org.apache.kudu.master.Master; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import org.apache.kudu.Common; +import org.apache.kudu.consensus.Metadata; +import org.apache.kudu.master.Master; public class TestAsyncKuduClient extends BaseKuduTest { private static final Logger LOG = LoggerFactory.getLogger(TestAsyncKuduClient.class); http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java index ac57401..b7f9db3 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java @@ -16,21 +16,24 @@ // under the License. package org.apache.kudu.client; -import org.apache.kudu.Schema; -import org.apache.kudu.WireProtocol.AppStatusPB; -import org.apache.kudu.tserver.Tserver.TabletServerErrorPB; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import com.stumbleupon.async.Callback; import com.stumbleupon.async.Deferred; import org.junit.BeforeClass; import org.junit.Test; -import java.util.Collections; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.List; - -import static org.junit.Assert.*; +import org.apache.kudu.Schema; +import org.apache.kudu.WireProtocol.AppStatusPB; +import org.apache.kudu.tserver.Tserver.TabletServerErrorPB; /** * This class can either start its own cluster or rely on an existing one. http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java index ce532cb..bfc4131 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java @@ -16,14 +16,14 @@ // under the License. package org.apache.kudu.client; -import org.junit.Test; - import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.BitSet; +import org.junit.Test; + public class TestBitSet { /** http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java index 4cf03de..ced6144 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java @@ -18,11 +18,11 @@ package org.apache.kudu.client; import static org.junit.Assert.assertEquals; +import java.math.BigInteger; + import org.junit.Assert; import org.junit.Test; -import java.math.BigInteger; - public class TestBytes { @Test http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java index 8b39a27..3a629db 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java @@ -16,17 +16,19 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.util.List; + import com.google.common.collect.Lists; import org.junit.Test; + import org.apache.kudu.ColumnSchema; import org.apache.kudu.Type; import org.apache.kudu.tserver.Tserver; -import java.io.IOException; -import java.util.List; - -import static org.junit.Assert.*; - public class TestColumnRangePredicate { @Test http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java index 334dd38..c822d79 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java @@ -16,13 +16,15 @@ // under the License. package org.apache.kudu.client; -import com.google.common.net.HostAndPort; -import com.stumbleupon.async.Deferred; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.List; -import static org.junit.Assert.*; +import com.google.common.net.HostAndPort; +import com.stumbleupon.async.Deferred; +import org.junit.Test; public class TestConnectionCache { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestDeadlineTracker.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestDeadlineTracker.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestDeadlineTracker.java index b36bd9b..00bc983 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestDeadlineTracker.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestDeadlineTracker.java @@ -16,14 +16,16 @@ // under the License. package org.apache.kudu.client; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.atomic.AtomicLong; import com.google.common.base.Stopwatch; import com.google.common.base.Ticker; import org.junit.Test; -import java.util.concurrent.atomic.AtomicLong; - public class TestDeadlineTracker { @Test http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java index d4fe444..64de32e 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java @@ -16,27 +16,27 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; - import org.junit.Before; import org.junit.Test; -import org.apache.kudu.ColumnSchema; -import org.apache.kudu.Schema; -import org.apache.kudu.Type; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import static org.junit.Assert.assertEquals; +import org.apache.kudu.ColumnSchema; +import org.apache.kudu.Schema; +import org.apache.kudu.Type; public class TestFlexiblePartitioning extends BaseKuduTest { private static final Logger LOG = LoggerFactory.getLogger(TestKuduClient.class); http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestGetMasterRegistrationReceived.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestGetMasterRegistrationReceived.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestGetMasterRegistrationReceived.java index 3882acd..b57a18c 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestGetMasterRegistrationReceived.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestGetMasterRegistrationReceived.java @@ -17,22 +17,23 @@ package org.apache.kudu.client; +import static org.apache.kudu.consensus.Metadata.RaftPeerPB.Role.FOLLOWER; +import static org.apache.kudu.consensus.Metadata.RaftPeerPB.Role.LEADER; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.List; + import com.google.common.collect.ImmutableList; import com.google.common.net.HostAndPort; import com.stumbleupon.async.Callback; import com.stumbleupon.async.Deferred; import org.junit.Test; + import org.apache.kudu.WireProtocol; import org.apache.kudu.consensus.Metadata; import org.apache.kudu.master.Master; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.apache.kudu.consensus.Metadata.RaftPeerPB.Role.FOLLOWER; -import static org.apache.kudu.consensus.Metadata.RaftPeerPB.Role.LEADER; - public class TestGetMasterRegistrationReceived { private static final List<HostAndPort> MASTERS = ImmutableList.of( http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java index fdf18ba..2b57f97 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java @@ -16,25 +16,28 @@ // under the License. package org.apache.kudu.client; +import static org.apache.kudu.Type.STRING; +import static org.apache.kudu.client.ExternalConsistencyMode.CLIENT_PROPAGATED; +import static org.apache.kudu.util.HybridTimeUtil.HTTimestampToPhysicalAndLogical; +import static org.apache.kudu.util.HybridTimeUtil.clockTimestampToHTTimestamp; +import static org.apache.kudu.util.HybridTimeUtil.physicalAndLogicalToHTTimestamp; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + import com.google.common.collect.ImmutableList; import com.stumbleupon.async.Deferred; -import org.apache.kudu.ColumnSchema; -import org.apache.kudu.Schema; import org.junit.BeforeClass; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import static org.apache.kudu.Type.STRING; -import static org.apache.kudu.client.ExternalConsistencyMode.CLIENT_PROPAGATED; -import static org.apache.kudu.util.HybridTimeUtil.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.kudu.ColumnSchema; +import org.apache.kudu.Schema; /** * This only tests client propagation since it's the only thing that is client-specific. http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java index 57a630e..f2415b1 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java @@ -19,9 +19,13 @@ package org.apache.kudu.client; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.List; + import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import org.junit.Test; + import org.apache.kudu.ColumnSchema; import org.apache.kudu.ColumnSchema.ColumnSchemaBuilder; import org.apache.kudu.Common; @@ -30,9 +34,6 @@ import org.apache.kudu.Type; import org.apache.kudu.client.PartitionSchema.HashBucketSchema; import org.apache.kudu.client.PartitionSchema.RangeSchema; -import java.util.ArrayList; -import java.util.List; - public class TestKeyEncoding { private static Schema buildSchema(ColumnSchemaBuilder... columns) { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java index 17606c8..06f3a07 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java @@ -16,19 +16,16 @@ // under the License. package org.apache.kudu.client; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER_EQUAL; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.LESS; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.LESS_EQUAL; import static org.apache.kudu.client.RowResult.timestampToString; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterators; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Collections; @@ -36,13 +33,16 @@ import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.kudu.ColumnSchema; import org.apache.kudu.Schema; import org.apache.kudu.Type; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestKuduClient extends BaseKuduTest { private static final Logger LOG = LoggerFactory.getLogger(TestKuduClient.class); http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java index 785594f..ca48ee8 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java @@ -17,16 +17,6 @@ package org.apache.kudu.client; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; - -import org.junit.Assert; -import org.junit.Test; -import org.apache.kudu.ColumnSchema; -import org.apache.kudu.Type; - -import java.util.Arrays; - import static org.apache.kudu.client.KuduPredicate.ComparisonOp.EQUAL; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER_EQUAL; @@ -34,6 +24,16 @@ import static org.apache.kudu.client.KuduPredicate.ComparisonOp.LESS; import static org.apache.kudu.client.KuduPredicate.ComparisonOp.LESS_EQUAL; import static org.apache.kudu.client.KuduPredicate.PredicateType.RANGE; +import java.util.Arrays; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import org.junit.Assert; +import org.junit.Test; + +import org.apache.kudu.ColumnSchema; +import org.apache.kudu.Type; + public class TestKuduPredicate { private static final ColumnSchema boolCol = http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java index c6b6bc2..55f9508 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java @@ -16,17 +16,19 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; -import org.junit.Before; +import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; -import static org.junit.Assert.*; - -import com.google.common.collect.ImmutableList; - public class TestKuduSession extends BaseKuduTest { @Rule public TestName name = new TestName(); http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java index 42dc4fe..96d62de 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java @@ -16,20 +16,26 @@ // under the License. package org.apache.kudu.client; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.apache.kudu.ColumnSchema; -import org.apache.kudu.Schema; -import org.apache.kudu.Type; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.*; +import org.apache.kudu.ColumnSchema; +import org.apache.kudu.Schema; +import org.apache.kudu.Type; public class TestKuduTable extends BaseKuduTest { private static final Logger LOG = LoggerFactory.getLogger(TestKuduTable.class); http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java index 08a3bdf..191be8f 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java @@ -16,11 +16,12 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; - public class TestLeaderFailover extends BaseKuduTest { private static final String TABLE_NAME = http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java index 7cc2413..cda6bb2 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java @@ -16,14 +16,13 @@ // under the License. package org.apache.kudu.client; +import static org.junit.Assert.assertEquals; + import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.assertEquals; - /** * Tests {@link AsyncKuduClient} with multiple masters. http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKdc.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKdc.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKdc.java index 609b1a0..79ce7d9 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKdc.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKdc.java @@ -16,9 +16,9 @@ // under the License. package org.apache.kudu.client; -import org.junit.Test; +import static org.junit.Assert.assertTrue; -import static org.junit.Assert.*; +import org.junit.Test; public class TestMiniKdc { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKuduCluster.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKuduCluster.java index 8b7d207..baa5658 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKuduCluster.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMiniKuduCluster.java @@ -13,16 +13,16 @@ */ package org.apache.kudu.client; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.net.Socket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; public class TestMiniKuduCluster { http://git-wip-us.apache.org/repos/asf/kudu/blob/22067edb/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java ---------------------------------------------------------------------- diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java index edc06c2..44b204a 100644 --- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java +++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java @@ -21,17 +21,17 @@ import static org.junit.Assert.fail; import java.util.ArrayList; +import com.google.common.collect.ImmutableList; +import com.google.common.primitives.Longs; import org.junit.Test; +import org.mockito.Mockito; + import org.apache.kudu.ColumnSchema; import org.apache.kudu.Schema; import org.apache.kudu.Type; import org.apache.kudu.WireProtocol.RowOperationsPB; import org.apache.kudu.client.Operation.ChangeType; import org.apache.kudu.tserver.Tserver.WriteRequestPBOrBuilder; -import org.mockito.Mockito; - -import com.google.common.collect.ImmutableList; -import com.google.common.primitives.Longs; /** * Unit tests for Operation