]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use SLF4J Logger in SessionRequestManager. 13/1813/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 31 May 2018 11:07:26 +0000 (14:07 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 31 May 2018 19:15:46 +0000 (19:15 +0000)
gitlab #14

Change-Id: Ia79a0fd4b895f02f98c6113cd1ca9fe95104c9d0

bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionRequestManager.java

index 5bdec52e99cfcb3cdb71010584250904e65ad9ac..a29d6ce045bc619ceae803dfe7bf6d48cb03241a 100644 (file)
@@ -6,7 +6,6 @@ import java.util.LinkedList;
 
 import org.simantics.db.Disposable;
 import org.simantics.db.Resource;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.CancelTransactionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.graph.WriteGraphImpl;
@@ -16,9 +15,13 @@ import org.simantics.db.impl.query.QueryProcessor.SessionRead;
 import org.simantics.db.impl.query.QueryProcessor.SessionTask;
 import org.simantics.db.request.WriteTraits;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SessionRequestManager {
 
+       private static final Logger LOGGER = LoggerFactory.getLogger(SessionRequestManager.class);
+
        private static boolean DEBUG = false;
        
        enum State {
@@ -123,7 +126,7 @@ public class SessionRequestManager {
                     transactionState.startReadTransaction(thread);
                     task.run(thread);
                 } catch (Throwable t) {
-                    Logger.defaultLogError(new DatabaseException("Read transaction could not be started", t));
+                    LOGGER.error("Read transaction could not be started", t);
                     if(task.throwable != null)
                         task.throwable.set(t);
                     state = State.ERROR;
@@ -149,7 +152,7 @@ public class SessionRequestManager {
                                try {
                                        transactionState.stopReadTransaction();
                                } catch (DatabaseException e) {
-                                       e.printStackTrace();
+                                       LOGGER.error("Read transaction could not be stopped", e);
                                }
                                
                        }
@@ -158,16 +161,6 @@ public class SessionRequestManager {
                
        }
 
-//     public synchronized void stopRead(int thread) {
-//             
-//             try {
-//                     transactionState.stopReadTransaction();
-//             } catch (DatabaseException e) {
-//                     e.printStackTrace();
-//             }
-//             
-//     }
-
        public synchronized void startWrite(int thread, final SessionTask task) {
                
                session.queryProvider2.scheduleAlways(thread, new SessionTask((WriteTraits)task.object, task.thread) {
@@ -178,8 +171,7 @@ public class SessionRequestManager {
                        try {
                                transactionState.startWriteTransaction(thread);
                        } catch (Throwable t) {
-                           DatabaseException e = new DatabaseException("Write transaction could not be started", t);
-                           Logger.defaultLogError(e);
+                           LOGGER.error("Write transaction could not be started", t);
                            return;
                        }
                                task.run(thread);
@@ -227,10 +219,10 @@ public class SessionRequestManager {
                                WriteGraphImpl graph = writeState.getGraph();
 
                                if(writeState.isExcepted()) {
-                                   
+
                                    if(!(writeState.exception instanceof CancelTransactionException))
-                                       writeState.exception.printStackTrace();
-                                   
+                                       LOGGER.error("Write request failed", writeState.exception);
+
                                    transactionState.cancelWriteTransaction(graph);
 
                                } else {
@@ -257,20 +249,6 @@ public class SessionRequestManager {
 
        }
 
-//     public synchronized void stopWrite(int thread) {
-//             
-//        session.clientChanges = new ClientChangesImpl(session);
-//
-//        WriteState<?> state = session.writeState;
-//
-//        System.err.println("D");
-//        state.finish();
-//        System.err.println("E");
-//        
-//        session.writeState = null;
-//        
-//     }
-
        public synchronized void ceased(int thread) {
 
                if(State.WRITE == state) {
@@ -401,7 +379,7 @@ public class SessionRequestManager {
                        try {
                                value.second.binaryFile.close();
                        } catch (IOException e) {
-                               Logger.defaultLogError("I/O exception while closing random access value file " + value.second.binaryFile.file() + " for resource " + value.first , e);
+                               LOGGER.error("I/O exception while closing random access value file " + value.second.binaryFile.file() + " for resource " + value.first , e);
                        }
                }
        }