Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/sprint-1' into sprint-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Kulichenko committed Feb 16, 2015
2 parents 33d50f6 + 7f33dcb commit 9f5b287
Show file tree
Hide file tree
Showing 212 changed files with 1,019 additions and 1,057 deletions.
Expand Up @@ -22,8 +22,8 @@

import java.io.*;

import static org.apache.ignite.transactions.IgniteTxConcurrency.*;
import static org.apache.ignite.transactions.IgniteTxIsolation.*;
import static org.apache.ignite.transactions.TransactionConcurrency.*;
import static org.apache.ignite.transactions.TransactionIsolation.*;

/**
* Demonstrates how to use cache transactions.
Expand Down Expand Up @@ -87,7 +87,7 @@ private static void deposit(int acctId, double amount) throws IgniteException {
// Clone every object we get from cache, so we can freely update it.
IgniteCache<Integer, Account> cache = Ignition.ignite().jcache(CACHE_NAME);

try (IgniteTx tx = Ignition.ignite().transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
try (Transaction tx = Ignition.ignite().transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
Account acct0 = cache.get(acctId);

assert acct0 != null;
Expand Down
Expand Up @@ -53,7 +53,7 @@ public static void main(String[] args) throws IgniteException {
// Clean up caches on all nodes before run.
cache.clear();

try (IgniteTx tx = ignite.transactions().txStart()) {
try (Transaction tx = ignite.transactions().txStart()) {
Person val = cache.get(id);

System.out.println("Read value: " + val);
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {

/** {@inheritDoc} */
@Override public Person load(Long key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand All @@ -54,7 +54,7 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {

/** {@inheritDoc} */
@Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
IgniteTx tx = transaction();
Transaction tx = transaction();

Long key = entry.getKey();
Person val = entry.getValue();
Expand All @@ -66,7 +66,7 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {

/** {@inheritDoc} */
@Override public void delete(Object key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand Down Expand Up @@ -101,7 +101,7 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {
/**
* @return Current transaction.
*/
@Nullable private IgniteTx transaction() {
@Nullable private Transaction transaction() {
CacheStoreSession ses = session();

return ses != null ? ses.transaction() : null;
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.apache.ignite.cache.store.*;
import org.apache.ignite.examples.datagrid.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.apache.ignite.transactions.Transaction;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.jetbrains.annotations.*;
Expand Down Expand Up @@ -51,7 +51,7 @@ public CacheHibernatePersonStore() {

/** {@inheritDoc} */
@Override public Person load(Long key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand All @@ -72,7 +72,7 @@ public CacheHibernatePersonStore() {

/** {@inheritDoc} */
@Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
IgniteTx tx = transaction();
Transaction tx = transaction();

Long key = entry.getKey();

Expand Down Expand Up @@ -104,7 +104,7 @@ public CacheHibernatePersonStore() {
/** {@inheritDoc} */
@SuppressWarnings({"JpaQueryApiInspection"})
@Override public void delete(Object key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand Down Expand Up @@ -166,11 +166,11 @@ public CacheHibernatePersonStore() {
* @param ses Hibernate session.
* @param tx Cache ongoing transaction.
*/
private void rollback(Session ses, IgniteTx tx) {
private void rollback(Session ses, Transaction tx) {
// Rollback only if there is no cache transaction,
// otherwise txEnd() will do all required work.
if (tx == null) {
Transaction hTx = ses.getTransaction();
org.hibernate.Transaction hTx = ses.getTransaction();

if (hTx != null && hTx.isActive())
hTx.rollback();
Expand All @@ -183,11 +183,11 @@ private void rollback(Session ses, IgniteTx tx) {
* @param ses Hibernate session.
* @param tx Cache ongoing transaction.
*/
private void end(Session ses, @Nullable IgniteTx tx) {
private void end(Session ses, @Nullable Transaction tx) {
// Commit only if there is no cache transaction,
// otherwise txEnd() will do all required work.
if (tx == null) {
Transaction hTx = ses.getTransaction();
org.hibernate.Transaction hTx = ses.getTransaction();

if (hTx != null && hTx.isActive())
hTx.commit();
Expand All @@ -200,14 +200,14 @@ private void end(Session ses, @Nullable IgniteTx tx) {
@Override public void txEnd(boolean commit) {
CacheStoreSession storeSes = session();

IgniteTx tx = storeSes.transaction();
Transaction tx = storeSes.transaction();

Map<String, Session> props = storeSes.properties();

Session ses = props.remove(ATTR_SES);

if (ses != null) {
Transaction hTx = ses.getTransaction();
org.hibernate.Transaction hTx = ses.getTransaction();

if (hTx != null) {
try {
Expand Down Expand Up @@ -238,7 +238,7 @@ private void end(Session ses, @Nullable IgniteTx tx) {
* @param tx Cache transaction.
* @return Session.
*/
private Session session(@Nullable IgniteTx tx) {
private Session session(@Nullable Transaction tx) {
Session ses;

if (tx != null) {
Expand Down Expand Up @@ -270,7 +270,7 @@ private Session session(@Nullable IgniteTx tx) {
/**
* @return Current transaction.
*/
@Nullable private IgniteTx transaction() {
@Nullable private Transaction transaction() {
CacheStoreSession ses = session();

return ses != null ? ses.transaction() : null;
Expand Down
Expand Up @@ -67,7 +67,7 @@ private void prepareDb() throws IgniteException {

/** {@inheritDoc} */
@Override public void txEnd(boolean commit) {
IgniteTx tx = transaction();
Transaction tx = transaction();

Map<String, Connection> props = session().properties();

Expand All @@ -88,7 +88,7 @@ private void prepareDb() throws IgniteException {

/** {@inheritDoc} */
@Nullable @Override public Person load(Long key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand Down Expand Up @@ -118,7 +118,7 @@ private void prepareDb() throws IgniteException {

/** {@inheritDoc} */
@Override public void write(Cache.Entry<? extends Long, ? extends Person> entry) {
IgniteTx tx = transaction();
Transaction tx = transaction();

Long key = entry.getKey();

Expand Down Expand Up @@ -164,7 +164,7 @@ private void prepareDb() throws IgniteException {

/** {@inheritDoc} */
@Override public void delete(Object key) {
IgniteTx tx = transaction();
Transaction tx = transaction();

System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');

Expand Down Expand Up @@ -228,7 +228,7 @@ private void prepareDb() throws IgniteException {
* @return Connection.
* @throws SQLException In case of error.
*/
private Connection connection(@Nullable IgniteTx tx) throws SQLException {
private Connection connection(@Nullable Transaction tx) throws SQLException {
if (tx != null) {
Map<Object, Object> props = session().properties();

Expand All @@ -255,7 +255,7 @@ private Connection connection(@Nullable IgniteTx tx) throws SQLException {
* @param tx Active transaction, if any.
* @param conn Allocated connection.
*/
private void end(@Nullable IgniteTx tx, @Nullable Connection conn) {
private void end(@Nullable Transaction tx, @Nullable Connection conn) {
if (tx == null && conn != null) {
// Close connection right away if there is no transaction.
try {
Expand Down Expand Up @@ -297,7 +297,7 @@ private Person person(Long id, String firstName, String lastName) {
/**
* @return Current transaction.
*/
@Nullable private IgniteTx transaction() {
@Nullable private Transaction transaction() {
CacheStoreSession ses = session();

return ses != null ? ses.transaction() : null;
Expand Down
Expand Up @@ -33,7 +33,7 @@ public interface IgniteTransactions {
* @throws IllegalStateException If transaction is already started by this thread.
* @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public IgniteTx txStart() throws IllegalStateException;
public Transaction txStart() throws IllegalStateException;

/**
* Starts new transaction with the specified concurrency and isolation.
Expand All @@ -44,7 +44,7 @@ public interface IgniteTransactions {
* @throws IllegalStateException If transaction is already started by this thread.
* @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public IgniteTx txStart(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation);
public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation);

/**
* Starts transaction with specified isolation, concurrency, timeout, invalidation flag,
Expand All @@ -58,7 +58,7 @@ public interface IgniteTransactions {
* @throws IllegalStateException If transaction is already started by this thread.
* @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public IgniteTx txStart(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation, long timeout,
public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout,
int txSize);

/**
Expand All @@ -68,12 +68,12 @@ public IgniteTx txStart(IgniteTxConcurrency concurrency, IgniteTxIsolation isola
* @return Transaction started by this thread or {@code null} if this thread
* does not have a transaction.
*/
public IgniteTx tx();
public Transaction tx();

/**
* @return Transaction metrics.
*/
public IgniteTxMetrics metrics();
public TransactionMetrics metrics();

/**
* Resets transaction metrics.
Expand Down
Expand Up @@ -32,7 +32,7 @@
public enum CacheAtomicityMode {
/**
* Specified fully {@code ACID}-compliant transactional cache behavior. See
* {@link IgniteTx} for more information about transactions.
* {@link Transaction} for more information about transactions.
* <p>
* This mode is currently the default cache atomicity mode. However, cache
* atomicity mode will be changed to {@link #ATOMIC} starting from version {@code 5.2},
Expand Down

0 comments on commit 9f5b287

Please sign in to comment.