--
You received this message because you are subscribed to the Google Groups "Tephra User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user...@googlegroups.com.
To post to this group, send email to tephr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/c3c18ecd-2cb6-4593-8d65-5126e66d3d1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Mar 28, 2016, at 10:36 PM, jinge...@gmail.com wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/973c266e-1e1d-4e3e-b71f-ffdd2882a5f5%40googlegroups.com.
0. tephra instance is running in hbase master's box.
1. setting hbase-site.xml
<!-- tephra -->
<property>
<name>data.tx.snapshot.dir</name>
<value>/snapshot</value>
</property>
<property>
<name>hbase.coprocessor.region.classes</name>
<value>co.cask.tephra.hbase10cdh.coprocessor.TransactionProcessor</value>
</property>
2. copy some jars to ${HBASE_HOME}/lib
tephra-core-0.7.0.jar
tephra-api-0.7.0.jar
tephra-hbase-compat-1.0-cdh-0.7.0.jar
twill-zookeeper-0.6.0-incubating.jar
twill-core-0.6.0-incubating.jar
twill-discovery-api-0.6.0-incubating.jar
twill-discovery-core-0.6.0-incubating.jar
twill-api-0.6.0-incubating.jar
twill-common-0.6.0-incubating.jar
3. create a table
HBaseAdmin hBaseAdmin = new HBaseAdmin(hTable.getConfiguration());
HTableDescriptor table = new HTableDescriptor("testtable");
HColumnDescriptor family = new HColumnDescriptor("d");
table.addFamily(family);
hBaseAdmin.createTable(table);
hBaseAdmin.close();
4. TransactionServiceBean
@PostConstruct
public void setup() throws IOException {
System.setProperty("hadoop.home.dir", "/");
conf = new ConfigurationFactory().get();
conf.set(TxConstants.Manager.CFG_TX_HDFS_USER, "hadoop");
conf.setInt(TxConstants.Manager.CFG_TX_LONG_TIMEOUT, 2);
Injector injector = Guice.createInjector(
new ConfigModule(conf),
new ZKModule(),
new DiscoveryModules().getDistributedModules(),
new TransactionModules().getDistributedModules(),
new TransactionClientModule()
);
ZKClientService zkClient = injector.getInstance(ZKClientService.class);
zkClient.startAndWait();
provider = new PooledClientProvider(conf, injector.getInstance(DiscoveryServiceClient.class));
}
HTable hTable = new HTable(conf, tableName.getBytes());
TransactionAwareHTable txTable = new TransactionAwareHTable(hTable, TxConstants.ConflictDetection.COLUMN, false);
txContext = new TransactionContext(new TransactionServiceClient(conf, provider), txTable);
4. put a cell
// hbase put logic
txContext.start();
Put put = new Put(row.getBytes());
values.forEach(value -> put.addColumn(value.family(), value.qualifier(), value.value()));
transactionAwareHTable.put(put);
txContext.finish();
5. delete a cell
// hbase delete logic
txContext.start();
Delete delete = new Delete(row.getBytes());
delete.addColumns(family.getBytes(), qualifier.getBytes());
transactionAwareHTable.delete(delete);
txContext.finish();
6. run major_compact in hbase-shell
hbase(main):005:0> major_compact 'testtable'
0 row(s) in 0.1630 seconds
7. scan
hbase(main):006:0> scan 'testtable'
ROW COLUMN+CELL
row row column=d:a, timestamp=1459242025562000000, value=
Thanks,
jingene.
coprocessor>INFO [RS_OPEN_REGION-dev-keephd004:60020-1] coprocessor.CoprocessorHost: System coprocessor co.cask.tephra.hbase10cdh.coprocessor.TransactionProcessor was loaded successfully with priority (536870911).Thanks,
jingene.
--
You received this message because you are subscribed to the Google Groups "Tephra User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user...@googlegroups.com.
To post to this group, send email to tephr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/b2229b9d-582f-4461-a10c-d0c8c78330b3%40googlegroups.com.