// Path: src/main/java/com/amebame/triton/server/TritonServer.java
// public class TritonServer {
// 	
// 	private static final Logger log = LogManager.getLogger(TritonServer.class);
// 	
// 	@Parameter(names = {"-p","--port"}, description="server port")
// 	private int port = 4848;
// 	
// 	@Parameter(names = {"-c","--config"}, description="config path")
// 	private String configPath = null;
// 	
// 	@Parameter(names = {"-h","--help"}, description="print this help")
// 	private boolean help = false;
// 	
// 	// Guice injector
// 	private Injector injector;
// 	
// 	public TritonServer() {
// 	}
// 	
// 	public void setPort(int port) {
// 		this.port = port;
// 	}
// 	
// 	public void setConfigPath(String configPath) {
// 		this.configPath = configPath;
// 	}
// 	
// 	public void start() {
// 		log.info("starting triton server");
// 		try {
// 			injector = Guice.createInjector(new TritonModule(configPath));
// 			ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
// 			bootstrap
// 			.childHandler(injector.getInstance(TritonServerChannelInitializer.class))
// 			.bind(port);
// 			log.info("triton server started on port {}", port);
// 		} catch (Exception e) {
// 			log.error("failed to start the server {}", e.getMessage(), e);
// 		}
// 	}
// 	
// 	public void stop() {
// 		log.info("stopping triton server");
// 		if (injector == null) {
// 			return;
// 		}
// 		ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
// 		if (bootstrap != null) {
// 			bootstrap.group().shutdownGracefully();
// 		}
// 	}
// 	
// 	public static void main(String[] args) {
// 		
// 		TritonServer server = new TritonServer();
// 		JCommander cmd = new JCommander(server, args);
// 		if (server.help) {
// 			cmd.usage();
// 			return;
// 		}
// 		server.start();
// 		Runtime.getRuntime().addShutdownHook(new ShutdownHook(server));
// 	}
// 	
// 	private static class ShutdownHook extends Thread {
// 		private TritonServer server;
// 		public ShutdownHook(TritonServer server) {
// 			setName("shutdown-hook");
// 			this.server = server;
// 		}
// 		@Override
// 		public void run() {
// 			// shutdown with cleaner
// 			TritonServerCleaner cleaner = server.injector.getInstance(TritonServerCleaner.class);
// 			cleaner.clean();
// 			// stop the server
// 			server.stop();
// 		}
// 	}
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.amebame.triton.client.TritonClient;
import com.amebame.triton.client.cassandra.entity.TritonCassandraKeyspace;
import com.amebame.triton.client.cassandra.entity.TritonCassandraTable;
import com.amebame.triton.client.cassandra.method.BatchOperation;
import com.amebame.triton.client.cassandra.method.BatchOperationMode;
import com.amebame.triton.client.cassandra.method.BatchUpdate;
import com.amebame.triton.client.cassandra.method.CreateKeyspace;
import com.amebame.triton.client.cassandra.method.CreateTable;
import com.amebame.triton.client.cassandra.method.DropKeyspace;
import com.amebame.triton.client.cassandra.method.GetColumns;
import com.amebame.triton.client.cassandra.method.ListKeyspace;
import com.amebame.triton.client.cassandra.method.ListTable;
import com.amebame.triton.client.cassandra.method.RemoveColumns;
import com.amebame.triton.client.cassandra.method.SetColumns;
import com.amebame.triton.client.cassandra.method.TruncateTable;
import com.amebame.triton.exception.TritonClientConnectException;
import com.amebame.triton.exception.TritonClientException;
import com.amebame.triton.exception.TritonException;
import com.amebame.triton.json.Json;
import com.amebame.triton.server.TritonServer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
		.put("column2_2", "value2_2")
		.put("column4", 100)
		.set("column3", Json.object().put("name1", "valuechild").put("name2", 1000))
		;
		set.setRows(rows);
		
		assertTrue(client.send(set).asBoolean());
		
		// get row
		GetColumns get = new GetColumns();
		get.setCluster(clusterName);
		get.setKeyspace(keyspaceName);
		get.setTable(familyName);
		// single key
		get.setKey(Json.text("row1"));
		// single column
		get.setColumn(Json.text("column1"));
		
		// get column
		result = client.send(get);
		assertNotNull(result);
		assertEquals("value1", result.asText());
		
		// multiple column
		get.setColumns(Json.array().add("column1").add("column3").add("column4"));
		result = client.send(get);
		assertEquals(3, result.size());
		assertEquals("value1", result.get("column1").asText());
		assertEquals(2, result.get("column3").size());
		assertEquals("valuechild", result.get("column3").get("name1").asText());
