incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/3] git commit: New RPC prototype.
Date Thu, 04 Oct 2012 02:46:42 GMT
Updated Branches:
  refs/heads/new-api-prototype [created] 5ea8d60ca


New RPC prototype.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/5ea8d60c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/5ea8d60c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/5ea8d60c

Branch: refs/heads/new-api-prototype
Commit: 5ea8d60ca85dcebef621be09e261c2399cf00ff3
Parents: b89d456
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Oct 3 22:44:56 2012 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Oct 3 22:44:56 2012 -0400

----------------------------------------------------------------------
 src/blur-new-api-prototype/pom.xml                 |  147 +
 src/blur-new-api-prototype/service.thrift          |   60 +
 .../org/apache/blur/proto/AbstractCommand.java     |   30 +
 .../java/org/apache/blur/proto/ClientManager.java  |  336 +
 .../main/java/org/apache/blur/proto/Command.java   |   24 +
 .../java/org/apache/blur/proto/Connection.java     |  130 +
 .../java/org/apache/blur/proto/LoadClient.java     |   43 +
 .../main/java/org/apache/blur/proto/RSession.java  |  121 +
 .../java/org/apache/blur/proto/ReadClient.java     |   62 +
 .../org/apache/blur/proto/ReadClientBatch.java     |   74 +
 .../main/java/org/apache/blur/proto/Server.java    |  258 +
 .../src/main/java/org/apache/blur/proto/Util.java  |  110 +
 .../main/java/org/apache/blur/proto/WSession.java  |   44 +
 .../org/apache/blur/proto/WSessionThreaded.java    |   84 +
 .../apache/blur/thrift/generated/Attribute.java    |  409 +
 .../blur/thrift/generated/BlurException.java       |  224 +
 .../apache/blur/thrift/generated/BlurTuple.java    | 8313 +++++++++++++++
 .../apache/blur/thrift/generated/ReadResult.java   |  320 +
 .../apache/blur/thrift/generated/ReadSession.java  |  319 +
 .../org/apache/blur/thrift/generated/TYPE.java     |   59 +
 .../org/apache/blur/thrift/generated/Tuple.java    |  357 +
 .../org/apache/blur/thrift/generated/Value.java    |  949 ++
 .../apache/blur/thrift/generated/WriteSession.java |  319 +
 .../src/main/resources/blur-default.properties     |   12 +
 24 files changed, 12804 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/pom.xml
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/pom.xml b/src/blur-new-api-prototype/pom.xml
new file mode 100644
index 0000000..548fd87
--- /dev/null
+++ b/src/blur-new-api-prototype/pom.xml
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.blur</groupId>
+	<artifactId>blur-new-api-prototype</artifactId>
+	<packaging>jar</packaging>
+	<name>Blur New API Prototype</name>
+	<version>0.2</version>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.lucene</groupId>
+			<artifactId>lucene-core</artifactId>
+			<version>4.0.0-BETA</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.lucene</groupId>
+			<artifactId>lucene-analyzers-common</artifactId>
+			<version>4.0.0-BETA</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.lucene</groupId>
+			<artifactId>lucene-queryparser</artifactId>
+			<version>4.0.0-BETA</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.hadoop</groupId>
+			<artifactId>hadoop-core</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.7.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.7</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.6.1</version>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.6.1</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.15</version>
+			<scope>provided</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>javax.mail</groupId>
+					<artifactId>mail</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.jms</groupId>
+					<artifactId>jms</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jdmk</groupId>
+					<artifactId>jmxtools</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jmx</groupId>
+					<artifactId>jmxri</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<pluginManagement>
+			<plugins>
+
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-compiler-plugin</artifactId>
+					<configuration>
+						<source>1.6</source>
+						<target>1.6</target>
+					</configuration>
+				</plugin>
+
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-dependency-plugin</artifactId>
+					<executions>
+						<execution>
+							<id>copy-dependencies</id>
+							<phase>package</phase>
+							<goals>
+								<goal>copy-dependencies</goal>
+							</goals>
+							<configuration>
+								<outputDirectory>${project.build.directory}/../../../lib
+								</outputDirectory>
+								<overWriteReleases>false</overWriteReleases>
+								<overWriteSnapshots>false</overWriteSnapshots>
+								<overWriteIfNewer>true</overWriteIfNewer>
+								<excludeTransitive>true</excludeTransitive>
+								<excludeArtifactIds>junit,commons-cli,commons-logging,hadoop-core,slf4j-api,slf4j-log4j12</excludeArtifactIds>
+							</configuration>
+						</execution>
+					</executions>
+				</plugin>
+				<plugin>
+					<artifactId>maven-assembly-plugin</artifactId>
+					<configuration>
+						<descriptorRefs>
+							<descriptorRef>jar-with-dependencies</descriptorRef>
+						</descriptorRefs>
+					</configuration>
+
+					<executions>
+						<execution>
+							<id>make-assembly</id>
+							<phase>package</phase>
+							<goals>
+								<goal>attached</goal>
+							</goals>
+						</execution>
+					</executions>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/service.thrift
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/service.thrift b/src/blur-new-api-prototype/service.thrift
new file mode 100644
index 0000000..6889665
--- /dev/null
+++ b/src/blur-new-api-prototype/service.thrift
@@ -0,0 +1,60 @@
+namespace java org.apache.blur.thrift.generated
+
+exception BlurException {
+
+}
+
+enum TYPE {
+  STRING, BOOL, SHORT, INT, LONG, DOUBLE, BINARY
+}
+
+struct Value {
+  1:TYPE type,
+  2:string stringValue,
+  3:bool boolValue,
+  4:i16 shortValue,
+  5:i32 intValue,
+  6:i64 longValue,
+  7:double doubleValue,
+  8:binary binaryValue
+}
+
+struct Attribute {
+  1:string name,
+  2:Value value
+}
+
+struct Tuple {
+  1:list<Attribute> attributes
+}
+
+struct ReadResult {
+  1:Tuple tuple
+}
+
+struct ReadSession {
+  1:string sessionId
+}
+
+struct WriteSession {
+  1:string sessionId
+}
+
+service BlurTuple {
+
+  ReadSession openReadSession() throws (1:BlurException e)
+  void executeQuery(1:ReadSession session, 2:string query) throws (1:BlurException e)
+  ReadResult nextMetaDataResult(1:ReadSession session) throws (1:BlurException e)
+  list<ReadResult> nextMetaDataResults(1:ReadSession session, 2:i32 batchSize) throws (1:BlurException e)
+  
+  ReadResult nextResult(1:ReadSession session) throws (1:BlurException e)
+  list<ReadResult> nextResults(1:ReadSession session, 2:i32 batchSize) throws (1:BlurException e)
+  
+  void closeReadSession(1:ReadSession session) throws (1:BlurException e)
+
+  WriteSession openWriteSession() throws (1:BlurException e)
+  void writeTuple(1:WriteSession session, 2:Tuple tuple) throws (1:BlurException e)
+  void commitWriteSession(1:WriteSession session) throws (1:BlurException e)
+  void rollbackWriteSession(1:WriteSession session) throws (1:BlurException e)
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/AbstractCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/AbstractCommand.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/AbstractCommand.java
new file mode 100644
index 0000000..fe02002
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/AbstractCommand.java
@@ -0,0 +1,30 @@
+package org.apache.blur.proto;
+
+/**
+ * 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.
+ */
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+
+public abstract class AbstractCommand<CLIENT, T> implements Cloneable {
+  public abstract T call(CLIENT client) throws BlurException, TException;
+
+  @Override
+  public Object clone() throws CloneNotSupportedException {
+    return super.clone();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ClientManager.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ClientManager.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ClientManager.java
new file mode 100644
index 0000000..5929012
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ClientManager.java
@@ -0,0 +1,336 @@
+package org.apache.blur.proto;
+
+/**
+ * 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.
+ */
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.Proxy.Type;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.BlurTuple.Client;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ClientManager {
+
+  private static final Object NULL = new Object();
+
+  private static final Log LOG = LogFactory.getLog(ClientManager.class);
+  private static final int MAX_RETRIES = 5;
+  private static final long BACK_OFF_TIME = TimeUnit.MILLISECONDS.toMillis(250);
+  private static final long MAX_BACK_OFF_TIME = TimeUnit.SECONDS.toMillis(10);
+  private static final long ONE_SECOND = TimeUnit.SECONDS.toMillis(1);
+
+  private static Map<Connection, BlockingQueue<Client>> clientPool = new ConcurrentHashMap<Connection, BlockingQueue<Client>>();
+  private static Thread daemon;
+  private static AtomicBoolean running = new AtomicBoolean(true);
+  private static Map<Connection, Object> badConnections = new ConcurrentHashMap<Connection, Object>();
+
+  static {
+    startDaemon();
+  }
+
+  private static void startDaemon() {
+    daemon = new Thread(new Runnable() {
+      private Set<Connection> good = new HashSet<Connection>();
+
+      @Override
+      public void run() {
+        while (running.get()) {
+          good.clear();
+          Set<Connection> badConns = badConnections.keySet();
+          for (Connection connection : badConns) {
+            if (isConnectionGood(connection)) {
+              good.add(connection);
+            }
+          }
+          for (Connection connection : good) {
+            badConnections.remove(connection);
+          }
+          try {
+            Thread.sleep(ONE_SECOND);
+          } catch (InterruptedException e) {
+            return;
+          }
+        }
+      }
+    });
+    daemon.setDaemon(true);
+    daemon.setName("Blur-Client-Manager-Connection-Checker");
+    daemon.start();
+  }
+
+  protected static boolean isConnectionGood(Connection connection) {
+    try {
+      returnClient(connection, getClient(connection));
+      return true;
+    } catch (TTransportException e) {
+      LOG.debug("Connection [" + connection + "] is still bad.");
+    } catch (IOException e) {
+      LOG.debug("Connection [" + connection + "] is still bad.");
+    }
+    return false;
+  }
+
+  public static <CLIENT, T> T execute(Connection connection, AbstractCommand<CLIENT, T> command) throws BlurException, TException, IOException {
+    return execute(connection, command, MAX_RETRIES, BACK_OFF_TIME, MAX_BACK_OFF_TIME);
+  }
+
+  public static <CLIENT, T> T execute(Connection connection, AbstractCommand<CLIENT, T> command, int maxRetries, long backOffTime, long maxBackOffTime) throws BlurException,
+      TException, IOException {
+    return execute(Arrays.asList(connection), command, maxRetries, backOffTime, maxBackOffTime);
+  }
+
+  public static <CLIENT, T> T execute(List<Connection> connections, AbstractCommand<CLIENT, T> command) throws BlurException, TException, IOException {
+    return execute(connections, command, MAX_RETRIES, BACK_OFF_TIME, MAX_BACK_OFF_TIME);
+  }
+
+  private static class LocalResources {
+    AtomicInteger retries = new AtomicInteger();
+    AtomicReference<Client> client = new AtomicReference<Client>();
+    List<Connection> shuffledConnections = new ArrayList<Connection>();
+    Random random = new Random();
+  }
+
+  @SuppressWarnings("unchecked")
+  public static <CLIENT, T> T execute(List<Connection> connections, AbstractCommand<CLIENT, T> command, int maxRetries, long backOffTime, long maxBackOffTime)
+      throws BlurException, TException, IOException {
+    LocalResources localResources = new LocalResources();
+    AtomicReference<Client> client = localResources.client;
+    Random random = localResources.random;
+    AtomicInteger retries = localResources.retries;
+    List<Connection> shuffledConnections = localResources.shuffledConnections;
+
+    retries.set(0);
+    shuffledConnections.addAll(connections);
+
+    Collections.shuffle(shuffledConnections, random);
+    boolean allBad = true;
+    int connectionErrorCount = 0;
+    while (true) {
+      for (Connection connection : shuffledConnections) {
+        if (isBadConnection(connection)) {
+          continue;
+        }
+        client.set(null);
+        try {
+          client.set(getClient(connection));
+        } catch (IOException e) {
+          if (handleError(connection, client, retries, command, e, maxRetries, backOffTime, maxBackOffTime)) {
+            throw e;
+          } else {
+            markBadConnection(connection);
+            continue;
+          }
+        }
+        try {
+          T result = command.call((CLIENT) client.get());
+          allBad = false;
+          return result;
+        } catch (RuntimeException e) {
+          Throwable cause = e.getCause();
+          if (cause instanceof TTransportException) {
+            TTransportException t = (TTransportException) cause;
+            if (handleError(connection, client, retries, command, t, maxRetries, backOffTime, maxBackOffTime)) {
+              throw t;
+            }
+          } else {
+            throw e;
+          }
+        } catch (TTransportException e) {
+          if (handleError(connection, client, retries, command, e, maxRetries, backOffTime, maxBackOffTime)) {
+            throw e;
+          }
+        } finally {
+          if (client.get() != null) {
+            returnClient(connection, client);
+          }
+        }
+      }
+      if (allBad) {
+        connectionErrorCount++;
+        LOG.error("All connections are bad [" + connectionErrorCount + "].");
+        if (connectionErrorCount >= maxRetries) {
+          throw new IOException("All connections are bad.");
+        }
+        try {
+          Thread.sleep(1000);
+        } catch (InterruptedException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    }
+  }
+
+  private static void markBadConnection(Connection connection) {
+    LOG.info("Marking bad connection [" + connection + "]");
+    badConnections.put(connection, NULL);
+  }
+
+  private static boolean isBadConnection(Connection connection) {
+    return badConnections.containsKey(connection);
+  }
+
+  private static <CLIENT, T> boolean handleError(Connection connection, AtomicReference<Client> client, AtomicInteger retries, AbstractCommand<CLIENT, T> command, Exception e,
+      int maxRetries, long backOffTime, long maxBackOffTime) {
+    if (client.get() != null) {
+      trashConnections(connection, client);
+      markBadConnection(connection);
+      client.set(null);
+    }
+    if (retries.get() > maxRetries) {
+      LOG.error("No more retries [" + retries + "] out of [" + maxRetries + "]");
+      return true;
+    }
+    LOG.error("Retrying call [" + command + "] retry [" + retries.get() + "] out of [" + maxRetries + "] message [" + e.getMessage() + "]");
+    sleep(backOffTime, maxBackOffTime, retries.get(), maxRetries);
+    retries.incrementAndGet();
+    return false;
+  }
+
+  public static void sleep(long backOffTime, long maxBackOffTime, int retry, int maxRetries) {
+    long extra = (maxBackOffTime - backOffTime) / maxRetries;
+    long sleep = backOffTime + (extra * retry);
+    LOG.info("Backing off call for [" + sleep + " ms]");
+    try {
+      Thread.sleep(sleep);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public static <CLIENT, T> T execute(String connectionStr, AbstractCommand<CLIENT, T> command, int maxRetries, long backOffTime, long maxBackOffTime) throws BlurException,
+      TException, IOException {
+    return execute(getConnections(connectionStr), command, maxRetries, backOffTime, maxBackOffTime);
+  }
+
+  public static List<Connection> getConnections(String connectionStr) {
+    int start = 0;
+    int index = connectionStr.indexOf(',');
+    if (index >= 0) {
+      List<Connection> connections = new ArrayList<Connection>();
+      while (index >= 0) {
+        connections.add(new Connection(connectionStr.substring(start, index)));
+        start = index + 1;
+        index = connectionStr.indexOf(',', start);
+      }
+      connections.add(new Connection(connectionStr.substring(start)));
+      return connections;
+    }
+    return Arrays.asList(new Connection(connectionStr));
+  }
+
+  public static <CLIENT, T> T execute(String connectionStr, AbstractCommand<CLIENT, T> command) throws BlurException, TException, IOException {
+    return execute(getConnections(connectionStr), command);
+  }
+
+  private static void returnClient(Connection connection, AtomicReference<Client> client) {
+    returnClient(connection, client.get());
+  }
+
+  private static void returnClient(Connection connection, Client client) {
+    try {
+      clientPool.get(connection).put(client);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  private static void trashConnections(Connection connection, AtomicReference<Client> c) {
+    BlockingQueue<Client> blockingQueue;
+    synchronized (clientPool) {
+      blockingQueue = clientPool.put(connection, new LinkedBlockingQueue<Client>());
+      try {
+        blockingQueue.put(c.get());
+      } catch (InterruptedException e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    LOG.info("Trashing client for connections [" + connection + "]");
+    for (Client client : blockingQueue) {
+      close(client);
+    }
+  }
+
+  public static void close(Client client) {
+    client.getInputProtocol().getTransport().close();
+    client.getOutputProtocol().getTransport().close();
+  }
+
+  private static Client getClient(Connection connection) throws TTransportException, IOException {
+    BlockingQueue<Client> blockingQueue;
+    synchronized (clientPool) {
+      blockingQueue = clientPool.get(connection);
+      if (blockingQueue == null) {
+        blockingQueue = new LinkedBlockingQueue<Client>();
+        clientPool.put(connection, blockingQueue);
+      }
+    }
+    if (blockingQueue.isEmpty()) {
+      return newClient(connection);
+    }
+    try {
+      return blockingQueue.take();
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public static Client newClient(Connection connection) throws TTransportException, IOException {
+    String host = connection.getHost();
+    int port = connection.getPort();
+    TSocket trans;
+    Socket socket;
+    if (connection.isProxy()) {
+      Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(connection.getProxyHost(), connection.getProxyPort()));
+      socket = new Socket(proxy);
+    } else {
+      socket = new Socket();
+    }
+    socket.setTcpNoDelay(true);
+    socket.connect(new InetSocketAddress(host, port));
+    trans = new TSocket(socket);
+    TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans));
+    Client client = new Client(proto);
+    return client;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Command.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Command.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Command.java
new file mode 100644
index 0000000..b354f3c
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Command.java
@@ -0,0 +1,24 @@
+package org.apache.blur.proto;
+
+/**
+ * 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.
+ */
+import org.apache.blur.thrift.generated.BlurTuple.Client;
+
+
+public abstract class Command<T> extends AbstractCommand<Client, T> {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Connection.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Connection.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Connection.java
new file mode 100644
index 0000000..fe3eee6
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Connection.java
@@ -0,0 +1,130 @@
+package org.apache.blur.proto;
+
+/**
+ * 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.
+ */
+public class Connection {
+
+  private String _host = null;
+  private int _port = -1;
+  private String _proxyHost = null;
+  private int _proxyPort = -1;
+  private boolean _proxy = false;
+
+  public Connection(String connectionStr) {
+    int index = connectionStr.indexOf(':');
+    if (index >= 0) {
+      int slashIndex = connectionStr.indexOf('/');
+      if (slashIndex > 0) {
+        _host = connectionStr.substring(0, index);
+        _port = Integer.parseInt(connectionStr.substring(index + 1, slashIndex));
+        int indexOfProxyPort = connectionStr.indexOf(':', slashIndex);
+        _proxyHost = connectionStr.substring(slashIndex + 1, indexOfProxyPort);
+        _proxyPort = Integer.parseInt(connectionStr.substring(indexOfProxyPort + 1));
+      } else {
+        _host = connectionStr.substring(0, index);
+        _port = Integer.parseInt(connectionStr.substring(index + 1));
+      }
+    } else {
+      throw new RuntimeException("Connection string of [" + connectionStr + "] does not match 'host1:port' or 'host1:port/proxyhost1:proxyport'");
+    }
+  }
+
+  public Connection(String host, int port, String proxyHost, int proxyPort) {
+    _port = port;
+    _host = host;
+    _proxyHost = proxyHost;
+    _proxyPort = proxyPort;
+    _proxy = true;
+  }
+
+  public Connection(String host, int port) {
+    _port = port;
+    _host = host;
+  }
+
+  public String getHost() {
+    return _host;
+  }
+
+  public int getPort() {
+    return _port;
+  }
+
+  public boolean isProxy() {
+    return _proxy;
+  }
+
+  public int getProxyPort() {
+    return _proxyPort;
+  }
+
+  public String getProxyHost() {
+    return _proxyHost;
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((_host == null) ? 0 : _host.hashCode());
+    result = prime * result + _port;
+    result = prime * result + (_proxy ? 1231 : 1237);
+    result = prime * result + ((_proxyHost == null) ? 0 : _proxyHost.hashCode());
+    result = prime * result + _proxyPort;
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    Connection other = (Connection) obj;
+    if (_host == null) {
+      if (other._host != null)
+        return false;
+    } else if (!_host.equals(other._host))
+      return false;
+    if (_port != other._port)
+      return false;
+    if (_proxy != other._proxy)
+      return false;
+    if (_proxyHost == null) {
+      if (other._proxyHost != null)
+        return false;
+    } else if (!_proxyHost.equals(other._proxyHost))
+      return false;
+    if (_proxyPort != other._proxyPort)
+      return false;
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    return "Connection [_host=" + _host + ", _port=" + _port + ", _proxy=" + _proxy + ", _proxyHost=" + _proxyHost + ", _proxyPort=" + _proxyPort + "]";
+  }
+
+  public Object getConnectionStr() {
+    if (_proxyHost != null) {
+      return _host + ":" + _port + "/" + _proxyHost + ":" + _proxyPort;
+    }
+    return _host + ":" + _port;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/LoadClient.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/LoadClient.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/LoadClient.java
new file mode 100644
index 0000000..3f0da07
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/LoadClient.java
@@ -0,0 +1,43 @@
+package org.apache.blur.proto;
+
+import java.io.IOException;
+import java.util.Random;
+
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.BlurTuple.Client;
+import org.apache.blur.thrift.generated.Tuple;
+import org.apache.blur.thrift.generated.WriteSession;
+import org.apache.thrift.TException;
+
+public class LoadClient {
+
+  public static void main(String[] args) throws BlurException, TException, IOException {
+    final int length = 1000000;
+    ClientManager.execute("localhost:9000", new Command<Void>() {
+      @Override
+      public Void call(Client client) throws BlurException, TException {
+        WriteSession session = client.openWriteSession();
+        long s = System.currentTimeMillis();
+        Random random = new Random();
+        for (int i = 0; i < length; i++) {
+          Tuple tuple = new Tuple();
+          tuple.addToAttributes(Util.newAttribute("id0", Long.toString(random.nextLong())));
+          tuple.addToAttributes(Util.newAttribute("id1", Long.toString(random.nextLong())));
+          tuple.addToAttributes(Util.newAttribute("id2", Long.toString(random.nextLong())));
+          tuple.addToAttributes(Util.newAttribute("id3", Long.toString(random.nextLong())));
+          tuple.addToAttributes(Util.newAttribute("id4", Long.toString(random.nextLong())));
+          client.writeTuple(session, tuple);
+        }
+        long m = System.currentTimeMillis();
+        client.commitWriteSession(session);
+        long e = System.currentTimeMillis();
+        double rate = length /  ((m - s) / 1000.0);
+        System.out.println("Load time [" + (m - s) + "] at [" + rate + "/s]");
+        System.out.println("Commit time [" + (e - m) + "]");
+        return null;
+      }
+    });
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/RSession.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/RSession.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/RSession.java
new file mode 100644
index 0000000..d83b940
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/RSession.java
@@ -0,0 +1,121 @@
+package org.apache.blur.proto;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
+
+public class RSession {
+
+  private String sessionId;
+  private IndexReader reader;
+  private IndexSearcher searcher;
+  private TopDocs topDocs;
+  private int totalHits;
+  private Query query;
+  private int position = 0;
+  private int totalPosition = 0;
+  private ScoreDoc scoreDoc;
+  private int fetch = 10000;
+  private boolean pagedBefore;
+  private double countToPreFetchAt = fetch * 0.6;
+  private boolean preFetch = true;
+  private ExecutorService executor;
+  private Future<TopDocs> futureFetch;
+  private boolean runningPreFetch = false;
+  private boolean metaData;
+
+  public IndexReader getReader() {
+    return reader;
+  }
+
+  public RSession(String sessionId, IndexReader reader) {
+    this.sessionId = sessionId;
+    this.reader = reader;
+    searcher = new IndexSearcher(reader);
+    executor = Executors.newSingleThreadExecutor();
+  }
+
+  public String getSessionId() {
+    return sessionId;
+  }
+
+  public void execute(Query query) throws IOException {
+    this.query = query;
+    topDocs = searcher.search(query, fetch);
+    totalHits = topDocs.totalHits;
+  }
+  
+  public int getTotalHits() {
+    metaData = true;
+    return totalHits;
+  }
+
+  public Document nextDocument() throws IOException {
+    if (totalPosition >= totalHits) {
+      return null;
+    }
+    try {
+      if (position >= topDocs.scoreDocs.length) {
+        page();
+      } else {
+        checkToSeeIfWeCanGetAhead();
+      }
+      this.scoreDoc = topDocs.scoreDocs[position];
+      return searcher.doc(topDocs.scoreDocs[position].doc);
+    } finally {
+      totalPosition++;
+      position++;
+    }
+  }
+
+  private void checkToSeeIfWeCanGetAhead() throws IOException {
+    if (preFetch && pagedBefore) {
+      if (position > countToPreFetchAt && !runningPreFetch) {
+        runningPreFetch = true;
+        final ScoreDoc after = topDocs.scoreDocs[topDocs.scoreDocs.length - 1];
+        futureFetch = executor.submit(new Callable<TopDocs>() {
+          @Override
+          public TopDocs call() throws Exception {
+            return searcher.searchAfter(after, query, fetch);
+          }
+        });
+      }
+    }
+  }
+
+  private void page() throws IOException {
+    if (preFetch && pagedBefore) {
+      try {
+        topDocs = futureFetch.get();
+        runningPreFetch = false;
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+      } catch (ExecutionException e) {
+        e.printStackTrace();
+      }
+    } else {
+      pagedBefore = true;
+      topDocs = searcher.searchAfter(scoreDoc, query, fetch);
+    }
+    position = 0;
+  }
+
+  public void close() throws IOException {
+    reader.close();
+  }
+
+  public boolean isMetaDataBeenFetched() {
+    return metaData;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClient.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClient.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClient.java
new file mode 100644
index 0000000..84eb280
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClient.java
@@ -0,0 +1,62 @@
+package org.apache.blur.proto;
+
+import java.io.IOException;
+
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.BlurTuple.Client;
+import org.apache.blur.thrift.generated.ReadResult;
+import org.apache.blur.thrift.generated.ReadSession;
+import org.apache.blur.thrift.generated.Tuple;
+import org.apache.thrift.TException;
+
+public class ReadClient {
+
+  public static void main(String[] args) throws BlurException, TException, IOException {
+    ClientManager.execute("localhost:9000", new Command<Void>() {
+      @Override
+      public Void call(Client client) throws BlurException, TException {
+        ReadSession session = client.openReadSession();
+        client.executeQuery(session, "*");
+        while (true) {
+          ReadResult metaDataResult = client.nextMetaDataResult(session);
+          Tuple tuple = metaDataResult.getTuple();
+          if (tuple == null) {
+            break;
+          }
+          System.out.println(tuple);
+        }
+        long count = 0;
+        long total = 0;
+        long start = System.nanoTime();
+        long attributeCount = 0;
+        long attributeTotal = 0;
+        while (true) {
+          long now = System.nanoTime();
+          if (start + 5000000000L < now) {
+            double seconds = (now - start) / 1000000000.0;
+            double rate = count / seconds;
+            double attributeRate = attributeCount / seconds;
+            System.out.println("Tuple count [" + total + "] at [" + rate + "/s] Attribute Count [" + attributeTotal + "] at [" + attributeRate + "/s]");
+            start = System.nanoTime();
+            count = 0;
+            attributeCount = 0;
+          }
+          ReadResult result = client.nextResult(session);
+//          System.out.println(result.getTuple());
+          if (result.getTuple() == null) {
+            break;
+          }
+          count++;
+          total++;
+          int atCount = result.getTuple().getAttributes().size();
+          attributeCount += atCount;
+          attributeTotal += atCount;
+        }
+        client.closeReadSession(session);
+        return null;
+      }
+    });
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClientBatch.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClientBatch.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClientBatch.java
new file mode 100644
index 0000000..0674184
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/ReadClientBatch.java
@@ -0,0 +1,74 @@
+package org.apache.blur.proto;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.BlurTuple.Client;
+import org.apache.blur.thrift.generated.ReadResult;
+import org.apache.blur.thrift.generated.ReadSession;
+import org.apache.blur.thrift.generated.Tuple;
+import org.apache.thrift.TException;
+
+public class ReadClientBatch {
+
+  public static void main(String[] args) throws BlurException, TException, IOException {
+    ClientManager.execute("localhost:9000", new Command<Void>() {
+      @Override
+      public Void call(Client client) throws BlurException, TException {
+        ReadSession session = client.openReadSession();
+        // client.executeQuery(session, "id1:fb*");
+        client.executeQuery(session, "*");
+        while (true) {
+          ReadResult metaDataResult = client.nextMetaDataResult(session);
+          Tuple tuple = metaDataResult.getTuple();
+          if (tuple == null) {
+            break;
+          }
+          System.out.println(tuple);
+        }
+
+        long count = 0;
+        long total = 0;
+        long start = System.nanoTime();
+        long attributeCount = 0;
+        long attributeTotal = 0;
+        while (true) {
+          long now = System.nanoTime();
+          if (start + 5000000000L < now) {
+            double seconds = (now - start) / 1000000000.0;
+            double rate = count / seconds;
+            double attributeRate = attributeCount / seconds;
+            System.out.println("Tuple count [" + total + "] at [" + rate + "/s] Attribute Count [" + attributeTotal + "] at [" + attributeRate + "/s]");
+            start = System.nanoTime();
+            count = 0;
+            attributeCount = 0;
+          }
+          List<ReadResult> results = client.nextResults(session, 10);
+          // System.out.println(result.getDocument());
+          if (results.isEmpty()) {
+            break;
+          }
+          count += results.size();
+          total += results.size();
+          int atCount = 0;
+          for (ReadResult rr : results) {
+            atCount += rr.getTuple().getAttributes().size();
+          }
+          attributeCount += atCount;
+          attributeTotal += atCount;
+        }
+        client.closeReadSession(session);
+
+        long now = System.nanoTime();
+        double seconds = (now - start) / 1000000000.0;
+        double rate = count / seconds;
+        double attributeRate = attributeCount / seconds;
+        System.out.println("Tuple count [" + total + "] at [" + rate + "/s] Attribute Count [" + attributeTotal + "] at [" + attributeRate + "/s]");
+        return null;
+      }
+    });
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Server.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Server.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Server.java
new file mode 100644
index 0000000..a009b97
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Server.java
@@ -0,0 +1,258 @@
+package org.apache.blur.proto;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.blur.thrift.generated.Attribute;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.BlurTuple.Iface;
+import org.apache.blur.thrift.generated.BlurTuple.Processor;
+import org.apache.blur.thrift.generated.ReadResult;
+import org.apache.blur.thrift.generated.ReadSession;
+import org.apache.blur.thrift.generated.Tuple;
+import org.apache.blur.thrift.generated.WriteSession;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.server.TThreadPoolServer.Args;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class Server implements Iface {
+
+  public static void main(String[] argsStr) throws TTransportException, IOException {
+    Server server = new Server(new File(argsStr[0]));
+    Processor<Iface> processor = new Processor<Iface>(server);
+    Args args = new Args(new TServerSocket(new InetSocketAddress("127.0.0.1", 9000)));
+    args.minWorkerThreads(50);
+    args.maxWorkerThreads(50);
+    args.processor(processor);
+    args.transportFactory(new TFramedTransport.Factory());
+    args.protocolFactory(new TBinaryProtocol.Factory(true, true));
+
+    TThreadPoolServer tserver = new TThreadPoolServer(args);
+    tserver.serve();
+  }
+
+  private Map<String, RSession> readSessions = new ConcurrentHashMap<String, RSession>();
+  private Map<String, WSession> writeSessions = new ConcurrentHashMap<String, WSession>();
+  private IndexWriter writer;
+  private File file;
+
+  public Server(File file) throws IOException {
+    this.file = file;
+    Directory directory = FSDirectory.open(file);
+    this.writer = openWriter(directory);
+  }
+
+  private IndexWriter openWriter(Directory directory) throws IOException {
+    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_40, new KeywordAnalyzer());
+    return new IndexWriter(directory, conf);
+  }
+
+  @Override
+  public ReadSession openReadSession() throws BlurException, TException {
+    try {
+      IndexReader reader = DirectoryReader.open(writer, true);
+      RSession session = new RSession(UUID.randomUUID().toString(), reader);
+      readSessions.put(session.getSessionId(), session);
+      return new ReadSession(session.getSessionId());
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public void executeQuery(ReadSession readSession, String query) throws BlurException, TException {
+    try {
+      RSession session = getSession(readSession);
+      if (query.trim().equals("*")) {
+        session.execute(new MatchAllDocsQuery());
+        return;
+      }
+      QueryParser parser = new QueryParser(Version.LUCENE_40, "SUPER", new KeywordAnalyzer());
+      parser.setAllowLeadingWildcard(true);
+      session.execute(parser.parse(query));
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public ReadResult nextMetaDataResult(ReadSession readSession) throws BlurException, TException {
+    try {
+      RSession session = getSession(readSession);
+      if (session.isMetaDataBeenFetched()) {
+        return new ReadResult((Tuple) null);
+      }
+      Tuple tuple = new Tuple();
+      tuple.addToAttributes(Util.newAttribute("totalResults", session.getTotalHits()));
+      return new ReadResult(tuple);
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public List<ReadResult> nextMetaDataResults(ReadSession readSession, int batchSize) throws BlurException, TException {
+    return Arrays.asList(nextMetaDataResult(readSession));
+  }
+
+  @Override
+  public ReadResult nextResult(ReadSession readSession) throws BlurException, TException {
+    try {
+      RSession session = getSession(readSession);
+      Tuple document = convert(session.nextDocument());
+      return new ReadResult(document);
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public List<ReadResult> nextResults(ReadSession readSession, int batchSize) throws BlurException, TException {
+    try {
+      RSession session = getSession(readSession);
+      List<ReadResult> results = new ArrayList<ReadResult>();
+      for (int i = 0; i < batchSize; i++) {
+        Tuple tuple = convert(session.nextDocument());
+        if (tuple == null) {
+          break;
+        }
+        results.add(new ReadResult(tuple));
+      }
+      return results;
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public void closeReadSession(ReadSession readSession) throws BlurException, TException {
+    try {
+      RSession session = readSessions.remove(readSession.getSessionId());
+      session.close();
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public WriteSession openWriteSession() throws BlurException, TException {
+    try {
+      String id = UUID.randomUUID().toString();
+      File f = new File(file, id);
+      Directory directory = FSDirectory.open(f);
+      WSession session = new WSessionThreaded(id, openWriter(directory), f, directory);
+      writeSessions.put(session.getSessionId(), session);
+      return new WriteSession(session.getSessionId());
+    } catch (Exception e) {
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public void writeTuple(WriteSession writeSession, Tuple tuple) throws BlurException, TException {
+    try {
+      WSession session = writeSessions.get(writeSession.getSessionId());
+      session.addDocument(convert(tuple));
+    } catch (Exception e) {
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public void commitWriteSession(WriteSession writeSession) throws BlurException, TException {
+    try {
+      WSession session = writeSessions.remove(writeSession.getSessionId());
+      session.closeWriter();
+      writer.addIndexes(session.getDirectory());
+      writer.commit();
+      writer.maybeMerge();
+      rm(session.getFile());
+    } catch (Exception e) {
+      throw new BlurException();
+    }
+  }
+
+  @Override
+  public void rollbackWriteSession(WriteSession writeSession) throws BlurException, TException {
+    try {
+      WSession session = writeSessions.remove(writeSession.getSessionId());
+      session.closeWriter();
+      rm(session.getFile());
+    } catch (Exception e) {
+      throw new BlurException();
+    }
+  }
+
+  private void rm(File file) {
+    if (!file.exists()) {
+      return;
+    }
+    if (file.isDirectory()) {
+      for (File f : file.listFiles()) {
+        rm(f);
+      }
+    }
+    file.delete();
+  }
+
+  private Document convert(Tuple tuple) {
+    if (tuple == null) {
+      return null;
+    }
+    Document newDoc = new Document();
+    for (Attribute field : tuple.getAttributes()) {
+      newDoc.add(Util.getField(field.getName(), field.getValue()));
+    }
+    return newDoc;
+  }
+
+  private Tuple convert(Document document) {
+    if (document == null) {
+      return null;
+    }
+    List<IndexableField> fields = document.getFields();
+    Tuple tuple = new Tuple();
+    for (IndexableField fieldable : fields) {
+      tuple.addToAttributes(Util.toAttribute(fieldable));
+    }
+    return tuple;
+  }
+
+  private RSession getSession(ReadSession readSession) throws BlurException {
+    RSession session = readSessions.get(readSession.getSessionId());
+    if (session == null) {
+      throw new BlurException();
+    }
+    return session;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Util.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Util.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Util.java
new file mode 100644
index 0000000..e21f8b9
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/Util.java
@@ -0,0 +1,110 @@
+package org.apache.blur.proto;
+
+import org.apache.blur.thrift.generated.Attribute;
+import org.apache.blur.thrift.generated.TYPE;
+import org.apache.blur.thrift.generated.Value;
+import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.LongField;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.index.IndexableField;
+
+public class Util {
+
+  public static Attribute newAttribute(String name, String value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, boolean value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, short value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, int value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, long value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, double value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Attribute newAttribute(String name, byte[] value) {
+    return new Attribute(name, newValue(value));
+  }
+
+  public static Value newValue(String value) {
+    Value v = new Value();
+    v.setStringValue(value);
+    v.setType(TYPE.STRING);
+    return v;
+  }
+
+  public static Value newValue(boolean value) {
+    Value v = new Value();
+    v.setBoolValue(value);
+    v.setType(TYPE.BOOL);
+    return v;
+  }
+
+  public static Value newValue(short value) {
+    Value v = new Value();
+    v.setShortValue(value);
+    v.setType(TYPE.SHORT);
+    return v;
+  }
+
+  public static Value newValue(int value) {
+    Value v = new Value();
+    v.setIntValue(value);
+    v.setType(TYPE.INT);
+    return v;
+  }
+
+  public static Value newValue(long value) {
+    Value v = new Value();
+    v.setLongValue(value);
+    v.setType(TYPE.LONG);
+    return v;
+  }
+
+  public static Value newValue(double value) {
+    Value v = new Value();
+    v.setDoubleValue(value);
+    v.setType(TYPE.DOUBLE);
+    return v;
+  }
+
+  public static Value newValue(byte[] value) {
+    Value v = new Value();
+    v.setBinaryValue(value);
+    v.setType(TYPE.BINARY);
+    return v;
+  }
+
+  public static IndexableField getField(String name, Value value) {
+    switch (value.getType()) {
+    case STRING:
+      return new StringField(name, value.getStringValue(), Store.YES);
+    case LONG:
+      return new LongField(name, value.getLongValue(), Store.YES);
+    default:
+      throw new RuntimeException("not supported");
+    }
+  }
+
+  public static Attribute toAttribute(IndexableField fieldable) {
+    Number numericValue = fieldable.numericValue();
+    if (numericValue == null) {
+      return newAttribute(fieldable.name(), fieldable.stringValue());
+    } else {
+      return newAttribute(fieldable.name(), (Long) numericValue);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSession.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSession.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSession.java
new file mode 100644
index 0000000..fdb564a
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSession.java
@@ -0,0 +1,44 @@
+package org.apache.blur.proto;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.Directory;
+
+public class WSession {
+
+  protected IndexWriter writer;
+  protected String sessionId;
+  protected File file;
+  protected Directory directory;
+
+  public WSession(String id, IndexWriter writer, File file, Directory directory) {
+    this.sessionId = id;
+    this.writer = writer;
+    this.file = file;
+    this.directory = directory;
+  }
+
+  public String getSessionId() {
+    return sessionId;
+  }
+
+  public void addDocument(Document document) throws IOException {
+    writer.addDocument(document);
+  }
+
+  public void closeWriter() throws IOException {
+    writer.close();
+  }
+
+  public File getFile() {
+    return file;
+  }
+
+  public Directory getDirectory() {
+    return directory;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSessionThreaded.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSessionThreaded.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSessionThreaded.java
new file mode 100644
index 0000000..b37226b
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/proto/WSessionThreaded.java
@@ -0,0 +1,84 @@
+package org.apache.blur.proto;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.Directory;
+
+public class WSessionThreaded extends WSession {
+
+  private Thread thread;
+  private volatile boolean running = true;
+  private BlockingQueue<Document> queue = new ArrayBlockingQueue<Document>(100);
+
+  public WSessionThreaded(String id, IndexWriter writer, File file, Directory directory) {
+    super(id, writer, file, directory);
+    startThread();
+  }
+
+  private void startThread() {
+    this.thread = new Thread(new Runnable() {
+      @Override
+      public void run() {
+        while (running) {
+          Document document;
+          try {
+            document = queue.poll(10, TimeUnit.MILLISECONDS);
+          } catch (InterruptedException e) {
+            e.printStackTrace();
+            return;
+          }
+          if (document != null) {
+            try {
+              writer.addDocument(document);
+            } catch (CorruptIndexException e) {
+              e.printStackTrace();
+            } catch (IOException e) {
+              e.printStackTrace();
+            }
+          }
+        }
+        List<Document> docs = new ArrayList<Document>();
+        queue.drainTo(docs);
+        try {
+          writer.addDocuments(docs);
+        } catch (CorruptIndexException e) {
+          e.printStackTrace();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+    });
+    thread.start();
+  }
+
+  public void addDocument(Document document) throws IOException {
+    if (running) {
+      try {
+        queue.put(document);
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+      }
+    } else {
+      throw new IOException("Writer closed");
+    }
+  }
+
+  public void closeWriter() throws IOException {
+    running = false;
+    try {
+      thread.join();
+    } catch (InterruptedException e) {
+      e.printStackTrace();
+    }
+    writer.close();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/Attribute.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/Attribute.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/Attribute.java
new file mode 100644
index 0000000..c6aafeb
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/Attribute.java
@@ -0,0 +1,409 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package org.apache.blur.thrift.generated;
+
+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;
+
+public class Attribute implements org.apache.thrift.TBase<Attribute, Attribute._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Attribute");
+
+  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+
+  public String name; // required
+  public Value value; // required
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    NAME((short)1, "name"),
+    VALUE((short)2, "value");
+
+    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: // NAME
+          return NAME;
+        case 2: // VALUE
+          return VALUE;
+        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
+
+  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.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Value.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Attribute.class, metaDataMap);
+  }
+
+  public Attribute() {
+  }
+
+  public Attribute(
+    String name,
+    Value value)
+  {
+    this();
+    this.name = name;
+    this.value = value;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public Attribute(Attribute other) {
+    if (other.isSetName()) {
+      this.name = other.name;
+    }
+    if (other.isSetValue()) {
+      this.value = new Value(other.value);
+    }
+  }
+
+  public Attribute deepCopy() {
+    return new Attribute(this);
+  }
+
+  @Override
+  public void clear() {
+    this.name = null;
+    this.value = null;
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  public Attribute setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  public void unsetName() {
+    this.name = null;
+  }
+
+  /** Returns true if field name is set (has been assigned a value) and false otherwise */
+  public boolean isSetName() {
+    return this.name != null;
+  }
+
+  public void setNameIsSet(boolean value) {
+    if (!value) {
+      this.name = null;
+    }
+  }
+
+  public Value getValue() {
+    return this.value;
+  }
+
+  public Attribute setValue(Value value) {
+    this.value = value;
+    return this;
+  }
+
+  public void unsetValue() {
+    this.value = null;
+  }
+
+  /** Returns true if field value is set (has been assigned a value) and false otherwise */
+  public boolean isSetValue() {
+    return this.value != null;
+  }
+
+  public void setValueIsSet(boolean value) {
+    if (!value) {
+      this.value = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case NAME:
+      if (value == null) {
+        unsetName();
+      } else {
+        setName((String)value);
+      }
+      break;
+
+    case VALUE:
+      if (value == null) {
+        unsetValue();
+      } else {
+        setValue((Value)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case NAME:
+      return getName();
+
+    case VALUE:
+      return getValue();
+
+    }
+    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 NAME:
+      return isSetName();
+    case VALUE:
+      return isSetValue();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof Attribute)
+      return this.equals((Attribute)that);
+    return false;
+  }
+
+  public boolean equals(Attribute that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_name = true && this.isSetName();
+    boolean that_present_name = true && that.isSetName();
+    if (this_present_name || that_present_name) {
+      if (!(this_present_name && that_present_name))
+        return false;
+      if (!this.name.equals(that.name))
+        return false;
+    }
+
+    boolean this_present_value = true && this.isSetValue();
+    boolean that_present_value = true && that.isSetValue();
+    if (this_present_value || that_present_value) {
+      if (!(this_present_value && that_present_value))
+        return false;
+      if (!this.value.equals(that.value))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  public int compareTo(Attribute other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    Attribute typedOther = (Attribute)other;
+
+    lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.name);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetValue()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
+      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: // NAME
+          if (field.type == org.apache.thrift.protocol.TType.STRING) {
+            this.name = iprot.readString();
+          } else { 
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+          }
+          break;
+        case 2: // VALUE
+          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
+            this.value = new Value();
+            this.value.read(iprot);
+          } 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);
+    if (this.name != null) {
+      oprot.writeFieldBegin(NAME_FIELD_DESC);
+      oprot.writeString(this.name);
+      oprot.writeFieldEnd();
+    }
+    if (this.value != null) {
+      oprot.writeFieldBegin(VALUE_FIELD_DESC);
+      this.value.write(oprot);
+      oprot.writeFieldEnd();
+    }
+    oprot.writeFieldStop();
+    oprot.writeStructEnd();
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Attribute(");
+    boolean first = true;
+
+    sb.append("name:");
+    if (this.name == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.name);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("value:");
+    if (this.value == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.value);
+    }
+    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 {
+      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);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5ea8d60c/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurException.java
----------------------------------------------------------------------
diff --git a/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurException.java b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurException.java
new file mode 100644
index 0000000..67ca68e
--- /dev/null
+++ b/src/blur-new-api-prototype/src/main/java/org/apache/blur/thrift/generated/BlurException.java
@@ -0,0 +1,224 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package org.apache.blur.thrift.generated;
+
+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;
+
+public class BlurException extends Exception implements org.apache.thrift.TBase<BlurException, BlurException._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BlurException");
+
+
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+;
+
+    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) {
+        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;
+    }
+  }
+  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);
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BlurException.class, metaDataMap);
+  }
+
+  public BlurException() {
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public BlurException(BlurException other) {
+  }
+
+  public BlurException deepCopy() {
+    return new BlurException(this);
+  }
+
+  @Override
+  public void clear() {
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    }
+    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) {
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof BlurException)
+      return this.equals((BlurException)that);
+    return false;
+  }
+
+  public boolean equals(BlurException that) {
+    if (that == null)
+      return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  public int compareTo(BlurException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    BlurException typedOther = (BlurException)other;
+
+    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) {
+        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.writeFieldStop();
+    oprot.writeStructEnd();
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("BlurException(");
+    boolean first = true;
+
+    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 {
+      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);
+    }
+  }
+
+}
+


Mime
View raw message