activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [2/5] activemq-artemis git commit: Code style fixes in JDBC Journal
Date Thu, 04 Feb 2016 18:21:49 GMT
Code style fixes in JDBC Journal


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/af89b930
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/af89b930
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/af89b930

Branch: refs/heads/master
Commit: af89b930040687e70758ee5591899d3c7d812994
Parents: 0e4a164
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Thu Feb 4 15:18:53 2016 +0000
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Thu Feb 4 16:24:47 2016 +0000

----------------------------------------------------------------------
 .../jdbc/store/journal/JDBCJournalImpl.java     |  8 ++------
 .../journal/JDBCJournalLoaderCallback.java      | 15 ++-------------
 .../journal/JDBCJournalReaderCallback.java      |  5 ++---
 .../jdbc/store/journal/JDBCJournalRecord.java   | 20 ++------------------
 4 files changed, 8 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af89b930/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
index 632d7a3..55e9f89 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
@@ -84,14 +84,12 @@ public class JDBCJournalImpl implements Journal {
    // Track Tx Records
    private Map<Long, TransactionHolder> transactions = new ConcurrentHashMap<>();
 
-   private boolean isLoaded = false;
-
    public JDBCJournalImpl(String jdbcUrl, String tableName) {
       this.tableName = tableName;
       this.jdbcUrl = jdbcUrl;
       timerThread = "Timer JDBC Journal(" + tableName + ")";
 
-      records = new ArrayList<JDBCJournalRecord>();
+      records = new ArrayList<>();
    }
 
    @Override
@@ -169,7 +167,6 @@ public class JDBCJournalImpl implements Journal {
                   break;
                case JDBCJournalRecord.ROLLBACK_RECORD:
                   // Roll back we remove all records associated with this TX ID.  This query
is always performed last.
-                  holder = transactions.get(record.getTxId());
                   deleteJournalTxRecords.setLong(1, record.getTxId());
                   deleteJournalTxRecords.addBatch();
                   break;
@@ -262,7 +259,7 @@ public class JDBCJournalImpl implements Journal {
 
          // On rollback we must update the tx map to remove all the tx entries
          for (TransactionHolder txH : txHolders) {
-            if (txH.prepared == false && txH.recordInfos.isEmpty() && txH.recordsToDelete.isEmpty())
{
+            if (!txH.prepared && txH.recordInfos.isEmpty() && txH.recordsToDelete.isEmpty())
{
                transactions.remove(txH.transactionID);
             }
          }
@@ -616,7 +613,6 @@ public class JDBCJournalImpl implements Journal {
          jli.setMaxID(((JDBCJournalLoaderCallback) reloadManager).getMaxId());
          jli.setNumberOfRecords(noRecords);
          transactions = jrc.getTransactions();
-         isLoaded = true;
       }
       return jli;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af89b930/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallback.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallback.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallback.java
index 12b8671..0627c54 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallback.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallback.java
@@ -29,19 +29,13 @@ import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
 
 public class JDBCJournalLoaderCallback implements LoaderCallback {
 
-   private static final int DELETE_FLUSH = 20000;
-
    private final List<PreparedTransactionInfo> preparedTransactions;
 
    private final TransactionFailureCallback failureCallback;
 
-   private final boolean fixBadTX;
-
    /* We keep track of list entries for each ID.  This preserves order and allows multiple
record insertions with the
    same ID.  We use this for deleting records */
-   private final Map<Long, List<Integer>> deleteReferences = new HashMap<Long,
List<Integer>>();
-
-   private Runtime runtime = Runtime.getRuntime();
+   private final Map<Long, List<Integer>> deleteReferences = new HashMap<>();
 
    private final List<RecordInfo> committedRecords;
 
@@ -54,7 +48,6 @@ public class JDBCJournalLoaderCallback implements LoaderCallback {
       this.committedRecords = committedRecords;
       this.preparedTransactions = preparedTransactions;
       this.failureCallback = failureCallback;
-      this.fixBadTX = fixBadTX;
    }
 
    public synchronized void checkMaxId(long id) {
@@ -71,7 +64,7 @@ public class JDBCJournalLoaderCallback implements LoaderCallback {
       int index = committedRecords.size();
       committedRecords.add(index, info);
 
-      ArrayList<Integer> indexes = new ArrayList<Integer>();
+      ArrayList<Integer> indexes = new ArrayList<>();
       indexes.add(index);
 
       deleteReferences.put(info.id, indexes);
@@ -89,10 +82,6 @@ public class JDBCJournalLoaderCallback implements LoaderCallback {
       }
    }
 
-   public int getNoRecords() {
-      return committedRecords.size();
-   }
-
    @Override
    public void failedTransaction(final long transactionID,
                                  final List<RecordInfo> records,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af89b930/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java
index a7c765e..445d303 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java
@@ -29,7 +29,7 @@ import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
 
 public class JDBCJournalReaderCallback implements JournalReaderCallback {
 
-   private final Map<Long, TransactionHolder> loadTransactions = new LinkedHashMap<Long,
TransactionHolder>();
+   private final Map<Long, TransactionHolder> loadTransactions = new LinkedHashMap<>();
 
    private final LoaderCallback loadManager;
 
@@ -90,12 +90,11 @@ public class JDBCJournalReaderCallback implements JournalReaderCallback
{
 
    public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws
Exception {
       // It is possible that the TX could be null, since deletes could have happened in the
journal.
-
       TransactionHolder tx = loadTransactions.get(transactionID);
-      tx.committed = true;
 
       // We can remove local Tx without associated records
       if (tx != null) {
+         tx.committed = true;
          for (RecordInfo txRecord : tx.recordInfos) {
             if (txRecord.isUpdate) {
                loadManager.updateRecord(txRecord);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af89b930/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
index bf52a17..1948e5a 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
@@ -116,29 +116,18 @@ public class JDBCJournalRecord {
    }
 
    public static String selectRecordsSQL(String tableName) {
-      return "SELECT id," + "recordType," + "compactCount," + "txId," + "userRecordType,"
+ "variableSize," + "record," + "txDataSize," + "txData," + "txCheckNoRecords " + "FROM "
+ tableName;
+      return "SELECT id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords
"
+         + "FROM " + tableName;
    }
 
    public static String deleteRecordsSQL(String tableName) {
       return "DELETE FROM " + tableName + " WHERE id = ?";
    }
 
-   public static String deleteCommittedDeleteRecordsForTxSQL(String tableName) {
-      return "DELETE FROM " + tableName + " WHERE id IN (SELECT id FROM " + tableName + "
WHERE txID=?)";
-   }
-
-   public static String deleteCommittedTxRecordsSQL(String tableName) {
-      return "DELETE FROM " + tableName + " WHERE txId=? AND (recordType=" + PREPARE_RECORD
+ " OR recordType=" + COMMIT_RECORD + ")";
-   }
-
    public static String deleteJournalTxRecordsSQL(String tableName) {
       return "DELETE FROM " + tableName + " WHERE txId=?";
    }
 
-   public static String deleteRolledBackTxSQL(String tableName) {
-      return "DELETE FROM " + tableName + " WHERE txId=?";
-   }
-
    public void complete(boolean success) {
       if (ioCompletion != null) {
          if (success) {
@@ -183,11 +172,6 @@ public class JDBCJournalRecord {
       statement.addBatch();
    }
 
-   protected void writeDeleteTxRecord(PreparedStatement deleteTxStatement) throws SQLException
{
-      deleteTxStatement.setLong(1, txId);
-      deleteTxStatement.addBatch();
-   }
-
    protected void writeDeleteRecord(PreparedStatement deleteStatement) throws SQLException
{
       deleteStatement.setLong(1, id);
       deleteStatement.addBatch();


Mime
View raw message