// Path: src/main/java/com/amebame/triton/server/TritonServer.java
// public class TritonServer {
// 	
// 	private static final Logger log = LogManager.getLogger(TritonServer.class);
// 	
// 	@Parameter(names = {"-p","--port"}, description="server port")
// 	private int port = 4848;
// 	
// 	@Parameter(names = {"-c","--config"}, description="config path")
// 	private String configPath = null;
// 	
// 	@Parameter(names = {"-h","--help"}, description="print this help")
// 	private boolean help = false;
// 	
// 	// Guice injector
// 	private Injector injector;
// 	
// 	public TritonServer() {
// 	}
// 	
// 	public void setPort(int port) {
// 		this.port = port;
// 	}
// 	
// 	public void setConfigPath(String configPath) {
// 		this.configPath = configPath;
// 	}
// 	
// 	public void start() {
// 		log.info("starting triton server");
// 		try {
// 			injector = Guice.createInjector(new TritonModule(configPath));
// 			ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
// 			bootstrap
// 			.childHandler(injector.getInstance(TritonServerChannelInitializer.class))
// 			.bind(port);
// 			log.info("triton server started on port {}", port);
// 		} catch (Exception e) {
// 			log.error("failed to start the server {}", e.getMessage(), e);
// 		}
// 	}
// 	
// 	public void stop() {
// 		log.info("stopping triton server");
// 		if (injector == null) {
// 			return;
// 		}
// 		ServerBootstrap bootstrap = injector.getInstance(ServerBootstrap.class);
// 		if (bootstrap != null) {
// 			bootstrap.group().shutdownGracefully();
// 		}
// 	}
// 	
// 	public static void main(String[] args) {
// 		
// 		TritonServer server = new TritonServer();
// 		JCommander cmd = new JCommander(server, args);
// 		if (server.help) {
// 			cmd.usage();
// 			return;
// 		}
// 		server.start();
// 		Runtime.getRuntime().addShutdownHook(new ShutdownHook(server));
// 	}
// 	
// 	private static class ShutdownHook extends Thread {
// 		private TritonServer server;
// 		public ShutdownHook(TritonServer server) {
// 			setName("shutdown-hook");
// 			this.server = server;
// 		}
// 		@Override
// 		public void run() {
// 			// shutdown with cleaner
// 			TritonServerCleaner cleaner = server.injector.getInstance(TritonServerCleaner.class);
// 			cleaner.clean();
// 			// stop the server
// 			server.stop();
// 		}
// 	}
// 
// }


// Path: src/test/java/com/amebame/proteus/triton/TritonCassandraClientTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.amebame.triton.client.TritonClient;
import com.amebame.triton.client.cassandra.entity.TritonCassandraKeyspace;
import com.amebame.triton.client.cassandra.entity.TritonCassandraTable;
import com.amebame.triton.client.cassandra.method.BatchOperation;
import com.amebame.triton.client.cassandra.method.BatchOperationMode;
import com.amebame.triton.client.cassandra.method.BatchUpdate;
import com.amebame.triton.client.cassandra.method.CreateKeyspace;
import com.amebame.triton.client.cassandra.method.CreateTable;
import com.amebame.triton.client.cassandra.method.DropKeyspace;
import com.amebame.triton.client.cassandra.method.GetColumns;
import com.amebame.triton.client.cassandra.method.ListKeyspace;
import com.amebame.triton.client.cassandra.method.ListTable;
import com.amebame.triton.client.cassandra.method.RemoveColumns;
import com.amebame.triton.client.cassandra.method.SetColumns;
import com.amebame.triton.client.cassandra.method.TruncateTable;
import com.amebame.triton.exception.TritonClientConnectException;
import com.amebame.triton.exception.TritonClientException;
import com.amebame.triton.exception.TritonException;
import com.amebame.triton.json.Json;
import com.amebame.triton.server.TritonServer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

		.put("column2_2", "value2_2")
		.put("column4", 100)
		.set("column3", Json.object().put("name1", "valuechild").put("name2", 1000))
		;
		set.setRows(rows);
		
		assertTrue(client.send(set).asBoolean());
		
		// get row
		GetColumns get = new GetColumns();
		get.setCluster(clusterName);
		get.setKeyspace(keyspaceName);
		get.setTable(familyName);
		// single key
		get.setKey(Json.text("row1"));
		// single column
		get.setColumn(Json.text("column1"));
		
		// get column
		result = client.send(get);
		assertNotNull(result);
		assertEquals("value1", result.asText());
		
		// multiple column
		get.setColumns(Json.array().add("column1").add("column3").add("column4"));
		result = client.send(get);
		assertEquals(3, result.size());
		assertEquals("value1", result.get("column1").asText());
		assertEquals(2, result.get("column3").size());
		assertEquals("valuechild", result.get("column3").get("name1").asText());
		assertEquals(1000, result.get("column3").get("name2").asInt());