| 68 | import com.stumbleupon.async.Deferred; |
| 69 | |
| 70 | @PrepareForTest({ HBaseClient.class, RegionClient.class, HBaseRpc.class, |
| 71 | GetRequest.class, RegionInfo.class, NioClientSocketChannelFactory.class, |
| 72 | Executors.class, HashedWheelTimer.class, NioClientBossPool.class, |
| 73 | NioWorkerPool.class }) |
| 74 | @Ignore // ignore for test runners |
| 75 | public class BaseTestHBaseClient { |
| 76 | protected static final Charset CHARSET = Charset.forName("ASCII"); |
| 77 | protected static final byte[] COMMA = { ',' }; |
| 78 | protected static final byte[] TIMESTAMP = "1234567890".getBytes(); |
| 79 | protected static final byte[] INFO = getStatic("INFO"); |
| 80 | protected static final byte[] REGIONINFO = getStatic("REGIONINFO"); |
| 81 | protected static final byte[] SERVER = getStatic("SERVER"); |
| 82 | protected static final byte[] TABLE = { 't', 'a', 'b', 'l', 'e' }; |
| 83 | protected static final byte[] KEY = { 'k', 'e', 'y' }; |
| 84 | protected static final byte[] KEY2 = { 'k', 'e', 'y', '2' }; |
| 85 | protected static final byte[] FAMILY = { 'f' }; |
| 86 | protected static final byte[] QUALIFIER = { 'q', 'u', 'a', 'l' }; |
| 87 | protected static final byte[] VALUE = { 'v', 'a', 'l', 'u', 'e' }; |
| 88 | protected static final byte[] EMPTY_ARRAY = new byte[0]; |
| 89 | protected static final KeyValue KV = new KeyValue(KEY, FAMILY, QUALIFIER, VALUE); |
| 90 | protected static final RegionInfo meta = mkregion(".META.", ".META.,,1234567890"); |
| 91 | protected static final RegionInfo region = mkregion("table", "table,,1234567890"); |
| 92 | protected static final int RS_PORT = 50511; |
| 93 | protected static final String ROOT_IP = "192.168.0.1"; |
| 94 | protected static final String META_IP = "192.168.0.2"; |
| 95 | protected static final String REGION_CLIENT_IP = "192.168.0.3"; |
| 96 | protected static String MOCK_RS_CLIENT_NAME = "Mock RegionClient"; |
| 97 | protected static String MOCK_ROOT_CLIENT_NAME = "Mock RootClient"; |
| 98 | protected static String MOCK_META_CLIENT_NAME = "Mock MetaClient"; |
| 99 | |
| 100 | protected HBaseClient client = null; |
| 101 | /** Extracted from {@link #client}. */ |
| 102 | protected ConcurrentSkipListMap<byte[], RegionInfo> regions_cache; |
| 103 | /** Extracted from {@link #client}. */ |
| 104 | protected ConcurrentHashMap<RegionInfo, RegionClient> region2client; |
| 105 | /** Extracted from {@link #client}. */ |
| 106 | protected ConcurrentHashMap<RegionClient, ArrayList<RegionInfo>> client2regions; |
| 107 | /** Extracted from {@link #client}. */ |
| 108 | protected ConcurrentSkipListMap<byte[], ArrayList<HBaseRpc>> got_nsre; |
| 109 | /** Extracted from {@link #client}. */ |
| 110 | protected HashMap<String, RegionClient> ip2client; |
| 111 | /** Extracted from {@link #client}. */ |
| 112 | protected Counter num_nsre_rpcs; |
| 113 | /** Fake client supposedly connected to -ROOT-. */ |
| 114 | protected RegionClient rootclient; |
| 115 | /** Fake client supposedly connected to .META.. */ |
| 116 | protected RegionClient metaclient; |
| 117 | /** Fake client supposedly connected to our fake test table. */ |
| 118 | protected RegionClient regionclient; |
| 119 | /** Each new region client is dumped here */ |
| 120 | protected List<RegionClient> region_clients = new ArrayList<RegionClient>(); |
| 121 | /** Fake Zookeeper client */ |
| 122 | protected ZKClient zkclient; |
| 123 | /** Fake channel factory */ |
| 124 | protected NioClientSocketChannelFactory channel_factory; |
| 125 | /** Fake channel returned from the factory */ |
| 126 | protected SocketChannel chan; |
| 127 | /** Fake timer for testing */ |