forked from larsgeorge/hbase-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upped to HBase 1.2.1 and Hadoop 2.7.1
- Loading branch information
1 parent
cbb4bd0
commit 3cf7498
Showing
6 changed files
with
81 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
ch09/src/main/java/transactions/MultiRowMutationExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package transactions; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.Coprocessor; | ||
import org.apache.hadoop.hbase.HBaseConfiguration; | ||
import org.apache.hadoop.hbase.HColumnDescriptor; | ||
import org.apache.hadoop.hbase.HTableDescriptor; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.Admin; | ||
import org.apache.hadoop.hbase.client.Connection; | ||
import org.apache.hadoop.hbase.client.ConnectionFactory; | ||
|
||
import util.HBaseHelper; | ||
|
||
// cc LoadWithTableDescriptorExample2 Load a coprocessor using the table descriptor using provided method | ||
public class MultiRowMutationExample { | ||
|
||
public static void main(String[] args) throws IOException { | ||
Configuration conf = HBaseConfiguration.create(); | ||
Connection connection = ConnectionFactory.createConnection(conf); | ||
HBaseHelper helper = HBaseHelper.getHelper(conf); | ||
helper.dropTable("testtable"); | ||
TableName tableName = TableName.valueOf("testtable"); | ||
|
||
// vv LoadWithTableDescriptorExample2 | ||
HTableDescriptor htd = new HTableDescriptor(tableName) // co LoadWithTableDescriptorExample2-1-Create Use fluent interface to create and configure the instance. | ||
.addFamily(new HColumnDescriptor("colfam1")) | ||
/*[*/.addCoprocessor(RegionObserverExample.class.getCanonicalName(), | ||
null, Coprocessor.PRIORITY_USER, null);/*]*/ // co LoadWithTableDescriptorExample2-2-AddCP Use the provided method to add the coprocessor. | ||
|
||
Admin admin = connection.getAdmin(); | ||
admin.createTable(htd); | ||
// ^^ LoadWithTableDescriptorExample2 | ||
|
||
System.out.println(admin.getTableDescriptor(tableName)); | ||
admin.close(); | ||
connection.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters