public static Long getTableTimestamp(PhoenixConnection connection, boolean transactional, TransactionFactory.Provider provider) throws SQLException { Long timestamp = null; if (!transactional) { return timestamp; } MutationState mutationState = connection.getMutationState(); if (!mutationState.isTransactionStarted()) { mutationState.startTransaction(provider); } timestamp = convertToMilliseconds(mutationState.getInitialWritePointer()); return timestamp; }
public static long getResolvedTimestamp(PhoenixConnection connection, boolean isTransactional, long defaultResolvedTimestamp) { MutationState mutationState = connection.getMutationState(); Long scn = connection.getSCN(); return scn != null ? scn : (isTransactional && mutationState.isTransactionStarted()) ? convertToMilliseconds(mutationState.getInitialWritePointer()) : defaultResolvedTimestamp; }
public static long getResolvedTimestamp(PhoenixConnection connection, MetaDataMutationResult result) { PTable table = result.getTable(); MutationState mutationState = connection.getMutationState(); boolean txInProgress = table != null && table.isTransactional() && mutationState.isTransactionStarted(); return txInProgress ? convertToMilliseconds(mutationState.getInitialWritePointer()) : result.getMutationTime(); }
public boolean startTransaction(Provider provider) throws SQLException { if (provider == null) { return false; } if (!connection.getQueryServices().getProps() .getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TXN_IF_TXN_DISABLED).build().buildException(); } if (connection.getSCN() != null) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET).build().buildException(); } if (phoenixTransactionContext == PhoenixTransactionContext.NULL_CONTEXT) { phoenixTransactionContext = provider.getTransactionProvider().getTransactionContext(connection); } else { if (provider != phoenixTransactionContext.getProvider()) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_MIX_TXN_PROVIDERS) .setMessage(phoenixTransactionContext.getProvider().name() + " and " + provider.name()).build() .buildException(); } } if (!isTransactionStarted()) { // Clear any transactional state in case transaction was ended outside // of Phoenix so we don't carry the old transaction state forward. We // cannot call reset() here due to the case of having mutations and // then transitioning from non transactional to transactional (which // would end up clearing our uncommitted state). resetTransactionalState(); phoenixTransactionContext.begin(); return true; } return false; }
public static long getResolvedTimestamp(PhoenixConnection connection, boolean isTransactional, long defaultResolvedTimestamp) { MutationState mutationState = connection.getMutationState(); Long scn = connection.getSCN(); return scn != null ? scn : (isTransactional && mutationState.isTransactionStarted()) ? convertToMilliseconds(mutationState.getInitialWritePointer()) : defaultResolvedTimestamp; }
public static Long getTableTimestamp(PhoenixConnection connection, boolean transactional, TransactionFactory.Provider provider) throws SQLException { Long timestamp = null; if (!transactional) { return timestamp; } MutationState mutationState = connection.getMutationState(); if (!mutationState.isTransactionStarted()) { mutationState.startTransaction(provider); } timestamp = convertToMilliseconds(mutationState.getInitialWritePointer()); return timestamp; }
public static long getResolvedTimestamp(PhoenixConnection connection, boolean isTransactional, long defaultResolvedTimestamp) { MutationState mutationState = connection.getMutationState(); Long scn = connection.getSCN(); return scn != null ? scn : (isTransactional && mutationState.isTransactionStarted()) ? convertToMilliseconds(mutationState.getInitialWritePointer()) : defaultResolvedTimestamp; }
public static Long getTableTimestamp(PhoenixConnection connection, boolean transactional, TransactionFactory.Provider provider) throws SQLException { Long timestamp = null; if (!transactional) { return timestamp; } MutationState mutationState = connection.getMutationState(); if (!mutationState.isTransactionStarted()) { mutationState.startTransaction(provider); } timestamp = convertToMilliseconds(mutationState.getInitialWritePointer()); return timestamp; }
public static long getResolvedTimestamp(PhoenixConnection connection, MetaDataMutationResult result) { PTable table = result.getTable(); MutationState mutationState = connection.getMutationState(); boolean txInProgress = table != null && table.isTransactional() && mutationState.isTransactionStarted(); return txInProgress ? convertToMilliseconds(mutationState.getInitialWritePointer()) : result.getMutationTime(); }
public static long getResolvedTimestamp(PhoenixConnection connection, MetaDataMutationResult result) { PTable table = result.getTable(); MutationState mutationState = connection.getMutationState(); boolean txInProgress = table != null && table.isTransactional() && mutationState.isTransactionStarted(); return txInProgress ? convertToMilliseconds(mutationState.getInitialWritePointer()) : result.getMutationTime(); }
public boolean startTransaction(Provider provider) throws SQLException { if (provider == null) { return false; } if (!connection.getQueryServices().getProps() .getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TXN_IF_TXN_DISABLED).build().buildException(); } if (connection.getSCN() != null) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET).build().buildException(); } if (phoenixTransactionContext == PhoenixTransactionContext.NULL_CONTEXT) { phoenixTransactionContext = provider.getTransactionProvider().getTransactionContext(connection); } else { if (provider != phoenixTransactionContext.getProvider()) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_MIX_TXN_PROVIDERS) .setMessage(phoenixTransactionContext.getProvider().name() + " and " + provider.name()).build() .buildException(); } } if (!isTransactionStarted()) { // Clear any transactional state in case transaction was ended outside // of Phoenix so we don't carry the old transaction state forward. We // cannot call reset() here due to the case of having mutations and // then transitioning from non transactional to transactional (which // would end up clearing our uncommitted state). resetTransactionalState(); phoenixTransactionContext.begin(); return true; } return false; }
public boolean startTransaction(Provider provider) throws SQLException { if (provider == null) { return false; } if (!connection.getQueryServices().getProps() .getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TXN_IF_TXN_DISABLED).build().buildException(); } if (connection.getSCN() != null) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET).build().buildException(); } if (phoenixTransactionContext == PhoenixTransactionContext.NULL_CONTEXT) { phoenixTransactionContext = provider.getTransactionProvider().getTransactionContext(connection); } else { if (provider != phoenixTransactionContext.getProvider()) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_MIX_TXN_PROVIDERS) .setMessage(phoenixTransactionContext.getProvider().name() + " and " + provider.name()).build() .buildException(); } } if (!isTransactionStarted()) { // Clear any transactional state in case transaction was ended outside // of Phoenix so we don't carry the old transaction state forward. We // cannot call reset() here due to the case of having mutations and // then transitioning from non transactional to transactional (which // would end up clearing our uncommitted state). resetTransactionalState(); phoenixTransactionContext.begin(); return true; } return false; }