Skip to content

Commit

Permalink
Migrate Connector.beginTransaction() implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Nov 17, 2021
1 parent ab22da1 commit bfcb5e8
Show file tree
Hide file tree
Showing 37 changed files with 48 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static Connector createTestSessionConnector()
return new Connector()
{
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new ConnectorTransactionHandle() {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface InternalConnector
extends Connector
{
@Override
default ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
default ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class MockConnector
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return MockConnectorTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void setUp()
Connector systemRoleConnector = new Connector()
{
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new ConnectorTransactionHandle() {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5328,7 +5328,7 @@ private static Connector createTestingConnector()
private final ConnectorMetadata metadata = new TestingMetadata();

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new ConnectorTransactionHandle() {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private static Connector createTestingConnector()
private final ConnectorMetadata metadata = new TestingMetadata();

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new ConnectorTransactionHandle() {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandl
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
ConnectorTransactionHandle transaction = new AccumuloTransactionHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public AtopConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return AtopTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public JdbcConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
JdbcTransactionHandle transaction = new JdbcTransactionHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public BigQueryConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
log.debug("beginTransaction(isolationLevel=%s, readOnly=%s)", isolationLevel, readOnly);
checkConnectorSupports(READ_COMMITTED, isolationLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public BlackHoleConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return BlackHoleTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public CassandraConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
return CassandraTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ElasticsearchConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return ElasticsearchTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ExampleConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public SheetsConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public ConnectorAccessControl getAccessControl()
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(SERIALIZABLE, isolationLevel);
ConnectorTransactionHandle transaction = new HiveTransactionHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public JmxRecordSetProvider getRecordSetProvider()
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return JmxTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public KafkaConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return KafkaTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandl
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean b)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return KinesisTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testCreateConnector()
ConnectorMetadata md = c.getMetadata(KinesisTransactionHandle.INSTANCE);
assertNotNull(md);

ConnectorTransactionHandle handle = c.beginTransaction(READ_COMMITTED, true);
ConnectorTransactionHandle handle = c.beginTransaction(READ_COMMITTED, true, true);
assertTrue(handle instanceof KinesisTransactionHandle);

c.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public KuduConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return KuduTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public LocalFileConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return LocalFileTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MemoryConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return MemoryTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public MongoConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
MongoTransactionHandle transaction = new MongoTransactionHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public PhoenixConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new JdbcTransactionHandle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public PhoenixConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return new JdbcTransactionHandle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PinotConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return PinotTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public PrometheusConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void start()
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
RaptorTransactionHandle transaction = new RaptorTransactionHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ public void testMaintenanceBlocked()
assertFalse(metadataDao.isMaintenanceBlockedLocked(tableId2));

// begin delete for table1
ConnectorTransactionHandle txn1 = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle txn1 = beginTransaction();
ConnectorTableHandle handle1 = getTableHandle(connector.getMetadata(txn1), "test1");
connector.getMetadata(txn1).beginDelete(SESSION, handle1);

assertTrue(metadataDao.isMaintenanceBlockedLocked(tableId1));
assertFalse(metadataDao.isMaintenanceBlockedLocked(tableId2));

// begin delete for table2
ConnectorTransactionHandle txn2 = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle txn2 = beginTransaction();
ConnectorTableHandle handle2 = getTableHandle(connector.getMetadata(txn2), "test2");
connector.getMetadata(txn2).beginDelete(SESSION, handle2);

assertTrue(metadataDao.isMaintenanceBlockedLocked(tableId1));
assertTrue(metadataDao.isMaintenanceBlockedLocked(tableId2));

// begin another delete for table1
ConnectorTransactionHandle txn3 = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle txn3 = beginTransaction();
ConnectorTableHandle handle3 = getTableHandle(connector.getMetadata(txn3), "test1");
connector.getMetadata(txn3).beginDelete(SESSION, handle3);

Expand Down Expand Up @@ -214,7 +214,7 @@ private void assertSplitShard(Type temporalType, String min, String max, int exp
.setPropertyMetadata(new RaptorSessionProperties(new StorageManagerConfig()).getSessionProperties())
.build();

ConnectorTransactionHandle transaction = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle transaction = beginTransaction();
connector.getMetadata(transaction).createTable(
SESSION,
new ConnectorTableMetadata(
Expand All @@ -224,7 +224,7 @@ private void assertSplitShard(Type temporalType, String min, String max, int exp
false);
connector.commit(transaction);

ConnectorTransactionHandle txn1 = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle txn1 = beginTransaction();
ConnectorTableHandle handle1 = getTableHandle(connector.getMetadata(txn1), "test");
ConnectorInsertTableHandle insertTableHandle = connector.getMetadata(txn1).beginInsert(session, handle1);
ConnectorPageSink raptorPageSink = connector.getPageSinkProvider().createPageSink(txn1, session, insertTableHandle);
Expand Down Expand Up @@ -256,7 +256,7 @@ else if (temporalType.equals(DATE)) {

private long createTable(String name)
{
ConnectorTransactionHandle transaction = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTransactionHandle transaction = beginTransaction();
connector.getMetadata(transaction).createTable(
SESSION,
new ConnectorTableMetadata(
Expand All @@ -265,12 +265,17 @@ private long createTable(String name)
false);
connector.commit(transaction);

transaction = connector.beginTransaction(READ_COMMITTED, false);
transaction = beginTransaction();
ConnectorTableHandle tableHandle = getTableHandle(connector.getMetadata(transaction), name);
connector.commit(transaction);
return ((RaptorTableHandle) tableHandle).getTableId();
}

private ConnectorTransactionHandle beginTransaction()
{
return connector.beginTransaction(READ_COMMITTED, false, true);
}

private static ConnectorTableHandle getTableHandle(ConnectorMetadata metadata, String name)
{
return metadata.getTableHandle(SESSION, new SchemaTableName("test", name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public RedisConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
return RedisTransactionHandle.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ThriftConnector(
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return ThriftTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
return new Connector()
{
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return TpcdsTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Connector create(String catalogName, Map<String, String> properties, Conn
return new Connector()
{
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return TpchTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Connector create(String catalogName, Map<String, String> properties, Conn
return new Connector()
{
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return TpchTransactionHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private TestConnector(ConnectorMetadata metadata)
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return TestingTransactionHandle.create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private TestConnector(ConnectorMetadata metadata)
}

@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
return TestingTransactionHandle.create();
}
Expand Down

0 comments on commit bfcb5e8

Please sign in to comment.