package com.splicemachine.mrio.api;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.mapreduce.TableInputFormat;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.task.JobContextImpl;

import com.splicemachine.derby.test.framework.SpliceNetConnection;
import com.splicemachine.derby.test.framework.SpliceUnitTest;

public class BaseMRIOTest extends SpliceUnitTest {
	protected static Configuration config;
	protected static SMSQLUtil sqlUtil;
	
	static {
		config = HBaseConfiguration.create();
		config.set("hbase.zookeeper.quorum", "127.0.0.1:2181");
		config.set(HConstants.HBASE_DIR,getHBaseDirectory());
        config.set("fs.default.name", "file:///"); // MapR Hack, tells it local filesystem
		sqlUtil = SMSQLUtil.getInstance(SpliceNetConnection.getDefaultLocalURL());
	}
	
	protected static void flushTable(String tableName) throws SQLException, IOException, InterruptedException {
		String conglomId = sqlUtil.getConglomID(tableName);
		HBaseAdmin admin = null;
		try {
			admin = new HBaseAdmin(config);
			admin.flush(conglomId);
		} finally { 
    		if (admin != null)
    			admin.close();
    		
			}
	}

	
	protected static void compactTable(String tableName) throws SQLException, IOException, InterruptedException {
		String conglomId = sqlUtil.getConglomID(tableName);
		HBaseAdmin admin = null;
		try {
			admin = new HBaseAdmin(config);
			admin.majorCompact(conglomId);
		} finally { 
    		if (admin != null)
    			admin.close();    		
			}
	}

	protected static void splitTable(String tableName) throws SQLException, IOException, InterruptedException {
		String conglomId = sqlUtil.getConglomID(tableName);
		HBaseAdmin admin = null;
		try {
			admin = new HBaseAdmin(config);
			admin.split(conglomId);
		} finally { 
    		if (admin != null)
    			admin.close();
    		
			}
	}
	
}

@@ -92,32 +92,8 @@
 on;%0A
-import java.util.List;%0A%0A
 impo
@@ -125,32 +125,32 @@
 .Configuration;%0A
+
 import org.apach
@@ -281,218 +281,8 @@
 in;%0A
-import org.apache.hadoop.hbase.mapreduce.TableInputFormat;%0Aimport org.apache.hadoop.mapreduce.InputSplit;%0Aimport org.apache.hadoop.mapreduce.JobContext;%0Aimport org.apache.hadoop.mapreduce.task.JobContextImpl;%0A%0A
 impo
@@ -405,16 +405,59 @@
 nitTest;
+%0Aimport com.splicemachine.mrio.MRConstants;
 %0A%0Apublic
@@ -744,16 +744,16 @@
 ory());%0A
-
         
@@ -835,16 +835,104 @@
 esystem%0A
+    %09config.set(MRConstants.SPLICE_JDBC_STR, SpliceNetConnection.getDefaultLocalURL());%0A
 %09%09sqlUti

Add Reference to Splice JDBC Driver