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