io.prestosql.spi.transaction.IsolationLevel Java Examples
The following examples show how to use
io.prestosql.spi.transaction.IsolationLevel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestingSession.java From presto with Apache License 2.0 | 6 votes |
private static Connector createTestSessionConnector() { return new Connector() { @Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return new ConnectorTransactionHandle() {}; } @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) { return new SystemTablesMetadata(new StaticSystemTablesProvider(ImmutableSet.of())); } }; }
Example #2
Source File: TransactionInfo.java From presto with Apache License 2.0 | 6 votes |
public TransactionInfo( TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext, DateTime createTime, Duration idleTime, List<CatalogName> catalogNames, Optional<CatalogName> writtenConnectorId) { this.transactionId = requireNonNull(transactionId, "transactionId is null"); this.isolationLevel = requireNonNull(isolationLevel, "isolationLevel is null"); this.readOnly = readOnly; this.autoCommitContext = autoCommitContext; this.createTime = requireNonNull(createTime, "createTime is null"); this.idleTime = requireNonNull(idleTime, "idleTime is null"); this.catalogNames = ImmutableList.copyOf(requireNonNull(catalogNames, "connectorIds is null")); this.writtenConnectorId = requireNonNull(writtenConnectorId, "writtenConnectorId is null"); }
Example #3
Source File: TestStartTransactionTask.java From presto with Apache License 2.0 | 6 votes |
@Test public void testStartTransactionExplicitModes() { Session session = sessionBuilder() .setClientTransactionSupport() .build(); TransactionManager transactionManager = createTestTransactionManager(); QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager); assertFalse(stateMachine.getSession().getTransactionId().isPresent()); getFutureValue(new StartTransactionTask().execute( new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList())); assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent()); assertEquals(transactionManager.getAllTransactionInfos().size(), 1); TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get()); assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE); assertTrue(transactionInfo.isReadOnly()); assertFalse(transactionInfo.isAutoCommitContext()); }
Example #4
Source File: TpcdsConnectorFactory.java From presto with Apache License 2.0 | 5 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { int splitsPerNode = getSplitsPerNode(config); NodeManager nodeManager = context.getNodeManager(); return new Connector() { @Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return TpcdsTransactionHandle.INSTANCE; } @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) { return new TpcdsMetadata(); } @Override public ConnectorSplitManager getSplitManager() { return new TpcdsSplitManager(nodeManager, splitsPerNode, isWithNoSexism(config)); } @Override public ConnectorRecordSetProvider getRecordSetProvider() { return new TpcdsRecordSetProvider(); } @Override public ConnectorNodePartitioningProvider getNodePartitioningProvider() { return new TpcdsNodePartitioningProvider(nodeManager, splitsPerNode); } }; }
Example #5
Source File: MongoConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_UNCOMMITTED, isolationLevel); MongoTransactionHandle transaction = new MongoTransactionHandle(); transactions.put(transaction, new MongoMetadata(mongoSession)); return transaction; }
Example #6
Source File: RaptorConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); RaptorTransactionHandle transaction = new RaptorTransactionHandle(); transactions.put(transaction, metadataFactory.create(tableId -> beginDelete(tableId, transaction.getUuid()))); return transaction; }
Example #7
Source File: TestAnalyzer.java From presto with Apache License 2.0 | 5 votes |
private static Connector createTestingConnector() { return new Connector() { private final ConnectorMetadata metadata = new TestingMetadata(); @Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return new ConnectorTransactionHandle() {}; } @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) { return metadata; } @Override public List<PropertyMetadata<?>> getAnalyzeProperties() { return ImmutableList.of( stringProperty("p1", "test string property", "", false), integerProperty("p2", "test integer property", 0, false)); } }; }
Example #8
Source File: IcebergConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); ConnectorTransactionHandle transaction = new HiveTransactionHandle(); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) { transactionManager.put(transaction, metadataFactory.create()); } return transaction; }
Example #9
Source File: InMemoryTransactionManager.java From presto with Apache License 2.0 | 5 votes |
@Override public TransactionId beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext) { TransactionId transactionId = TransactionId.create(); BoundedExecutor executor = new BoundedExecutor(finishingExecutor, maxFinishingConcurrency); TransactionMetadata transactionMetadata = new TransactionMetadata(transactionId, isolationLevel, readOnly, autoCommitContext, catalogManager, executor); checkState(transactions.put(transactionId, transactionMetadata) == null, "Duplicate transaction ID: %s", transactionId); return transactionId; }
Example #10
Source File: BigQueryConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { log.debug("beginTransaction(isolationLevel=%s, readOnly=%s)", isolationLevel, readOnly); checkConnectorSupports(READ_COMMITTED, isolationLevel); return BigQueryTransactionHandle.INSTANCE; }
Example #11
Source File: InMemoryTransactionManager.java From presto with Apache License 2.0 | 5 votes |
public TransactionMetadata( TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext, CatalogManager catalogManager, Executor finishingExecutor) { this.transactionId = requireNonNull(transactionId, "transactionId is null"); this.isolationLevel = requireNonNull(isolationLevel, "isolationLevel is null"); this.readOnly = readOnly; this.autoCommitContext = autoCommitContext; this.catalogManager = requireNonNull(catalogManager, "catalogManager is null"); this.finishingExecutor = listeningDecorator(ExecutorServiceAdapter.from(requireNonNull(finishingExecutor, "finishingExecutor is null"))); }
Example #12
Source File: JdbcConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); JdbcTransactionHandle transaction = new JdbcTransactionHandle(); transactions.put(transaction, jdbcMetadataFactory.create()); return transaction; }
Example #13
Source File: AccumuloConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_UNCOMMITTED, isolationLevel); ConnectorTransactionHandle transaction = new AccumuloTransactionHandle(); transactions.put(transaction, metadataFactory.create()); return transaction; }
Example #14
Source File: StartTransactionTask.java From presto with Apache License 2.0 | 5 votes |
@Override public ListenableFuture<?> execute(StartTransaction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters) { Session session = stateMachine.getSession(); if (!session.isClientTransactionSupport()) { throw new PrestoException(StandardErrorCode.INCOMPATIBLE_CLIENT, "Client does not support transactions"); } if (session.getTransactionId().isPresent()) { throw new PrestoException(StandardErrorCode.NOT_SUPPORTED, "Nested transactions not supported"); } Optional<IsolationLevel> isolationLevel = extractIsolationLevel(statement); Optional<Boolean> readOnly = extractReadOnly(statement); TransactionId transactionId = transactionManager.beginTransaction( isolationLevel.orElse(TransactionManager.DEFAULT_ISOLATION), readOnly.orElse(TransactionManager.DEFAULT_READ_ONLY), false); stateMachine.setStartedTransactionId(transactionId); // Since the current session does not contain this new transaction ID, we need to manually mark it as inactive // when this statement completes. transactionManager.trySetInactive(transactionId); return immediateFuture(null); }
Example #15
Source File: HiveConnector.java From presto with Apache License 2.0 | 5 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_UNCOMMITTED, isolationLevel); ConnectorTransactionHandle transaction = new HiveTransactionHandle(); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { transactionManager.put(transaction, metadataFactory.create()); } return transaction; }
Example #16
Source File: StartTransactionTask.java From presto with Apache License 2.0 | 5 votes |
private static Optional<IsolationLevel> extractIsolationLevel(StartTransaction startTransaction) { if (startTransaction.getTransactionModes().stream() .filter(Isolation.class::isInstance) .count() > 1) { throw semanticException(SYNTAX_ERROR, startTransaction, "Multiple transaction isolation levels specified"); } return startTransaction.getTransactionModes().stream() .filter(Isolation.class::isInstance) .map(Isolation.class::cast) .map(Isolation::getLevel) .map(StartTransactionTask::convertLevel) .findFirst(); }
Example #17
Source File: StartTransactionTask.java From presto with Apache License 2.0 | 5 votes |
private static IsolationLevel convertLevel(Isolation.Level level) { switch (level) { case SERIALIZABLE: return IsolationLevel.SERIALIZABLE; case REPEATABLE_READ: return IsolationLevel.REPEATABLE_READ; case READ_COMMITTED: return IsolationLevel.READ_COMMITTED; case READ_UNCOMMITTED: return IsolationLevel.READ_UNCOMMITTED; default: throw new AssertionError("Unhandled isolation level: " + level); } }
Example #18
Source File: TestingTransactionManager.java From presto with Apache License 2.0 | 5 votes |
@Override public TransactionInfo getTransactionInfo(TransactionId transactionId) { checkArgument(transactions.containsKey(transactionId), "Unknown transaction"); return new TransactionInfo( transactionId, IsolationLevel.READ_UNCOMMITTED, false, //read only false, // auto commit DateTime.now(), // created Duration.succinctNanos(0), // idle ImmutableList.of(), // catalogs Optional.empty()); // write catalog }
Example #19
Source File: MockConnectorFactory.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return new ConnectorTransactionHandle() {}; }
Example #20
Source File: ElasticsearchConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); return ElasticsearchTransactionHandle.INSTANCE; }
Example #21
Source File: TestingTransactionManager.java From presto with Apache License 2.0 | 4 votes |
@Override public TransactionId beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext) { return beginTransaction(autoCommitContext); }
Example #22
Source File: MemoryConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return MemoryTransactionHandle.INSTANCE; }
Example #23
Source File: TpchConnectorFactory.java From presto with Apache License 2.0 | 4 votes |
@Override public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) { int splitsPerNode = getSplitsPerNode(properties); ColumnNaming columnNaming = ColumnNaming.valueOf(properties.getOrDefault(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.SIMPLIFIED.name()).toUpperCase()); NodeManager nodeManager = context.getNodeManager(); return new Connector() { @Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return TpchTransactionHandle.INSTANCE; } @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) { return new TpchMetadata(columnNaming, predicatePushdownEnabled, partitioningEnabled); } @Override public ConnectorSplitManager getSplitManager() { return new TpchSplitManager(nodeManager, splitsPerNode); } @Override public ConnectorPageSourceProvider getPageSourceProvider() { if (isProducePages(properties)) { return new TpchPageSourceProvider(getMaxRowsPerPage(properties)); } throw new UnsupportedOperationException(); } @Override public ConnectorRecordSetProvider getRecordSetProvider() { if (!isProducePages(properties)) { return new TpchRecordSetProvider(); } throw new UnsupportedOperationException(); } @Override public ConnectorNodePartitioningProvider getNodePartitioningProvider() { return new TpchNodePartitioningProvider(nodeManager, splitsPerNode); } }; }
Example #24
Source File: GlobalSystemConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly) { return new GlobalSystemTransactionHandle(transactionId); }
Example #25
Source File: ThriftConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return ThriftTransactionHandle.INSTANCE; }
Example #26
Source File: LocalFileConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); return LocalFileTransactionHandle.INSTANCE; }
Example #27
Source File: CassandraConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_UNCOMMITTED, isolationLevel); return CassandraTransactionHandle.INSTANCE; }
Example #28
Source File: KuduConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { checkConnectorSupports(READ_COMMITTED, isolationLevel); return KuduTransactionHandle.INSTANCE; }
Example #29
Source File: KinesisConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean b) { checkConnectorSupports(READ_COMMITTED, isolationLevel); return KinesisTransactionHandle.INSTANCE; }
Example #30
Source File: SheetsConnector.java From presto with Apache License 2.0 | 4 votes |
@Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return INSTANCE; }