Search in sources :

Example 6 with ComException

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

the class SlaveLocksClientTest method acquireExclusiveMustThrowIfMasterThrows.

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

Example 7 with ComException

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

the class SlaveLocksClientTest method closeMustThrowIfMasterThrows.

@Test(expected = DistributedLockFailureException.class)
public void closeMustThrowIfMasterThrows() throws Exception {
    when(master.endLockSession(any(RequestContext.class), anyBoolean())).thenThrow(new ComException());
    // initialise
    client.acquireExclusive(LockTracer.NONE, NODE, 1);
    client.close();
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Example 8 with ComException

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

the class SlaveLocksClientTest method stopDoesNotThrowWhenMasterCommunicationThrowsComException.

@Test
public void stopDoesNotThrowWhenMasterCommunicationThrowsComException() {
    ComException error = new ComException("Communication failure");
    when(master.endLockSession(any(RequestContext.class), anyBoolean())).thenThrow(error);
    client.stop();
    logProvider.assertExactly(inLog(SlaveLocksClient.class).warn(equalTo("Unable to stop lock session on master"), CoreMatchers.<Throwable>instanceOf(DistributedLockFailureException.class)));
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Example 9 with ComException

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

the class BackupTool method executeBackup.

BackupOutcome executeBackup(HostnamePort hostnamePort, File to, ConsistencyCheck consistencyCheck, Config config, long timeout, boolean forensics) throws ToolFailureException {
    try {
        systemOut.println("Performing backup from '" + hostnamePort + "'");
        String host = hostnamePort.getHost();
        int port = hostnamePort.getPort();
        BackupOutcome outcome = backupService.doIncrementalBackupOrFallbackToFull(host, port, to, consistencyCheck, config, timeout, forensics);
        systemOut.println("Done");
        return outcome;
    } catch (UnexpectedStoreVersionException e) {
        throw new ToolFailureException(e.getMessage(), e);
    } catch (MismatchingStoreIdException e) {
        throw new ToolFailureException(String.format(MISMATCHED_STORE_ID, e.getExpected(), e.getEncountered()));
    } catch (ComException e) {
        throw new ToolFailureException("Couldn't connect to '" + hostnamePort + "'", e);
    } catch (IncrementalBackupNotPossibleException e) {
        throw new ToolFailureException(e.getMessage(), e);
    }
}
Also used : ComException(org.neo4j.com.ComException) UnexpectedStoreVersionException(org.neo4j.kernel.impl.store.UnexpectedStoreVersionException) BackupOutcome(org.neo4j.backup.BackupService.BackupOutcome) MismatchingStoreIdException(org.neo4j.kernel.impl.store.MismatchingStoreIdException)

Example 10 with ComException

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

the class SlaveTransactionCommitProcess method commit.

@Override
public long commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) throws TransactionFailureException {
    if (batch.next() != null) {
        throw new IllegalArgumentException("Only supports single-commit on slave --> master");
    }
    try {
        TransactionRepresentation representation = batch.transactionRepresentation();
        RequestContext context = requestContextFactory.newRequestContext(representation.getLockSessionId());
        try (Response<Long> response = master.commit(context, representation)) {
            return response.response();
        }
    } catch (IOException e) {
        throw new TransactionFailureException(Status.Transaction.TransactionCommitFailed, e, "Could not commit transaction on the master");
    } catch (ComException e) {
        throw new TransientTransactionFailureException("Cannot commit this transaction on the master. " + "The master is either down, or we have network connectivity problems.", e);
    }
}
Also used : ComException(org.neo4j.com.ComException) TransientTransactionFailureException(org.neo4j.graphdb.TransientTransactionFailureException) TransactionFailureException(org.neo4j.kernel.api.exceptions.TransactionFailureException) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) TransientTransactionFailureException(org.neo4j.graphdb.TransientTransactionFailureException) RequestContext(org.neo4j.com.RequestContext) IOException(java.io.IOException)

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