/*******************************************************************************
 *
 *    Copyright (C) 2015-2018 the BBoxDB project
 *
 *    Licensed 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.bboxdb.networkproxy.handler;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.bboxdb.network.client.BBoxDBCluster;
import org.bboxdb.network.client.future.EmptyResultFuture;
import org.bboxdb.networkproxy.ProxyConst;
import org.bboxdb.networkproxy.ProxyHelper;
import org.bboxdb.networkproxy.misc.TupleStringSerializer;
import org.bboxdb.storage.entity.Tuple;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PutHandler implements ProxyCommandHandler {

	/**
	 * The Logger
	 */
	private final static Logger logger = LoggerFactory.getLogger(PutHandler.class);

	@Override
	public void handleCommand(final BBoxDBCluster bboxdbClient, final InputStream socketInputStream,
			final OutputStream socketOutputStream) throws IOException {

		final String table = ProxyHelper.readStringFromServer(socketInputStream);
		final Tuple tuple = TupleStringSerializer.readTuple(socketInputStream);

		logger.info("Got put call for table {} and tuple {}", table, tuple);

		try {
			final EmptyResultFuture insertResult = bboxdbClient.insertTuple(table, tuple);
			insertResult.waitForCompletion();
			socketOutputStream.write(ProxyConst.RESULT_OK);
		} catch(InterruptedException e) {
			logger.debug("Got interrupted exception while handling bboxdb call");
			Thread.currentThread().interrupt();
			socketOutputStream.write(ProxyConst.RESULT_FAILED);
		} catch (Exception e) {
			logger.error("Got exception while proessing bboxdb call", e);
			socketOutputStream.write(ProxyConst.RESULT_FAILED);
		}
	}
}

@@ -1957,24 +1957,209 @@
 mpletion();%0A
+%0A%09%09%09if(insertResult.isFailed()) %7B%0A%09%09%09%09logger.error(%22--%3E Got failed put result: %7B%7D%22, insertResult.getAllMessages());%0A%09%09%09%09socketOutputStream.write(ProxyConst.RESULT_FAILED);%0A%09%09%09%7D else %7B%0A%09
 %09%09%09socketOut
@@ -2197,16 +2197,21 @@
 LT_OK);%0A
+%09%09%09%7D%0A
 %09%09%7D catc

Handle failed put