http://git-wip-us.apache.org/repos/asf/hbase-site/blob/80652933/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html index 3b83a16..0c894de 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html @@ -1478,960 +1478,960 @@ <span class="sourceLineNo">1470</span> */<a name="line.1470"></a> <span class="sourceLineNo">1471</span> public Table createTable(TableName tableName, byte[][] families, byte[][] splitKeys)<a name="line.1471"></a> <span class="sourceLineNo">1472</span> throws IOException {<a name="line.1472"></a> -<span class="sourceLineNo">1473</span> return createTable(tableName, families, splitKeys, new Configuration(getConfiguration()));<a name="line.1473"></a> +<span class="sourceLineNo">1473</span> return createTable(tableName, families, splitKeys, 1, new Configuration(getConfiguration()));<a name="line.1473"></a> <span class="sourceLineNo">1474</span> }<a name="line.1474"></a> <span class="sourceLineNo">1475</span><a name="line.1475"></a> -<span class="sourceLineNo">1476</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1476"></a> -<span class="sourceLineNo">1477</span> int numVersions, byte[] startKey, byte[] endKey, int numRegions)<a name="line.1477"></a> -<span class="sourceLineNo">1478</span> throws IOException{<a name="line.1478"></a> -<span class="sourceLineNo">1479</span> HTableDescriptor desc = createTableDescriptor(tableName, families, numVersions);<a name="line.1479"></a> -<span class="sourceLineNo">1480</span><a name="line.1480"></a> -<span class="sourceLineNo">1481</span> getAdmin().createTable(desc, startKey, endKey, numRegions);<a name="line.1481"></a> -<span class="sourceLineNo">1482</span> // HBaseAdmin only waits for regions to appear in hbase:meta we<a name="line.1482"></a> -<span class="sourceLineNo">1483</span> // should wait until they are assigned<a name="line.1483"></a> -<span class="sourceLineNo">1484</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1484"></a> -<span class="sourceLineNo">1485</span> return getConnection().getTable(tableName);<a name="line.1485"></a> -<span class="sourceLineNo">1486</span> }<a name="line.1486"></a> -<span class="sourceLineNo">1487</span><a name="line.1487"></a> -<span class="sourceLineNo">1488</span> /**<a name="line.1488"></a> -<span class="sourceLineNo">1489</span> * Create a table.<a name="line.1489"></a> -<span class="sourceLineNo">1490</span> * @param htd<a name="line.1490"></a> -<span class="sourceLineNo">1491</span> * @param families<a name="line.1491"></a> -<span class="sourceLineNo">1492</span> * @param c Configuration to use<a name="line.1492"></a> -<span class="sourceLineNo">1493</span> * @return A Table instance for the created table.<a name="line.1493"></a> -<span class="sourceLineNo">1494</span> * @throws IOException<a name="line.1494"></a> -<span class="sourceLineNo">1495</span> */<a name="line.1495"></a> -<span class="sourceLineNo">1496</span> public Table createTable(TableDescriptor htd, byte[][] families, Configuration c)<a name="line.1496"></a> -<span class="sourceLineNo">1497</span> throws IOException {<a name="line.1497"></a> -<span class="sourceLineNo">1498</span> return createTable(htd, families, null, c);<a name="line.1498"></a> -<span class="sourceLineNo">1499</span> }<a name="line.1499"></a> -<span class="sourceLineNo">1500</span><a name="line.1500"></a> -<span class="sourceLineNo">1501</span> /**<a name="line.1501"></a> -<span class="sourceLineNo">1502</span> * Create a table.<a name="line.1502"></a> -<span class="sourceLineNo">1503</span> * @param htd table descriptor<a name="line.1503"></a> -<span class="sourceLineNo">1504</span> * @param families array of column families<a name="line.1504"></a> -<span class="sourceLineNo">1505</span> * @param splitKeys array of split keys<a name="line.1505"></a> -<span class="sourceLineNo">1506</span> * @param c Configuration to use<a name="line.1506"></a> -<span class="sourceLineNo">1507</span> * @return A Table instance for the created table.<a name="line.1507"></a> -<span class="sourceLineNo">1508</span> * @throws IOException if getAdmin or createTable fails<a name="line.1508"></a> -<span class="sourceLineNo">1509</span> */<a name="line.1509"></a> -<span class="sourceLineNo">1510</span> public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys,<a name="line.1510"></a> -<span class="sourceLineNo">1511</span> Configuration c) throws IOException {<a name="line.1511"></a> -<span class="sourceLineNo">1512</span> // Disable blooms (they are on by default as of 0.95) but we disable them here because<a name="line.1512"></a> -<span class="sourceLineNo">1513</span> // tests have hard coded counts of what to expect in block cache, etc., and blooms being<a name="line.1513"></a> -<span class="sourceLineNo">1514</span> // on is interfering.<a name="line.1514"></a> -<span class="sourceLineNo">1515</span> return createTable(htd, families, splitKeys, BloomType.NONE, HConstants.DEFAULT_BLOCKSIZE, c);<a name="line.1515"></a> -<span class="sourceLineNo">1516</span> }<a name="line.1516"></a> -<span class="sourceLineNo">1517</span><a name="line.1517"></a> -<span class="sourceLineNo">1518</span> /**<a name="line.1518"></a> -<span class="sourceLineNo">1519</span> * Create a table.<a name="line.1519"></a> -<span class="sourceLineNo">1520</span> * @param htd table descriptor<a name="line.1520"></a> -<span class="sourceLineNo">1521</span> * @param families array of column families<a name="line.1521"></a> -<span class="sourceLineNo">1522</span> * @param splitKeys array of split keys<a name="line.1522"></a> -<span class="sourceLineNo">1523</span> * @param type Bloom type<a name="line.1523"></a> -<span class="sourceLineNo">1524</span> * @param blockSize block size<a name="line.1524"></a> -<span class="sourceLineNo">1525</span> * @param c Configuration to use<a name="line.1525"></a> -<span class="sourceLineNo">1526</span> * @return A Table instance for the created table.<a name="line.1526"></a> -<span class="sourceLineNo">1527</span> * @throws IOException if getAdmin or createTable fails<a name="line.1527"></a> -<span class="sourceLineNo">1528</span> */<a name="line.1528"></a> -<span class="sourceLineNo">1529</span><a name="line.1529"></a> -<span class="sourceLineNo">1530</span> public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys,<a name="line.1530"></a> -<span class="sourceLineNo">1531</span> BloomType type, int blockSize, Configuration c) throws IOException {<a name="line.1531"></a> -<span class="sourceLineNo">1532</span> TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(htd);<a name="line.1532"></a> -<span class="sourceLineNo">1533</span> for (byte[] family : families) {<a name="line.1533"></a> -<span class="sourceLineNo">1534</span> builder.setColumnFamily(<a name="line.1534"></a> -<span class="sourceLineNo">1535</span> ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(type)<a name="line.1535"></a> -<span class="sourceLineNo">1536</span> .setBlocksize(blockSize).build());<a name="line.1536"></a> -<span class="sourceLineNo">1537</span> }<a name="line.1537"></a> -<span class="sourceLineNo">1538</span> TableDescriptor td = builder.build();<a name="line.1538"></a> -<span class="sourceLineNo">1539</span> getAdmin().createTable(td, splitKeys);<a name="line.1539"></a> -<span class="sourceLineNo">1540</span> // HBaseAdmin only waits for regions to appear in hbase:meta<a name="line.1540"></a> -<span class="sourceLineNo">1541</span> // we should wait until they are assigned<a name="line.1541"></a> -<span class="sourceLineNo">1542</span> waitUntilAllRegionsAssigned(td.getTableName());<a name="line.1542"></a> -<span class="sourceLineNo">1543</span> return getConnection().getTable(td.getTableName());<a name="line.1543"></a> -<span class="sourceLineNo">1544</span> }<a name="line.1544"></a> -<span class="sourceLineNo">1545</span><a name="line.1545"></a> -<span class="sourceLineNo">1546</span> /**<a name="line.1546"></a> -<span class="sourceLineNo">1547</span> * Create a table.<a name="line.1547"></a> -<span class="sourceLineNo">1548</span> * @param htd table descriptor<a name="line.1548"></a> -<span class="sourceLineNo">1549</span> * @param splitRows array of split keys<a name="line.1549"></a> -<span class="sourceLineNo">1550</span> * @return A Table instance for the created table.<a name="line.1550"></a> -<span class="sourceLineNo">1551</span> * @throws IOException<a name="line.1551"></a> -<span class="sourceLineNo">1552</span> */<a name="line.1552"></a> -<span class="sourceLineNo">1553</span> public Table createTable(TableDescriptor htd, byte[][] splitRows)<a name="line.1553"></a> -<span class="sourceLineNo">1554</span> throws IOException {<a name="line.1554"></a> -<span class="sourceLineNo">1555</span> getAdmin().createTable(htd, splitRows);<a name="line.1555"></a> -<span class="sourceLineNo">1556</span> // HBaseAdmin only waits for regions to appear in hbase:meta<a name="line.1556"></a> -<span class="sourceLineNo">1557</span> // we should wait until they are assigned<a name="line.1557"></a> -<span class="sourceLineNo">1558</span> waitUntilAllRegionsAssigned(htd.getTableName());<a name="line.1558"></a> -<span class="sourceLineNo">1559</span> return getConnection().getTable(htd.getTableName());<a name="line.1559"></a> -<span class="sourceLineNo">1560</span> }<a name="line.1560"></a> -<span class="sourceLineNo">1561</span><a name="line.1561"></a> -<span class="sourceLineNo">1562</span> /**<a name="line.1562"></a> -<span class="sourceLineNo">1563</span> * Create a table.<a name="line.1563"></a> -<span class="sourceLineNo">1564</span> * @param tableName<a name="line.1564"></a> -<span class="sourceLineNo">1565</span> * @param families<a name="line.1565"></a> -<span class="sourceLineNo">1566</span> * @param splitKeys<a name="line.1566"></a> -<span class="sourceLineNo">1567</span> * @param c Configuration to use<a name="line.1567"></a> -<span class="sourceLineNo">1568</span> * @return A Table instance for the created table.<a name="line.1568"></a> -<span class="sourceLineNo">1569</span> * @throws IOException<a name="line.1569"></a> -<span class="sourceLineNo">1570</span> */<a name="line.1570"></a> -<span class="sourceLineNo">1571</span> public Table createTable(TableName tableName, byte[][] families, byte[][] splitKeys,<a name="line.1571"></a> -<span class="sourceLineNo">1572</span> final Configuration c) throws IOException {<a name="line.1572"></a> -<span class="sourceLineNo">1573</span> return createTable(new HTableDescriptor(tableName), families, splitKeys, c);<a name="line.1573"></a> -<span class="sourceLineNo">1574</span> }<a name="line.1574"></a> -<span class="sourceLineNo">1575</span><a name="line.1575"></a> -<span class="sourceLineNo">1576</span> /**<a name="line.1576"></a> -<span class="sourceLineNo">1577</span> * Create a table.<a name="line.1577"></a> -<span class="sourceLineNo">1578</span> * @param tableName<a name="line.1578"></a> -<span class="sourceLineNo">1579</span> * @param family<a name="line.1579"></a> -<span class="sourceLineNo">1580</span> * @param numVersions<a name="line.1580"></a> -<span class="sourceLineNo">1581</span> * @return A Table instance for the created table.<a name="line.1581"></a> -<span class="sourceLineNo">1582</span> * @throws IOException<a name="line.1582"></a> -<span class="sourceLineNo">1583</span> */<a name="line.1583"></a> -<span class="sourceLineNo">1584</span> public Table createTable(TableName tableName, byte[] family, int numVersions)<a name="line.1584"></a> -<span class="sourceLineNo">1585</span> throws IOException {<a name="line.1585"></a> -<span class="sourceLineNo">1586</span> return createTable(tableName, new byte[][]{family}, numVersions);<a name="line.1586"></a> -<span class="sourceLineNo">1587</span> }<a name="line.1587"></a> -<span class="sourceLineNo">1588</span><a name="line.1588"></a> -<span class="sourceLineNo">1589</span> /**<a name="line.1589"></a> -<span class="sourceLineNo">1590</span> * Create a table.<a name="line.1590"></a> -<span class="sourceLineNo">1591</span> * @param tableName<a name="line.1591"></a> -<span class="sourceLineNo">1592</span> * @param families<a name="line.1592"></a> -<span class="sourceLineNo">1593</span> * @param numVersions<a name="line.1593"></a> -<span class="sourceLineNo">1594</span> * @return A Table instance for the created table.<a name="line.1594"></a> -<span class="sourceLineNo">1595</span> * @throws IOException<a name="line.1595"></a> -<span class="sourceLineNo">1596</span> */<a name="line.1596"></a> -<span class="sourceLineNo">1597</span> public Table createTable(TableName tableName, byte[][] families, int numVersions)<a name="line.1597"></a> -<span class="sourceLineNo">1598</span> throws IOException {<a name="line.1598"></a> -<span class="sourceLineNo">1599</span> return createTable(tableName, families, numVersions, (byte[][]) null);<a name="line.1599"></a> -<span class="sourceLineNo">1600</span> }<a name="line.1600"></a> -<span class="sourceLineNo">1601</span><a name="line.1601"></a> -<span class="sourceLineNo">1602</span> /**<a name="line.1602"></a> -<span class="sourceLineNo">1603</span> * Create a table.<a name="line.1603"></a> -<span class="sourceLineNo">1604</span> * @param tableName<a name="line.1604"></a> -<span class="sourceLineNo">1605</span> * @param families<a name="line.1605"></a> -<span class="sourceLineNo">1606</span> * @param numVersions<a name="line.1606"></a> -<span class="sourceLineNo">1607</span> * @param splitKeys<a name="line.1607"></a> -<span class="sourceLineNo">1608</span> * @return A Table instance for the created table.<a name="line.1608"></a> -<span class="sourceLineNo">1609</span> * @throws IOException<a name="line.1609"></a> -<span class="sourceLineNo">1610</span> */<a name="line.1610"></a> -<span class="sourceLineNo">1611</span> public Table createTable(TableName tableName, byte[][] families, int numVersions,<a name="line.1611"></a> -<span class="sourceLineNo">1612</span> byte[][] splitKeys) throws IOException {<a name="line.1612"></a> -<span class="sourceLineNo">1613</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1613"></a> -<span class="sourceLineNo">1614</span> for (byte[] family : families) {<a name="line.1614"></a> -<span class="sourceLineNo">1615</span> HColumnDescriptor hcd = new HColumnDescriptor(family).setMaxVersions(numVersions);<a name="line.1615"></a> -<span class="sourceLineNo">1616</span> desc.addFamily(hcd);<a name="line.1616"></a> -<span class="sourceLineNo">1617</span> }<a name="line.1617"></a> -<span class="sourceLineNo">1618</span> getAdmin().createTable(desc, splitKeys);<a name="line.1618"></a> -<span class="sourceLineNo">1619</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1619"></a> -<span class="sourceLineNo">1620</span> // assigned<a name="line.1620"></a> -<span class="sourceLineNo">1621</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1621"></a> -<span class="sourceLineNo">1622</span> return getConnection().getTable(tableName);<a name="line.1622"></a> -<span class="sourceLineNo">1623</span> }<a name="line.1623"></a> -<span class="sourceLineNo">1624</span><a name="line.1624"></a> -<span class="sourceLineNo">1625</span> /**<a name="line.1625"></a> -<span class="sourceLineNo">1626</span> * Create a table with multiple regions.<a name="line.1626"></a> -<span class="sourceLineNo">1627</span> * @param tableName<a name="line.1627"></a> -<span class="sourceLineNo">1628</span> * @param families<a name="line.1628"></a> -<span class="sourceLineNo">1629</span> * @param numVersions<a name="line.1629"></a> -<span class="sourceLineNo">1630</span> * @return A Table instance for the created table.<a name="line.1630"></a> -<span class="sourceLineNo">1631</span> * @throws IOException<a name="line.1631"></a> -<span class="sourceLineNo">1632</span> */<a name="line.1632"></a> -<span class="sourceLineNo">1633</span> public Table createMultiRegionTable(TableName tableName, byte[][] families, int numVersions)<a name="line.1633"></a> -<span class="sourceLineNo">1634</span> throws IOException {<a name="line.1634"></a> -<span class="sourceLineNo">1635</span> return createTable(tableName, families, numVersions, KEYS_FOR_HBA_CREATE_TABLE);<a name="line.1635"></a> -<span class="sourceLineNo">1636</span> }<a name="line.1636"></a> -<span class="sourceLineNo">1637</span><a name="line.1637"></a> -<span class="sourceLineNo">1638</span> /**<a name="line.1638"></a> -<span class="sourceLineNo">1639</span> * Create a table.<a name="line.1639"></a> -<span class="sourceLineNo">1640</span> * @param tableName<a name="line.1640"></a> -<span class="sourceLineNo">1641</span> * @param families<a name="line.1641"></a> -<span class="sourceLineNo">1642</span> * @param numVersions<a name="line.1642"></a> -<span class="sourceLineNo">1643</span> * @param blockSize<a name="line.1643"></a> -<span class="sourceLineNo">1644</span> * @return A Table instance for the created table.<a name="line.1644"></a> -<span class="sourceLineNo">1645</span> * @throws IOException<a name="line.1645"></a> -<span class="sourceLineNo">1646</span> */<a name="line.1646"></a> -<span class="sourceLineNo">1647</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1647"></a> -<span class="sourceLineNo">1648</span> int numVersions, int blockSize) throws IOException {<a name="line.1648"></a> -<span class="sourceLineNo">1649</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1649"></a> -<span class="sourceLineNo">1650</span> for (byte[] family : families) {<a name="line.1650"></a> -<span class="sourceLineNo">1651</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1651"></a> -<span class="sourceLineNo">1652</span> .setMaxVersions(numVersions)<a name="line.1652"></a> -<span class="sourceLineNo">1653</span> .setBlocksize(blockSize);<a name="line.1653"></a> -<span class="sourceLineNo">1654</span> desc.addFamily(hcd);<a name="line.1654"></a> -<span class="sourceLineNo">1655</span> }<a name="line.1655"></a> -<span class="sourceLineNo">1656</span> getAdmin().createTable(desc);<a name="line.1656"></a> -<span class="sourceLineNo">1657</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1657"></a> -<span class="sourceLineNo">1658</span> // assigned<a name="line.1658"></a> -<span class="sourceLineNo">1659</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1659"></a> -<span class="sourceLineNo">1660</span> return getConnection().getTable(tableName);<a name="line.1660"></a> -<span class="sourceLineNo">1661</span> }<a name="line.1661"></a> -<span class="sourceLineNo">1662</span><a name="line.1662"></a> -<span class="sourceLineNo">1663</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1663"></a> -<span class="sourceLineNo">1664</span> int numVersions, int blockSize, String cpName) throws IOException {<a name="line.1664"></a> -<span class="sourceLineNo">1665</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1665"></a> -<span class="sourceLineNo">1666</span> for (byte[] family : families) {<a name="line.1666"></a> -<span class="sourceLineNo">1667</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1667"></a> -<span class="sourceLineNo">1668</span> .setMaxVersions(numVersions)<a name="line.1668"></a> -<span class="sourceLineNo">1669</span> .setBlocksize(blockSize);<a name="line.1669"></a> -<span class="sourceLineNo">1670</span> desc.addFamily(hcd);<a name="line.1670"></a> -<span class="sourceLineNo">1671</span> }<a name="line.1671"></a> -<span class="sourceLineNo">1672</span> if(cpName != null) {<a name="line.1672"></a> -<span class="sourceLineNo">1673</span> desc.addCoprocessor(cpName);<a name="line.1673"></a> -<span class="sourceLineNo">1674</span> }<a name="line.1674"></a> -<span class="sourceLineNo">1675</span> getAdmin().createTable(desc);<a name="line.1675"></a> -<span class="sourceLineNo">1676</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1676"></a> -<span class="sourceLineNo">1677</span> // assigned<a name="line.1677"></a> -<span class="sourceLineNo">1678</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1678"></a> -<span class="sourceLineNo">1679</span> return getConnection().getTable(tableName);<a name="line.1679"></a> -<span class="sourceLineNo">1680</span> }<a name="line.1680"></a> -<span class="sourceLineNo">1681</span><a name="line.1681"></a> -<span class="sourceLineNo">1682</span> /**<a name="line.1682"></a> -<span class="sourceLineNo">1683</span> * Create a table.<a name="line.1683"></a> -<span class="sourceLineNo">1684</span> * @param tableName<a name="line.1684"></a> -<span class="sourceLineNo">1685</span> * @param families<a name="line.1685"></a> -<span class="sourceLineNo">1686</span> * @param numVersions<a name="line.1686"></a> -<span class="sourceLineNo">1687</span> * @return A Table instance for the created table.<a name="line.1687"></a> -<span class="sourceLineNo">1688</span> * @throws IOException<a name="line.1688"></a> -<span class="sourceLineNo">1689</span> */<a name="line.1689"></a> -<span class="sourceLineNo">1690</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1690"></a> -<span class="sourceLineNo">1691</span> int[] numVersions)<a name="line.1691"></a> -<span class="sourceLineNo">1692</span> throws IOException {<a name="line.1692"></a> -<span class="sourceLineNo">1693</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1693"></a> -<span class="sourceLineNo">1694</span> int i = 0;<a name="line.1694"></a> -<span class="sourceLineNo">1695</span> for (byte[] family : families) {<a name="line.1695"></a> -<span class="sourceLineNo">1696</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1696"></a> -<span class="sourceLineNo">1697</span> .setMaxVersions(numVersions[i]);<a name="line.1697"></a> -<span class="sourceLineNo">1698</span> desc.addFamily(hcd);<a name="line.1698"></a> -<span class="sourceLineNo">1699</span> i++;<a name="line.1699"></a> -<span class="sourceLineNo">1700</span> }<a name="line.1700"></a> -<span class="sourceLineNo">1701</span> getAdmin().createTable(desc);<a name="line.1701"></a> -<span class="sourceLineNo">1702</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1702"></a> -<span class="sourceLineNo">1703</span> // assigned<a name="line.1703"></a> -<span class="sourceLineNo">1704</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1704"></a> -<span class="sourceLineNo">1705</span> return getConnection().getTable(tableName);<a name="line.1705"></a> -<span class="sourceLineNo">1706</span> }<a name="line.1706"></a> -<span class="sourceLineNo">1707</span><a name="line.1707"></a> -<span class="sourceLineNo">1708</span> /**<a name="line.1708"></a> -<span class="sourceLineNo">1709</span> * Create a table.<a name="line.1709"></a> -<span class="sourceLineNo">1710</span> * @param tableName<a name="line.1710"></a> -<span class="sourceLineNo">1711</span> * @param family<a name="line.1711"></a> -<span class="sourceLineNo">1712</span> * @param splitRows<a name="line.1712"></a> -<span class="sourceLineNo">1713</span> * @return A Table instance for the created table.<a name="line.1713"></a> -<span class="sourceLineNo">1714</span> * @throws IOException<a name="line.1714"></a> -<span class="sourceLineNo">1715</span> */<a name="line.1715"></a> -<span class="sourceLineNo">1716</span> public Table createTable(TableName tableName, byte[] family, byte[][] splitRows)<a name="line.1716"></a> -<span class="sourceLineNo">1717</span> throws IOException {<a name="line.1717"></a> -<span class="sourceLineNo">1718</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1718"></a> -<span class="sourceLineNo">1719</span> HColumnDescriptor hcd = new HColumnDescriptor(family);<a name="line.1719"></a> -<span class="sourceLineNo">1720</span> desc.addFamily(hcd);<a name="line.1720"></a> -<span class="sourceLineNo">1721</span> getAdmin().createTable(desc, splitRows);<a name="line.1721"></a> -<span class="sourceLineNo">1722</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1722"></a> -<span class="sourceLineNo">1723</span> // assigned<a name="line.1723"></a> -<span class="sourceLineNo">1724</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1724"></a> -<span class="sourceLineNo">1725</span> return getConnection().getTable(tableName);<a name="line.1725"></a> -<span class="sourceLineNo">1726</span> }<a name="line.1726"></a> -<span class="sourceLineNo">1727</span><a name="line.1727"></a> -<span class="sourceLineNo">1728</span> /**<a name="line.1728"></a> -<span class="sourceLineNo">1729</span> * Create a table with multiple regions.<a name="line.1729"></a> -<span class="sourceLineNo">1730</span> * @param tableName<a name="line.1730"></a> -<span class="sourceLineNo">1731</span> * @param family<a name="line.1731"></a> -<span class="sourceLineNo">1732</span> * @return A Table instance for the created table.<a name="line.1732"></a> -<span class="sourceLineNo">1733</span> * @throws IOException<a name="line.1733"></a> -<span class="sourceLineNo">1734</span> */<a name="line.1734"></a> -<span class="sourceLineNo">1735</span> public Table createMultiRegionTable(TableName tableName, byte[] family) throws IOException {<a name="line.1735"></a> -<span class="sourceLineNo">1736</span> return createTable(tableName, family, KEYS_FOR_HBA_CREATE_TABLE);<a name="line.1736"></a> -<span class="sourceLineNo">1737</span> }<a name="line.1737"></a> -<span class="sourceLineNo">1738</span><a name="line.1738"></a> -<span class="sourceLineNo">1739</span> /**<a name="line.1739"></a> -<span class="sourceLineNo">1740</span> * Modify a table, synchronous. Waiting logic similar to that of {@code admin.rb#alter_status}.<a name="line.1740"></a> -<span class="sourceLineNo">1741</span> */<a name="line.1741"></a> -<span class="sourceLineNo">1742</span> @SuppressWarnings("serial")<a name="line.1742"></a> -<span class="sourceLineNo">1743</span> public static void modifyTableSync(Admin admin, TableDescriptor desc)<a name="line.1743"></a> -<span class="sourceLineNo">1744</span> throws IOException, InterruptedException {<a name="line.1744"></a> -<span class="sourceLineNo">1745</span> admin.modifyTable(desc);<a name="line.1745"></a> -<span class="sourceLineNo">1746</span> Pair<Integer, Integer> status = new Pair<Integer, Integer>() {{<a name="line.1746"></a> -<span class="sourceLineNo">1747</span> setFirst(0);<a name="line.1747"></a> -<span class="sourceLineNo">1748</span> setSecond(0);<a name="line.1748"></a> -<span class="sourceLineNo">1749</span> }};<a name="line.1749"></a> -<span class="sourceLineNo">1750</span> int i = 0;<a name="line.1750"></a> -<span class="sourceLineNo">1751</span> do {<a name="line.1751"></a> -<span class="sourceLineNo">1752</span> status = admin.getAlterStatus(desc.getTableName());<a name="line.1752"></a> -<span class="sourceLineNo">1753</span> if (status.getSecond() != 0) {<a name="line.1753"></a> -<span class="sourceLineNo">1754</span> LOG.debug(status.getSecond() - status.getFirst() + "/" + status.getSecond()<a name="line.1754"></a> -<span class="sourceLineNo">1755</span> + " regions updated.");<a name="line.1755"></a> -<span class="sourceLineNo">1756</span> Thread.sleep(1 * 1000L);<a name="line.1756"></a> -<span class="sourceLineNo">1757</span> } else {<a name="line.1757"></a> -<span class="sourceLineNo">1758</span> LOG.debug("All regions updated.");<a name="line.1758"></a> -<span class="sourceLineNo">1759</span> break;<a name="line.1759"></a> -<span class="sourceLineNo">1760</span> }<a name="line.1760"></a> -<span class="sourceLineNo">1761</span> } while (status.getFirst() != 0 && i++ < 500);<a name="line.1761"></a> -<span class="sourceLineNo">1762</span> if (status.getFirst() != 0) {<a name="line.1762"></a> -<span class="sourceLineNo">1763</span> throw new IOException("Failed to update all regions even after 500 seconds.");<a name="line.1763"></a> -<span class="sourceLineNo">1764</span> }<a name="line.1764"></a> -<span class="sourceLineNo">1765</span> }<a name="line.1765"></a> -<span class="sourceLineNo">1766</span><a name="line.1766"></a> -<span class="sourceLineNo">1767</span> /**<a name="line.1767"></a> -<span class="sourceLineNo">1768</span> * Set the number of Region replicas.<a name="line.1768"></a> -<span class="sourceLineNo">1769</span> */<a name="line.1769"></a> -<span class="sourceLineNo">1770</span> public static void setReplicas(Admin admin, TableName table, int replicaCount)<a name="line.1770"></a> -<span class="sourceLineNo">1771</span> throws IOException, InterruptedException {<a name="line.1771"></a> -<span class="sourceLineNo">1772</span> admin.disableTable(table);<a name="line.1772"></a> -<span class="sourceLineNo">1773</span> HTableDescriptor desc = new HTableDescriptor(admin.getTableDescriptor(table));<a name="line.1773"></a> -<span class="sourceLineNo">1774</span> desc.setRegionReplication(replicaCount);<a name="line.1774"></a> -<span class="sourceLineNo">1775</span> admin.modifyTable(desc.getTableName(), desc);<a name="line.1775"></a> -<span class="sourceLineNo">1776</span> admin.enableTable(table);<a name="line.1776"></a> -<span class="sourceLineNo">1777</span> }<a name="line.1777"></a> -<span class="sourceLineNo">1778</span><a name="line.1778"></a> -<span class="sourceLineNo">1779</span> /**<a name="line.1779"></a> -<span class="sourceLineNo">1780</span> * Drop an existing table<a name="line.1780"></a> -<span class="sourceLineNo">1781</span> * @param tableName existing table<a name="line.1781"></a> -<span class="sourceLineNo">1782</span> */<a name="line.1782"></a> -<span class="sourceLineNo">1783</span> public void deleteTable(TableName tableName) throws IOException {<a name="line.1783"></a> -<span class="sourceLineNo">1784</span> try {<a name="line.1784"></a> -<span class="sourceLineNo">1785</span> getAdmin().disableTable(tableName);<a name="line.1785"></a> -<span class="sourceLineNo">1786</span> } catch (TableNotEnabledException e) {<a name="line.1786"></a> -<span class="sourceLineNo">1787</span> LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");<a name="line.1787"></a> -<span class="sourceLineNo">1788</span> }<a name="line.1788"></a> -<span class="sourceLineNo">1789</span> getAdmin().deleteTable(tableName);<a name="line.1789"></a> -<span class="sourceLineNo">1790</span> }<a name="line.1790"></a> -<span class="sourceLineNo">1791</span><a name="line.1791"></a> -<span class="sourceLineNo">1792</span> /**<a name="line.1792"></a> -<span class="sourceLineNo">1793</span> * Drop an existing table<a name="line.1793"></a> -<span class="sourceLineNo">1794</span> * @param tableName existing table<a name="line.1794"></a> -<span class="sourceLineNo">1795</span> */<a name="line.1795"></a> -<span class="sourceLineNo">1796</span> public void deleteTableIfAny(TableName tableName) throws IOException {<a name="line.1796"></a> -<span class="sourceLineNo">1797</span> try {<a name="line.1797"></a> -<span class="sourceLineNo">1798</span> deleteTable(tableName);<a name="line.1798"></a> -<span class="sourceLineNo">1799</span> } catch (TableNotFoundException e) {<a name="line.1799"></a> -<span class="sourceLineNo">1800</span> // ignore<a name="line.1800"></a> -<span class="sourceLineNo">1801</span> }<a name="line.1801"></a> -<span class="sourceLineNo">1802</span> }<a name="line.1802"></a> -<span class="sourceLineNo">1803</span><a name="line.1803"></a> -<span class="sourceLineNo">1804</span> // ==========================================================================<a name="line.1804"></a> -<span class="sourceLineNo">1805</span> // Canned table and table descriptor creation<a name="line.1805"></a> -<span class="sourceLineNo">1806</span> // TODO replace HBaseTestCase<a name="line.1806"></a> -<span class="sourceLineNo">1807</span><a name="line.1807"></a> -<span class="sourceLineNo">1808</span> public final static byte [] fam1 = Bytes.toBytes("colfamily11");<a name="line.1808"></a> -<span class="sourceLineNo">1809</span> public final static byte [] fam2 = Bytes.toBytes("colfamily21");<a name="line.1809"></a> -<span class="sourceLineNo">1810</span> public final static byte [] fam3 = Bytes.toBytes("colfamily31");<a name="line.1810"></a> -<span class="sourceLineNo">1811</span> public static final byte[][] COLUMNS = {fam1, fam2, fam3};<a name="line.1811"></a> -<span class="sourceLineNo">1812</span> private static final int MAXVERSIONS = 3;<a name="line.1812"></a> -<span class="sourceLineNo">1813</span><a name="line.1813"></a> -<span class="sourceLineNo">1814</span> public static final char FIRST_CHAR = 'a';<a name="line.1814"></a> -<span class="sourceLineNo">1815</span> public static final char LAST_CHAR = 'z';<a name="line.1815"></a> -<span class="sourceLineNo">1816</span> public static final byte [] START_KEY_BYTES = {FIRST_CHAR, FIRST_CHAR, FIRST_CHAR};<a name="line.1816"></a> -<span class="sourceLineNo">1817</span> public static final String START_KEY = new String(START_KEY_BYTES, HConstants.UTF8_CHARSET);<a name="line.1817"></a> -<span class="sourceLineNo">1818</span><a name="line.1818"></a> -<span class="sourceLineNo">1819</span> @Deprecated<a name="line.1819"></a> -<span class="sourceLineNo">1820</span> public HTableDescriptor createTableDescriptor(final String name,<a name="line.1820"></a> -<span class="sourceLineNo">1821</span> final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {<a name="line.1821"></a> -<span class="sourceLineNo">1822</span> return this.createTableDescriptor(TableName.valueOf(name), minVersions, versions, ttl,<a name="line.1822"></a> -<span class="sourceLineNo">1823</span> keepDeleted);<a name="line.1823"></a> -<span class="sourceLineNo">1824</span> }<a name="line.1824"></a> +<span class="sourceLineNo">1476</span> /**<a name="line.1476"></a> +<span class="sourceLineNo">1477</span> * Create a table.<a name="line.1477"></a> +<span class="sourceLineNo">1478</span> * @param tableName the table name<a name="line.1478"></a> +<span class="sourceLineNo">1479</span> * @param families the families<a name="line.1479"></a> +<span class="sourceLineNo">1480</span> * @param splitKeys the splitkeys<a name="line.1480"></a> +<span class="sourceLineNo">1481</span> * @param replicaCount the region replica count<a name="line.1481"></a> +<span class="sourceLineNo">1482</span> * @return A Table instance for the created table.<a name="line.1482"></a> +<span class="sourceLineNo">1483</span> * @throws IOException throws IOException<a name="line.1483"></a> +<span class="sourceLineNo">1484</span> */<a name="line.1484"></a> +<span class="sourceLineNo">1485</span> public Table createTable(TableName tableName, byte[][] families, byte[][] splitKeys,<a name="line.1485"></a> +<span class="sourceLineNo">1486</span> int replicaCount) throws IOException {<a name="line.1486"></a> +<span class="sourceLineNo">1487</span> return createTable(tableName, families, splitKeys, replicaCount,<a name="line.1487"></a> +<span class="sourceLineNo">1488</span> new Configuration(getConfiguration()));<a name="line.1488"></a> +<span class="sourceLineNo">1489</span> }<a name="line.1489"></a> +<span class="sourceLineNo">1490</span><a name="line.1490"></a> +<span class="sourceLineNo">1491</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1491"></a> +<span class="sourceLineNo">1492</span> int numVersions, byte[] startKey, byte[] endKey, int numRegions)<a name="line.1492"></a> +<span class="sourceLineNo">1493</span> throws IOException{<a name="line.1493"></a> +<span class="sourceLineNo">1494</span> HTableDescriptor desc = createTableDescriptor(tableName, families, numVersions);<a name="line.1494"></a> +<span class="sourceLineNo">1495</span><a name="line.1495"></a> +<span class="sourceLineNo">1496</span> getAdmin().createTable(desc, startKey, endKey, numRegions);<a name="line.1496"></a> +<span class="sourceLineNo">1497</span> // HBaseAdmin only waits for regions to appear in hbase:meta we<a name="line.1497"></a> +<span class="sourceLineNo">1498</span> // should wait until they are assigned<a name="line.1498"></a> +<span class="sourceLineNo">1499</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1499"></a> +<span class="sourceLineNo">1500</span> return getConnection().getTable(tableName);<a name="line.1500"></a> +<span class="sourceLineNo">1501</span> }<a name="line.1501"></a> +<span class="sourceLineNo">1502</span><a name="line.1502"></a> +<span class="sourceLineNo">1503</span> /**<a name="line.1503"></a> +<span class="sourceLineNo">1504</span> * Create a table.<a name="line.1504"></a> +<span class="sourceLineNo">1505</span> * @param htd<a name="line.1505"></a> +<span class="sourceLineNo">1506</span> * @param families<a name="line.1506"></a> +<span class="sourceLineNo">1507</span> * @param c Configuration to use<a name="line.1507"></a> +<span class="sourceLineNo">1508</span> * @return A Table instance for the created table.<a name="line.1508"></a> +<span class="sourceLineNo">1509</span> * @throws IOException<a name="line.1509"></a> +<span class="sourceLineNo">1510</span> */<a name="line.1510"></a> +<span class="sourceLineNo">1511</span> public Table createTable(TableDescriptor htd, byte[][] families, Configuration c)<a name="line.1511"></a> +<span class="sourceLineNo">1512</span> throws IOException {<a name="line.1512"></a> +<span class="sourceLineNo">1513</span> return createTable(htd, families, null, c);<a name="line.1513"></a> +<span class="sourceLineNo">1514</span> }<a name="line.1514"></a> +<span class="sourceLineNo">1515</span><a name="line.1515"></a> +<span class="sourceLineNo">1516</span> /**<a name="line.1516"></a> +<span class="sourceLineNo">1517</span> * Create a table.<a name="line.1517"></a> +<span class="sourceLineNo">1518</span> * @param htd table descriptor<a name="line.1518"></a> +<span class="sourceLineNo">1519</span> * @param families array of column families<a name="line.1519"></a> +<span class="sourceLineNo">1520</span> * @param splitKeys array of split keys<a name="line.1520"></a> +<span class="sourceLineNo">1521</span> * @param c Configuration to use<a name="line.1521"></a> +<span class="sourceLineNo">1522</span> * @return A Table instance for the created table.<a name="line.1522"></a> +<span class="sourceLineNo">1523</span> * @throws IOException if getAdmin or createTable fails<a name="line.1523"></a> +<span class="sourceLineNo">1524</span> */<a name="line.1524"></a> +<span class="sourceLineNo">1525</span> public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys,<a name="line.1525"></a> +<span class="sourceLineNo">1526</span> Configuration c) throws IOException {<a name="line.1526"></a> +<span class="sourceLineNo">1527</span> // Disable blooms (they are on by default as of 0.95) but we disable them here because<a name="line.1527"></a> +<span class="sourceLineNo">1528</span> // tests have hard coded counts of what to expect in block cache, etc., and blooms being<a name="line.1528"></a> +<span class="sourceLineNo">1529</span> // on is interfering.<a name="line.1529"></a> +<span class="sourceLineNo">1530</span> return createTable(htd, families, splitKeys, BloomType.NONE, HConstants.DEFAULT_BLOCKSIZE, c);<a name="line.1530"></a> +<span class="sourceLineNo">1531</span> }<a name="line.1531"></a> +<span class="sourceLineNo">1532</span><a name="line.1532"></a> +<span class="sourceLineNo">1533</span> /**<a name="line.1533"></a> +<span class="sourceLineNo">1534</span> * Create a table.<a name="line.1534"></a> +<span class="sourceLineNo">1535</span> * @param htd table descriptor<a name="line.1535"></a> +<span class="sourceLineNo">1536</span> * @param families array of column families<a name="line.1536"></a> +<span class="sourceLineNo">1537</span> * @param splitKeys array of split keys<a name="line.1537"></a> +<span class="sourceLineNo">1538</span> * @param type Bloom type<a name="line.1538"></a> +<span class="sourceLineNo">1539</span> * @param blockSize block size<a name="line.1539"></a> +<span class="sourceLineNo">1540</span> * @param c Configuration to use<a name="line.1540"></a> +<span class="sourceLineNo">1541</span> * @return A Table instance for the created table.<a name="line.1541"></a> +<span class="sourceLineNo">1542</span> * @throws IOException if getAdmin or createTable fails<a name="line.1542"></a> +<span class="sourceLineNo">1543</span> */<a name="line.1543"></a> +<span class="sourceLineNo">1544</span><a name="line.1544"></a> +<span class="sourceLineNo">1545</span> public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys,<a name="line.1545"></a> +<span class="sourceLineNo">1546</span> BloomType type, int blockSize, Configuration c) throws IOException {<a name="line.1546"></a> +<span class="sourceLineNo">1547</span> TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(htd);<a name="line.1547"></a> +<span class="sourceLineNo">1548</span> for (byte[] family : families) {<a name="line.1548"></a> +<span class="sourceLineNo">1549</span> builder.setColumnFamily(<a name="line.1549"></a> +<span class="sourceLineNo">1550</span> ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(type)<a name="line.1550"></a> +<span class="sourceLineNo">1551</span> .setBlocksize(blockSize).build());<a name="line.1551"></a> +<span class="sourceLineNo">1552</span> }<a name="line.1552"></a> +<span class="sourceLineNo">1553</span> TableDescriptor td = builder.build();<a name="line.1553"></a> +<span class="sourceLineNo">1554</span> getAdmin().createTable(td, splitKeys);<a name="line.1554"></a> +<span class="sourceLineNo">1555</span> // HBaseAdmin only waits for regions to appear in hbase:meta<a name="line.1555"></a> +<span class="sourceLineNo">1556</span> // we should wait until they are assigned<a name="line.1556"></a> +<span class="sourceLineNo">1557</span> waitUntilAllRegionsAssigned(td.getTableName());<a name="line.1557"></a> +<span class="sourceLineNo">1558</span> return getConnection().getTable(td.getTableName());<a name="line.1558"></a> +<span class="sourceLineNo">1559</span> }<a name="line.1559"></a> +<span class="sourceLineNo">1560</span><a name="line.1560"></a> +<span class="sourceLineNo">1561</span> /**<a name="line.1561"></a> +<span class="sourceLineNo">1562</span> * Create a table.<a name="line.1562"></a> +<span class="sourceLineNo">1563</span> * @param htd table descriptor<a name="line.1563"></a> +<span class="sourceLineNo">1564</span> * @param splitRows array of split keys<a name="line.1564"></a> +<span class="sourceLineNo">1565</span> * @return A Table instance for the created table.<a name="line.1565"></a> +<span class="sourceLineNo">1566</span> * @throws IOException<a name="line.1566"></a> +<span class="sourceLineNo">1567</span> */<a name="line.1567"></a> +<span class="sourceLineNo">1568</span> public Table createTable(TableDescriptor htd, byte[][] splitRows)<a name="line.1568"></a> +<span class="sourceLineNo">1569</span> throws IOException {<a name="line.1569"></a> +<span class="sourceLineNo">1570</span> getAdmin().createTable(htd, splitRows);<a name="line.1570"></a> +<span class="sourceLineNo">1571</span> // HBaseAdmin only waits for regions to appear in hbase:meta<a name="line.1571"></a> +<span class="sourceLineNo">1572</span> // we should wait until they are assigned<a name="line.1572"></a> +<span class="sourceLineNo">1573</span> waitUntilAllRegionsAssigned(htd.getTableName());<a name="line.1573"></a> +<span class="sourceLineNo">1574</span> return getConnection().getTable(htd.getTableName());<a name="line.1574"></a> +<span class="sourceLineNo">1575</span> }<a name="line.1575"></a> +<span class="sourceLineNo">1576</span><a name="line.1576"></a> +<span class="sourceLineNo">1577</span> /**<a name="line.1577"></a> +<span class="sourceLineNo">1578</span> * Create a table.<a name="line.1578"></a> +<span class="sourceLineNo">1579</span> * @param tableName the table name<a name="line.1579"></a> +<span class="sourceLineNo">1580</span> * @param families the families<a name="line.1580"></a> +<span class="sourceLineNo">1581</span> * @param splitKeys the split keys<a name="line.1581"></a> +<span class="sourceLineNo">1582</span> * @param replicaCount the replica count<a name="line.1582"></a> +<span class="sourceLineNo">1583</span> * @param c Configuration to use<a name="line.1583"></a> +<span class="sourceLineNo">1584</span> * @return A Table instance for the created table.<a name="line.1584"></a> +<span class="sourceLineNo">1585</span> * @throws IOException<a name="line.1585"></a> +<span class="sourceLineNo">1586</span> */<a name="line.1586"></a> +<span class="sourceLineNo">1587</span> public Table createTable(TableName tableName, byte[][] families, byte[][] splitKeys,<a name="line.1587"></a> +<span class="sourceLineNo">1588</span> int replicaCount, final Configuration c) throws IOException {<a name="line.1588"></a> +<span class="sourceLineNo">1589</span> HTableDescriptor htd = new HTableDescriptor(tableName);<a name="line.1589"></a> +<span class="sourceLineNo">1590</span> htd.setRegionReplication(replicaCount);<a name="line.1590"></a> +<span class="sourceLineNo">1591</span> return createTable(htd, families, splitKeys, c);<a name="line.1591"></a> +<span class="sourceLineNo">1592</span> }<a name="line.1592"></a> +<span class="sourceLineNo">1593</span><a name="line.1593"></a> +<span class="sourceLineNo">1594</span> /**<a name="line.1594"></a> +<span class="sourceLineNo">1595</span> * Create a table.<a name="line.1595"></a> +<span class="sourceLineNo">1596</span> * @param tableName<a name="line.1596"></a> +<span class="sourceLineNo">1597</span> * @param family<a name="line.1597"></a> +<span class="sourceLineNo">1598</span> * @param numVersions<a name="line.1598"></a> +<span class="sourceLineNo">1599</span> * @return A Table instance for the created table.<a name="line.1599"></a> +<span class="sourceLineNo">1600</span> * @throws IOException<a name="line.1600"></a> +<span class="sourceLineNo">1601</span> */<a name="line.1601"></a> +<span class="sourceLineNo">1602</span> public Table createTable(TableName tableName, byte[] family, int numVersions)<a name="line.1602"></a> +<span class="sourceLineNo">1603</span> throws IOException {<a name="line.1603"></a> +<span class="sourceLineNo">1604</span> return createTable(tableName, new byte[][]{family}, numVersions);<a name="line.1604"></a> +<span class="sourceLineNo">1605</span> }<a name="line.1605"></a> +<span class="sourceLineNo">1606</span><a name="line.1606"></a> +<span class="sourceLineNo">1607</span> /**<a name="line.1607"></a> +<span class="sourceLineNo">1608</span> * Create a table.<a name="line.1608"></a> +<span class="sourceLineNo">1609</span> * @param tableName<a name="line.1609"></a> +<span class="sourceLineNo">1610</span> * @param families<a name="line.1610"></a> +<span class="sourceLineNo">1611</span> * @param numVersions<a name="line.1611"></a> +<span class="sourceLineNo">1612</span> * @return A Table instance for the created table.<a name="line.1612"></a> +<span class="sourceLineNo">1613</span> * @throws IOException<a name="line.1613"></a> +<span class="sourceLineNo">1614</span> */<a name="line.1614"></a> +<span class="sourceLineNo">1615</span> public Table createTable(TableName tableName, byte[][] families, int numVersions)<a name="line.1615"></a> +<span class="sourceLineNo">1616</span> throws IOException {<a name="line.1616"></a> +<span class="sourceLineNo">1617</span> return createTable(tableName, families, numVersions, (byte[][]) null);<a name="line.1617"></a> +<span class="sourceLineNo">1618</span> }<a name="line.1618"></a> +<span class="sourceLineNo">1619</span><a name="line.1619"></a> +<span class="sourceLineNo">1620</span> /**<a name="line.1620"></a> +<span class="sourceLineNo">1621</span> * Create a table.<a name="line.1621"></a> +<span class="sourceLineNo">1622</span> * @param tableName<a name="line.1622"></a> +<span class="sourceLineNo">1623</span> * @param families<a name="line.1623"></a> +<span class="sourceLineNo">1624</span> * @param numVersions<a name="line.1624"></a> +<span class="sourceLineNo">1625</span> * @param splitKeys<a name="line.1625"></a> +<span class="sourceLineNo">1626</span> * @return A Table instance for the created table.<a name="line.1626"></a> +<span class="sourceLineNo">1627</span> * @throws IOException<a name="line.1627"></a> +<span class="sourceLineNo">1628</span> */<a name="line.1628"></a> +<span class="sourceLineNo">1629</span> public Table createTable(TableName tableName, byte[][] families, int numVersions,<a name="line.1629"></a> +<span class="sourceLineNo">1630</span> byte[][] splitKeys) throws IOException {<a name="line.1630"></a> +<span class="sourceLineNo">1631</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1631"></a> +<span class="sourceLineNo">1632</span> for (byte[] family : families) {<a name="line.1632"></a> +<span class="sourceLineNo">1633</span> HColumnDescriptor hcd = new HColumnDescriptor(family).setMaxVersions(numVersions);<a name="line.1633"></a> +<span class="sourceLineNo">1634</span> desc.addFamily(hcd);<a name="line.1634"></a> +<span class="sourceLineNo">1635</span> }<a name="line.1635"></a> +<span class="sourceLineNo">1636</span> getAdmin().createTable(desc, splitKeys);<a name="line.1636"></a> +<span class="sourceLineNo">1637</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1637"></a> +<span class="sourceLineNo">1638</span> // assigned<a name="line.1638"></a> +<span class="sourceLineNo">1639</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1639"></a> +<span class="sourceLineNo">1640</span> return getConnection().getTable(tableName);<a name="line.1640"></a> +<span class="sourceLineNo">1641</span> }<a name="line.1641"></a> +<span class="sourceLineNo">1642</span><a name="line.1642"></a> +<span class="sourceLineNo">1643</span> /**<a name="line.1643"></a> +<span class="sourceLineNo">1644</span> * Create a table with multiple regions.<a name="line.1644"></a> +<span class="sourceLineNo">1645</span> * @param tableName<a name="line.1645"></a> +<span class="sourceLineNo">1646</span> * @param families<a name="line.1646"></a> +<span class="sourceLineNo">1647</span> * @param numVersions<a name="line.1647"></a> +<span class="sourceLineNo">1648</span> * @return A Table instance for the created table.<a name="line.1648"></a> +<span class="sourceLineNo">1649</span> * @throws IOException<a name="line.1649"></a> +<span class="sourceLineNo">1650</span> */<a name="line.1650"></a> +<span class="sourceLineNo">1651</span> public Table createMultiRegionTable(TableName tableName, byte[][] families, int numVersions)<a name="line.1651"></a> +<span class="sourceLineNo">1652</span> throws IOException {<a name="line.1652"></a> +<span class="sourceLineNo">1653</span> return createTable(tableName, families, numVersions, KEYS_FOR_HBA_CREATE_TABLE);<a name="line.1653"></a> +<span class="sourceLineNo">1654</span> }<a name="line.1654"></a> +<span class="sourceLineNo">1655</span><a name="line.1655"></a> +<span class="sourceLineNo">1656</span> /**<a name="line.1656"></a> +<span class="sourceLineNo">1657</span> * Create a table.<a name="line.1657"></a> +<span class="sourceLineNo">1658</span> * @param tableName<a name="line.1658"></a> +<span class="sourceLineNo">1659</span> * @param families<a name="line.1659"></a> +<span class="sourceLineNo">1660</span> * @param numVersions<a name="line.1660"></a> +<span class="sourceLineNo">1661</span> * @param blockSize<a name="line.1661"></a> +<span class="sourceLineNo">1662</span> * @return A Table instance for the created table.<a name="line.1662"></a> +<span class="sourceLineNo">1663</span> * @throws IOException<a name="line.1663"></a> +<span class="sourceLineNo">1664</span> */<a name="line.1664"></a> +<span class="sourceLineNo">1665</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1665"></a> +<span class="sourceLineNo">1666</span> int numVersions, int blockSize) throws IOException {<a name="line.1666"></a> +<span class="sourceLineNo">1667</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1667"></a> +<span class="sourceLineNo">1668</span> for (byte[] family : families) {<a name="line.1668"></a> +<span class="sourceLineNo">1669</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1669"></a> +<span class="sourceLineNo">1670</span> .setMaxVersions(numVersions)<a name="line.1670"></a> +<span class="sourceLineNo">1671</span> .setBlocksize(blockSize);<a name="line.1671"></a> +<span class="sourceLineNo">1672</span> desc.addFamily(hcd);<a name="line.1672"></a> +<span class="sourceLineNo">1673</span> }<a name="line.1673"></a> +<span class="sourceLineNo">1674</span> getAdmin().createTable(desc);<a name="line.1674"></a> +<span class="sourceLineNo">1675</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1675"></a> +<span class="sourceLineNo">1676</span> // assigned<a name="line.1676"></a> +<span class="sourceLineNo">1677</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1677"></a> +<span class="sourceLineNo">1678</span> return getConnection().getTable(tableName);<a name="line.1678"></a> +<span class="sourceLineNo">1679</span> }<a name="line.1679"></a> +<span class="sourceLineNo">1680</span><a name="line.1680"></a> +<span class="sourceLineNo">1681</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1681"></a> +<span class="sourceLineNo">1682</span> int numVersions, int blockSize, String cpName) throws IOException {<a name="line.1682"></a> +<span class="sourceLineNo">1683</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1683"></a> +<span class="sourceLineNo">1684</span> for (byte[] family : families) {<a name="line.1684"></a> +<span class="sourceLineNo">1685</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1685"></a> +<span class="sourceLineNo">1686</span> .setMaxVersions(numVersions)<a name="line.1686"></a> +<span class="sourceLineNo">1687</span> .setBlocksize(blockSize);<a name="line.1687"></a> +<span class="sourceLineNo">1688</span> desc.addFamily(hcd);<a name="line.1688"></a> +<span class="sourceLineNo">1689</span> }<a name="line.1689"></a> +<span class="sourceLineNo">1690</span> if(cpName != null) {<a name="line.1690"></a> +<span class="sourceLineNo">1691</span> desc.addCoprocessor(cpName);<a name="line.1691"></a> +<span class="sourceLineNo">1692</span> }<a name="line.1692"></a> +<span class="sourceLineNo">1693</span> getAdmin().createTable(desc);<a name="line.1693"></a> +<span class="sourceLineNo">1694</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1694"></a> +<span class="sourceLineNo">1695</span> // assigned<a name="line.1695"></a> +<span class="sourceLineNo">1696</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1696"></a> +<span class="sourceLineNo">1697</span> return getConnection().getTable(tableName);<a name="line.1697"></a> +<span class="sourceLineNo">1698</span> }<a name="line.1698"></a> +<span class="sourceLineNo">1699</span><a name="line.1699"></a> +<span class="sourceLineNo">1700</span> /**<a name="line.1700"></a> +<span class="sourceLineNo">1701</span> * Create a table.<a name="line.1701"></a> +<span class="sourceLineNo">1702</span> * @param tableName<a name="line.1702"></a> +<span class="sourceLineNo">1703</span> * @param families<a name="line.1703"></a> +<span class="sourceLineNo">1704</span> * @param numVersions<a name="line.1704"></a> +<span class="sourceLineNo">1705</span> * @return A Table instance for the created table.<a name="line.1705"></a> +<span class="sourceLineNo">1706</span> * @throws IOException<a name="line.1706"></a> +<span class="sourceLineNo">1707</span> */<a name="line.1707"></a> +<span class="sourceLineNo">1708</span> public Table createTable(TableName tableName, byte[][] families,<a name="line.1708"></a> +<span class="sourceLineNo">1709</span> int[] numVersions)<a name="line.1709"></a> +<span class="sourceLineNo">1710</span> throws IOException {<a name="line.1710"></a> +<span class="sourceLineNo">1711</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1711"></a> +<span class="sourceLineNo">1712</span> int i = 0;<a name="line.1712"></a> +<span class="sourceLineNo">1713</span> for (byte[] family : families) {<a name="line.1713"></a> +<span class="sourceLineNo">1714</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1714"></a> +<span class="sourceLineNo">1715</span> .setMaxVersions(numVersions[i]);<a name="line.1715"></a> +<span class="sourceLineNo">1716</span> desc.addFamily(hcd);<a name="line.1716"></a> +<span class="sourceLineNo">1717</span> i++;<a name="line.1717"></a> +<span class="sourceLineNo">1718</span> }<a name="line.1718"></a> +<span class="sourceLineNo">1719</span> getAdmin().createTable(desc);<a name="line.1719"></a> +<span class="sourceLineNo">1720</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1720"></a> +<span class="sourceLineNo">1721</span> // assigned<a name="line.1721"></a> +<span class="sourceLineNo">1722</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1722"></a> +<span class="sourceLineNo">1723</span> return getConnection().getTable(tableName);<a name="line.1723"></a> +<span class="sourceLineNo">1724</span> }<a name="line.1724"></a> +<span class="sourceLineNo">1725</span><a name="line.1725"></a> +<span class="sourceLineNo">1726</span> /**<a name="line.1726"></a> +<span class="sourceLineNo">1727</span> * Create a table.<a name="line.1727"></a> +<span class="sourceLineNo">1728</span> * @param tableName<a name="line.1728"></a> +<span class="sourceLineNo">1729</span> * @param family<a name="line.1729"></a> +<span class="sourceLineNo">1730</span> * @param splitRows<a name="line.1730"></a> +<span class="sourceLineNo">1731</span> * @return A Table instance for the created table.<a name="line.1731"></a> +<span class="sourceLineNo">1732</span> * @throws IOException<a name="line.1732"></a> +<span class="sourceLineNo">1733</span> */<a name="line.1733"></a> +<span class="sourceLineNo">1734</span> public Table createTable(TableName tableName, byte[] family, byte[][] splitRows)<a name="line.1734"></a> +<span class="sourceLineNo">1735</span> throws IOException {<a name="line.1735"></a> +<span class="sourceLineNo">1736</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1736"></a> +<span class="sourceLineNo">1737</span> HColumnDescriptor hcd = new HColumnDescriptor(family);<a name="line.1737"></a> +<span class="sourceLineNo">1738</span> desc.addFamily(hcd);<a name="line.1738"></a> +<span class="sourceLineNo">1739</span> getAdmin().createTable(desc, splitRows);<a name="line.1739"></a> +<span class="sourceLineNo">1740</span> // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are<a name="line.1740"></a> +<span class="sourceLineNo">1741</span> // assigned<a name="line.1741"></a> +<span class="sourceLineNo">1742</span> waitUntilAllRegionsAssigned(tableName);<a name="line.1742"></a> +<span class="sourceLineNo">1743</span> return getConnection().getTable(tableName);<a name="line.1743"></a> +<span class="sourceLineNo">1744</span> }<a name="line.1744"></a> +<span class="sourceLineNo">1745</span><a name="line.1745"></a> +<span class="sourceLineNo">1746</span> /**<a name="line.1746"></a> +<span class="sourceLineNo">1747</span> * Create a table with multiple regions.<a name="line.1747"></a> +<span class="sourceLineNo">1748</span> * @param tableName<a name="line.1748"></a> +<span class="sourceLineNo">1749</span> * @param family<a name="line.1749"></a> +<span class="sourceLineNo">1750</span> * @return A Table instance for the created table.<a name="line.1750"></a> +<span class="sourceLineNo">1751</span> * @throws IOException<a name="line.1751"></a> +<span class="sourceLineNo">1752</span> */<a name="line.1752"></a> +<span class="sourceLineNo">1753</span> public Table createMultiRegionTable(TableName tableName, byte[] family) throws IOException {<a name="line.1753"></a> +<span class="sourceLineNo">1754</span> return createTable(tableName, family, KEYS_FOR_HBA_CREATE_TABLE);<a name="line.1754"></a> +<span class="sourceLineNo">1755</span> }<a name="line.1755"></a> +<span class="sourceLineNo">1756</span><a name="line.1756"></a> +<span class="sourceLineNo">1757</span> /**<a name="line.1757"></a> +<span class="sourceLineNo">1758</span> * Modify a table, synchronous. Waiting logic similar to that of {@code admin.rb#alter_status}.<a name="line.1758"></a> +<span class="sourceLineNo">1759</span> */<a name="line.1759"></a> +<span class="sourceLineNo">1760</span> @SuppressWarnings("serial")<a name="line.1760"></a> +<span class="sourceLineNo">1761</span> public static void modifyTableSync(Admin admin, TableDescriptor desc)<a name="line.1761"></a> +<span class="sourceLineNo">1762</span> throws IOException, InterruptedException {<a name="line.1762"></a> +<span class="sourceLineNo">1763</span> admin.modifyTable(desc);<a name="line.1763"></a> +<span class="sourceLineNo">1764</span> Pair<Integer, Integer> status = new Pair<Integer, Integer>() {{<a name="line.1764"></a> +<span class="sourceLineNo">1765</span> setFirst(0);<a name="line.1765"></a> +<span class="sourceLineNo">1766</span> setSecond(0);<a name="line.1766"></a> +<span class="sourceLineNo">1767</span> }};<a name="line.1767"></a> +<span class="sourceLineNo">1768</span> int i = 0;<a name="line.1768"></a> +<span class="sourceLineNo">1769</span> do {<a name="line.1769"></a> +<span class="sourceLineNo">1770</span> status = admin.getAlterStatus(desc.getTableName());<a name="line.1770"></a> +<span class="sourceLineNo">1771</span> if (status.getSecond() != 0) {<a name="line.1771"></a> +<span class="sourceLineNo">1772</span> LOG.debug(status.getSecond() - status.getFirst() + "/" + status.getSecond()<a name="line.1772"></a> +<span class="sourceLineNo">1773</span> + " regions updated.");<a name="line.1773"></a> +<span class="sourceLineNo">1774</span> Thread.sleep(1 * 1000L);<a name="line.1774"></a> +<span class="sourceLineNo">1775</span> } else {<a name="line.1775"></a> +<span class="sourceLineNo">1776</span> LOG.debug("All regions updated.");<a name="line.1776"></a> +<span class="sourceLineNo">1777</span> break;<a name="line.1777"></a> +<span class="sourceLineNo">1778</span> }<a name="line.1778"></a> +<span class="sourceLineNo">1779</span> } while (status.getFirst() != 0 && i++ < 500);<a name="line.1779"></a> +<span class="sourceLineNo">1780</span> if (status.getFirst() != 0) {<a name="line.1780"></a> +<span class="sourceLineNo">1781</span> throw new IOException("Failed to update all regions even after 500 seconds.");<a name="line.1781"></a> +<span class="sourceLineNo">1782</span> }<a name="line.1782"></a> +<span class="sourceLineNo">1783</span> }<a name="line.1783"></a> +<span class="sourceLineNo">1784</span><a name="line.1784"></a> +<span class="sourceLineNo">1785</span> /**<a name="line.1785"></a> +<span class="sourceLineNo">1786</span> * Set the number of Region replicas.<a name="line.1786"></a> +<span class="sourceLineNo">1787</span> */<a name="line.1787"></a> +<span class="sourceLineNo">1788</span> public static void setReplicas(Admin admin, TableName table, int replicaCount)<a name="line.1788"></a> +<span class="sourceLineNo">1789</span> throws IOException, InterruptedException {<a name="line.1789"></a> +<span class="sourceLineNo">1790</span> admin.disableTable(table);<a name="line.1790"></a> +<span class="sourceLineNo">1791</span> HTableDescriptor desc = new HTableDescriptor(admin.getTableDescriptor(table));<a name="line.1791"></a> +<span class="sourceLineNo">1792</span> desc.setRegionReplication(replicaCount);<a name="line.1792"></a> +<span class="sourceLineNo">1793</span> admin.modifyTable(desc.getTableName(), desc);<a name="line.1793"></a> +<span class="sourceLineNo">1794</span> admin.enableTable(table);<a name="line.1794"></a> +<span class="sourceLineNo">1795</span> }<a name="line.1795"></a> +<span class="sourceLineNo">1796</span><a name="line.1796"></a> +<span class="sourceLineNo">1797</span> /**<a name="line.1797"></a> +<span class="sourceLineNo">1798</span> * Drop an existing table<a name="line.1798"></a> +<span class="sourceLineNo">1799</span> * @param tableName existing table<a name="line.1799"></a> +<span class="sourceLineNo">1800</span> */<a name="line.1800"></a> +<span class="sourceLineNo">1801</span> public void deleteTable(TableName tableName) throws IOException {<a name="line.1801"></a> +<span class="sourceLineNo">1802</span> try {<a name="line.1802"></a> +<span class="sourceLineNo">1803</span> getAdmin().disableTable(tableName);<a name="line.1803"></a> +<span class="sourceLineNo">1804</span> } catch (TableNotEnabledException e) {<a name="line.1804"></a> +<span class="sourceLineNo">1805</span> LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");<a name="line.1805"></a> +<span class="sourceLineNo">1806</span> }<a name="line.1806"></a> +<span class="sourceLineNo">1807</span> getAdmin().deleteTable(tableName);<a name="line.1807"></a> +<span class="sourceLineNo">1808</span> }<a name="line.1808"></a> +<span class="sourceLineNo">1809</span><a name="line.1809"></a> +<span class="sourceLineNo">1810</span> /**<a name="line.1810"></a> +<span class="sourceLineNo">1811</span> * Drop an existing table<a name="line.1811"></a> +<span class="sourceLineNo">1812</span> * @param tableName existing table<a name="line.1812"></a> +<span class="sourceLineNo">1813</span> */<a name="line.1813"></a> +<span class="sourceLineNo">1814</span> public void deleteTableIfAny(TableName tableName) throws IOException {<a name="line.1814"></a> +<span class="sourceLineNo">1815</span> try {<a name="line.1815"></a> +<span class="sourceLineNo">1816</span> deleteTable(tableName);<a name="line.1816"></a> +<span class="sourceLineNo">1817</span> } catch (TableNotFoundException e) {<a name="line.1817"></a> +<span class="sourceLineNo">1818</span> // ignore<a name="line.1818"></a> +<span class="sourceLineNo">1819</span> }<a name="line.1819"></a> +<span class="sourceLineNo">1820</span> }<a name="line.1820"></a> +<span class="sourceLineNo">1821</span><a name="line.1821"></a> +<span class="sourceLineNo">1822</span> // ==========================================================================<a name="line.1822"></a> +<span class="sourceLineNo">1823</span> // Canned table and table descriptor creation<a name="line.1823"></a> +<span class="sourceLineNo">1824</span> // TODO replace HBaseTestCase<a name="line.1824"></a> <span class="sourceLineNo">1825</span><a name="line.1825"></a> -<span class="sourceLineNo">1826</span> /**<a name="line.1826"></a> -<span class="sourceLineNo">1827</span> * Create a table of name <code>name</code>.<a name="line.1827"></a> -<span class="sourceLineNo">1828</span> * @param name Name to give table.<a name="line.1828"></a> -<span class="sourceLineNo">1829</span> * @return Column descriptor.<a name="line.1829"></a> -<span class="sourceLineNo">1830</span> */<a name="line.1830"></a> -<span class="sourceLineNo">1831</span> @Deprecated<a name="line.1831"></a> -<span class="sourceLineNo">1832</span> public HTableDescriptor createTableDescriptor(final String name) {<a name="line.1832"></a> -<span class="sourceLineNo">1833</span> return createTableDescriptor(TableName.valueOf(name), HColumnDescriptor.DEFAULT_MIN_VERSIONS,<a name="line.1833"></a> -<span class="sourceLineNo">1834</span> MAXVERSIONS, HConstants.FOREVER, HColumnDescriptor.DEFAULT_KEEP_DELETED);<a name="line.1834"></a> -<span class="sourceLineNo">1835</span> }<a name="line.1835"></a> +<span class="sourceLineNo">1826</span> public final static byte [] fam1 = Bytes.toBytes("colfamily11");<a name="line.1826"></a> +<span class="sourceLineNo">1827</span> public final static byte [] fam2 = Bytes.toBytes("colfamily21");<a name="line.1827"></a> +<span class="sourceLineNo">1828</span> public final static byte [] fam3 = Bytes.toBytes("colfamily31");<a name="line.1828"></a> +<span class="sourceLineNo">1829</span> public static final byte[][] COLUMNS = {fam1, fam2, fam3};<a name="line.1829"></a> +<span class="sourceLineNo">1830</span> private static final int MAXVERSIONS = 3;<a name="line.1830"></a> +<span class="sourceLineNo">1831</span><a name="line.1831"></a> +<span class="sourceLineNo">1832</span> public static final char FIRST_CHAR = 'a';<a name="line.1832"></a> +<span class="sourceLineNo">1833</span> public static final char LAST_CHAR = 'z';<a name="line.1833"></a> +<span class="sourceLineNo">1834</span> public static final byte [] START_KEY_BYTES = {FIRST_CHAR, FIRST_CHAR, FIRST_CHAR};<a name="line.1834"></a> +<span class="sourceLineNo">1835</span> public static final String START_KEY = new String(START_KEY_BYTES, HConstants.UTF8_CHARSET);<a name="line.1835"></a> <span class="sourceLineNo">1836</span><a name="line.1836"></a> -<span class="sourceLineNo">1837</span> public HTableDescriptor createTableDescriptor(final TableName name,<a name="line.1837"></a> -<span class="sourceLineNo">1838</span> final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {<a name="line.1838"></a> -<span class="sourceLineNo">1839</span> HTableDescriptor htd = new HTableDescriptor(name);<a name="line.1839"></a> -<span class="sourceLineNo">1840</span> for (byte[] cfName : new byte[][]{ fam1, fam2, fam3 }) {<a name="line.1840"></a> -<span class="sourceLineNo">1841</span> htd.addFamily(new HColumnDescriptor(cfName)<a name="line.1841"></a> -<span class="sourceLineNo">1842</span> .setMinVersions(minVersions)<a name="line.1842"></a> -<span class="sourceLineNo">1843</span> .setMaxVersions(versions)<a name="line.1843"></a> -<span class="sourceLineNo">1844</span> .setKeepDeletedCells(keepDeleted)<a name="line.1844"></a> -<span class="sourceLineNo">1845</span> .setBlockCacheEnabled(false)<a name="line.1845"></a> -<span class="sourceLineNo">1846</span> .setTimeToLive(ttl)<a name="line.1846"></a> -<span class="sourceLineNo">1847</span> );<a name="line.1847"></a> -<span class="sourceLineNo">1848</span> }<a name="line.1848"></a> -<span class="sourceLineNo">1849</span> return htd;<a name="line.1849"></a> -<span class="sourceLineNo">1850</span> }<a name="line.1850"></a> -<span class="sourceLineNo">1851</span><a name="line.1851"></a> -<span class="sourceLineNo">1852</span> /**<a name="line.1852"></a> -<span class="sourceLineNo">1853</span> * Create a table of name <code>name</code>.<a name="line.1853"></a> -<span class="sourceLineNo">1854</span> * @param name Name to give table.<a name="line.1854"></a> -<span class="sourceLineNo">1855</span> * @return Column descriptor.<a name="line.1855"></a> -<span class="sourceLineNo">1856</span> */<a name="line.1856"></a> -<span class="sourceLineNo">1857</span> public HTableDescriptor createTableDescriptor(final TableName name) {<a name="line.1857"></a> -<span class="sourceLineNo">1858</span> return createTableDescriptor(name, HColumnDescriptor.DEFAULT_MIN_VERSIONS,<a name="line.1858"></a> -<span class="sourceLineNo">1859</span> MAXVERSIONS, HConstants.FOREVER, HColumnDescriptor.DEFAULT_KEEP_DELETED);<a name="line.1859"></a> -<span class="sourceLineNo">1860</span> }<a name="line.1860"></a> -<span class="sourceLineNo">1861</span><a name="line.1861"></a> -<span class="sourceLineNo">1862</span> public HTableDescriptor createTableDescriptor(final TableName tableName,<a name="line.1862"></a> -<span class="sourceLineNo">1863</span> byte[] family) {<a name="line.1863"></a> -<span class="sourceLineNo">1864</span> return createTableDescriptor(tableName, new byte[][] {family}, 1);<a name="line.1864"></a> -<span class="sourceLineNo">1865</span> }<a name="line.1865"></a> -<span class="sourceLineNo">1866</span><a name="line.1866"></a> -<span class="sourceLineNo">1867</span> public HTableDescriptor createTableDescriptor(final TableName tableName,<a name="line.1867"></a> -<span class="sourceLineNo">1868</span> byte[][] families, int maxVersions) {<a name="line.1868"></a> -<span class="sourceLineNo">1869</span> HTableDescriptor desc = new HTableDescriptor(tableName);<a name="line.1869"></a> -<span class="sourceLineNo">1870</span> for (byte[] family : families) {<a name="line.1870"></a> -<span class="sourceLineNo">1871</span> HColumnDescriptor hcd = new HColumnDescriptor(family)<a name="line.1871"></a> -<span class="sourceLineNo">1872</span> .setMaxVersions(maxVersions);<a name="line.1872"></a> -<span class="sourceLineNo">1873</span> desc.addFamily(hcd);<a name="line.1873"></a> -<span class="sourceLineNo">1874</span> }<a name="line.1874"></a> -<span class="sourceLineNo">1875</span> return desc;<a name="line.1875"></a> -<span class="sourceLineNo">1876</span> }<a name="line.1876"></a> -<span class="sourceLineNo">1877</span><a name="line.1877"></a> -<span class="sourceLineNo">1878</span> /**<a name="line.1878"></a> -<span class="sourceLineNo">1879</span> * Create an HRegion that writes to the local tmp dirs<a name="line.1879"></a> -<span class="sourceLineNo">1880</span> * @param desc a table descriptor indicating which table the region belongs to<a name="line.1880"></a> -<span class="sourceLineNo">1881</span> * @param startKey the start boundary of the region<a name="line.1881"></a> -<span class="sourceLineNo">1882</span> * @param endKey the end boundary of the region<a name="line.1882"></a> -<span class="sourceLineNo">1883</span> * @return a region that writes to local dir for testing<a name="line.1883"></a> -<span class="sourceLineNo">1884</span> * @throws IOException<a name="line.1884"></a> -<span class="sourceLineNo">1885</span> */<a name="line.1885"></a> -<span class="sourceLineNo">1886</span> public HRegion createLocalHRegion(TableDescriptor desc, byte [] startKey,<a name="line.1886"></a> -<span class="sourceLineNo">1887</span> byte [] endKey)<a name="line.1887"></a> -<span class="sourceLineNo">1888</span> throws IOException {<a name="line.1888"></a> -<span class="sourceLineNo">1889</span> HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey);<a name="line.1889"></a> -<span class="sourceLineNo">1890</span> return createLocalHRegion(hri, desc);<a name="line.1890"></a> -<span class="sourceLineNo">1891</span> }<a name="line.1891"></a> -<span class="sourceLineNo">1892</span><a name="line.1892"></a> -<span class="sourceLineNo">1893</span> /**<a name="line.1893"></a> -<span class="sourceLineNo">1894</span> * Create an HRegion that writes to the local tmp dirs. Creates the WAL for you. Be sure to call<a name="line.1894"></a> -<span class="sourceLineNo">1895</span> * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when you're finished with it.<a name="line.1895"></a> -<span class="sourceLineNo">1896</span> */<a name="line.1896"></a> -<span class="sourceLineNo">1897</span> public HRegion createLocalHRegion(RegionInfo info, TableDescriptor desc) throws IOException {<a name="line.1897"></a> -<span class="sourceLineNo">1898</span> return createRegionAndWAL(info, getDataTestDir(), getConfiguration(), desc);<a name="line.1898"></a> -<span class="sourceLineNo">1899</span> }<a name="line.1899"></a> -<span class="sourceLineNo">1900</span><a name="line.1900"></a> -<span class="sourceLineNo">1901</span> /**<a name="line.1901"></a> -<span class="sourceLineNo">1902</span> * Create an HRegion that writes to the local tmp dirs with specified wal<a name="line.1902"></a> -<span class="sourceLineNo">1903</span> * @param info regioninfo<a name="line.1903"></a> -<span class="sourceLineNo">1904</span> * @param desc table descriptor<a name="line.1904"></a> -<span class="sourceLineNo">1905</span> * @param wal wal for this region.<a name="line.1905"></a> -<span class="sourceLineNo">1906</span> * @return created hregion<a name="line.1906"></a> -<span class="sourceLineNo">1907</span> * @throws IOException<a name="line.1907"></a> -<span class="sourceLineNo">1908</span> */<a name="line.1908"></a> -<span class="sourceLineNo">1909</span> public HRegion createLocalHRegion(RegionInfo info, TableDescriptor desc, WAL wal)<a name="line.1909"></a> -<span class="sourceLineNo">1910</span> throws IOException {<a name="line.1910"></a> -<span class="sourceLineNo">1911</span> return HRegion.createHRegion(info, getDataTestDir(), getConfiguration(), desc, wal);<a name="line.1911"></a> -<span class="sourceLineNo">1912</span> }<a name="line.1912"></a> -<span class="sourceLineNo">1913</span><a name="line.1913"></a> -<span class="sourceLineNo">1914</span> /**<a name="line.1914"></a> -<span class="sourceLineNo">1915</span> * @param tableName<a name="line.1915"></a> -<span class="sourceLineNo">1916</span> * @param startKey<a name="line.1916"></a> -<span class="sourceLineNo">1917</span> * @param stopKey<a name="line.1917"></a> -<span class="sourceLineNo">1918</span> * @param callingMethod<a name="line.1918"></a> -<span class="sourceLineNo">1919</span> * @param conf<a name="line.1919"></a> -<span class="sourceLineNo">1920</span> * @param isReadOnly<a name="line.1920"></a> -<span class="sourceLineNo">1921</span> * @param families<a name="line.1921"></a> -<span class="sourceLineNo">1922</span> * @throws IOException<a name="line.1922"></a> -<span class="sourceLineNo">1923</span> * @return A region on which you must call<a name="line.1923"></a> -<span class="sourceLineNo">1924</span> {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.<a name="line.1924"></a> -<span class="sourceLineNo">1925</span> * @deprecated use<a name="line.1925"></a> -<span class="sourceLineNo">1926</span> * {@link #createLocalHRegion(TableName, byte[], byte[], boolean, Durability, WAL, byte[]...)}<a name="line.1926"></a> -<span class="sourceLineNo">1927</span> */<a name="line.1927"></a> -<span class="sourceLineNo">1928</span> @Deprecated<a name="line.1928"></a> -<span class="sourceLineNo">1929</span> public HRegion createLocalHRegion(byte[] tableName, byte[] startKey, byte[] stopKey,<a name="line.1929"></a> -<span class="sourceLineNo">1930</span> String callingMethod, Configuration conf, boolean isReadOnly, Durability durability,<a name="line.1930"></a> -<span class="sourceLineNo">1931</span> WAL wal, byte[]... families) throws IOException {<a name="line.1931"></a> -<span class="sourceLineNo">1932</span> return this<a name="line.1932"></a> -<span class="sourceLineNo">1933</span> .createLocalHRegion(TableName.valueOf(tableName), startKey, stopKey, isReadOnly, durability,<a name="line.1933"></a> -<span class="sourceLineNo">1934</span> wal, families);<a name="line.1934"></a> -<span class="sourceLineNo">1935</span> }<a name="line.1935"></a> -<span class="sourceLineNo">1936</span><a name="line.1936"></a> -<span class="sourceLineNo">1937</span> /**<a name="line.1937"></a> -<span class="sourceLineNo">1938</span> * @param tableName<a name="line.1938"></a> -<span class="sourceLineNo">1939</span> * @param startKey<a name="line.1939"></a> -<span class="sourceLineNo">1940</span> * @param stopKey<a name="line.1940"></a> -<span class="sourceLineNo">1941</span> * @param isReadOnly<a name="line.1941"></a> -<span class="sourceLineNo">1942</span> * @param families<a name="line.1942"></a> -<span class="sourceLineNo">1943</span> * @return A region on which you must call<a name="line.1943"></a> -<span class="sourceLineNo">1944</span> * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.<a name="line.1944"></a> -<span class="sourceLineNo">1945</span> * @throws IOException<a name="line.1945"></a> -<span class="sourceLineNo">1946</span> */<a name="line.1946"></a> -<span class="sourceLineNo">1947</span> public HRegion createLocalHRegion(TableName tableName, byte[] startKey, byte[] stopKey,<a name="line.1947"></a> -<span class="sourceLineNo">1948</span> boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException {<a name="line.1948"></a> -<span class="sourceLineNo">1949</span> return createLocalHRegionWithInMemoryFlags(tableName,startKey, stopKey, isReadOnly,<a name="line.1949"></a> -<span class="sourceLineNo">1950</span> durability, wal, null, families);<a name="line.1950"></a> -<span class="sourceLineNo">1951</span> }<a name="line.1951"></a> -<span class="sourceLineNo">1952</span><a name="line.1952"></a> -<span class="sourceLineNo">1953</span> public HRegion createLocalHRegionWithInMemoryFlags(TableName tableName, byte[] startKey,<a name="line.1953"></a> -<span class="sourceLineNo">1954</span> byte[] stopKey,<a name="line.1954"></a> -<span class="sourceLineNo">1955</span> boolean isReadOnly, Durability durability, WAL wal, boolean[] compactedMemStore,<a name="line.1955"></a> -<span class="sourceLineNo">1956</span> byte[]... families)<a name="line.1956"></a> -<span class="sourceLineNo">1957</span> throws IOException {<a name="line.1957"></a> -<span class="sourceLineNo">1958</span> HTableDescriptor htd = new HTableDescriptor(tableName);<a name="line.1958"></a> -<span class="sourceLineNo">1959</span> htd.setReadOnly(isReadOnly);<a name="line.1959"></a> -<span class="sourceLineNo">1960</span> int i=0;<a name="line.1960"></a> -<span class="sourceLineNo">1961</span> for (byte[] family : families) {<a name="line.1961"></a> -<span class="sourceLineNo">1962</span> HColumnDescriptor hcd = new HColumnDescriptor(family);<a name="line.1962"></a> -<span class="sourceLineNo">1963</span> if(compactedMemStore != null && i < compactedMemStore.length) {<a name="line.1963"></a> -<span class="sourceLineNo">1964</span> hcd.setInMemoryCompaction(MemoryCompactionPolicy.BASIC);<a name="line.1964"></a> -<span class="sourceLineNo">1965</span> } else {<a name="line.1965"></a> -<span class="sourceLineNo">1966</span> hcd.setInMemoryCompaction(MemoryCompactionPolicy.NONE);<a name="line.1966"></a> -<span class="sourceLineNo">1967</span><a name="line.1967"></a> -<span class="sourceLineNo">1968</span> }<a name="line.1968"></a> -<span class="sourceLineNo">1969</span> i++;<a name="line.1969"></a> -<span class="sourceLineNo">1970</span> // Set default to be three versions.<a name="line.1970"></a> -<span class="sourceLineNo">1971</span> hcd.setMaxVersions(Integer.MAX_VALUE);<a name="line.1971"></a> -<span class="sourceLineNo">1972</span> htd.addFamily(hcd);<a name="line.1972"></a> -<span class="sourceLineNo">1973</span> }<a name="line.1973"></a> -<span class="sourceLineNo">1974</span> htd.setDurability(durability);<a name="line.1974"></a> -<span class="sourceLineNo">1975</span> HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false);<a name="line.1975"></a> -<span class="sourceLineNo">1976</span> return createLocalHRegion(info, htd, wal);<a name="line.1976"></a> -<span class="sourceLineNo">1977</span> }<a name="line.1977"></a> -<span class="sourceLineNo">1978</span><a name="line.1978"></a> -<span class="sourceLineNo">1979</span> //<a name="line.1979"></a> -<span class="sourceLineNo">1980</span> // ==========================================================================<a name="line.1980"></a> -<span class="sourceLineNo">1981</span><a name="line.1981"></a> -<span class="sourceLineNo">1982</span> /**<a name="line.1982"></a> -<span class="sourceLineNo">1983</span> * Provide an existing table name to truncate.<a name="line.1983"></a> -<span class="sourceLineNo">1984</span> * Scans the table and issues a delete for each row read.<a name="line.1984"></a> -<span class="sourceLineNo">1985</span> * @param tableName existing table<a name="line.1985"></a> -<span class="sourceLineNo">1986</span> * @return HTable to that new table<a name="line.1986"></a> -<span class="sourceLineNo">1987</span> * @throws IOException<a name="line.1987"></a> -<span class="sourceLineNo">1988</span> */<a name="line.1988"></a> -<span class="sourceLineNo">1989</span> public Table deleteTableData(TableName tableName) throws IOException {<a name="line.1989"></a> -<span class="sourceLineNo">1990</span> Table table = getConnection().getTable(tableName);<a name="line.1990"></a> -<span class="sourceLineNo">1991</span> Scan scan = new Scan();<a name="line.1991"></a> -<span class="sourceLineNo">1992</span> ResultScanner resScan = table.getScanner(scan);<a name="line.1992"></a> -<span class="sourceLineNo">1993</span> for(Result res : resScan) {<a name="line.1993"></a> -<span class="sourceLineNo">1994</span> Delete del = new Delete(res.getRow());<a name="line.1994"></a> -<span class="sourceLineNo">1995</span> table.delete(del);<a name="line.1995"></a> -<span class="sourceLineNo">1996</span> }<a name="line.1996"></a> -<span class="sourceLineNo">1997</span> resScan = table.getScanner(scan);<a name="line.1997"></a> -<span class="sourceLineNo">1998</span> resScan.close();<a name="line.1998"></a> -<span class="sourceLineNo">1999</span> return table;<a name="line.1999"></a> -<span class="sourceLineNo">2000</span> }<a name="line.2000"></a> -<span class="sourceLineNo">2001</span><a name="line.2001"></a> -<span class="sourceLineNo">2002</span> /**<a name="line.2002"></a> -<span class="sourceLineNo">2003</span> * Truncate a table using the admin command.<a name="line.2003"></a> -<span class="sourceLineNo">2004</span> * Effectively disables, deletes, and recreates the table.<a name="line.2004"></a> -<span class="sourceLineNo">2005</span> * @param tableName table which must exist.<a name="line.2005"></a> -<span class="sourceLineNo">2006</span> * @param preserveRegions keep the existing split points<a name="line.2006"></a> -<span class="sourceLineNo">2007</span> * @return HTable for the new table<a name="line.2007"></a> -<span class="sourceLineNo">2008</span> */<a name="line.2008"></a> -<span class="sourceLineNo">2009</span> public Table truncateTable(final TableName tableName, final boolean preserveRegions) throws<a name="line.2009"></a> -<span class="sourceLineNo">2010</span> IOException {<a name="line.2010"></a> -<span class="sourceLineNo">2011</span> Admin admin = getAdmin();<a name="line.2011"></a> -<span class="sourceLineNo">2012</span> if (!admin.isTableDisabled(tableName)) {<a name="line.2012"></a> -<span class="sourceLineNo">2013</span> admin.disableTable(tableName);<a name="line.2013"></a> +<span class="sourceLineNo">1837</span> @
<TRUNCATED>