You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/04/12 16:37:29 UTC

svn commit: r1467287 [13/14] - in /accumulo/branches/1.4: ./ src/core/src/main/java/org/apache/accumulo/core/client/impl/thrift/ src/core/src/main/java/org/apache/accumulo/core/client/mock/ src/core/src/main/java/org/apache/accumulo/core/data/thrift/ s...

Added: accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/WriterOptions.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/WriterOptions.java?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/WriterOptions.java (added)
+++ accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/WriterOptions.java Fri Apr 12 14:37:09 2013
@@ -0,0 +1,587 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package org.apache.accumulo.proxy.thrift;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all") public class WriterOptions implements org.apache.thrift.TBase<WriterOptions, WriterOptions._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("WriterOptions");
+
+  private static final org.apache.thrift.protocol.TField MAX_MEMORY_FIELD_DESC = new org.apache.thrift.protocol.TField("maxMemory", org.apache.thrift.protocol.TType.I64, (short)1);
+  private static final org.apache.thrift.protocol.TField LATENCY_MS_FIELD_DESC = new org.apache.thrift.protocol.TField("latencyMs", org.apache.thrift.protocol.TType.I64, (short)2);
+  private static final org.apache.thrift.protocol.TField TIMEOUT_MS_FIELD_DESC = new org.apache.thrift.protocol.TField("timeoutMs", org.apache.thrift.protocol.TType.I64, (short)3);
+  private static final org.apache.thrift.protocol.TField THREADS_FIELD_DESC = new org.apache.thrift.protocol.TField("threads", org.apache.thrift.protocol.TType.I32, (short)4);
+
+  public long maxMemory;
+  public long latencyMs;
+  public long timeoutMs;
+  public int threads;
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    MAX_MEMORY((short)1, "maxMemory"),
+    LATENCY_MS((short)2, "latencyMs"),
+    TIMEOUT_MS((short)3, "timeoutMs"),
+    THREADS((short)4, "threads");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // MAX_MEMORY
+          return MAX_MEMORY;
+        case 2: // LATENCY_MS
+          return LATENCY_MS;
+        case 3: // TIMEOUT_MS
+          return TIMEOUT_MS;
+        case 4: // THREADS
+          return THREADS;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  private static final int __MAXMEMORY_ISSET_ID = 0;
+  private static final int __LATENCYMS_ISSET_ID = 1;
+  private static final int __TIMEOUTMS_ISSET_ID = 2;
+  private static final int __THREADS_ISSET_ID = 3;
+  private BitSet __isset_bit_vector = new BitSet(4);
+
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MAX_MEMORY, new org.apache.thrift.meta_data.FieldMetaData("maxMemory", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.LATENCY_MS, new org.apache.thrift.meta_data.FieldMetaData("latencyMs", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.TIMEOUT_MS, new org.apache.thrift.meta_data.FieldMetaData("timeoutMs", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.THREADS, new org.apache.thrift.meta_data.FieldMetaData("threads", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(WriterOptions.class, metaDataMap);
+  }
+
+  public WriterOptions() {
+  }
+
+  public WriterOptions(
+    long maxMemory,
+    long latencyMs,
+    long timeoutMs,
+    int threads)
+  {
+    this();
+    this.maxMemory = maxMemory;
+    setMaxMemoryIsSet(true);
+    this.latencyMs = latencyMs;
+    setLatencyMsIsSet(true);
+    this.timeoutMs = timeoutMs;
+    setTimeoutMsIsSet(true);
+    this.threads = threads;
+    setThreadsIsSet(true);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public WriterOptions(WriterOptions other) {
+    __isset_bit_vector.clear();
+    __isset_bit_vector.or(other.__isset_bit_vector);
+    this.maxMemory = other.maxMemory;
+    this.latencyMs = other.latencyMs;
+    this.timeoutMs = other.timeoutMs;
+    this.threads = other.threads;
+  }
+
+  public WriterOptions deepCopy() {
+    return new WriterOptions(this);
+  }
+
+  @Override
+  public void clear() {
+    setMaxMemoryIsSet(false);
+    this.maxMemory = 0;
+    setLatencyMsIsSet(false);
+    this.latencyMs = 0;
+    setTimeoutMsIsSet(false);
+    this.timeoutMs = 0;
+    setThreadsIsSet(false);
+    this.threads = 0;
+  }
+
+  public long getMaxMemory() {
+    return this.maxMemory;
+  }
+
+  public WriterOptions setMaxMemory(long maxMemory) {
+    this.maxMemory = maxMemory;
+    setMaxMemoryIsSet(true);
+    return this;
+  }
+
+  public void unsetMaxMemory() {
+    __isset_bit_vector.clear(__MAXMEMORY_ISSET_ID);
+  }
+
+  /** Returns true if field maxMemory is set (has been assigned a value) and false otherwise */
+  public boolean isSetMaxMemory() {
+    return __isset_bit_vector.get(__MAXMEMORY_ISSET_ID);
+  }
+
+  public void setMaxMemoryIsSet(boolean value) {
+    __isset_bit_vector.set(__MAXMEMORY_ISSET_ID, value);
+  }
+
+  public long getLatencyMs() {
+    return this.latencyMs;
+  }
+
+  public WriterOptions setLatencyMs(long latencyMs) {
+    this.latencyMs = latencyMs;
+    setLatencyMsIsSet(true);
+    return this;
+  }
+
+  public void unsetLatencyMs() {
+    __isset_bit_vector.clear(__LATENCYMS_ISSET_ID);
+  }
+
+  /** Returns true if field latencyMs is set (has been assigned a value) and false otherwise */
+  public boolean isSetLatencyMs() {
+    return __isset_bit_vector.get(__LATENCYMS_ISSET_ID);
+  }
+
+  public void setLatencyMsIsSet(boolean value) {
+    __isset_bit_vector.set(__LATENCYMS_ISSET_ID, value);
+  }
+
+  public long getTimeoutMs() {
+    return this.timeoutMs;
+  }
+
+  public WriterOptions setTimeoutMs(long timeoutMs) {
+    this.timeoutMs = timeoutMs;
+    setTimeoutMsIsSet(true);
+    return this;
+  }
+
+  public void unsetTimeoutMs() {
+    __isset_bit_vector.clear(__TIMEOUTMS_ISSET_ID);
+  }
+
+  /** Returns true if field timeoutMs is set (has been assigned a value) and false otherwise */
+  public boolean isSetTimeoutMs() {
+    return __isset_bit_vector.get(__TIMEOUTMS_ISSET_ID);
+  }
+
+  public void setTimeoutMsIsSet(boolean value) {
+    __isset_bit_vector.set(__TIMEOUTMS_ISSET_ID, value);
+  }
+
+  public int getThreads() {
+    return this.threads;
+  }
+
+  public WriterOptions setThreads(int threads) {
+    this.threads = threads;
+    setThreadsIsSet(true);
+    return this;
+  }
+
+  public void unsetThreads() {
+    __isset_bit_vector.clear(__THREADS_ISSET_ID);
+  }
+
+  /** Returns true if field threads is set (has been assigned a value) and false otherwise */
+  public boolean isSetThreads() {
+    return __isset_bit_vector.get(__THREADS_ISSET_ID);
+  }
+
+  public void setThreadsIsSet(boolean value) {
+    __isset_bit_vector.set(__THREADS_ISSET_ID, value);
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case MAX_MEMORY:
+      if (value == null) {
+        unsetMaxMemory();
+      } else {
+        setMaxMemory((Long)value);
+      }
+      break;
+
+    case LATENCY_MS:
+      if (value == null) {
+        unsetLatencyMs();
+      } else {
+        setLatencyMs((Long)value);
+      }
+      break;
+
+    case TIMEOUT_MS:
+      if (value == null) {
+        unsetTimeoutMs();
+      } else {
+        setTimeoutMs((Long)value);
+      }
+      break;
+
+    case THREADS:
+      if (value == null) {
+        unsetThreads();
+      } else {
+        setThreads((Integer)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case MAX_MEMORY:
+      return new Long(getMaxMemory());
+
+    case LATENCY_MS:
+      return new Long(getLatencyMs());
+
+    case TIMEOUT_MS:
+      return new Long(getTimeoutMs());
+
+    case THREADS:
+      return new Integer(getThreads());
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case MAX_MEMORY:
+      return isSetMaxMemory();
+    case LATENCY_MS:
+      return isSetLatencyMs();
+    case TIMEOUT_MS:
+      return isSetTimeoutMs();
+    case THREADS:
+      return isSetThreads();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof WriterOptions)
+      return this.equals((WriterOptions)that);
+    return false;
+  }
+
+  public boolean equals(WriterOptions that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_maxMemory = true;
+    boolean that_present_maxMemory = true;
+    if (this_present_maxMemory || that_present_maxMemory) {
+      if (!(this_present_maxMemory && that_present_maxMemory))
+        return false;
+      if (this.maxMemory != that.maxMemory)
+        return false;
+    }
+
+    boolean this_present_latencyMs = true;
+    boolean that_present_latencyMs = true;
+    if (this_present_latencyMs || that_present_latencyMs) {
+      if (!(this_present_latencyMs && that_present_latencyMs))
+        return false;
+      if (this.latencyMs != that.latencyMs)
+        return false;
+    }
+
+    boolean this_present_timeoutMs = true;
+    boolean that_present_timeoutMs = true;
+    if (this_present_timeoutMs || that_present_timeoutMs) {
+      if (!(this_present_timeoutMs && that_present_timeoutMs))
+        return false;
+      if (this.timeoutMs != that.timeoutMs)
+        return false;
+    }
+
+    boolean this_present_threads = true;
+    boolean that_present_threads = true;
+    if (this_present_threads || that_present_threads) {
+      if (!(this_present_threads && that_present_threads))
+        return false;
+      if (this.threads != that.threads)
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  public int compareTo(WriterOptions other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    WriterOptions typedOther = (WriterOptions)other;
+
+    lastComparison = Boolean.valueOf(isSetMaxMemory()).compareTo(typedOther.isSetMaxMemory());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMaxMemory()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxMemory, typedOther.maxMemory);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLatencyMs()).compareTo(typedOther.isSetLatencyMs());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLatencyMs()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.latencyMs, typedOther.latencyMs);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTimeoutMs()).compareTo(typedOther.isSetTimeoutMs());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTimeoutMs()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timeoutMs, typedOther.timeoutMs);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetThreads()).compareTo(typedOther.isSetThreads());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetThreads()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.threads, typedOther.threads);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    org.apache.thrift.protocol.TField field;
+    iprot.readStructBegin();
+    while (true)
+    {
+      field = iprot.readFieldBegin();
+      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
+        break;
+      }
+      switch (field.id) {
+        case 1: // MAX_MEMORY
+          if (field.type == org.apache.thrift.protocol.TType.I64) {
+            this.maxMemory = iprot.readI64();
+            setMaxMemoryIsSet(true);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 2: // LATENCY_MS
+          if (field.type == org.apache.thrift.protocol.TType.I64) {
+            this.latencyMs = iprot.readI64();
+            setLatencyMsIsSet(true);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 3: // TIMEOUT_MS
+          if (field.type == org.apache.thrift.protocol.TType.I64) {
+            this.timeoutMs = iprot.readI64();
+            setTimeoutMsIsSet(true);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 4: // THREADS
+          if (field.type == org.apache.thrift.protocol.TType.I32) {
+            this.threads = iprot.readI32();
+            setThreadsIsSet(true);
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        default:
+          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+      }
+      iprot.readFieldEnd();
+    }
+    iprot.readStructEnd();
+
+    // check for required fields of primitive type, which can't be checked in the validate method
+    validate();
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
+    oprot.writeFieldBegin(MAX_MEMORY_FIELD_DESC);
+    oprot.writeI64(this.maxMemory);
+    oprot.writeFieldEnd();
+    oprot.writeFieldBegin(LATENCY_MS_FIELD_DESC);
+    oprot.writeI64(this.latencyMs);
+    oprot.writeFieldEnd();
+    oprot.writeFieldBegin(TIMEOUT_MS_FIELD_DESC);
+    oprot.writeI64(this.timeoutMs);
+    oprot.writeFieldEnd();
+    oprot.writeFieldBegin(THREADS_FIELD_DESC);
+    oprot.writeI32(this.threads);
+    oprot.writeFieldEnd();
+    oprot.writeFieldStop();
+    oprot.writeStructEnd();
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("WriterOptions(");
+    boolean first = true;
+
+    sb.append("maxMemory:");
+    sb.append(this.maxMemory);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("latencyMs:");
+    sb.append(this.latencyMs);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("timeoutMs:");
+    sb.append(this.timeoutMs);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("threads:");
+    sb.append(this.threads);
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+    try {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bit_vector = new BitSet(1);
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+}
+

Propchange: accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/WriterOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/branches/1.4/src/proxy/src/main/scripts/generate-thrift.sh
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/main/scripts/generate-thrift.sh?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/main/scripts/generate-thrift.sh (added)
+++ accumulo/branches/1.4/src/proxy/src/main/scripts/generate-thrift.sh Fri Apr 12 14:37:09 2013
@@ -0,0 +1,24 @@
+#! /usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This script will regenerate the thrift code for accumulo-proxy.
+INCLUDED_MODULES=(-)
+BASE_OUTPUT_PACKAGE='org.apache.accumulo'
+PACKAGES_TO_GENERATE=(proxy)
+
+. ../core/src/main/thrift/thrift.sh
+

Propchange: accumulo/branches/1.4/src/proxy/src/main/scripts/generate-thrift.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/branches/1.4/src/proxy/src/main/thrift/proxy.thrift
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/main/thrift/proxy.thrift?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/main/thrift/proxy.thrift (added)
+++ accumulo/branches/1.4/src/proxy/src/main/thrift/proxy.thrift Fri Apr 12 14:37:09 2013
@@ -0,0 +1,308 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+namespace cpp accumulo
+namespace java org.apache.accumulo.proxy.thrift
+
+struct Key {
+  1:binary row;
+  2:binary colFamily;
+  3:binary colQualifier;
+  4:binary colVisibility;
+  5:optional i64 timestamp
+}
+
+enum PartialKey {
+  ROW,
+  ROW_COLFAM,
+  ROW_COLFAM_COLQUAL,
+  ROW_COLFAM_COLQUAL_COLVIS,
+  ROW_COLFAM_COLQUAL_COLVIS_TIME,
+  ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL
+}
+
+struct ColumnUpdate {
+  1:binary colFamily,
+  2:binary colQualifier,
+  3:optional binary colVisibility,
+  4:optional i64 timestamp,
+  5:optional binary value,
+  6:optional bool deleteCell
+}
+
+struct KeyValue {
+  1:Key key,
+  2:binary value
+}
+
+struct ScanResult {
+  1:list<KeyValue> results,
+  2:bool more
+}
+
+struct Range {
+  1:Key start,
+  2:bool startInclusive
+  3:Key stop,
+  4:bool stopInclusive
+}
+
+struct ScanColumn {
+  1:binary colFamily,
+  2:optional binary colQualifier
+}
+
+struct IteratorSetting {
+  1: i32 priority,
+  2: string name,
+  3: string iteratorClass,
+  4: map<string,string> properties
+}
+
+struct ScanOptions {
+  1:optional set<binary> authorizations;
+  2:optional Range range,
+  3:optional list<ScanColumn> columns;
+  4:optional list<IteratorSetting> iterators;
+  5:optional i32 bufferSize;
+} 
+
+struct BatchScanOptions {
+  1:optional set<binary> authorizations;
+  2:optional list<Range> ranges;
+  3:optional list<ScanColumn> columns;
+  4:optional list<IteratorSetting> iterators;
+  5:optional i32 threads;
+} 
+
+struct KeyValueAndPeek {
+  1:KeyValue keyValue,
+  2:bool hasNext
+}
+
+enum TablePermission {
+  READ = 2,
+  WRITE = 3,
+  BULK_IMPORT = 4,
+  ALTER_TABLE = 5,
+  GRANT = 6,
+  DROP_TABLE = 7,
+}
+
+enum SystemPermission {
+  GRANT = 0,
+  CREATE_TABLE = 1,
+  DROP_TABLE = 2,
+  ALTER_TABLE = 3,
+  CREATE_USER = 4,
+  DROP_USER = 5,
+  ALTER_USER = 6,
+  SYSTEM = 7,
+}
+
+enum ScanType {
+    SINGLE,
+    BATCH
+}
+
+enum ScanState {
+    IDLE,
+    RUNNING,
+    QUEUED
+}
+
+struct KeyExtent {
+  1:string tableId,
+  2:binary endRow,
+  3:binary prevEndRow
+}
+
+struct Column {
+  1:binary colFamily;
+  2:binary colQualifier;
+  3:binary colVisibility;
+}
+
+struct ActiveScan {
+  1:string client
+  2:string user
+  3:string table
+  4:i64 age
+  5:i64 idleTime
+  6:ScanType type
+  7:ScanState state
+  8:KeyExtent extent
+  9:list<Column> columns
+  10:list<IteratorSetting> iterators
+  11:list<binary> authorizations
+}
+
+
+struct WriterOptions {
+ 1:i64 maxMemory
+ 2:i64 latencyMs
+ 3:i64 timeoutMs
+ 4:i32 threads
+}
+
+enum IteratorScope {
+  MINC,
+  MAJC,
+  SCAN
+}
+
+enum TimeType {
+  LOGICAL,
+  MILLIS
+}
+
+exception UnknownScanner {
+  1:string msg
+}
+
+exception UnknownWriter {
+  1:string msg
+}
+
+exception NoMoreEntriesException {
+  1:string msg
+}
+
+exception AccumuloException {
+  1:string msg
+}
+
+exception AccumuloSecurityException {
+  1:string msg
+}
+
+exception TableNotFoundException {
+  1:string msg
+}
+
+exception TableExistsException {
+  1:string msg
+}
+
+exception MutationsRejectedException {
+  1:string msg
+}
+
+service AccumuloProxy
+{
+  // get an authentication token
+  binary login(1:string principal, 2:map<string, string> loginProperties)                              throws (1:AccumuloSecurityException ouch2);
+
+  // table operations
+  i32 addConstraint (1:binary login, 2:string tableName, 3:string constraintClassName)                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void addSplits (1:binary login, 2:string tableName, 3:set<binary> splits)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void attachIterator (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
+                       4:set<IteratorScope> scopes) 
+                                                                                                       throws (1:AccumuloSecurityException ouch1, 2:AccumuloException ouch2, 3:TableNotFoundException ouch3);
+  void checkIteratorConflicts (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
+                               4:set<IteratorScope> scopes) 
+                                                                                                       throws (1:AccumuloException ouch1, 2:TableNotFoundException ouch2);
+  void clearLocatorCache (1:binary login, 2:string tableName)                                          throws (1:TableNotFoundException ouch1);
+  void cloneTable (1:binary login, 2:string tableName, 3:string newTableName, 4:bool flush, 
+                   5:map<string,string> propertiesToSet, 6:set<string> propertiesToExclude) 
+                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
+  void compactTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow, 
+		     5:list<IteratorSetting> iterators, 6:bool flush, 7:bool wait)                             throws (1:AccumuloSecurityException ouch1, 2:TableNotFoundException ouch2, 3:AccumuloException ouch3);
+
+  void createTable (1:binary login, 2:string tableName, 3:bool versioningIter, 4:TimeType type)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableExistsException ouch3);
+  void deleteTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void deleteRows (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)             throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void flushTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow,
+                   5:bool wait)
+                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  map<string,set<string>> getLocalityGroups (1:binary login, 2:string tableName)                       throws (1:AccumuloException ouch1, 2:TableNotFoundException ouch2);
+  IteratorSetting getIteratorSetting (1:binary login, 2:string tableName, 
+                                      3:string iteratorName, 4:IteratorScope scope) 
+                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  binary getMaxRow (1:binary login, 2:string tableName, 3:set<binary> auths, 4:binary startRow, 
+                    5:bool startInclusive, 6:binary endRow, 7:bool endInclusive) 
+                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  map<string,string> getTableProperties (1:binary login, 2:string tableName)                           throws (1:AccumuloException ouch1, 2:TableNotFoundException ouch2);
+  void importDirectory (1:binary login, 2:string tableName, 3:string importDir, 
+                        4:string failureDir, 5:bool setTime) 
+                                                                                                       throws (1:TableNotFoundException ouch1, 2:AccumuloException ouch3, 3:AccumuloSecurityException ouch4);
+  list<binary> listSplits (1:binary login, 2:string tableName, 3:i32 maxSplits)                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  set<string> listTables (1:binary login);
+  map<string,set<IteratorScope>> listIterators (1:binary login, 2:string tableName)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  map<string,i32> listConstraints (1:binary login, 2:string tableName)                                 throws (1:AccumuloException ouch1, 2:TableNotFoundException ouch2);
+  void mergeTablets (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void offlineTable (1:binary login, 2:string tableName)                                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void onlineTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void removeConstraint (1:binary login, 2:string tableName, 3:i32 constraint)                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void removeIterator (1:binary login, 2:string tableName, 3:string iterName, 
+                       4:set<IteratorScope> scopes)
+                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void removeTableProperty (1:binary login, 2:string tableName, 3:string property)                     throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void renameTable (1:binary login, 2:string oldTableName, 3:string newTableName)                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
+  void setLocalityGroups (1:binary login, 2:string tableName, 3:map<string,set<string>> groups)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void setTableProperty (1:binary login, 2:string tableName, 3:string property, 4:string value)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  set<Range> splitRangeByTablets (1:binary login, 2:string tableName, 3:Range range, 4:i32 maxSplits)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  bool tableExists (1:binary login, 2:string tableName);
+  map<string,string> tableIdMap (1:binary login);
+
+  // instance operations
+  list<ActiveScan> getActiveScans (1:binary login, 2:string tserver)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  map<string,string> getSiteConfiguration (1:binary login)                                           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  map<string,string> getSystemConfiguration (1:binary login)                                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  list<string> getTabletServers (1:binary login);
+  void removeProperty (1:binary login, 2:string property)                                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void setProperty (1:binary login, 2:string property, 3:string value)                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  bool testClassLoad (1:binary login, 2:string className, 3:string asTypeName)                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+
+  // security operations
+  bool authenticateUser (1:binary login, 2:string user, 3:map<string, string> properties)            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void changeUserAuthorizations (1:binary login, 2:string user, 3:set<binary> authorizations)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void changeLocalUserPassword (1:binary login, 2:string user, 3:binary password)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void createLocalUser (1:binary login, 2:string user, 3:binary password)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void dropLocalUser (1:binary login, 2:string user)                                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  list<binary> getUserAuthorizations (1:binary login, 2:string user)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void grantSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void grantTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  bool hasSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  bool hasTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  set<string> listLocalUsers (1:binary login)                                                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  void revokeSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
+  void revokeTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm) throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+
+
+  // scanning
+  string createBatchScanner(1:binary login, 2:string tableName, 3:BatchScanOptions options)          throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+  string createScanner(1:binary login, 2:string tableName, 3:ScanOptions options)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+
+  // use the scanner
+  bool hasNext(1:string scanner)                        throws(1:UnknownScanner ouch1);
+  KeyValueAndPeek nextEntry(1:string scanner)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
+  ScanResult nextK(1:string scanner, 2:i32 k)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
+  void closeScanner(1:string scanner)                   throws(1:UnknownScanner ouch1);
+
+  // writing
+  void updateAndFlush(1:binary login, 2:string tableName, 3:map<binary, list<ColumnUpdate>> cells) throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:MutationsRejectedException ouch4);
+  string createWriter(1:binary login, 2:string tableName, 3:WriterOptions opts)                    throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
+
+  // use the writer
+  oneway void update(1:string writer, 2:map<binary, list<ColumnUpdate>> cells);
+  void flush(1:string writer)                                                                      throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
+  void closeWriter(1:string writer)                                                                throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
+
+  // utilities
+  Range getRowRange(1:binary row);
+  Key getFollowing(1:Key key, 2:PartialKey part);
+}
\ No newline at end of file

