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();
}
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);
}
}
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();
}
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();
}
}
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;
}
Aggregations