phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twdsilva <...@git.apache.org>
Subject [GitHub] phoenix pull request #418: [PHOENIX-3623] Integrate Omid with Phoenix.
Date Tue, 18 Dec 2018 18:25:15 GMT
Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/418#discussion_r242648708
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
---
    @@ -63,26 +83,106 @@ public PhoenixTransactionContext getTransactionContext(PhoenixConnection
connect
     
         @Override
         public PhoenixTransactionClient getTransactionClient(Configuration config, ConnectionInfo
connectionInfo) throws SQLException{
    -        return new OmidTransactionClient();
    +        if (transactionManager == null) {
    +            try {
    +                HBaseOmidClientConfiguration clientConf = new HBaseOmidClientConfiguration();
    +                clientConf.setConflictAnalysisLevel(OmidClientConfiguration.ConflictDetectionLevel.ROW);
    +                transactionManager = (HBaseTransactionManager) HBaseTransactionManager.newInstance(clientConf);
    +            } catch (IOException | InterruptedException e) {
    +                throw new SQLExceptionInfo.Builder(
    +                        SQLExceptionCode.TRANSACTION_FAILED)
    +                        .setMessage(e.getMessage()).setRootCause(e).build()
    +                        .buildException();
    +            }
    +        }
    +
    +        return new OmidTransactionClient(transactionManager);
         }
     
         static class OmidTransactionClient implements PhoenixTransactionClient {
    +        private final HBaseTransactionManager transactionManager;
    +
    +        public OmidTransactionClient(HBaseTransactionManager transactionManager) {
    +            this.transactionManager = transactionManager;
    +        }
    +
    +        public HBaseTransactionManager getTransactionClient() {
    +            return transactionManager;
    +        }
    +
             @Override
             public void close() throws IOException {}
         }
     
    +    // For testing only
    +    public CommitTable.Client getCommitTableClient() {
    +        return commitTableClient;
    +    }
    +    
         @Override
         public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo
connectionInfo, int port) throws  SQLException{
    -        return new OmidTransactionService();
    +        TSOServerConfig tsoConfig = new TSOServerConfig();
    +        TSOServer tso;
    +
    +        tsoConfig.setPort(port);
    +        tsoConfig.setConflictMapSize(config.getInt(OMID_TSO_CONFLICT_MAP_SIZE, DEFAULT_OMID_TSO_CONFLICT_MAP_SIZE));
    +        tsoConfig.setTimestampType(config.get(OMID_TSO_TIMESTAMP_TYPE, DEFAULT_OMID_TSO_TIMESTAMP_TYPE));
    +
    +        Injector injector = Guice.createInjector(new TSOMockModule(tsoConfig));
    +        tso = injector.getInstance(TSOServer.class);
    +        tso.startAndWait();
    +
    +        OmidClientConfiguration clientConfig = new OmidClientConfiguration();
    +        clientConfig.setConnectionString("localhost:" + port);
    +        clientConfig.setConflictAnalysisLevel(OmidClientConfiguration.ConflictDetectionLevel.ROW);
    +
    +        InMemoryCommitTable commitTable = (InMemoryCommitTable) injector.getInstance(CommitTable.class);
    --- End diff --
    
    Do we always use an InMemoryCommitTable? or is this just for tests?


---

Mime
View raw message