Added: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java (added)
+++ accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java Fri Apr 12 14:37:09 2013
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.proxy;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.iterators.DevNull;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iterators.user.SummingCombiner;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.proxy.thrift.AccumuloProxy.Client;
+import org.apache.accumulo.proxy.thrift.*;
+import org.apache.accumulo.server.test.functional.SlowIterator;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.TServer;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+/**
+ * Call every method on the proxy and try to verify that it works.
+ */
+public class SimpleTest {
+  
+  public static final String TABLE_TEST = "test";
+
+  private static String secret = "";
+  private static Random random = new Random();
+  private static TServer proxyServer;
+  private static Thread thread;
+  private static int proxyPort;
+  private static org.apache.accumulo.proxy.thrift.AccumuloProxy.Client client;
+  private static String principal = "root";
+  @SuppressWarnings("serial")
+  private static Map<String, String> properties = new TreeMap<String, String>() {{ put("password",secret);}}; 
+  private static ByteBuffer creds = null;
+
+  private static Class<? extends TProtocolFactory> protocolClass;
+
+  static Class<? extends TProtocolFactory> getRandomProtocol() {
+    List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>();
+    protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class);
+    
+    Random rand = new Random();
+    return protocolFactories.get(rand.nextInt(protocolFactories.size()));
+  }
+
+  @BeforeClass
+  public static void setupMiniCluster() throws Exception {
+
+    Properties props = new Properties();
+    props.put("org.apache.accumulo.proxy.ProxyServer.useMockInstance", "true");
+
+    protocolClass = getRandomProtocol();
+    System.out.println(protocolClass.getName());
+
+    proxyPort = 40000 + random.nextInt(20000);
+    proxyServer = Proxy.createProxyServer(org.apache.accumulo.proxy.thrift.AccumuloProxy.class, org.apache.accumulo.proxy.ProxyServer.class, proxyPort,
+        protocolClass, props);
+    thread = new Thread() {
+      @Override
+      public void run() {
+        proxyServer.serve();
+      }
+    };
+    thread.start();
+    while (!proxyServer.isServing())
+      UtilWaitThread.sleep(100);
+    client = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
+    creds = client.login(principal, properties);
+  }
+
+  @Test
+  public void testInstanceOperations() throws Exception {
+    // get something we know is in the site config
+    Map<String,String> cfg = client.getSiteConfiguration(creds);
+
+    // set a property in zookeeper
+    client.setProperty(creds, "table.split.threshold", "500M");
+    
+    // check that we can read it
+    for (int i = 0; i < 5; i++) {
+      cfg = client.getSystemConfiguration(creds);
+      if ("500M".equals(cfg.get("table.split.threshold")))
+          break;
+      Thread.sleep(200);
+    }
+    assertEquals("500M", cfg.get("table.split.threshold"));
+
+    // unset the setting, check that it's not what it was
+    client.removeProperty(creds, "table.split.threshold");
+    for (int i = 0; i < 5; i++) {
+      cfg = client.getSystemConfiguration(creds);
+      if (!"500M".equals(cfg.get("table.split.threshold")))
+          break;
+      Thread.sleep(200);
+    }
+    assertTrue("500M" != cfg.get("table.split.threshold"));
+
+    // try to load some classes via the proxy
+    assertTrue(client.testClassLoad(creds, DevNull.class.getName(), SortedKeyValueIterator.class.getName()));
+    assertFalse(client.testClassLoad(creds, "foo.bar", SortedKeyValueIterator.class.getName()));
+
+    // create a table that's very slow, so we can look for scans/compactions
+    client.createTable(creds, "slow", true, TimeType.MILLIS);
+    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
+    client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class));
+    client.updateAndFlush(creds, "slow", mutation("row", "cf", "cq", "value"));
+    client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
+    client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
+    client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
+    
+    // scan
+    Thread t = new Thread() {
+      @Override
+      public void run() {
+        String scanner;
+        try {
+          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
+          scanner = client2.createScanner(creds, "slow", null);
+          client2.nextK(scanner, 10);
+          client2.closeScanner(scanner);
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+      }
+    };
+    t.start();
+  }
+  
+  @Test
+  public void testSecurityOperations() throws Exception {
+    // check password
+    assertTrue(client.authenticateUser(creds, "root", s2pp(secret)));
+    assertFalse(client.authenticateUser(creds, "root", s2pp("fail")));
+
+    // create a user
+    client.createLocalUser(creds, "stooge", s2bb("password"));
+    // change auths
+    Set<String> users = client.listLocalUsers(creds);
+    assertEquals(new HashSet<String>(Arrays.asList("root", "stooge")), users);
+    HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"),s2bb("B")));
+    client.changeUserAuthorizations(creds, "stooge", auths);
+    List<ByteBuffer> update = client.getUserAuthorizations(creds, "stooge");
+    assertEquals(auths, new HashSet<ByteBuffer>(update));
+    
+    // change password
+    client.changeLocalUserPassword(creds, "stooge", s2bb(""));
+    assertTrue(client.authenticateUser(creds, "stooge", s2pp("")));
+    
+    // check permission failure
+    @SuppressWarnings("serial")
+    ByteBuffer stooge = client.login("stooge", new TreeMap<String,String>() {{put("password",""); }});
+    
+    // grant permissions and test
+    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
+    client.grantSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
+    assertTrue(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
+    client.createTable(stooge, "success", true, TimeType.MILLIS);
+    client.listTables(creds).contains("succcess");
+    
+    // revoke permissions
+    client.revokeSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
+    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
+
+    // create a table to test table permissions
+    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
+
+    // grant
+    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
+    client.grantTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
+    assertTrue(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
+    String scanner = client.createScanner(stooge, TABLE_TEST, null);
+    client.nextK(scanner, 10);
+    client.closeScanner(scanner);
+
+    // delete user
+    client.dropLocalUser(creds, "stooge");
+    users = client.listLocalUsers(creds);
+    assertEquals(1, users.size());
+    
+  }
+
+  @Test
+  public void testBatchWriter() throws Exception {
+      if (client.tableExists(creds, TABLE_TEST))
+          client.deleteTable(creds, TABLE_TEST);
+
+      client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
+
+      client.removeConstraint(creds, TABLE_TEST, 1);
+
+      WriterOptions writerOptions = new WriterOptions();
+      writerOptions.setLatencyMs(10000);
+      writerOptions.setMaxMemory(3000);
+      writerOptions.setThreads(1);
+      writerOptions.setTimeoutMs(100000);
+
+      String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
+
+      client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
+      client.flush(batchWriter);
+      client.closeWriter(batchWriter);
+
+      String scanner = client.createScanner(creds, TABLE_TEST, null);
+      ScanResult more = client.nextK(scanner, 2);
+      assertEquals(1, more.getResults().size());
+      client.closeScanner(scanner);
+
+      client.deleteTable(creds, TABLE_TEST);
+  }
+  
+  @Test
+  public void testTableOperations() throws Exception {
+    if (client.tableExists(creds, TABLE_TEST))
+      client.deleteTable(creds, TABLE_TEST);
+    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
+
+    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
+    String scanner = client.createScanner(creds, TABLE_TEST, null);
+    ScanResult more = client.nextK(scanner, 2);
+    client.closeScanner(scanner);
+    assertFalse(more.isMore());
+    assertEquals(1, more.getResults().size());
+    assertEquals(s2bb("x"), more.getResults().get(0).value);
+    // iterators
+    client.deleteTable(creds, TABLE_TEST);
+    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
+    HashMap<String, String> options = new HashMap<String, String>();
+    options.put("type", "STRING");
+    options.put("columns", "cf");
+    IteratorSetting setting = new IteratorSetting(10, TABLE_TEST, SummingCombiner.class.getName(), options);
+    client.attachIterator(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
+    for (int i = 0; i < 10; i++) {
+      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "1"));
+    }
+    scanner = client.createScanner(creds, TABLE_TEST, null);
+    more = client.nextK(scanner, 2);
+    client.closeScanner(scanner);
+    assertEquals("10", new String(more.getResults().get(0).getValue()));
+    try {
+      client.checkIteratorConflicts(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
+      fail("checkIteratorConflicts did not throw and exception");
+    } catch (Exception ex) {
+    }
+    client.removeIterator(creds, TABLE_TEST, "test", EnumSet.allOf(IteratorScope.class));
+    for (int i = 0; i < 10; i++) {
+      client.updateAndFlush(creds, TABLE_TEST, mutation("row"+i, "cf", "cq", ""+i));
+    }
+    scanner = client.createScanner(creds, TABLE_TEST, null);
+    more = client.nextK(scanner, 100);
+    client.closeScanner(scanner);
+    assertEquals(10, more.getResults().size());
+
+  }
+  
+  // scan !METADATA table for file entries for the given table
+  private int countFiles(String table) throws Exception {
+    Map<String,String> tableIdMap = client.tableIdMap(creds);
+    String tableId = tableIdMap.get(table);
+    Key start = new Key();
+    start.row = s2bb(tableId + ";");
+    Key end = new Key();
+    end.row = s2bb(tableId + "<");
+    end = client.getFollowing(end, PartialKey.ROW);
+    ScanOptions opt = new ScanOptions();
+    opt.range = new Range(start, true, end, false);
+    opt.columns = Collections.singletonList(new ScanColumn(s2bb("file")));
+    String scanner = client.createScanner(creds, Constants.METADATA_TABLE_NAME, opt);
+    int result = 0;
+    while (true) {
+      ScanResult more = client.nextK(scanner, 100);
+      result += more.getResults().size();
+      if (!more.more)
+        break;
+    }
+    return result;
+  }
+
+  private Map<ByteBuffer,List<ColumnUpdate>> mutation(String row, String cf, String cq, String value) {
+    ColumnUpdate upd = new ColumnUpdate(s2bb(cf), s2bb(cq));
+    upd.setValue(value.getBytes());
+    return Collections.singletonMap(s2bb(row), Collections.singletonList(upd));
+  }
+
+  private ByteBuffer s2bb(String cf) {
+    return ByteBuffer.wrap(cf.getBytes());
+  }
+
+  private Map<String, String> s2pp(String cf) {
+    Map<String, String> toRet = new TreeMap<String, String>();
+    toRet.put("password", cf);
+    return toRet;
+  }
+}

Propchange: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java (added)
+++ accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java Fri Apr 12 14:37:09 2013
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.proxy;
+
+import org.apache.accumulo.proxy.thrift.AccumuloException;
+import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.server.TServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.nio.ByteBuffer;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import static org.junit.Assert.*;
+
+public class TestProxyInstanceOperations {
+  protected static TServer proxy;
+  protected static Thread thread;
+  protected static TestProxyClient tpc;
+  protected static ByteBuffer userpass;
+  protected static final int port = 10197;
+  
+  @SuppressWarnings("serial")
+  @BeforeClass
+  public static void setup() throws Exception {
+    Properties prop = new Properties();
+    prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance", "true");
+    
+    proxy = Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"), Class.forName("org.apache.accumulo.proxy.ProxyServer"),
+        port, TCompactProtocol.Factory.class, prop);
+    thread = new Thread() {
+      @Override
+      public void run() {
+        proxy.serve();
+      }
+    };
+    thread.start();
+    tpc = new TestProxyClient("localhost", port);
+    userpass = tpc.proxy.login("root", new TreeMap<String, String>() {{ put("password",""); }});
+  }
+  
+  @AfterClass
+  public static void tearDown() throws InterruptedException {
+    proxy.stop();
+    thread.join();
+  }
+  
+  @Test
+  public void properties() throws TException, AccumuloException, AccumuloSecurityException {
+    tpc.proxy().setProperty(userpass, "test.systemprop", "whistletips");
+    
+    assertEquals(tpc.proxy().getSystemConfiguration(userpass).get("test.systemprop"), "whistletips");
+    tpc.proxy().removeProperty(userpass, "test.systemprop");
+    assertNull(tpc.proxy().getSystemConfiguration(userpass).get("test.systemprop"));
+    
+  }
+  
+  @Test
+  public void testClassLoad() throws TException, AccumuloException, AccumuloSecurityException {
+    assertTrue(tpc.proxy().testClassLoad(userpass, "org.apache.accumulo.core.iterators.user.RegExFilter", "org.apache.accumulo.core.iterators.Filter"));
+  }
+  
+}

Propchange: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java (added)
+++ accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java Fri Apr 12 14:37:09 2013
@@ -0,0 +1,479 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.proxy;
+
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.iterators.user.RegExFilter;
+import org.apache.accumulo.proxy.thrift.*;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.server.TServer;
+import org.junit.*;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+
+
+public class TestProxyReadWrite {
+  protected static TServer proxy;
+  protected static Thread thread;
+  protected static TestProxyClient tpc;
+  protected static ByteBuffer userpass;
+  protected static final int port = 10194;
+  protected static final String testtable = "testtable";
+
+  @SuppressWarnings("serial")
+  @BeforeClass
+  public static void setup() throws Exception {
+
+    Properties prop = new Properties();
+    prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance", "true");
+
+    proxy = Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"), Class.forName("org.apache.accumulo.proxy.ProxyServer"),
+        port, TCompactProtocol.Factory.class, prop);
+    thread = new Thread() {
+      @Override
+      public void run() {
+        proxy.serve();
+      }
+    };
+
+    thread.start();
+    tpc = new TestProxyClient("localhost", port);
+    userpass = tpc.proxy().login("root", new TreeMap<String, String>() {{put("password",""); }});
+  }
+
+
+    @AfterClass
+  public static void tearDown() throws InterruptedException, IOException {
+    proxy.stop();
+    thread.join();
+  }
+  
+  @Before
+  public void makeTestTable() throws Exception {
+    tpc.proxy().createTable(userpass, testtable, true, TimeType.MILLIS);
+  }
+  
+  @After
+  public void deleteTestTable() throws Exception {
+    tpc.proxy().deleteTable(userpass, testtable);
+  }
+  
+  private static void addMutation(Map<ByteBuffer,List<ColumnUpdate>> mutations, String row, String cf, String cq, String value) {
+    ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(cf.getBytes()), ByteBuffer.wrap(cq.getBytes()));
+    update.setValue(value.getBytes());
+    mutations.put(ByteBuffer.wrap(row.getBytes()), Collections.singletonList(update));
+  }
+  
+  private static void addMutation(Map<ByteBuffer,List<ColumnUpdate>> mutations, String row, String cf, String cq, String vis, String value) {
+    ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(cf.getBytes()), ByteBuffer.wrap(cq.getBytes()));
+    update.setValue(value.getBytes());
+    update.setColVisibility(vis.getBytes());
+    mutations.put(ByteBuffer.wrap(row.getBytes()), Collections.singletonList(update));
+  }
+  
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a range so only the entries between -Inf...5 come back (there should be
+   * 50,000)
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithRange() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    Key stop = new Key();
+    stop.setRow("5".getBytes());
+    BatchScanOptions options = new BatchScanOptions();
+    options.ranges = Collections.singletonList(new Range(null, false, stop, false));
+    String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+
+    private class MyTest {
+
+        public void addMutation(Mutation m) throws MutationsRejectedException {
+            throw new MutationsRejectedException();
+        }
+    }
+
+
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a columnFamily so only the entries with specified column family come back (there should be
+   * 50,000)
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithColumnFamilyOnly() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+	
+      addMutation(mutations, String.format(format, i), "cf" + (i % 2) , "cq" + (i % 2), Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    BatchScanOptions options = new BatchScanOptions();
+
+	ScanColumn sc = new ScanColumn();
+	sc.colFamily = ByteBuffer.wrap("cf0".getBytes());
+
+    options.columns = Collections.singletonList(sc);
+    String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a columnFamily + columnQualififer so only the entries with specified column 
+   * come back (there should be 50,000)
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithFullColumn() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+	
+      addMutation(mutations, String.format(format, i), "cf" + (i % 2) , "cq" + (i % 2), Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    BatchScanOptions options = new BatchScanOptions();
+
+	ScanColumn sc = new ScanColumn();
+	sc.colFamily = ByteBuffer.wrap("cf0".getBytes());
+	sc.colQualifier = ByteBuffer.wrap("cq0".getBytes());
+
+    options.columns = Collections.singletonList(sc);
+    String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+
+
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Filter the results so only the even numbers come back.
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteBatchOneShotWithFilterIterator() throws Exception {
+    int maxInserts = 10000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+      
+    }
+    
+    String regex = ".*[02468]";
+    
+    org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
+    RegExFilter.setRegexs(is, regex, null, null, null, false);
+    
+    IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
+    ScanOptions opts = new ScanOptions();
+    opts.iterators = Collections.singletonList(pis);
+    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      for (KeyValue kv : kvList.getResults()) {
+        assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
+        
+        i += 2;
+      }
+      hasNext = kvList.isMore();
+    }
+  }
+  
+  @Test
+  public void readWriteOneShotWithRange() throws Exception {
+    int maxInserts = 100000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+      }
+    }
+    
+    Key stop = new Key();
+    stop.setRow("5".getBytes());
+    ScanOptions opts = new ScanOptions();
+    opts.range = new Range(null, false, stop, false);
+    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      i += kvList.getResultsSize();
+      hasNext = kvList.isMore();
+    }
+    assertEquals(i, 50000);
+  }
+  
+  /**
+   * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Filter the results so only the even numbers come back.
+   * 
+   * @throws Exception
+   */
+  @Test
+  public void readWriteOneShotWithFilterIterator() throws Exception {
+    int maxInserts = 10000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        
+        tpc.proxy().updateAndFlush(userpass, testtable, mutations);
+        mutations.clear();
+        
+      }
+      
+    }
+    
+    String regex = ".*[02468]";
+    
+    org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
+    RegExFilter.setRegexs(is, regex, null, null, null, false);
+    
+    IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
+    ScanOptions opts = new ScanOptions();
+    opts.iterators = Collections.singletonList(pis);
+    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      for (KeyValue kv : kvList.getResults()) {
+        assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
+        
+        i += 2;
+      }
+      hasNext = kvList.isMore();
+    }
+  }
+  
+  // @Test
+  // This test takes kind of a long time. Enable it if you think you may have memory issues.
+  public void manyWritesAndReads() throws Exception {
+    int maxInserts = 1000000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$06d";
+    String writer = tpc.proxy().createWriter(userpass, testtable, null);
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        
+        tpc.proxy().update(writer, mutations);
+        mutations.clear();
+        
+      }
+      
+    }
+    
+    tpc.proxy().flush(writer);
+    tpc.proxy().closeWriter(writer);
+    
+    String cookie = tpc.proxy().createScanner(userpass, testtable, null);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      for (KeyValue kv : kvList.getResults()) {
+        assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
+        i++;
+      }
+      hasNext = kvList.isMore();
+      if (hasNext)
+        assertEquals(k, kvList.getResults().size());
+    }
+    assertEquals(maxInserts, i);
+  }
+  
+  @Test
+  public void asynchReadWrite() throws Exception {
+    int maxInserts = 10000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    String writer = tpc.proxy().createWriter(userpass, testtable, null);
+    for (int i = 0; i < maxInserts; i++) {
+      addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().update(writer, mutations);
+        mutations.clear();
+      }
+    }
+    
+    tpc.proxy().flush(writer);
+    tpc.proxy().closeWriter(writer);
+    
+    String regex = ".*[02468]";
+    
+    org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
+    RegExFilter.setRegexs(is, regex, null, null, null, false);
+    
+    IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
+    ScanOptions opts = new ScanOptions();
+    opts.iterators = Collections.singletonList(pis);
+    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    int numRead = 0;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      for (KeyValue kv : kvList.getResults()) {
+        assertEquals(i, Integer.parseInt(new String(kv.getKey().getRow())));
+        numRead++;
+        i += 2;
+      }
+      hasNext = kvList.isMore();
+    }
+    assertEquals(maxInserts / 2, numRead);
+  }
+  
+  @Test
+  public void testVisibility() throws Exception {
+    
+    Set<ByteBuffer> auths = new HashSet<ByteBuffer>();
+    auths.add(ByteBuffer.wrap("even".getBytes()));
+    tpc.proxy().changeUserAuthorizations(userpass, "root", auths);
+    
+    int maxInserts = 10000;
+    Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
+    String format = "%1$05d";
+    String writer = tpc.proxy().createWriter(userpass, testtable, null);
+    for (int i = 0; i < maxInserts; i++) {
+      if (i % 2 == 0)
+        addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, "even", Util.randString(10));
+      else
+        addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, "odd", Util.randString(10));
+      
+      if (i % 1000 == 0 || i == maxInserts - 1) {
+        tpc.proxy().update(writer, mutations);
+        mutations.clear();
+      }
+    }
+    
+    tpc.proxy().flush(writer);
+    tpc.proxy().closeWriter(writer);
+    ScanOptions opts = new ScanOptions();
+    opts.authorizations = auths;
+    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
+    
+    int i = 0;
+    boolean hasNext = true;
+    
+    int k = 1000;
+    int numRead = 0;
+    while (hasNext) {
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
+      for (KeyValue kv : kvList.getResults()) {
+        assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
+        i += 2;
+        numRead++;
+      }
+      hasNext = kvList.isMore();
+      
+    }
+    assertEquals(maxInserts / 2, numRead);
+  }
+  
+}

