Search in sources :

Example 16 with ComException

use of org.neo4j.com.ComException in project neo4j by neo4j.

the class SlaveLocksClientTest method mustThrowIfStartingNewLockSessionOnMasterThrowsComException.

@Test(expected = DistributedLockFailureException.class)
public void mustThrowIfStartingNewLockSessionOnMasterThrowsComException() throws Exception {
    when(master.newLockSession(any(RequestContext.class))).thenThrow(new ComException());
    client.acquireShared(LockTracer.NONE, NODE, 1);
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Example 17 with ComException

use of org.neo4j.com.ComException in project neo4j by neo4j.

the class SlaveLocksClientTest method acquireSharedMustThrowIfMasterThrows.

@Test(expected = DistributedLockFailureException.class)
public void acquireSharedMustThrowIfMasterThrows() throws Exception {
    whenMasterAcquireShared().thenThrow(new ComException());
    client.acquireShared(LockTracer.NONE, NODE, 1);
}
Also used : ComException(org.neo4j.com.ComException) Test(org.junit.Test)

Example 18 with ComException

use of org.neo4j.com.ComException in project neo4j by neo4j.

the class SlaveLocksClientTest method mustCloseLocalClientEvenIfMasterThrows.

@Test
public void mustCloseLocalClientEvenIfMasterThrows() throws Exception {
    when(master.endLockSession(any(RequestContext.class), anyBoolean())).thenThrow(new ComException());
    try {
        // initialise
        client.acquireExclusive(LockTracer.NONE, NODE, 1);
        client.close();
        fail("Expected client.close to throw");
    } catch (Exception ignore) {
    }
    verify(local).close();
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext) ComException(org.neo4j.com.ComException) TransactionFailureException(org.neo4j.kernel.api.exceptions.TransactionFailureException) LockClientStoppedException(org.neo4j.kernel.impl.locking.LockClientStoppedException) TransientFailureException(org.neo4j.graphdb.TransientFailureException) Test(org.junit.Test)

Example 19 with ComException

use of org.neo4j.com.ComException in project neo4j by neo4j.

the class HaIdGeneratorFactoryTest method shouldTranslateComExceptionsIntoTransientTransactionFailures.

@Test(expected = TransientTransactionFailureException.class)
public void shouldTranslateComExceptionsIntoTransientTransactionFailures() throws Exception {
    when(master.allocateIds(any(RequestContext.class), any(IdType.class))).thenThrow(new ComException());
    IdGenerator generator = switchToSlave();
    generator.nextId();
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext) IdGenerator(org.neo4j.kernel.impl.store.id.IdGenerator) IdType(org.neo4j.kernel.impl.store.id.IdType) Test(org.junit.Test)

Example 20 with ComException

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());
}
Also used : ComException(org.neo4j.com.ComException) InvalidEpochException(org.neo4j.kernel.ha.com.master.InvalidEpochException) RequestContext(org.neo4j.com.RequestContext)

Aggregations

ComException (org.neo4j.com.ComException)23 Test (org.junit.Test)12 RequestContext (org.neo4j.com.RequestContext)9 ZooKeeperException (org.neo4j.kernel.ha.zookeeper.ZooKeeperException)3 IOException (java.io.IOException)2 URI (java.net.URI)2 Node (org.neo4j.graphdb.Node)2 Relationship (org.neo4j.graphdb.Relationship)2 MismatchingStoreIdException (org.neo4j.kernel.impl.store.MismatchingStoreIdException)2 URISyntaxException (java.net.URISyntaxException)1 ReadableByteChannel (java.nio.channels.ReadableByteChannel)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1