use of io.aeron.exceptions.AeronException in project Aeron by real-logic.
the class ConsensusModuleContextCloseTests method ownsAeronClient.
@Test
void ownsAeronClient() throws Exception {
context.ownsAeronClient(true);
final AeronException ex = assertThrows(AeronException.class, context::close);
assertSame(aeronException, ex);
final InOrder inOrder = inOrder(countedErrorHandler, errorHandler, aeron);
inOrder.verify(countedErrorHandler).onError(recodingLogException);
inOrder.verify(countedErrorHandler).onError(markFileException);
inOrder.verify((AutoCloseable) errorHandler).close();
inOrder.verify(aeron).close();
inOrder.verifyNoMoreInteractions();
}
use of io.aeron.exceptions.AeronException in project Aeron by real-logic.
the class FileStoreLogFactory method checkStorage.
private void checkStorage(final long logLength) {
if (checkStorage) {
final long usableSpace = getUsableSpace();
if (usableSpace < logLength) {
throw new AeronException("insufficient usable storage for new log of length=" + logLength + " in " + fileStore);
}
if (usableSpace <= lowStorageWarningThreshold) {
final String msg = "space is running low: threshold=" + lowStorageWarningThreshold + " usable=" + usableSpace + " in " + fileStore;
errorHandler.onError(new AeronException(msg, AeronException.Category.WARN));
}
}
}
use of io.aeron.exceptions.AeronException in project Aeron by real-logic.
the class UdpChannelTransport method updateEndpoint.
/**
* Endpoint has moved to a new address. Handle this.
*
* @param newAddress to send data to.
* @param statusIndicator for the channel
*/
public void updateEndpoint(final InetSocketAddress newAddress, final AtomicCounter statusIndicator) {
try {
if (null != sendDatagramChannel) {
sendDatagramChannel.disconnect();
sendDatagramChannel.connect(newAddress);
connectAddress = newAddress;
if (null != statusIndicator) {
statusIndicator.setOrdered(ChannelEndpointStatus.ACTIVE);
}
}
} catch (final Exception ex) {
if (null != statusIndicator) {
statusIndicator.setOrdered(ChannelEndpointStatus.ERRORED);
}
final String message = "re-resolve endpoint channel error - " + ex.getMessage() + " (at " + ex.getStackTrace()[0].toString() + "): " + udpChannel.originalUriString();
throw new AeronException(message, ex);
}
}
use of io.aeron.exceptions.AeronException in project Aeron by real-logic.
the class DriverTool method main.
/**
* Main method for launching the process.
*
* @param args passed to the process.
*/
public static void main(final String[] args) {
boolean printPidOnly = false;
boolean terminateDriver = false;
if (0 != args.length) {
checkForHelp(args);
if (args[0].equals("pid")) {
printPidOnly = true;
} else if (args[0].equals("terminate")) {
terminateDriver = true;
}
}
final File cncFile = CommonContext.newDefaultCncFile();
final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "cnc");
final DirectBuffer cncMetaData = createMetaDataBuffer(cncByteBuffer);
final int cncVersion = cncMetaData.getInt(cncVersionOffset(0));
checkVersion(cncVersion);
final ManyToOneRingBuffer toDriver = new ManyToOneRingBuffer(createToDriverBuffer(cncByteBuffer, cncMetaData));
if (printPidOnly) {
System.out.println(pid(cncMetaData));
} else if (terminateDriver) {
final DriverProxy driverProxy = new DriverProxy(toDriver, toDriver.nextCorrelationId());
if (!driverProxy.terminateDriver(null, 0, 0)) {
throw new AeronException("could not send termination request.");
}
} else {
System.out.println("Command `n Control file: " + cncFile);
System.out.format("Version: %d, PID: %d%n", cncVersion, pid(cncMetaData));
printDateActivityAndStartTimestamps(startTimestampMs(cncMetaData), toDriver.consumerHeartbeatTime());
}
}
use of io.aeron.exceptions.AeronException in project aeron by real-logic.
the class Aeron method waitForFileMapping.
@SuppressWarnings("try")
private static MappedByteBuffer waitForFileMapping(final File file, final EpochClock clock, final long deadlineMs) {
while (true) {
while (!file.exists() || file.length() < CncFileDescriptor.META_DATA_LENGTH) {
if (clock.time() > deadlineMs) {
throw new DriverTimeoutException("CnC file not created: " + file.getAbsolutePath());
}
sleep(Configuration.IDLE_SLEEP_MS);
}
try (FileChannel fileChannel = FileChannel.open(file.toPath(), READ, WRITE)) {
final long fileSize = fileChannel.size();
if (fileSize < CncFileDescriptor.META_DATA_LENGTH) {
if (clock.time() > deadlineMs) {
throw new DriverTimeoutException("CnC file is created but not populated");
}
fileChannel.close();
sleep(Configuration.IDLE_SLEEP_MS);
continue;
}
return fileChannel.map(READ_WRITE, 0, fileSize);
} catch (final NoSuchFileException ignore) {
} catch (final IOException ex) {
throw new AeronException("cannot open CnC file", ex);
}
}
}
Aggregations