Search in sources :

Example 76 with Logger

use of java.util.logging.Logger in project graphdb by neo4j-attic.

the class XaResourceManager method checkXids.

synchronized void checkXids() throws IOException {
    msgLog.logMessage("XaResourceManager[" + name + "] sorting " + xidMap.size() + " xids");
    Iterator<Xid> keyIterator = xidMap.keySet().iterator();
    LinkedList<Xid> xids = new LinkedList<Xid>();
    while (keyIterator.hasNext()) {
        xids.add(keyIterator.next());
    }
    // comparator only used here
    Collections.sort(xids, new Comparator<Xid>() {

        public int compare(Xid o1, Xid o2) {
            Integer id1 = txOrderMap.get(o1);
            Integer id2 = txOrderMap.get(o2);
            if (id1 == null && id2 == null) {
                return 0;
            }
            if (id1 == null) {
                return Integer.MAX_VALUE;
            }
            if (id2 == null) {
                return Integer.MIN_VALUE;
            }
            return id1 - id2;
        }
    });
    // = null;
    txOrderMap.clear();
    Logger logger = Logger.getLogger(tf.getClass().getName());
    while (!xids.isEmpty()) {
        Xid xid = xids.removeFirst();
        XidStatus status = xidMap.get(xid);
        TransactionStatus txStatus = status.getTransactionStatus();
        XaTransaction xaTransaction = txStatus.getTransaction();
        int identifier = xaTransaction.getIdentifier();
        if (xaTransaction.isRecovered()) {
            if (txStatus.commitStarted()) {
                logger.fine("Marking 1PC [" + name + "] tx " + identifier + " as done");
                log.doneInternal(identifier);
                xidMap.remove(xid);
                recoveredTxCount--;
            } else if (!txStatus.prepared()) {
                logger.fine("Rolling back non prepared tx [" + name + "]" + "txIdent[" + identifier + "]");
                log.doneInternal(xaTransaction.getIdentifier());
                xidMap.remove(xid);
                recoveredTxCount--;
            } else {
                logger.fine("2PC tx [" + name + "] " + txStatus + " txIdent[" + identifier + "]");
            }
        }
    }
    checkIfRecoveryComplete();
}
Also used : Xid(javax.transaction.xa.Xid) Logger(java.util.logging.Logger) StringLogger(org.neo4j.kernel.impl.util.StringLogger) LinkedList(java.util.LinkedList)

Example 77 with Logger

use of java.util.logging.Logger in project graphdb by neo4j-attic.

the class TestNeo4jConstrains method testIllegalPropertyType.

