Java 类com.facebook.presto.spi.transaction.IsolationLevel 实例源码

项目:presto    文件:TestAccessControlManager.java   
private static void registerBogusConnector(TransactionManager transactionManager, String connectorId)
{
    transactionManager.addConnector(connectorId, new Connector()
    {
        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
        {
            // Just return something
            return new ConnectorTransactionHandle() {};
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
        {
            throw new UnsupportedOperationException();
        }

        @Override
        public ConnectorSplitManager getSplitManager()
        {
            throw new UnsupportedOperationException();
        }
    });
}
项目:presto    文件:TestStartTransactionTask.java   
@Test
public void testStartTransactionExplicitModes()
        throws Exception
{
    Session session = sessionBuilder()
            .setClientTransactionSupport()
            .build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "START TRANSACTION", session, URI.create("fake://uri"), true, transactionManager, executor);
    Assert.assertFalse(stateMachine.getSession().getTransactionId().isPresent());

    new StartTransactionTask().execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine).join();
    Assert.assertFalse(stateMachine.getQueryInfoWithoutDetails().isClearTransactionId());
    Assert.assertTrue(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().isPresent());
    Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);

    TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().get());
    Assert.assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
    Assert.assertTrue(transactionInfo.isReadOnly());
    Assert.assertFalse(transactionInfo.isAutoCommitContext());
}
项目:rakam    文件:ExpressionCompiler.java   
@Inject
public ExpressionCompiler() {
    TransactionManager transactionManager = TransactionManager.createTestTransactionManager();
    Metadata metadata = MetadataManager.createTestMetadataManager();

    this.serde = metadata.getBlockEncodingSerde();
    this.metadata = metadata;
    this.featuresConfig = new FeaturesConfig();
    this.typeManager = metadata.getTypeManager();
    this.session = Session.builder(new SessionPropertyManager())
            .setIdentity(new Identity("user", Optional.empty()))
            .setTimeZoneKey(TimeZoneKey.UTC_KEY)
            .setLocale(Locale.ENGLISH)
            .setQueryId(QueryId.valueOf("row_expression_compiler"))
            .setTransactionId(transactionManager.beginTransaction(IsolationLevel.REPEATABLE_READ, true, true))
            .build();

    this.expressionOptimizer = new ExpressionOptimizer(metadata.getFunctionRegistry(), metadata.getTypeManager(), session);

}
项目:paraflow    文件:HDFSConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
    HDFSTransactionHandle transaction = new HDFSTransactionHandle();
    transactions.putIfAbsent(transaction, hdfsMetadataFactory.create());
    return transaction;
}
项目:presto    文件:JmxConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> properties)
{
    return new Connector()
    {
        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
        {
            checkConnectorSupports(READ_COMMITTED, isolationLevel);
            return JmxTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
        {
            return new JmxMetadata(connectorId, mbeanServer);
        }

        @Override
        public ConnectorSplitManager getSplitManager()
        {
            return new JmxSplitManager(connectorId, nodeManager);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider()
        {
            return new JmxRecordSetProvider(mbeanServer, nodeManager.getCurrentNode().getNodeIdentifier());
        }
    };
}
项目:presto    文件:TransactionManager.java   
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, executor);
    checkState(transactions.put(transactionId, transactionMetadata) == null, "Duplicate transaction ID: %s", transactionId);
    return transactionId;
}
项目:presto    文件:TransactionManager.java   
public TransactionMetadata(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext, Executor finishingExecutor)
{
    this.transactionId = requireNonNull(transactionId, "transactionId is null");
    this.isolationLevel = requireNonNull(isolationLevel, "isolationLevel is null");
    this.readOnly = readOnly;
    this.autoCommitContext = autoCommitContext;
    this.finishingExecutor = requireNonNull(finishingExecutor, "finishingExecutor is null");
}
项目:presto    文件:TransactionInfo.java   
public TransactionInfo(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly, boolean autoCommitContext, DateTime createTime, Duration idleTime, List<String> connectorIds, Optional<String> 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.connectorIds = ImmutableList.copyOf(requireNonNull(connectorIds, "connectorIds is null"));
    this.writtenConnectorId = requireNonNull(writtenConnectorId, "writtenConnectorId is null");
}
项目:presto    文件:StartTransactionTask.java   
@Override
public CompletableFuture<?> execute(StartTransaction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
    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 completedFuture(null);
}
项目:presto    文件:StartTransactionTask.java   
private Optional<IsolationLevel> extractIsolationLevel(StartTransaction startTransaction)
{
    if (startTransaction.getTransactionModes().stream()
            .filter(Isolation.class::isInstance)
            .count() > 1) {
        throw new SemanticException(INVALID_TRANSACTION_MODE, 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();
}
项目:presto    文件:StartTransactionTask.java   
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);
    }
}
项目:presto    文件:TpchConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> properties)
{
    int splitsPerNode = getSplitsPerNode(properties);

    return new Connector()
    {
        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
        {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction)
        {
            return new TpchMetadata(connectorId);
        }

        @Override
        public ConnectorSplitManager getSplitManager()
        {
            return new TpchSplitManager(connectorId, nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider()
        {
            return new TpchRecordSetProvider();
        }
    };
}
项目:presto    文件:SampledTpchConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> properties)
{
    requireNonNull(properties, "properties is null");
    int splitsPerNode = getSplitsPerNode(properties);

    return new Connector()
    {
        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
        {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction)
        {
            return new SampledTpchMetadata(connectorId);
        }

        @Override
        public ConnectorSplitManager getSplitManager()
        {
            return new TpchSplitManager(connectorId, nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider()
        {
            return new SampledTpchRecordSetProvider(connectorId, sampleWeight);
        }
    };
}
项目:presto-rest    文件:RestConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    return new RestTransactionHandle(0);
}
项目:presto-ethereum    文件:EthereumConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
    checkConnectorSupports(READ_COMMITTED, isolationLevel);
    return EthereumTransactionHandle.INSTANCE;
}
项目:monarch    文件:AmpoolConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean b)
{
    log.info("INFORMATION: AmpoolConnector beginTransaction() called.");
    return INSTANCE;
}
项目:presto-kudu    文件:KuduConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(READ_COMMITTED, isolationLevel);
    return KuduTransactionHandle.INSTANCE;
}
项目:presto    文件:KafkaConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(READ_COMMITTED, isolationLevel);
    return KafkaTransactionHandle.INSTANCE;
}
项目:presto    文件:RaptorConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(READ_COMMITTED, isolationLevel);
    return new RaptorTransactionHandle();
}
项目:presto    文件:BlackHoleConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    return BlackHoleTransactionHandle.INSTANCE;
}
项目:presto    文件:IndexedTpchConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> properties)
{
    int splitsPerNode = getSplitsPerNode(properties);
    TpchIndexedData indexedData = new TpchIndexedData(connectorId, indexSpec);

    return new Connector()
    {
        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
        {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
        {
            return new TpchIndexMetadata(connectorId, indexedData);
        }

        @Override
        public ConnectorSplitManager getSplitManager()
        {
            return new TpchSplitManager(connectorId, nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider()
        {
            return new TpchRecordSetProvider();
        }

        @Override
        public ConnectorIndexProvider getIndexProvider()
        {
            return new TpchIndexProvider(indexedData);
        }

        @Override
        public Set<SystemTable> getSystemTables()
        {
            return ImmutableSet.of(new ExampleSystemTable());
        }
    };
}
项目:presto    文件:LegacyTransactionConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(connector.getIsolationLevel(), isolationLevel);
    return LegacyTransactionHandle.create(connectorId);
}
项目:presto    文件:TransactionBuilder.java   
public TransactionBuilder withIsolationLevel(IsolationLevel isolationLevel)
{
    this.isolationLevel = requireNonNull(isolationLevel, "isolationLevel is null");
    return this;
}
项目:presto    文件:TransactionBuilder.java   
public TransactionBuilder readUncommitted()
{
    return withIsolationLevel(IsolationLevel.READ_UNCOMMITTED);
}
项目:presto    文件:TransactionBuilder.java   
public TransactionBuilder readCommitted()
{
    return withIsolationLevel(IsolationLevel.READ_COMMITTED);
}
项目:presto    文件:TransactionBuilder.java   
public TransactionBuilder repeatableRead()
{
    return withIsolationLevel(IsolationLevel.REPEATABLE_READ);
}
项目:presto    文件:TransactionBuilder.java   
public TransactionBuilder serializable()
{
    return withIsolationLevel(IsolationLevel.SERIALIZABLE);
}
项目:presto    文件:TransactionInfo.java   
public IsolationLevel getIsolationLevel()
{
    return isolationLevel;
}
项目:presto    文件:InternalConnector.java   
default ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    throw new UnsupportedOperationException();
}
项目:presto    文件:InformationSchemaConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly)
{
    return new InformationSchemaTransactionHandle(transactionId);
}
项目:presto    文件:SystemConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly)
{
    return new SystemTransactionHandle(connectorId, transactionHandleFunction.apply(transactionId));
}
项目:presto    文件:GlobalSystemConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly)
{
    return new GlobalSystemTransactionHandle(connectorId, transactionId);
}
项目:presto    文件:Connector.java   
/**
 * Get the transaction read isolation level supported by this connector.
 */
default IsolationLevel getIsolationLevel()
{
    return IsolationLevel.READ_UNCOMMITTED;
}
项目:presto    文件:CassandraConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
{
    checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
    return CassandraTransactionHandle.INSTANCE;
}
项目:presto-plugins    文件:SpreadsheetConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
  return SpreadsheetTransactionHandle.INSTANCE;
}
项目:presto-kinesis    文件:KinesisConnector.java   
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean b)
{
    checkConnectorSupports(READ_COMMITTED, isolationLevel);
    return KinesisTransactionHandle.INSTANCE;
}
项目:presto    文件:InternalConnector.java   
ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly);
项目:presto    文件:Connector.java   
ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly);