use of org.neo4j.com.ComException in project graphdb by neo4j-attic.
the class SlaveLockManager method getReadLock.
@Override
public void getReadLock(Object resource) throws DeadlockDetectedException, IllegalResourceException {
try {
Node node = resource instanceof Node ? (Node) resource : null;
Relationship relationship = resource instanceof Relationship ? (Relationship) resource : null;
if (node == null && relationship == null) {
// This is a "fake" resource, only grab the lock locally
super.getReadLock(resource);
return;
}
// if ( hasAlreadyGotLock() )
// {
// return;
// }
LockResult result = null;
do {
int eventIdentifier = getLocalTxId();
result = node != null ? receiver.receive(broker.getMaster().first().acquireNodeReadLock(receiver.getSlaveContext(eventIdentifier), node.getId())) : receiver.receive(broker.getMaster().first().acquireRelationshipReadLock(receiver.getSlaveContext(eventIdentifier), relationship.getId()));
switch(result.getStatus()) {
case OK_LOCKED:
super.getReadLock(resource);
return;
case DEAD_LOCKED:
throw new DeadlockDetectedException(result.getDeadlockMessage());
}
} while (result.getStatus() == LockStatus.NOT_LOCKED);
} catch (ZooKeeperException e) {
receiver.newMaster(null, e);
throw e;
} catch (ComException e) {
receiver.newMaster(null, e);
throw e;
}
}
use of org.neo4j.com.ComException in project graphdb by neo4j-attic.
the class HaBackupProvider method resolve.
@Override
public URI resolve(URI address) {
String master = null;
try {
System.out.println("Asking ZooKeeper service at '" + address + "' for master");
master = getMasterServerInCluster(address.getSchemeSpecificPart().substring(// skip the "//" part
2));
System.out.println("Found master '" + master + "' in cluster");
} catch (ComException e) {
throw e;
} catch (RuntimeException e) {
if (e.getCause() instanceof KeeperException) {
KeeperException zkException = (KeeperException) e.getCause();
System.out.println("Couldn't connect to '" + address + "', " + zkException.getMessage());
}
throw e;
}
URI toReturn = null;
try {
toReturn = new URI(master);
} catch (URISyntaxException e) {
// no way
}
return toReturn;
}
use of org.neo4j.com.ComException in project neo4j by neo4j.
the class SlaveUpdatePuller method doPullUpdates.
private void doPullUpdates() {
try {
RequestContext context = requestContextFactory.newRequestContext();
try (Response<Void> ignored = master.pullUpdates(context)) {
// Updates would be applied as part of response processing
monitor.pulledUpdates(context.lastAppliedTransaction());
}
invalidEpochCappedLogger.reset();
comExceptionCappedLogger.reset();
} catch (InvalidEpochException e) {
invalidEpochHandler.handle();
invalidEpochCappedLogger.warn("Pull updates by " + this + " failed at the epoch check", e);
} catch (ComException e) {
invalidEpochCappedLogger.warn("Pull updates by " + this + " failed due to network error.", e);
} catch (Throwable e) {
logger.error("Pull updates by " + this + " failed", e);
}
lastUpdateTime.setLastUpdateTime(currentTimeMillis());
}
Aggregations