@Test
public void testIllegalPropertyType() {
    Logger log = Logger.getLogger(NodeManager.class.getName());
    Level level = log.getLevel();
    log.setLevel(Level.OFF);
    try {
        Node node1 = getGraphDb().createNode();
        try {
            node1.setProperty(key, new Object());
            fail("Shouldn't validate");
        } catch (Exception e) {
        // good
        }
        try {
            Transaction tx = getTransaction();
            tx.success();
            tx.finish();
            fail("Shouldn't validate");
        } catch (Exception e) {
        }
        // good
        setTransaction(getGraphDb().beginTx());
        try {
            getGraphDb().getNodeById(node1.getId());
            fail("Node should not exist, previous tx didn't rollback");
        } catch (NotFoundException e) {
        // good
        }
        node1 = getGraphDb().createNode();
        Node node2 = getGraphDb().createNode();
        Relationship rel = node1.createRelationshipTo(node2, MyRelTypes.TEST);
        try {
            rel.setProperty(key, new Object());
            fail("Shouldn't validate");
        } catch (Exception e) {
        // good
        }
        try {
            Transaction tx = getTransaction();
            tx.success();
            tx.finish();
            fail("Shouldn't validate");
        } catch (Exception e) {
        }
        // good
        setTransaction(getGraphDb().beginTx());
        try {
            getGraphDb().getNodeById(node1.getId());
            fail("Node should not exist, previous tx didn't rollback");
        } catch (NotFoundException e) {
        // good
        }
        try {
            getGraphDb().getNodeById(node2.getId());
            fail("Node should not exist, previous tx didn't rollback");
        } catch (NotFoundException e) {
        // good
        }
    } finally {
        log.setLevel(level);
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) NotFoundException(org.neo4j.graphdb.NotFoundException) Level(java.util.logging.Level) Logger(java.util.logging.Logger) NotFoundException(org.neo4j.graphdb.NotFoundException) Test(org.junit.Test)

Example 78 with Logger

use of java.util.logging.Logger in project neo4j-mobile-android by neo4j-contrib.

the class XaResourceManager method checkXids.

synchronized void checkXids() throws IOException {
    msgLog.logMessage("XaResourceManager[" + name + "] sorting " + xidMap.size() + " xids");
    Iterator<Xid> keyIterator = xidMap.keySet().iterator();
    LinkedList<Xid> xids = new LinkedList<Xid>();
    while (keyIterator.hasNext()) {
        xids.add(keyIterator.next());
    }
    // comparator only used here
    Collections.sort(xids, new Comparator<Xid>() {

        public int compare(Xid o1, Xid o2) {
            Integer id1 = txOrderMap.get(o1);
            Integer id2 = txOrderMap.get(o2);
            if (id1 == null && id2 == null) {
                return 0;
            }
            if (id1 == null) {
                return Integer.MAX_VALUE;
            }
            if (id2 == null) {
                return Integer.MIN_VALUE;
            }
            return id1 - id2;
        }
    });
    // = null;
    txOrderMap.clear();
    Logger logger = Logger.getLogger(tf.getClass().getName());
    while (!xids.isEmpty()) {
        Xid xid = xids.removeFirst();
        XidStatus status = xidMap.get(xid);
        TransactionStatus txStatus = status.getTransactionStatus();
        XaTransaction xaTransaction = txStatus.getTransaction();
        int identifier = xaTransaction.getIdentifier();
        if (xaTransaction.isRecovered()) {
            if (txStatus.commitStarted()) {
                logger.fine("Marking 1PC [" + name + "] tx " + identifier + " as done");
                log.doneInternal(identifier);
                xidMap.remove(xid);
                recoveredTxCount--;
            } else if (!txStatus.prepared()) {
                logger.fine("Rolling back non prepared tx [" + name + "]" + "txIdent[" + identifier + "]");
                log.doneInternal(xaTransaction.getIdentifier());
                xidMap.remove(xid);
                recoveredTxCount--;
            } else {
                logger.fine("2PC tx [" + name + "] " + txStatus + " txIdent[" + identifier + "]");
            }
        }
    }
    checkIfRecoveryComplete();
}
Also used : Xid(javax.transaction.xa.Xid) Logger(java.util.logging.Logger) StringLogger(org.neo4j.kernel.impl.util.StringLogger) LinkedList(java.util.LinkedList)

Example 79 with Logger

use of java.util.logging.Logger in project graphdb by neo4j-attic.

the class TestDynamicStore method testStickyStore.

@Test
public void testStickyStore() throws IOException {
    Logger log = Logger.getLogger(CommonAbstractStore.class.getName());
    Level level = log.getLevel();
    try {
        log.setLevel(Level.OFF);
        createEmptyStore(dynamicStoreFile(), 30);
        FileChannel fileChannel = new RandomAccessFile(dynamicStoreFile(), "rw").getChannel();
        fileChannel.truncate(fileChannel.size() - 2);
        fileChannel.close();
        DynamicArrayStore store = newStore();
        store.makeStoreOk();
        store.close();
    } finally {
        log.setLevel(level);
        deleteBothFiles();
    }
}
Also used : RandomAccessFile(java.io.RandomAccessFile) FileChannel(java.nio.channels.FileChannel) Level(java.util.logging.Level) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 80 with Logger

use of java.util.logging.Logger in project jersey by jersey.

the class JerseyTest method unregisterLogHandler.

/**
     * Un-register {@link Handler log handler} from the list of root loggers.
     */
private void unregisterLogHandler() {
    for (final Logger root : getRootLoggers()) {
        root.setLevel(logLevelMap.get(root));
        root.removeHandler(getLogHandler());
    }
    logHandler = null;
}
Also used : Logger(java.util.logging.Logger)

Aggregations

Logger (java.util.logging.Logger)499 Test (org.junit.Test)70 LogRecord (java.util.logging.LogRecord)60 ActionReport (org.glassfish.api.ActionReport)56 Handler (java.util.logging.Handler)52 IOException (java.io.IOException)37 File (java.io.File)36 Level (java.util.logging.Level)25 ArrayList (java.util.ArrayList)22 ConsoleHandler (java.util.logging.ConsoleHandler)19 Properties (java.util.Properties)15 SimpleFormatter (java.util.logging.SimpleFormatter)15 Config (com.sun.enterprise.config.serverbeans.Config)14 HashMap (java.util.HashMap)14 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ResourceBundle (java.util.ResourceBundle)11 LogManager (java.util.logging.LogManager)11 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)10