You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/01/09 03:44:37 UTC
[33/66] [abbrv] accumulo git commit: ACCUMULO-3451 Format master
branch (1.7.0-SNAPSHOT)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java b/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
index 482fc62..a7cd3f5 100644
--- a/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
@@ -59,7 +59,7 @@ public class StatusUtil {
/**
* Creates a {@link Status} for newly-created data that must be replicated
- *
+ *
* @param recordsIngested
* Offset of records which need to be replicated
* @return A {@link Status} tracking data that must be replicated
@@ -94,7 +94,7 @@ public class StatusUtil {
/**
* Creates a @{link Status} for a file which has new data and data which has been replicated
- *
+ *
* @param recordsReplicated
* Offset of records which have been replicated
* @param recordsIngested
@@ -107,7 +107,7 @@ public class StatusUtil {
/**
* Same as {@link #replicatedAndIngested(long, long)} but uses the provided {@link Builder}
- *
+ *
* @param builder
* An existing builder
* @param recordsReplicated
@@ -165,7 +165,8 @@ public class StatusUtil {
}
/**
- * @param v Value with serialized Status
+ * @param v
+ * Value with serialized Status
* @return A Status created from the Value
*/
public static Status fromValue(Value v) throws InvalidProtocolBufferException {
@@ -174,7 +175,9 @@ public class StatusUtil {
/**
* Is the given Status fully replicated and is its file ready for deletion on the source
- * @param status a Status protobuf
+ *
+ * @param status
+ * a Status protobuf
* @return True if the file this Status references can be deleted.
*/
public static boolean isSafeForRemoval(Status status) {
@@ -183,7 +186,9 @@ public class StatusUtil {
/**
* Is the given Status fully replicated but potentially not yet safe for deletion
- * @param status a Status protobuf
+ *
+ * @param status
+ * a Status protobuf
* @return True if the file this Status references is fully replicated so far
*/
public static boolean isFullyReplicated(Status status) {
@@ -196,7 +201,9 @@ public class StatusUtil {
/**
* Given the {@link Status}, is there replication work to be done
- * @param status Status for a file
+ *
+ * @param status
+ * Status for a file
* @return true if replication work is required
*/
public static boolean isWorkRequired(Status status) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/replication/proto/Replication.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/replication/proto/Replication.java b/core/src/main/java/org/apache/accumulo/core/replication/proto/Replication.java
index 2bff020..07168a6 100644
--- a/core/src/main/java/org/apache/accumulo/core/replication/proto/Replication.java
+++ b/core/src/main/java/org/apache/accumulo/core/replication/proto/Replication.java
@@ -19,13 +19,13 @@
package org.apache.accumulo.core.replication.proto;
-@SuppressWarnings("all") public final class Replication {
+@SuppressWarnings("all")
+public final class Replication {
private Replication() {}
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistry registry) {
- }
- public interface StatusOrBuilder
- extends com.google.protobuf.MessageOrBuilder {
+
+ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {}
+
+ public interface StatusOrBuilder extends com.google.protobuf.MessageOrBuilder {
// optional int64 begin = 1 [default = 0];
/**
@@ -36,6 +36,7 @@ package org.apache.accumulo.core.replication.proto;
* </pre>
*/
boolean hasBegin();
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -54,6 +55,7 @@ package org.apache.accumulo.core.replication.proto;
* </pre>
*/
boolean hasEnd();
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -72,6 +74,7 @@ package org.apache.accumulo.core.replication.proto;
* </pre>
*/
boolean hasInfiniteEnd();
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -90,6 +93,7 @@ package org.apache.accumulo.core.replication.proto;
* </pre>
*/
boolean hasClosed();
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -108,6 +112,7 @@ package org.apache.accumulo.core.replication.proto;
* </pre>
*/
boolean hasCreatedTime();
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -117,20 +122,23 @@ package org.apache.accumulo.core.replication.proto;
*/
long getCreatedTime();
}
+
/**
* Protobuf type {@code Status}
*/
- public static final class Status extends
- com.google.protobuf.GeneratedMessage
- implements StatusOrBuilder {
+ public static final class Status extends com.google.protobuf.GeneratedMessage implements StatusOrBuilder {
// Use Status.newBuilder() to construct.
private Status(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
super(builder);
this.unknownFields = builder.getUnknownFields();
}
- private Status(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private Status(boolean noInit) {
+ this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance();
+ }
private static final Status defaultInstance;
+
public static Status getDefaultInstance() {
return defaultInstance;
}
@@ -140,19 +148,17 @@ package org.apache.accumulo.core.replication.proto;
}
private final com.google.protobuf.UnknownFieldSet unknownFields;
+
@java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
+ public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
return this.unknownFields;
}
- private Status(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+
+ private Status(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
initFields();
int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
@@ -162,8 +168,7 @@ package org.apache.accumulo.core.replication.proto;
done = true;
break;
default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
@@ -198,30 +203,24 @@ package org.apache.accumulo.core.replication.proto;
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
+ throw new com.google.protobuf.InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_descriptor;
}
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.accumulo.core.replication.proto.Replication.Status.class, org.apache.accumulo.core.replication.proto.Replication.Status.Builder.class);
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_fieldAccessorTable.ensureFieldAccessorsInitialized(
+ org.apache.accumulo.core.replication.proto.Replication.Status.class, org.apache.accumulo.core.replication.proto.Replication.Status.Builder.class);
}
- public static com.google.protobuf.Parser<Status> PARSER =
- new com.google.protobuf.AbstractParser<Status>() {
- public Status parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ public static com.google.protobuf.Parser<Status> PARSER = new com.google.protobuf.AbstractParser<Status>() {
+ public Status parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new Status(input, extensionRegistry);
}
@@ -236,6 +235,7 @@ package org.apache.accumulo.core.replication.proto;
// optional int64 begin = 1 [default = 0];
public static final int BEGIN_FIELD_NUMBER = 1;
private long begin_;
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -246,6 +246,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasBegin() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -260,6 +261,7 @@ package org.apache.accumulo.core.replication.proto;
// optional int64 end = 2 [default = 0];
public static final int END_FIELD_NUMBER = 2;
private long end_;
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -270,6 +272,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasEnd() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -284,6 +287,7 @@ package org.apache.accumulo.core.replication.proto;
// optional bool infiniteEnd = 3 [default = false];
public static final int INFINITEEND_FIELD_NUMBER = 3;
private boolean infiniteEnd_;
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -294,6 +298,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasInfiniteEnd() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -308,6 +313,7 @@ package org.apache.accumulo.core.replication.proto;
// optional bool closed = 4 [default = false];
public static final int CLOSED_FIELD_NUMBER = 4;
private boolean closed_;
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -318,6 +324,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasClosed() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -332,6 +339,7 @@ package org.apache.accumulo.core.replication.proto;
// optional int64 createdTime = 5 [default = 0];
public static final int CREATEDTIME_FIELD_NUMBER = 5;
private long createdTime_;
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -342,6 +350,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasCreatedTime() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -360,17 +369,19 @@ package org.apache.accumulo.core.replication.proto;
closed_ = false;
createdTime_ = 0L;
}
+
private byte memoizedIsInitialized = -1;
+
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
- if (isInitialized != -1) return isInitialized == 1;
+ if (isInitialized != -1)
+ return isInitialized == 1;
memoizedIsInitialized = 1;
return true;
}
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
getSerializedSize();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt64(1, begin_);
@@ -391,30 +402,27 @@ package org.apache.accumulo.core.replication.proto;
}
private int memoizedSerializedSize = -1;
+
public int getSerializedSize() {
int size = memoizedSerializedSize;
- if (size != -1) return size;
+ if (size != -1)
+ return size;
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(1, begin_);
+ size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, begin_);
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(2, end_);
+ size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, end_);
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(3, infiniteEnd_);
+ size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, infiniteEnd_);
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(4, closed_);
+ size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, closed_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(5, createdTime_);
+ size += com.google.protobuf.CodedOutputStream.computeInt64Size(5, createdTime_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -422,94 +430,94 @@ package org.apache.accumulo.core.replication.proto;
}
private static final long serialVersionUID = 0L;
+
@java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
+ protected java.lang.Object writeReplace() throws java.io.ObjectStreamException {
return super.writeReplace();
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- com.google.protobuf.ByteString data)
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
+
public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(java.io.InputStream input)
- throws java.io.IOException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(java.io.InputStream input) throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- com.google.protobuf.CodedInputStream input)
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
+
+ public static org.apache.accumulo.core.replication.proto.Replication.Status parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
public static Builder newBuilder(org.apache.accumulo.core.replication.proto.Replication.Status prototype) {
return newBuilder().mergeFrom(prototype);
}
- public Builder toBuilder() { return newBuilder(this); }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
@java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
+
/**
* Protobuf type {@code Status}
*/
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder>
- implements org.apache.accumulo.core.replication.proto.Replication.StatusOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+ org.apache.accumulo.core.replication.proto.Replication.StatusOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_descriptor;
}
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.accumulo.core.replication.proto.Replication.Status.class, org.apache.accumulo.core.replication.proto.Replication.Status.Builder.class);
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_fieldAccessorTable.ensureFieldAccessorsInitialized(
+ org.apache.accumulo.core.replication.proto.Replication.Status.class, org.apache.accumulo.core.replication.proto.Replication.Status.Builder.class);
}
// Construct using org.apache.accumulo.core.replication.proto.Replication.Status.newBuilder()
@@ -517,15 +525,15 @@ package org.apache.accumulo.core.replication.proto;
maybeForceBuilderInitialization();
}
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
+
private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- }
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {}
}
+
private static Builder create() {
return new Builder();
}
@@ -549,8 +557,7 @@ package org.apache.accumulo.core.replication.proto;
return create().mergeFrom(buildPartial());
}
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return org.apache.accumulo.core.replication.proto.Replication.internal_static_Status_descriptor;
}
@@ -597,7 +604,7 @@ package org.apache.accumulo.core.replication.proto;
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof org.apache.accumulo.core.replication.proto.Replication.Status) {
- return mergeFrom((org.apache.accumulo.core.replication.proto.Replication.Status)other);
+ return mergeFrom((org.apache.accumulo.core.replication.proto.Replication.Status) other);
} else {
super.mergeFrom(other);
return this;
@@ -605,7 +612,8 @@ package org.apache.accumulo.core.replication.proto;
}
public Builder mergeFrom(org.apache.accumulo.core.replication.proto.Replication.Status other) {
- if (other == org.apache.accumulo.core.replication.proto.Replication.Status.getDefaultInstance()) return this;
+ if (other == org.apache.accumulo.core.replication.proto.Replication.Status.getDefaultInstance())
+ return this;
if (other.hasBegin()) {
setBegin(other.getBegin());
}
@@ -629,9 +637,7 @@ package org.apache.accumulo.core.replication.proto;
return true;
}
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
org.apache.accumulo.core.replication.proto.Replication.Status parsedMessage = null;
try {
@@ -646,10 +652,12 @@ package org.apache.accumulo.core.replication.proto;
}
return this;
}
+
private int bitField0_;
// optional int64 begin = 1 [default = 0];
- private long begin_ ;
+ private long begin_;
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -660,6 +668,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasBegin() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -670,6 +679,7 @@ package org.apache.accumulo.core.replication.proto;
public long getBegin() {
return begin_;
}
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -683,6 +693,7 @@ package org.apache.accumulo.core.replication.proto;
onChanged();
return this;
}
+
/**
* <code>optional int64 begin = 1 [default = 0];</code>
*
@@ -698,7 +709,8 @@ package org.apache.accumulo.core.replication.proto;
}
// optional int64 end = 2 [default = 0];
- private long end_ ;
+ private long end_;
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -709,6 +721,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasEnd() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -719,6 +732,7 @@ package org.apache.accumulo.core.replication.proto;
public long getEnd() {
return end_;
}
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -732,6 +746,7 @@ package org.apache.accumulo.core.replication.proto;
onChanged();
return this;
}
+
/**
* <code>optional int64 end = 2 [default = 0];</code>
*
@@ -747,7 +762,8 @@ package org.apache.accumulo.core.replication.proto;
}
// optional bool infiniteEnd = 3 [default = false];
- private boolean infiniteEnd_ ;
+ private boolean infiniteEnd_;
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -758,6 +774,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasInfiniteEnd() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -768,6 +785,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean getInfiniteEnd() {
return infiniteEnd_;
}
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -781,6 +799,7 @@ package org.apache.accumulo.core.replication.proto;
onChanged();
return this;
}
+
/**
* <code>optional bool infiniteEnd = 3 [default = false];</code>
*
@@ -796,7 +815,8 @@ package org.apache.accumulo.core.replication.proto;
}
// optional bool closed = 4 [default = false];
- private boolean closed_ ;
+ private boolean closed_;
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -807,6 +827,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasClosed() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -817,6 +838,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean getClosed() {
return closed_;
}
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -830,6 +852,7 @@ package org.apache.accumulo.core.replication.proto;
onChanged();
return this;
}
+
/**
* <code>optional bool closed = 4 [default = false];</code>
*
@@ -845,7 +868,8 @@ package org.apache.accumulo.core.replication.proto;
}
// optional int64 createdTime = 5 [default = 0];
- private long createdTime_ ;
+ private long createdTime_;
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -856,6 +880,7 @@ package org.apache.accumulo.core.replication.proto;
public boolean hasCreatedTime() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -866,6 +891,7 @@ package org.apache.accumulo.core.replication.proto;
public long getCreatedTime() {
return createdTime_;
}
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -879,6 +905,7 @@ package org.apache.accumulo.core.replication.proto;
onChanged();
return this;
}
+
/**
* <code>optional int64 createdTime = 5 [default = 0];</code>
*
@@ -904,45 +931,30 @@ package org.apache.accumulo.core.replication.proto;
// @@protoc_insertion_point(class_scope:Status)
}
- private static com.google.protobuf.Descriptors.Descriptor
- internal_static_Status_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Status_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_Status_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_Status_fieldAccessorTable;
- public static com.google.protobuf.Descriptors.FileDescriptor
- getDescriptor() {
+ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
return descriptor;
}
- private static com.google.protobuf.Descriptors.FileDescriptor
- descriptor;
+
+ private static com.google.protobuf.Descriptors.FileDescriptor descriptor;
static {
- java.lang.String[] descriptorData = {
- "\n#src/main/protobuf/replication.proto\"u\n" +
- "\006Status\022\020\n\005begin\030\001 \001(\003:\0010\022\016\n\003end\030\002 \001(\003:\001" +
- "0\022\032\n\013infiniteEnd\030\003 \001(\010:\005false\022\025\n\006closed\030" +
- "\004 \001(\010:\005false\022\026\n\013createdTime\030\005 \001(\003:\0010B.\n*" +
- "org.apache.accumulo.core.replication.pro" +
- "toH\001"
+ java.lang.String[] descriptorData = {"\n#src/main/protobuf/replication.proto\"u\n"
+ + "\006Status\022\020\n\005begin\030\001 \001(\003:\0010\022\016\n\003end\030\002 \001(\003:\001"
+ + "0\022\032\n\013infiniteEnd\030\003 \001(\010:\005false\022\025\n\006closed\030"
+ + "\004 \001(\010:\005false\022\026\n\013createdTime\030\005 \001(\003:\0010B.\n*" + "org.apache.accumulo.core.replication.pro" + "toH\001"};
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_Status_descriptor = getDescriptor().getMessageTypes().get(0);
+ internal_static_Status_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_Status_descriptor,
+ new java.lang.String[] {"Begin", "End", "InfiniteEnd", "Closed", "CreatedTime",});
+ return null;
+ }
};
- com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
- new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
- public com.google.protobuf.ExtensionRegistry assignDescriptors(
- com.google.protobuf.Descriptors.FileDescriptor root) {
- descriptor = root;
- internal_static_Status_descriptor =
- getDescriptor().getMessageTypes().get(0);
- internal_static_Status_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Status_descriptor,
- new java.lang.String[] { "Begin", "End", "InfiniteEnd", "Closed", "CreatedTime", });
- return null;
- }
- };
- com.google.protobuf.Descriptors.FileDescriptor
- .internalBuildGeneratedFileFrom(descriptorData,
- new com.google.protobuf.Descriptors.FileDescriptor[] {
- }, assigner);
+ com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {},
+ assigner);
}
// @@protoc_insertion_point(outer_class_scope)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/rpc/TBufferedSocket.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/TBufferedSocket.java b/core/src/main/java/org/apache/accumulo/core/rpc/TBufferedSocket.java
index 87b7c13..942c554 100644
--- a/core/src/main/java/org/apache/accumulo/core/rpc/TBufferedSocket.java
+++ b/core/src/main/java/org/apache/accumulo/core/rpc/TBufferedSocket.java
@@ -24,16 +24,16 @@ import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TSocket;
public class TBufferedSocket extends TIOStreamTransport {
-
+
String client;
-
+
public TBufferedSocket(TSocket sock, int bufferSize) throws IOException {
super(new BufferedInputStream(sock.getSocket().getInputStream(), bufferSize), new BufferedOutputStream(sock.getSocket().getOutputStream(), bufferSize));
client = sock.getSocket().getInetAddress().getHostAddress() + ":" + sock.getSocket().getPort();
}
-
+
public String getClientString() {
return client;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/rpc/TTimeoutTransport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/TTimeoutTransport.java b/core/src/main/java/org/apache/accumulo/core/rpc/TTimeoutTransport.java
index 6eace77..8c23555 100644
--- a/core/src/main/java/org/apache/accumulo/core/rpc/TTimeoutTransport.java
+++ b/core/src/main/java/org/apache/accumulo/core/rpc/TTimeoutTransport.java
@@ -34,16 +34,16 @@ import org.apache.thrift.transport.TTransport;
import com.google.common.net.HostAndPort;
public class TTimeoutTransport {
-
+
private static InputStream getInputStream(Socket socket, long timeout) {
try {
Method m = NetUtils.class.getMethod("getInputStream", Socket.class, Long.TYPE);
- return (InputStream)m.invoke(null, socket, timeout);
+ return (InputStream) m.invoke(null, socket, timeout);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
-
+
public static TTransport create(HostAndPort addr, long timeoutMillis) throws IOException {
return create(new InetSocketAddress(addr.getHostText(), addr.getPort()), timeoutMillis);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocol.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocol.java b/core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocol.java
index 74aad57..e7c6a44 100644
--- a/core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocol.java
+++ b/core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocol.java
@@ -44,4 +44,4 @@ public class TraceProtocol extends TCompactProtocol {
public TraceProtocol(TTransport transport) {
super(transport);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/AuthorizationContainer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/AuthorizationContainer.java b/core/src/main/java/org/apache/accumulo/core/security/AuthorizationContainer.java
index 029b622..01ad46d 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/AuthorizationContainer.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/AuthorizationContainer.java
@@ -25,7 +25,8 @@ public interface AuthorizationContainer {
/**
* Checks whether this object contains the given authorization.
*
- * @param auth authorization, as a string encoded in UTF-8
+ * @param auth
+ * authorization, as a string encoded in UTF-8
* @return true if authorization is in this collection
*/
boolean contains(ByteSequence auth);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java b/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
index b6ce5b7..001fed2 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
@@ -54,7 +54,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* A special header string used when serializing instances of this class.
- *
+ *
* @see #serialize()
*/
public static final String HEADER = "!AUTH1:";
@@ -102,7 +102,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Constructs an authorization object from a collection of string authorizations that have each already been encoded as UTF-8 bytes. Warning: This method does
* not verify that each encoded string is valid UTF-8.
- *
+ *
* @param authorizations
* collection of authorizations, as strings encoded in UTF-8
* @throws IllegalArgumentException
@@ -119,7 +119,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Constructs an authorization object from a list of string authorizations that have each already been encoded as UTF-8 bytes. Warning: This method does not
* verify that each encoded string is valid UTF-8.
- *
+ *
* @param authorizations
* list of authorizations, as strings encoded in UTF-8 and placed in buffers
* @throws IllegalArgumentException
@@ -137,7 +137,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Constructs an authorizations object from a serialized form. This is NOT a constructor for a set of authorizations of size one. Warning: This method does
* not verify that the encoded serialized form is valid UTF-8.
- *
+ *
* @param authorizations
* a serialized authorizations string produced by {@link #getAuthorizationsArray()} or {@link #serialize()}, converted to UTF-8 bytes
* @throws IllegalArgumentException
@@ -167,14 +167,14 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Constructs an empty set of authorizations.
- *
+ *
* @see #Authorizations(String...)
*/
public Authorizations() {}
/**
* Constructs an authorizations object from a set of human-readable authorizations.
- *
+ *
* @param authorizations
* array of authorizations
* @throws IllegalArgumentException
@@ -197,7 +197,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Returns a serialized form of these authorizations.
- *
+ *
* @return serialized form of these authorizations, as a string encoded in UTF-8
* @see #serialize()
*/
@@ -207,7 +207,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Gets the authorizations in sorted order. The returned list is not modifiable.
- *
+ *
* @return authorizations, each as a string encoded in UTF-8
* @see #Authorizations(Collection)
*/
@@ -223,7 +223,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Gets the authorizations in sorted order. The returned list is not modifiable.
- *
+ *
* @return authorizations, each as a string encoded in UTF-8 and within a buffer
*/
public List<ByteBuffer> getAuthorizationsBB() {
@@ -251,7 +251,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Checks whether this object contains the given authorization.
- *
+ *
* @param auth
* authorization, as a string encoded in UTF-8
* @return true if authorization is in this collection
@@ -262,7 +262,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Checks whether this object contains the given authorization. Warning: This method does not verify that the encoded string is valid UTF-8.
- *
+ *
* @param auth
* authorization, as a string encoded in UTF-8
* @return true if authorization is in this collection
@@ -274,7 +274,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Checks whether this object contains the given authorization.
- *
+ *
* @param auth
* authorization
* @return true if authorization is in this collection
@@ -308,7 +308,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Gets the size of this collection of authorizations.
- *
+ *
* @return collection size
*/
public int size() {
@@ -317,7 +317,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Checks if this collection of authorizations is empty.
- *
+ *
* @return true if this collection contains no authorizations
*/
public boolean isEmpty() {
@@ -331,7 +331,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable, Authoriza
/**
* Returns a serialized form of these authorizations. Convert the returned string to UTF-8 bytes to deserialize with {@link #Authorizations(byte[])}.
- *
+ *
* @return serialized form of authorizations
*/
public String serialize() {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java b/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
index 3e930f5..e6d26de 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
@@ -38,20 +38,19 @@ import org.apache.hadoop.io.WritableComparator;
* definition of an expression.
*
* <P>
- * The expression is a sequence of characters from the set [A-Za-z0-9_-.] along with the
- * binary operators "&" and "|" indicating that both operands are necessary, or the either
- * is necessary. The following are valid expressions for visibility:
- *
+ * The expression is a sequence of characters from the set [A-Za-z0-9_-.] along with the binary operators "&" and "|" indicating that both operands are
+ * necessary, or the either is necessary. The following are valid expressions for visibility:
+ *
* <pre>
* A
* A|B
* (A|B)&(C|D)
* orange|(red&yellow)
* </pre>
- *
+ *
* <P>
* The following are not valid expressions for visibility:
- *
+ *
* <pre>
* A|B&C
* A=B
@@ -61,19 +60,21 @@ import org.apache.hadoop.io.WritableComparator;
* )
* dog|!cat
* </pre>
- *
+ *
* <P>
- * In addition to the base set of visibilities, any character can be used in the expression if it is quoted. If the quoted term contains '"' or '\', then escape
- * the character with '\'. The {@link #quote(String)} method can be used to properly quote and escape terms automatically. The following is an example of a quoted term:
+ * In addition to the base set of visibilities, any character can be used in the expression if it is quoted. If the quoted term contains '"' or '\', then
+ * escape the character with '\'. The {@link #quote(String)} method can be used to properly quote and escape terms automatically. The following is an example of
+ * a quoted term:
+ *
* <pre>
* "A#C"<span />&<span />B
* </pre>
*/
public class ColumnVisibility {
-
+
Node node = null;
private byte[] expression;
-
+
/**
* Accessor for the underlying byte string.
*
@@ -82,7 +83,7 @@ public class ColumnVisibility {
public byte[] getExpression() {
return expression;
}
-
+
/**
* The node types in a parse tree for a visibility expression.
*/
@@ -94,7 +95,7 @@ public class ColumnVisibility {
* All empty nodes are equal and represent the same value.
*/
private static final Node EMPTY_NODE = new Node(NodeType.EMPTY, 0);
-
+
/**
* A node in the parse tree for a visibility expression.
*/
@@ -107,76 +108,76 @@ public class ColumnVisibility {
int start;
int end;
List<Node> children = EMPTY;
-
+
public Node(NodeType type, int start) {
this.type = type;
this.start = start;
this.end = start + 1;
}
-
+
public Node(int start, int end) {
this.type = NodeType.TERM;
this.start = start;
this.end = end;
}
-
+
public void add(Node child) {
if (children == EMPTY)
children = new ArrayList<Node>();
-
+
children.add(child);
}
-
+
public NodeType getType() {
return type;
}
-
+
public List<Node> getChildren() {
return children;
}
-
+
public int getTermStart() {
return start;
}
-
+
public int getTermEnd() {
return end;
}
-
+
public ByteSequence getTerm(byte expression[]) {
if (type != NodeType.TERM)
throw new RuntimeException();
-
+
if (expression[start] == '"') {
// its a quoted term
int qStart = start + 1;
int qEnd = end - 1;
-
+
return new ArrayByteSequence(expression, qStart, qEnd - qStart);
}
return new ArrayByteSequence(expression, start, end - start);
}
}
-
+
/**
- * A node comparator. Nodes sort according to node type, terms sort
- * lexicographically. AND and OR nodes sort by number of children, or if
- * the same by corresponding children.
+ * A node comparator. Nodes sort according to node type, terms sort lexicographically. AND and OR nodes sort by number of children, or if the same by
+ * corresponding children.
*/
public static class NodeComparator implements Comparator<Node>, Serializable {
-
+
private static final long serialVersionUID = 1L;
byte[] text;
-
+
/**
* Creates a new comparator.
*
- * @param text expression string, encoded in UTF-8
+ * @param text
+ * expression string, encoded in UTF-8
*/
public NodeComparator(byte[] text) {
this.text = text;
}
-
+
@Override
public int compare(Node a, Node b) {
int diff = a.type.ordinal() - b.type.ordinal();
@@ -201,14 +202,14 @@ public class ColumnVisibility {
return 0;
}
}
-
+
/*
* Convience method that delegates to normalize with a new NodeComparator constructed using the supplied expression.
*/
public static Node normalize(Node root, byte[] expression) {
return normalize(root, expression, new NodeComparator(expression));
}
-
+
// @formatter:off
/*
* Walks an expression's AST in order to:
@@ -231,16 +232,16 @@ public class ColumnVisibility {
rolledUp.addAll(root.children);
root.children.clear();
root.children.addAll(rolledUp);
-
+
// need to promote a child if it's an only child
if (root.children.size() == 1) {
return root.children.get(0);
}
}
-
+
return root;
}
-
+
/*
* Walks an expression's AST and appends a string representation to a supplied StringBuilder. This method adds parens where necessary.
*/
@@ -261,7 +262,7 @@ public class ColumnVisibility {
}
}
}
-
+
/**
* Generates a byte[] that represents a normalized, but logically equivalent, form of this evaluator's expression.
*
@@ -273,13 +274,13 @@ public class ColumnVisibility {
stringify(normRoot, expression, builder);
return builder.toString().getBytes(UTF_8);
}
-
+
private static class ColumnVisibilityParser {
private int index = 0;
private int parens = 0;
-
+
public ColumnVisibilityParser() {}
-
+
Node parse(byte[] expression) {
if (expression.length > 0) {
Node node = parse_(expression);
@@ -293,7 +294,7 @@ public class ColumnVisibility {
}
return null;
}
-
+
Node processTerm(int start, int end, Node expr, byte[] expression) {
if (start != end) {
if (expr != null)
@@ -304,14 +305,14 @@ public class ColumnVisibility {
throw new BadArgumentException("empty term", new String(expression, UTF_8), start);
return expr;
}
-
+
Node parse_(byte[] expression) {
Node result = null;
Node expr = null;
int wholeTermStart = index;
int subtermStart = index;
boolean subtermComplete = false;
-
+
while (index < expression.length) {
switch (expression[index++]) {
case '&': {
@@ -369,7 +370,7 @@ public class ColumnVisibility {
case '"': {
if (subtermStart != index - 1)
throw new BadArgumentException("expression needs & or |", new String(expression, UTF_8), index - 1);
-
+
while (index < expression.length && expression[index] != '"') {
if (expression[index] == '\\') {
index++;
@@ -378,23 +379,23 @@ public class ColumnVisibility {
}
index++;
}
-
+
if (index == expression.length)
throw new BadArgumentException("unclosed quote", new String(expression, UTF_8), subtermStart);
-
+
if (subtermStart + 1 == index)
throw new BadArgumentException("empty term", new String(expression, UTF_8), subtermStart);
-
+
index++;
-
+
subtermComplete = true;
-
+
break;
}
default: {
if (subtermComplete)
throw new BadArgumentException("expression needs & or |", new String(expression, UTF_8), index - 1);
-
+
byte c = expression[index - 1];
if (!Authorizations.isValidAuthChar(c))
throw new BadArgumentException("bad character (" + c + ")", new String(expression, UTF_8), index - 1);
@@ -413,7 +414,7 @@ public class ColumnVisibility {
return result;
}
}
-
+
private void validate(byte[] expression) {
if (expression != null && expression.length > 0) {
ColumnVisibilityParser p = new ColumnVisibilityParser();
@@ -423,16 +424,16 @@ public class ColumnVisibility {
}
this.expression = expression;
}
-
+
/**
* Creates an empty visibility. Normally, elements with empty visibility can be seen by everyone. Though, one could change this behavior with filters.
- *
+ *
* @see #ColumnVisibility(String)
*/
public ColumnVisibility() {
this(new byte[] {});
}
-
+
/**
* Creates a column visibility for a Mutation.
*
@@ -442,32 +443,34 @@ public class ColumnVisibility {
public ColumnVisibility(String expression) {
this(expression.getBytes(UTF_8));
}
-
+
/**
* Creates a column visibility for a Mutation.
*
- * @param expression visibility expression
+ * @param expression
+ * visibility expression
* @see #ColumnVisibility(String)
*/
public ColumnVisibility(Text expression) {
this(TextUtil.getBytes(expression));
}
-
+
/**
* Creates a column visibility for a Mutation from a string already encoded in UTF-8 bytes.
*
- * @param expression visibility expression, encoded as UTF-8 bytes
+ * @param expression
+ * visibility expression, encoded as UTF-8 bytes
* @see #ColumnVisibility(String)
*/
public ColumnVisibility(byte[] expression) {
validate(expression);
}
-
+
@Override
public String toString() {
return "[" + new String(expression, UTF_8) + "]";
}
-
+
/**
* See {@link #equals(ColumnVisibility)}
*/
@@ -477,22 +480,23 @@ public class ColumnVisibility {
return equals((ColumnVisibility) obj);
return false;
}
-
+
/**
* Compares two ColumnVisibilities for string equivalence, not as a meaningful comparison of terms and conditions.
*
- * @param otherLe other column visibility
+ * @param otherLe
+ * other column visibility
* @return true if this visibility equals the other via string comparison
*/
public boolean equals(ColumnVisibility otherLe) {
return Arrays.equals(expression, otherLe.expression);
}
-
+
@Override
public int hashCode() {
return Arrays.hashCode(expression);
}
-
+
/**
* Gets the parse tree for this column visibility.
*
@@ -501,7 +505,7 @@ public class ColumnVisibility {
public Node getParseTree() {
return node;
}
-
+
/**
* Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done.
*
@@ -516,33 +520,35 @@ public class ColumnVisibility {
* ColumnVisibility cv = new ColumnVisibility(quote("A#C") + "&" + quote("FOO"));
* </pre>
*
- * @param term term to quote
+ * @param term
+ * term to quote
* @return quoted term (unquoted if unnecessary)
*/
public static String quote(String term) {
return new String(quote(term.getBytes(UTF_8)), UTF_8);
}
-
+
/**
* Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done.
*
- * @param term term to quote, encoded as UTF-8 bytes
+ * @param term
+ * term to quote, encoded as UTF-8 bytes
* @return quoted term (unquoted if unnecessary), encoded as UTF-8 bytes
* @see #quote(String)
*/
public static byte[] quote(byte[] term) {
boolean needsQuote = false;
-
+
for (int i = 0; i < term.length; i++) {
if (!Authorizations.isValidAuthChar(term[i])) {
needsQuote = true;
break;
}
}
-
+
if (!needsQuote)
return term;
-
+
return VisibilityEvaluator.escape(term, true);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/Credentials.java b/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
index 525a958..ed7789a 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.security;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.nio.ByteBuffer;
+
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
@@ -33,7 +34,7 @@ import org.apache.accumulo.core.util.Base64;
* important, so that the authentication token carried in a {@link Connector} can be destroyed, invalidating future RPC operations from that {@link Connector}.
* <p>
* See ACCUMULO-1312
- *
+ *
* @since 1.6.0
*/
public class Credentials {
@@ -43,7 +44,7 @@ public class Credentials {
/**
* Creates a new credentials object.
- *
+ *
* @param principal
* unique identifier for the entity (e.g. a user or service) authorized for these credentials
* @param token
@@ -56,7 +57,7 @@ public class Credentials {
/**
* Gets the principal.
- *
+ *
* @return unique identifier for the entity (e.g. a user or service) authorized for these credentials
*/
public String getPrincipal() {
@@ -65,7 +66,7 @@ public class Credentials {
/**
* Gets the authentication token.
- *
+ *
* @return authentication token used to prove that the principal for these credentials has been properly verified
*/
public AuthenticationToken getToken() {
@@ -75,7 +76,7 @@ public class Credentials {
/**
* Converts the current object to the relevant thrift type. The object returned from this contains a non-destroyable version of the
* {@link AuthenticationToken}, so this should be used just before placing on the wire, and references to it should be tightly controlled.
- *
+ *
* @param instance
* client instance
* @return Thrift credentials
@@ -92,7 +93,9 @@ public class Credentials {
/**
* Converts a given thrift object to our internal Credentials representation.
- * @param serialized a Thrift encoded set of credentials
+ *
+ * @param serialized
+ * a Thrift encoded set of credentials
* @return a new Credentials instance; destroy the token when you're done.
*/
public static Credentials fromThrift(TCredentials serialized) {
@@ -102,7 +105,7 @@ public class Credentials {
/**
* Converts the current object to a serialized form. The object returned from this contains a non-destroyable version of the {@link AuthenticationToken}, so
* references to it should be tightly controlled.
- *
+ *
* @return serialized form of these credentials
*/
public final String serialize() {
@@ -113,7 +116,7 @@ public class Credentials {
/**
* Converts the serialized form to an instance of {@link Credentials}. The original serialized form will not be affected.
- *
+ *
* @param serializedForm
* serialized form of credentials
* @return deserialized credentials
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java b/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
index 44cee0c..638f630 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
@@ -30,8 +30,8 @@ public enum NamespacePermission {
GRANT((byte) 3),
ALTER_TABLE((byte) 4),
CREATE_TABLE((byte) 5),
- DROP_TABLE((byte) 6),
- BULK_IMPORT((byte) 7),
+ DROP_TABLE((byte) 6),
+ BULK_IMPORT((byte) 7),
DROP_NAMESPACE((byte) 8);
final private byte permID;
@@ -48,7 +48,7 @@ public enum NamespacePermission {
/**
* Gets the byte ID of this permission.
- *
+ *
* @return byte ID
*/
public byte getId() {
@@ -57,7 +57,7 @@ public enum NamespacePermission {
/**
* Returns a list of printable permission values.
- *
+ *
* @return list of namespace permission values, as "Namespace." + permission name
*/
public static List<String> printableValues() {
@@ -73,7 +73,7 @@ public enum NamespacePermission {
/**
* Gets the permission matching the given byte ID.
- *
+ *
* @param id
* byte ID
* @return system permission
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/SystemPermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/SystemPermission.java b/core/src/main/java/org/apache/accumulo/core/security/SystemPermission.java
index d9109ec..b998179 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/SystemPermission.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/SystemPermission.java
@@ -25,8 +25,7 @@ import java.util.List;
*/
public enum SystemPermission {
/*
- * One may add new permissions, but new permissions must use new numbers.
- * Current numbers in use must not be changed.
+ * One may add new permissions, but new permissions must use new numbers. Current numbers in use must not be changed.
*/
GRANT((byte) 0),
CREATE_TABLE((byte) 1),
@@ -39,20 +38,20 @@ public enum SystemPermission {
CREATE_NAMESPACE((byte) 8),
DROP_NAMESPACE((byte) 9),
ALTER_NAMESPACE((byte) 10);
-
+
private byte permID;
-
+
private static HashMap<Byte,SystemPermission> mapping;
static {
mapping = new HashMap<Byte,SystemPermission>(SystemPermission.values().length);
for (SystemPermission perm : SystemPermission.values())
mapping.put(perm.permID, perm);
}
-
+
private SystemPermission(byte id) {
this.permID = id;
}
-
+
/**
* Gets the byte ID of this permission.
*
@@ -61,7 +60,7 @@ public enum SystemPermission {
public byte getId() {
return this.permID;
}
-
+
/**
* Returns a list of printable permission values.
*
@@ -69,21 +68,23 @@ public enum SystemPermission {
*/
public static List<String> printableValues() {
SystemPermission[] a = SystemPermission.values();
-
+
List<String> list = new ArrayList<String>(a.length);
-
+
for (SystemPermission p : a)
list.add("System." + p);
-
+
return list;
}
-
+
/**
* Gets the permission matching the given byte ID.
*
- * @param id byte ID
+ * @param id
+ * byte ID
* @return system permission
- * @throws IndexOutOfBoundsException if the byte ID is invalid
+ * @throws IndexOutOfBoundsException
+ * if the byte ID is invalid
*/
public static SystemPermission getPermissionById(byte id) {
if (mapping.containsKey(id))
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/TablePermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/TablePermission.java b/core/src/main/java/org/apache/accumulo/core/security/TablePermission.java
index 05895f5..b6d122f 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/TablePermission.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/TablePermission.java
@@ -24,8 +24,7 @@ import java.util.List;
*/
public enum TablePermission {
/*
- * One may add new permissions, but new permissions must use new numbers.
- * Current numbers in use must not be changed.
+ * One may add new permissions, but new permissions must use new numbers. Current numbers in use must not be changed.
*/
// CREATE_LOCALITY_GROUP(0),
// DROP_LOCALITY_GROUP(1),
@@ -35,19 +34,19 @@ public enum TablePermission {
ALTER_TABLE((byte) 5),
GRANT((byte) 6),
DROP_TABLE((byte) 7);
-
+
final private byte permID;
-
+
final private static TablePermission mapping[] = new TablePermission[8];
static {
for (TablePermission perm : TablePermission.values())
mapping[perm.permID] = perm;
}
-
+
private TablePermission(byte id) {
this.permID = id;
}
-
+
/**
* Gets the byte ID of this permission.
*
@@ -56,7 +55,7 @@ public enum TablePermission {
public byte getId() {
return this.permID;
}
-
+
/**
* Returns a list of printable permission values.
*
@@ -64,21 +63,23 @@ public enum TablePermission {
*/
public static List<String> printableValues() {
TablePermission[] a = TablePermission.values();
-
+
List<String> list = new ArrayList<String>(a.length);
-
+
for (TablePermission p : a)
list.add("Table." + p);
-
+
return list;
}
-
+
/**
* Gets the permission matching the given byte ID.
*
- * @param id byte ID
+ * @param id
+ * byte ID
* @return table permission
- * @throws IndexOutOfBoundsException if the byte ID is invalid
+ * @throws IndexOutOfBoundsException
+ * if the byte ID is invalid
*/
public static TablePermission getPermissionById(byte id) {
TablePermission result = mapping[id];
@@ -86,5 +87,5 @@ public enum TablePermission {
return result;
throw new IndexOutOfBoundsException("No such permission");
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java b/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
index c4fe5ac..90cf951 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
@@ -28,8 +28,7 @@ import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.util.BadArgumentException;
/**
- * A constraint that checks the visibility of columns against the actor's
- * authorizations. Violation codes:
+ * A constraint that checks the visibility of columns against the actor's authorizations. Violation codes:
* <p>
* <ul>
* <li>1 = failure to parse visibility expression</li>
@@ -37,7 +36,7 @@ import org.apache.accumulo.core.util.BadArgumentException;
* </ul>
*/
public class VisibilityConstraint implements Constraint {
-
+
@Override
public String getViolationDescription(short violationCode) {
switch (violationCode) {
@@ -46,47 +45,47 @@ public class VisibilityConstraint implements Constraint {
case 2:
return "User does not have authorization on column visibility";
}
-
+
return null;
}
-
+
@Override
public List<Short> check(Environment env, Mutation mutation) {
List<ColumnUpdate> updates = mutation.getUpdates();
-
+
HashSet<String> ok = null;
if (updates.size() > 1)
ok = new HashSet<String>();
-
+
VisibilityEvaluator ve = null;
-
+
for (ColumnUpdate update : updates) {
-
+
byte[] cv = update.getColumnVisibility();
if (cv.length > 0) {
String key = null;
if (ok != null && ok.contains(key = new String(cv, UTF_8)))
continue;
-
+
try {
-
+
if (ve == null)
ve = new VisibilityEvaluator(env);
-
+
if (!ve.evaluate(new ColumnVisibility(cv)))
return Collections.singletonList(Short.valueOf((short) 2));
-
+
} catch (BadArgumentException bae) {
return Collections.singletonList(new Short((short) 1));
} catch (VisibilityParseException e) {
return Collections.singletonList(new Short((short) 1));
}
-
+
if (ok != null)
ok.add(key);
}
}
-
+
return null;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/VisibilityEvaluator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/VisibilityEvaluator.java b/core/src/main/java/org/apache/accumulo/core/security/VisibilityEvaluator.java
index 6baa17c..8535731 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/VisibilityEvaluator.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/VisibilityEvaluator.java
@@ -26,39 +26,40 @@ import org.apache.accumulo.core.security.ColumnVisibility.Node;
*/
public class VisibilityEvaluator {
private AuthorizationContainer auths;
-
+
/**
- * Creates a new {@link Authorizations} object with escaped forms of the
- * authorizations in the given object.
+ * Creates a new {@link Authorizations} object with escaped forms of the authorizations in the given object.
*
- * @param auths original authorizations
+ * @param auths
+ * original authorizations
* @return authorizations object with escaped authorization strings
* @see #escape(byte[], boolean)
*/
static Authorizations escape(Authorizations auths) {
ArrayList<byte[]> retAuths = new ArrayList<byte[]>(auths.getAuthorizations().size());
-
+
for (byte[] auth : auths.getAuthorizations())
retAuths.add(escape(auth, false));
-
+
return new Authorizations(retAuths);
}
-
+
/**
- * Properly escapes an authorization string. The string can be quoted if
- * desired.
+ * Properly escapes an authorization string. The string can be quoted if desired.
*
- * @param auth authorization string, as UTF-8 encoded bytes
- * @param quote true to wrap escaped authorization in quotes
+ * @param auth
+ * authorization string, as UTF-8 encoded bytes
+ * @param quote
+ * true to wrap escaped authorization in quotes
* @return escaped authorization string
*/
public static byte[] escape(byte[] auth, boolean quote) {
int escapeCount = 0;
-
+
for (int i = 0; i < auth.length; i++)
if (auth[i] == '"' || auth[i] == '\\')
escapeCount++;
-
+
if (escapeCount > 0 || quote) {
byte[] escapedAuth = new byte[auth.length + escapeCount + (quote ? 2 : 0)];
int index = quote ? 1 : 0;
@@ -67,52 +68,53 @@ public class VisibilityEvaluator {
escapedAuth[index++] = '\\';
escapedAuth[index++] = auth[i];
}
-
+
if (quote) {
escapedAuth[0] = '"';
escapedAuth[escapedAuth.length - 1] = '"';
}
-
+
auth = escapedAuth;
}
return auth;
}
-
+
/**
- * Creates a new evaluator for the authorizations found in the given
- * environment.
+ * Creates a new evaluator for the authorizations found in the given environment.
*
- * @param env environment containing authorizations
+ * @param env
+ * environment containing authorizations
*/
VisibilityEvaluator(Environment env) {
this.auths = env.getAuthorizationsContainer();
}
-
+
/**
- * Creates a new evaluator for the given collection of authorizations.
- * Each authorization string is escaped before handling, and the original
- * strings are unchanged.
+ * Creates a new evaluator for the given collection of authorizations. Each authorization string is escaped before handling, and the original strings are
+ * unchanged.
*
- * @param authorizations authorizations object
+ * @param authorizations
+ * authorizations object
*/
public VisibilityEvaluator(Authorizations authorizations) {
- this.auths = escape((Authorizations) authorizations);
+ this.auths = escape((Authorizations) authorizations);
}
-
+
/**
- * Evaluates the given column visibility against the authorizations provided to this evaluator.
- * A visibility passes evaluation if all authorizations in it are contained in those known to the evaluator, and
- * all AND and OR subexpressions have at least two children.
+ * Evaluates the given column visibility against the authorizations provided to this evaluator. A visibility passes evaluation if all authorizations in it are
+ * contained in those known to the evaluator, and all AND and OR subexpressions have at least two children.
*
- * @param visibility column visibility to evaluate
+ * @param visibility
+ * column visibility to evaluate
* @return true if visibility passes evaluation
- * @throws VisibilityParseException if an AND or OR subexpression has less than two children, or a subexpression is of an unknown type
+ * @throws VisibilityParseException
+ * if an AND or OR subexpression has less than two children, or a subexpression is of an unknown type
*/
public boolean evaluate(ColumnVisibility visibility) throws VisibilityParseException {
// The VisibilityEvaluator computes a trie from the given Authorizations, that ColumnVisibility expressions can be evaluated against.
return evaluate(visibility.getExpression(), visibility.getParseTree());
}
-
+
private final boolean evaluate(final byte[] expression, final Node root) throws VisibilityParseException {
if (expression.length == 0)
return true;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java b/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
index ca24884..d48840e 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
@@ -30,15 +30,18 @@ public class VisibilityParseException extends ParseException {
/**
* Creates a new exception.
*
- * @param reason reason string
- * @param visibility visibility that could not be parsed
- * @param errorOffset offset into visibility where parsing failed
+ * @param reason
+ * reason string
+ * @param visibility
+ * visibility that could not be parsed
+ * @param errorOffset
+ * offset into visibility where parsing failed
*/
public VisibilityParseException(String reason, byte[] visibility, int errorOffset) {
super(reason, errorOffset);
this.visibility = new String(visibility, UTF_8);
}
-
+
@Override
public String getMessage() {
return super.getMessage() + " in string '" + visibility + "' at position " + super.getErrorOffset();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
index 3ce648e..c929cab 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
-// Buffers all input in a growing buffer until flush() is called. Then entire buffer is written, with size information, and padding to force the underlying
+// Buffers all input in a growing buffer until flush() is called. Then entire buffer is written, with size information, and padding to force the underlying
// crypto output stream to also fully flush
public class BlockedOutputStream extends OutputStream {
int blockSize;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
index e5ad13d..b70cf57 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
@@ -39,11 +39,10 @@ import org.apache.log4j.Logger;
* A {@link SecretKeyEncryptionStrategy} that gets its key from HDFS and caches it for IO.
*/
public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncryptionStrategy {
-
+
private static final Logger log = Logger.getLogger(CachingHDFSSecretKeyEncryptionStrategy.class);
private SecretKeyCache secretKeyCache = new SecretKeyCache();
-
-
+
@Override
public CryptoModuleParameters encryptSecretKey(CryptoModuleParameters context) {
try {
@@ -55,7 +54,7 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
}
return context;
}
-
+
@Override
public CryptoModuleParameters decryptSecretKey(CryptoModuleParameters context) {
try {
@@ -67,7 +66,7 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
}
return context;
}
-
+
private void doKeyEncryptionOperation(int encryptionMode, CryptoModuleParameters params) throws IOException {
Cipher cipher = DefaultCryptoModuleUtils.getCipher(params.getAllOptions().get(Property.CRYPTO_DEFAULT_KEY_STRATEGY_CIPHER_SUITE.getKey()));
@@ -76,8 +75,8 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
} catch (InvalidKeyException e) {
log.error(e);
throw new RuntimeException(e);
- }
-
+ }
+
if (Cipher.UNWRAP_MODE == encryptionMode) {
try {
Key plaintextKey = cipher.unwrap(params.getEncryptedKey(), params.getAlgorithmName(), Cipher.SECRET_KEY);
@@ -102,43 +101,41 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
log.error(e);
throw new RuntimeException(e);
}
-
- }
+
+ }
}
-
+
private static class SecretKeyCache {
private boolean initialized = false;
private byte[] keyEncryptionKey;
private String pathToKeyName;
-
-
- public SecretKeyCache() {
- };
-
+
+ public SecretKeyCache() {};
+
public synchronized void ensureSecretKeyCacheInitialized(CryptoModuleParameters context) throws IOException {
-
+
if (initialized) {
return;
}
-
+
// First identify if the KEK already exists
pathToKeyName = getFullPathToKey(context);
-
+
if (pathToKeyName == null || pathToKeyName.equals("")) {
pathToKeyName = Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getDefaultValue();
}
// TODO ACCUMULO-2530 Ensure volumes a properly supported
- Path pathToKey = new Path(pathToKeyName);
- FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path pathToKey = new Path(pathToKeyName);
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
DataInputStream in = null;
try {
if (!fs.exists(pathToKey)) {
initializeKeyEncryptionKey(fs, pathToKey, context);
}
-
+
in = fs.open(pathToKey);
int keyEncryptionKeyLength = in.readInt();
@@ -146,14 +143,14 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
in.read(keyEncryptionKey);
initialized = true;
-
+
} catch (IOException e) {
log.error("Could not initialize key encryption cache", e);
} finally {
IOUtils.closeQuietly(in);
}
}
-
+
private void initializeKeyEncryptionKey(FileSystem fs, Path pathToKey, CryptoModuleParameters params) throws IOException {
DataOutputStream out = null;
try {
@@ -169,30 +166,29 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
out.flush();
} finally {
if (out != null) {
- out.close();
+ out.close();
}
}
-
+
}
@SuppressWarnings("deprecation")
private String getFullPathToKey(CryptoModuleParameters params) {
String pathToKeyName = params.getAllOptions().get(Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getKey());
String instanceDirectory = params.getAllOptions().get(Property.INSTANCE_DFS_DIR.getKey());
-
-
+
if (pathToKeyName == null) {
pathToKeyName = Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getDefaultValue();
}
-
+
if (instanceDirectory == null) {
instanceDirectory = Property.INSTANCE_DFS_DIR.getDefaultValue();
}
-
+
if (!pathToKeyName.startsWith("/")) {
pathToKeyName = "/" + pathToKeyName;
}
-
+
String fullPath = instanceDirectory + pathToKeyName;
return fullPath;
}
@@ -205,6 +201,5 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
return pathToKeyName;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModule.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModule.java
index 535c141..44531dc 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModule.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModule.java
@@ -27,70 +27,71 @@ import javax.crypto.CipherOutputStream;
/**
* Classes that obey this interface may be used to provide encrypting and decrypting streams to the rest of Accumulo. Classes that obey this interface may be
* configured as the crypto module by setting the property crypto.module.class in the accumulo-site.xml file.
- *
- *
+ *
+ *
*/
public interface CryptoModule {
-
+
/**
- * Takes a {@link CryptoModuleParameters} object containing an {@link OutputStream} to wrap within a {@link CipherOutputStream}. The various other parts of the
- * {@link CryptoModuleParameters} object specify the details about the type of encryption to use. Callers should pay special attention to the
+ * Takes a {@link CryptoModuleParameters} object containing an {@link OutputStream} to wrap within a {@link CipherOutputStream}. The various other parts of
+ * the {@link CryptoModuleParameters} object specify the details about the type of encryption to use. Callers should pay special attention to the
* {@link CryptoModuleParameters#getRecordParametersToStream()} and {@link CryptoModuleParameters#getCloseUnderylingStreamAfterCryptoStreamClose()} flags
* within the {@link CryptoModuleParameters} object, as they control whether or not this method will write to the given {@link OutputStream} in
* {@link CryptoModuleParameters#getPlaintextOutputStream()}.
- *
+ *
* <p>
- *
+ *
* This method returns a {@link CryptoModuleParameters} object. Implementers of this interface maintain a contract that the returned object is <i>the same</i>
* as the one passed in, always. Return values are enclosed within that object, as some other calls will typically return more than one value.
- *
+ *
* @param params
* the {@link CryptoModuleParameters} object that specifies how to set up the encrypted stream.
* @return the same {@link CryptoModuleParameters} object with the {@link CryptoModuleParameters#getEncryptedOutputStream()} set to a stream that is not null.
- * That stream may be exactly the same stream as {@link CryptoModuleParameters#getPlaintextInputStream()} if the params object specifies no cryptography.
+ * That stream may be exactly the same stream as {@link CryptoModuleParameters#getPlaintextInputStream()} if the params object specifies no
+ * cryptography.
*/
CryptoModuleParameters getEncryptingOutputStream(CryptoModuleParameters params) throws IOException;
-
-
-
+
/**
* Takes a {@link CryptoModuleParameters} object containing an {@link InputStream} to wrap within a {@link CipherInputStream}. The various other parts of the
* {@link CryptoModuleParameters} object specify the details about the type of encryption to use. Callers should pay special attention to the
* {@link CryptoModuleParameters#getRecordParametersToStream()} and {@link CryptoModuleParameters#getCloseUnderylingStreamAfterCryptoStreamClose()} flags
* within the {@link CryptoModuleParameters} object, as they control whether or not this method will read from the given {@link InputStream} in
* {@link CryptoModuleParameters#getEncryptedInputStream()}.
- *
+ *
* <p>
- *
+ *
* This method returns a {@link CryptoModuleParameters} object. Implementers of this interface maintain a contract that the returned object is <i>the same</i>
* as the one passed in, always. Return values are enclosed within that object, as some other calls will typically return more than one value.
- *
+ *
* @param params
* the {@link CryptoModuleParameters} object that specifies how to set up the encrypted stream.
* @return the same {@link CryptoModuleParameters} object with the {@link CryptoModuleParameters#getPlaintextInputStream()} set to a stream that is not null.
- * That stream may be exactly the same stream as {@link CryptoModuleParameters#getEncryptedInputStream()} if the params object specifies no cryptography.
+ * That stream may be exactly the same stream as {@link CryptoModuleParameters#getEncryptedInputStream()} if the params object specifies no
+ * cryptography.
*/
CryptoModuleParameters getDecryptingInputStream(CryptoModuleParameters params) throws IOException;
-
/**
- * Generates a random session key and sets it into the {@link CryptoModuleParameters#getPlaintextKey()} property. Saves callers from
- * having to set up their own secure random provider. Also will set the {@link CryptoModuleParameters#getSecureRandom()} property if it
- * has not already been set by some other function.
- *
- * @param params a {@link CryptoModuleParameters} object contained a correctly instantiated set of properties.
+ * Generates a random session key and sets it into the {@link CryptoModuleParameters#getPlaintextKey()} property. Saves callers from having to set up their
+ * own secure random provider. Also will set the {@link CryptoModuleParameters#getSecureRandom()} property if it has not already been set by some other
+ * function.
+ *
+ * @param params
+ * a {@link CryptoModuleParameters} object contained a correctly instantiated set of properties.
* @return the same {@link CryptoModuleParameters} object with the plaintext key set
*/
CryptoModuleParameters generateNewRandomSessionKey(CryptoModuleParameters params);
-
+
/**
* Generates a {@link Cipher} object based on the parameters in the given {@link CryptoModuleParameters} object and places it into the
- * {@link CryptoModuleParameters#getCipher()} property. Callers may choose to use this method if they want to get the initialization
- * vector from the cipher before proceeding to create wrapped streams.
- *
- * @param params a {@link CryptoModuleParameters} object contained a correctly instantiated set of properties.
+ * {@link CryptoModuleParameters#getCipher()} property. Callers may choose to use this method if they want to get the initialization vector from the cipher
+ * before proceeding to create wrapped streams.
+ *
+ * @param params
+ * a {@link CryptoModuleParameters} object contained a correctly instantiated set of properties.
* @return the same {@link CryptoModuleParameters} object with the cipher set.
*/
CryptoModuleParameters initializeCipher(CryptoModuleParameters params);
-
+
}