void checkTableInfo(TableInfoModel model) { assertEquals(model.getName(), TABLE.getNameAsString()); Iterator<TableRegionModel> regions = model.getRegions().iterator(); assertTrue(regions.hasNext()); while (regions.hasNext()) { TableRegionModel region = regions.next(); boolean found = false; for (HRegionLocation e: regionMap) { HRegionInfo hri = e.getRegionInfo(); String hriRegionName = hri.getRegionNameAsString(); String regionName = region.getName(); if (hriRegionName.equals(regionName)) { found = true; byte[] startKey = hri.getStartKey(); byte[] endKey = hri.getEndKey(); ServerName serverName = e.getServerName(); InetSocketAddress sa = new InetSocketAddress(serverName.getHostname(), serverName.getPort()); String location = sa.getHostName() + ":" + Integer.valueOf(sa.getPort()); assertEquals(hri.getRegionId(), region.getId()); assertTrue(Bytes.equals(startKey, region.getStartKey())); assertTrue(Bytes.equals(endKey, region.getEndKey())); assertEquals(location, region.getLocation()); break; } } assertTrue(found); } }
void checkTableInfo(TableInfoModel model) { assertEquals(model.getName(), TABLE); Iterator<TableRegionModel> regions = model.getRegions().iterator(); assertTrue(regions.hasNext()); while (regions.hasNext()) { TableRegionModel region = regions.next(); boolean found = false; for (Map.Entry<HRegionInfo,HServerAddress> e: regionMap.entrySet()) { HRegionInfo hri = e.getKey(); String hriRegionName = hri.getRegionNameAsString(); String regionName = region.getName(); if (hriRegionName.equals(regionName)) { found = true; byte[] startKey = hri.getStartKey(); byte[] endKey = hri.getEndKey(); InetSocketAddress sa = e.getValue().getInetSocketAddress(); String location = sa.getHostName() + ":" + Integer.valueOf(sa.getPort()); assertEquals(hri.getRegionId(), region.getId()); assertTrue(Bytes.equals(startKey, region.getStartKey())); assertTrue(Bytes.equals(endKey, region.getEndKey())); assertEquals(location, region.getLocation()); break; } } assertTrue(found); } }
void checkTableInfo(TableInfoModel model) { assertEquals(model.getName(), TABLE); Iterator<TableRegionModel> regions = model.getRegions().iterator(); assertTrue(regions.hasNext()); while (regions.hasNext()) { TableRegionModel region = regions.next(); boolean found = false; for (Map.Entry<HRegionInfo, ServerName> e: regionMap.entrySet()) { HRegionInfo hri = e.getKey(); String hriRegionName = hri.getRegionNameAsString(); String regionName = region.getName(); if (hriRegionName.equals(regionName)) { found = true; byte[] startKey = hri.getStartKey(); byte[] endKey = hri.getEndKey(); InetSocketAddress sa = new InetSocketAddress(e.getValue().getHostname(), e.getValue().getPort()); String location = sa.getHostName() + ":" + Integer.valueOf(sa.getPort()); assertEquals(hri.getRegionId(), region.getId()); assertTrue(Bytes.equals(startKey, region.getStartKey())); assertTrue(Bytes.equals(endKey, region.getEndKey())); assertEquals(location, region.getLocation()); break; } } assertTrue(found); } }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(3); REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration()); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); context = JAXBContext.newInstance( TableModel.class, TableInfoModel.class, TableListModel.class, TableRegionModel.class); Admin admin = TEST_UTIL.getHBaseAdmin(); if (admin.tableExists(TABLE)) { return; } HTableDescriptor htd = new HTableDescriptor(TABLE); htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); admin.createTable(htd); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); List<Put> puts = new ArrayList<>(); for (byte b1 = 'a'; b1 < 'z'; b1++) { for (byte b2 = 'a'; b2 < 'z'; b2++) { for (byte b3 = 'a'; b3 < 'z'; b3++) { k[0] = b1; k[1] = b2; k[2] = b3; Put put = new Put(k); put.setDurability(Durability.SKIP_WAL); put.add(famAndQf[0], famAndQf[1], k); puts.add(put); } } } Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); // get the initial layout (should just be one region) RegionLocator regionLocator = connection.getRegionLocator(TABLE); List<HRegionLocation> m = regionLocator.getAllRegionLocations(); assertEquals(m.size(), 1); // tell the master to split the table admin.split(TABLE); // give some time for the split to happen long timeout = System.currentTimeMillis() + (15 * 1000); while (System.currentTimeMillis() < timeout && m.size()!=2){ try { Thread.sleep(250); } catch (InterruptedException e) { LOG.warn(StringUtils.stringifyException(e)); } // check again m = regionLocator.getAllRegionLocations(); } // should have two regions now assertEquals(m.size(), 2); regionMap = m; LOG.info("regions: " + regionMap); regionLocator.close(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(3); REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration()); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); context = JAXBContext.newInstance( TableModel.class, TableInfoModel.class, TableListModel.class, TableRegionModel.class); HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); if (admin.tableExists(TABLE)) { return; } HTableDescriptor htd = new HTableDescriptor(TABLE); htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); admin.createTable(htd); HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); for (byte b1 = 'a'; b1 < 'z'; b1++) { for (byte b2 = 'a'; b2 < 'z'; b2++) { for (byte b3 = 'a'; b3 < 'z'; b3++) { k[0] = b1; k[1] = b2; k[2] = b3; Put put = new Put(k); put.setWriteToWAL(false); put.add(famAndQf[0], famAndQf[1], k); table.put(put); } } } table.flushCommits(); // get the initial layout (should just be one region) Map<HRegionInfo,HServerAddress> m = table.getRegionsInfo(); assertEquals(m.size(), 1); // tell the master to split the table admin.split(TABLE); // give some time for the split to happen long timeout = System.currentTimeMillis() + (15 * 1000); while (System.currentTimeMillis() < timeout && m.size()!=2){ try { Thread.sleep(250); } catch (InterruptedException e) { LOG.warn(StringUtils.stringifyException(e)); } // check again m = table.getRegionsInfo(); } // should have two regions now assertEquals(m.size(), 2); regionMap = m; LOG.info("regions: " + regionMap); table.close(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(3); REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration()); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); context = JAXBContext.newInstance( TableModel.class, TableInfoModel.class, TableListModel.class, TableRegionModel.class); HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); if (admin.tableExists(TABLE)) { return; } HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE)); htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); admin.createTable(htd); HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); for (byte b1 = 'a'; b1 < 'z'; b1++) { for (byte b2 = 'a'; b2 < 'z'; b2++) { for (byte b3 = 'a'; b3 < 'z'; b3++) { k[0] = b1; k[1] = b2; k[2] = b3; Put put = new Put(k); put.setDurability(Durability.SKIP_WAL); put.add(famAndQf[0], famAndQf[1], k); table.put(put); } } } table.flushCommits(); // get the initial layout (should just be one region) Map<HRegionInfo, ServerName> m = table.getRegionLocations(); assertEquals(m.size(), 1); // tell the master to split the table admin.split(TABLE); // give some time for the split to happen long timeout = System.currentTimeMillis() + (15 * 1000); while (System.currentTimeMillis() < timeout && m.size()!=2){ try { Thread.sleep(250); } catch (InterruptedException e) { LOG.warn(StringUtils.stringifyException(e)); } // check again m = table.getRegionLocations(); } // should have two regions now assertEquals(m.size(), 2); regionMap = m; LOG.info("regions: " + regionMap); table.close(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(3); REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration()); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); context = JAXBContext.newInstance( TableModel.class, TableInfoModel.class, TableListModel.class, TableRegionModel.class); Admin admin = TEST_UTIL.getAdmin(); if (admin.tableExists(TABLE)) { return; } HTableDescriptor htd = new HTableDescriptor(TABLE); htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); admin.createTable(htd); byte[] k = new byte[3]; byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN)); List<Put> puts = new ArrayList<>(); for (byte b1 = 'a'; b1 < 'z'; b1++) { for (byte b2 = 'a'; b2 < 'z'; b2++) { for (byte b3 = 'a'; b3 < 'z'; b3++) { k[0] = b1; k[1] = b2; k[2] = b3; Put put = new Put(k); put.setDurability(Durability.SKIP_WAL); put.addColumn(famAndQf[0], famAndQf[1], k); puts.add(put); } } } Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); // get the initial layout (should just be one region) RegionLocator regionLocator = connection.getRegionLocator(TABLE); List<HRegionLocation> m = regionLocator.getAllRegionLocations(); assertEquals(1, m.size()); // tell the master to split the table admin.split(TABLE); // give some time for the split to happen TestEndToEndSplitTransaction.blockUntilRegionSplit(TEST_UTIL.getConfiguration(), 60000, m.get(0).getRegionInfo().getRegionName(), true); long timeout = System.currentTimeMillis() + (15 * 1000); while (System.currentTimeMillis() < timeout && m.size()!=2){ try { Thread.sleep(250); } catch (InterruptedException e) { LOG.warn(StringUtils.stringifyException(e)); } // check again m = regionLocator.getAllRegionLocations(); } // should have two regions now assertEquals(2, m.size()); regionMap = m; LOG.info("regions: " + regionMap); regionLocator.close(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(3); REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration()); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); context = JAXBContext.newInstance( TableModel.class, TableInfoModel.class, TableListModel.class, TableRegionModel.class); HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); if (admin.tableExists(TABLE)) { return; } HTableDescriptor htd = new HTableDescriptor(TABLE); htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); admin.createTable(htd); HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); for (byte b1 = 'a'; b1 < 'z'; b1++) { for (byte b2 = 'a'; b2 < 'z'; b2++) { for (byte b3 = 'a'; b3 < 'z'; b3++) { k[0] = b1; k[1] = b2; k[2] = b3; Put put = new Put(k); put.setWriteToWAL(false); put.add(famAndQf[0], famAndQf[1], k); table.put(put); } } } table.flushCommits(); // get the initial layout (should just be one region) Map<HRegionInfo, ServerName> m = table.getRegionLocations(); assertEquals(m.size(), 1); // tell the master to split the table admin.split(TABLE); // give some time for the split to happen long timeout = System.currentTimeMillis() + (15 * 1000); while (System.currentTimeMillis() < timeout && m.size()!=2){ try { Thread.sleep(250); } catch (InterruptedException e) { LOG.warn(StringUtils.stringifyException(e)); } // check again m = table.getRegionLocations(); } // should have two regions now assertEquals(m.size(), 2); regionMap = m; LOG.info("regions: " + regionMap); table.close(); }