use of org.apache.tephra.Transaction in project cdap by caskdata.
the class ExploreExtensiveSchemaTableTestRun method start.
@BeforeClass
public static void start() throws Exception {
initialize(tmpFolder);
datasetFramework.addModule(extensiveSchema, new ExtensiveSchemaTableDefinition.ExtensiveSchemaTableModule());
// Performing admin operations to create dataset instance
datasetFramework.addInstance("ExtensiveSchemaTable", MY_TABLE, DatasetProperties.EMPTY);
// Accessing dataset instance to perform data operations
ExtensiveSchemaTableDefinition.ExtensiveSchemaTable table = datasetFramework.getDataset(MY_TABLE, DatasetDefinition.NO_ARGUMENTS, null);
Assert.assertNotNull(table);
Transaction tx1 = transactionManager.startShort(100);
table.startTx(tx1);
ExtensiveSchemaTableDefinition.ExtensiveSchema value1 = new ExtensiveSchemaTableDefinition.ExtensiveSchema("foo", 1, 1.23f, 2.45d, (long) 1000, (byte) 100, true, (short) 8, new int[] { 10, 11 }, new float[] { 1.67f, 2.89f }, new double[] { 10.56d, 8.78d }, new long[] { 101, 201 }, new byte[] { 106, 110 }, new boolean[] { true, false }, new short[] { 50, 51 }, new String[] { "foo", "bar" }, ImmutableList.of(10, 20), ImmutableList.of(10.45f, 20.98f), ImmutableList.of(10.99d, 20.90d), ImmutableList.of((long) 654, (long) 2897), ImmutableList.of((byte) 22, (byte) 23), ImmutableList.of(true, true), ImmutableList.of((short) 76, (short) 39), ImmutableList.of("foo2", "bar2"), ImmutableMap.of("foo3", 51), ImmutableMap.of(3.55f, 51.98d), ImmutableMap.of((long) 890, (byte) 45), ImmutableMap.of(true, (short) 27), new ExtensiveSchemaTableDefinition.Value("foo", 2), new ExtensiveSchemaTableDefinition.Value[] { new ExtensiveSchemaTableDefinition.Value("bar", 3), new ExtensiveSchemaTableDefinition.Value("foobar", 4) }, ImmutableList.of(new ExtensiveSchemaTableDefinition.Value("foobar2", 3)), ImmutableMap.of("key", new ExtensiveSchemaTableDefinition.Value("foobar3", 9)), 42L);
value1.setExt(value1);
table.put("1", value1);
Assert.assertTrue(table.commitTx());
transactionManager.canCommit(tx1.getTransactionId(), table.getTxChanges());
transactionManager.commit(tx1.getTransactionId(), tx1.getWritePointer());
table.postTxCommit();
Transaction tx2 = transactionManager.startShort(100);
table.startTx(tx2);
}
use of org.apache.tephra.Transaction in project cdap by caskdata.
the class HiveExploreServiceTestRun method testTable.
@Test
public void testTable() throws Exception {
KeyStructValueTableDefinition.KeyStructValueTable table = datasetFramework.getDataset(MY_TABLE, DatasetDefinition.NO_ARGUMENTS, null);
Assert.assertNotNull(table);
Transaction tx = transactionManager.startShort(100);
table.startTx(tx);
Assert.assertEquals(new KeyValue.Value("first", Lists.newArrayList(1, 2, 3, 4, 5)), table.get("1"));
transactionManager.abort(tx);
}
use of org.apache.tephra.Transaction in project cdap by caskdata.
the class HiveExploreServiceTestRun method start.
@BeforeClass
public static void start() throws Exception {
initialize(tmpFolder);
datasetFramework.addModule(KEY_STRUCT_VALUE, new KeyStructValueTableDefinition.KeyStructValueTableModule());
datasetFramework.addModule(OTHER_KEY_STRUCT_VALUE, new KeyStructValueTableDefinition.KeyStructValueTableModule());
// Performing admin operations to create dataset instance
datasetFramework.addInstance("keyStructValueTable", MY_TABLE, DatasetProperties.EMPTY);
datasetFramework.addInstance("keyStructValueTable", OTHER_MY_TABLE, DatasetProperties.EMPTY);
// Accessing dataset instance to perform data operations
KeyStructValueTableDefinition.KeyStructValueTable table = datasetFramework.getDataset(MY_TABLE, DatasetDefinition.NO_ARGUMENTS, null);
Assert.assertNotNull(table);
Transaction tx1 = transactionManager.startShort(100);
table.startTx(tx1);
KeyValue.Value value1 = new KeyValue.Value("first", Lists.newArrayList(1, 2, 3, 4, 5));
KeyValue.Value value2 = new KeyValue.Value("two", Lists.newArrayList(10, 11, 12, 13, 14));
table.put("1", value1);
table.put("2", value2);
Assert.assertEquals(value1, table.get("1"));
Assert.assertTrue(table.commitTx());
transactionManager.canCommit(tx1.getTransactionId(), table.getTxChanges());
transactionManager.commit(tx1.getTransactionId(), tx1.getWritePointer());
table.postTxCommit();
Transaction tx2 = transactionManager.startShort(100);
table.startTx(tx2);
Assert.assertEquals(value1, table.get("1"));
}
use of org.apache.tephra.Transaction in project cdap by caskdata.
the class ExploreDisabledTest method testDeployRecordScannable.
@Test
public void testDeployRecordScannable() throws Exception {
// Try to deploy a dataset that is not record scannable, when explore is enabled.
// This should be processed with no exception being thrown
DatasetModuleId module1 = new DatasetModuleId(namespaceId.getNamespace(), "module1");
DatasetId instance1 = namespaceId.dataset("table1");
datasetFramework.addModule(module1, new KeyStructValueTableDefinition.KeyStructValueTableModule());
// Performing admin operations to create dataset instance
datasetFramework.addInstance("keyStructValueTable", instance1, DatasetProperties.EMPTY);
Transaction tx1 = transactionManager.startShort(100);
// Accessing dataset instance to perform data operations
KeyStructValueTableDefinition.KeyStructValueTable table = datasetFramework.getDataset(instance1, DatasetDefinition.NO_ARGUMENTS, null);
Assert.assertNotNull(table);
table.startTx(tx1);
KeyStructValueTableDefinition.KeyValue.Value value1 = new KeyStructValueTableDefinition.KeyValue.Value("first", Lists.newArrayList(1, 2, 3, 4, 5));
KeyStructValueTableDefinition.KeyValue.Value value2 = new KeyStructValueTableDefinition.KeyValue.Value("two", Lists.newArrayList(10, 11, 12, 13, 14));
table.put("1", value1);
table.put("2", value2);
Assert.assertEquals(value1, table.get("1"));
Assert.assertTrue(table.commitTx());
transactionManager.canCommit(tx1.getTransactionId(), table.getTxChanges());
transactionManager.commit(tx1.getTransactionId(), tx1.getWritePointer());
table.postTxCommit();
Transaction tx2 = transactionManager.startShort(100);
table.startTx(tx2);
Assert.assertEquals(value1, table.get("1"));
datasetFramework.deleteInstance(instance1);
datasetFramework.deleteModule(module1);
}
use of org.apache.tephra.Transaction in project cdap by caskdata.
the class LevelDBQueueTest method forceEviction.
@Override
protected void forceEviction(QueueName queueName, int numGroups) throws Exception {
QueueEvictor evictor = ((LevelDBQueueClientFactory) queueClientFactory).createEvictor(queueName, numGroups);
Transaction tx = txSystemClient.startShort();
// There is no change, just to get the latest transaction for eviction
txSystemClient.commitOrThrow(tx);
Uninterruptibles.getUninterruptibly(evictor.evict(tx));
}
Aggregations