Propchange: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java?rev=1467287&view=auto
==============================================================================
--- accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java (added)
+++ accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java Fri Apr 12 14:37:09 2013
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.proxy;
+
+import org.apache.accumulo.core.util.ByteBufferUtil;
+import org.apache.accumulo.proxy.thrift.*;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.server.TServer;
+import org.junit.*;
+
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+public class TestProxySecurityOperations {
+  protected static TServer proxy;
+  protected static Thread thread;
+  protected static TestProxyClient tpc;
+  protected static ByteBuffer userpass;
+  protected static final int port = 10196;
+  protected static final String testtable = "testtable";
+  protected static final String testuser = "VonJines";
+  protected static final ByteBuffer testpw = ByteBuffer.wrap("fiveones".getBytes());
+  
+  @SuppressWarnings("serial")
+  @BeforeClass
+  public static void setup() throws Exception {
+    Properties prop = new Properties();
+    prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance", "true");
+    
+    proxy = Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"), Class.forName("org.apache.accumulo.proxy.ProxyServer"),
+        port, TCompactProtocol.Factory.class, prop);
+    thread = new Thread() {
+      @Override
+      public void run() {
+        proxy.serve();
+      }
+    };
+    thread.start();
+    
+    tpc = new TestProxyClient("localhost", port);
+    userpass = tpc.proxy().login("root", new TreeMap<String, String>() {{put("password",""); }});
+  }
+  
+  @AfterClass
+  public static void tearDown() throws InterruptedException {
+    proxy.stop();
+    thread.join();
+  }
+  
+  @Before
+  public void makeTestTableAndUser() throws Exception {
+    tpc.proxy().createTable(userpass, testtable, true, TimeType.MILLIS);
+    tpc.proxy().createLocalUser(userpass, testuser, testpw);
+  }
+  
+  @After
+  public void deleteTestTable() throws Exception {
+    tpc.proxy().deleteTable(userpass, testtable);
+    tpc.proxy().dropLocalUser(userpass, testuser);
+  }
+  
+  @Test
+  public void create() throws TException, AccumuloException, TableNotFoundException, AccumuloSecurityException {
+    tpc.proxy().createLocalUser(userpass, testuser + "2", testpw);
+    assertTrue(tpc.proxy().listLocalUsers(userpass).contains(testuser + "2"));
+    tpc.proxy().dropLocalUser(userpass, testuser + "2");
+    assertTrue(!tpc.proxy().listLocalUsers(userpass).contains(testuser + "2"));
+  }
+  
+  @Test
+  public void authenticate() throws TException, AccumuloException, AccumuloSecurityException {
+    assertTrue(tpc.proxy().authenticateUser(userpass, testuser, bb2pp(testpw)));
+    assertFalse(tpc.proxy().authenticateUser(userpass, "EvilUser", bb2pp(testpw)));
+    
+    tpc.proxy().changeLocalUserPassword(userpass, testuser, ByteBuffer.wrap("newpass".getBytes()));
+    assertFalse(tpc.proxy().authenticateUser(userpass, testuser, bb2pp(testpw)));
+    assertTrue(tpc.proxy().authenticateUser(userpass, testuser, bb2pp(ByteBuffer.wrap("newpass".getBytes()))));
+    
+  }
+  
+  @Test
+  public void tablePermissions() throws TException, AccumuloException, TableNotFoundException, AccumuloSecurityException {
+    tpc.proxy().grantTablePermission(userpass, testuser, testtable, TablePermission.ALTER_TABLE);
+    assertTrue(tpc.proxy().hasTablePermission(userpass, testuser, testtable, TablePermission.ALTER_TABLE));
+    
+    tpc.proxy().revokeTablePermission(userpass, testuser, testtable, TablePermission.ALTER_TABLE);
+    assertFalse(tpc.proxy().hasTablePermission(userpass, testuser, testtable, TablePermission.ALTER_TABLE));
+    
+  }
+  
+  @Test
+  public void systemPermissions() throws TException, AccumuloException, AccumuloSecurityException {
+    tpc.proxy().grantSystemPermission(userpass, testuser, SystemPermission.ALTER_USER);
+    assertTrue(tpc.proxy().hasSystemPermission(userpass, testuser, SystemPermission.ALTER_USER));
+    
+    tpc.proxy().revokeSystemPermission(userpass, testuser, SystemPermission.ALTER_USER);
+    assertFalse(tpc.proxy().hasSystemPermission(userpass, testuser, SystemPermission.ALTER_USER));
+    
+  }
+  
+  @Test
+  public void auths() throws TException, AccumuloException, AccumuloSecurityException {
+    HashSet<ByteBuffer> newauths = new HashSet<ByteBuffer>();
+    newauths.add(ByteBuffer.wrap("BBR".getBytes()));
+    newauths.add(ByteBuffer.wrap("Barney".getBytes()));
+    tpc.proxy().changeUserAuthorizations(userpass, testuser, newauths);
+    List<ByteBuffer> actualauths = tpc.proxy().getUserAuthorizations(userpass, testuser);
+    assertEquals(actualauths.size(), newauths.size());
+    
+    for (ByteBuffer auth : actualauths) {
+      assertTrue(newauths.contains(auth));
+    }
+  }
+  
+  private Map<String, String> bb2pp(ByteBuffer cf) {
+    Map<String, String> toRet = new TreeMap<String, String>();
+    toRet.put("password", ByteBufferUtil.toString(cf));
+    return toRet;
+  }
+
+}

Propchange: accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
------------------------------------------------------------------------------
    svn:eol-style = native