org.agrona.SystemUtil Java Examples
The following examples show how to use
org.agrona.SystemUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AeronStat.java From aeron with Apache License 2.0 | 6 votes |
private static void printOutput(final CncFileReader cncFileReader, final CounterFilter counterFilter) { final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); System.out.print(dateFormat.format(new Date())); System.out.println( " - Aeron Stat (CnC v" + cncFileReader.semanticVersion() + ")" + ", pid " + SystemUtil.getPid() + ", heartbeat age " + cncFileReader.driverHeartbeatAgeMs() + "ms"); System.out.println("======================================================================"); final CountersReader counters = cncFileReader.countersReader(); counters.forEach( (counterId, typeId, keyBuffer, label) -> { if (counterFilter.filter(typeId, keyBuffer)) { final long value = counters.getCounterValue(counterId); System.out.format("%3d: %,20d - %s%n", counterId, value, label); } } ); System.out.println("--"); }
Example #2
Source File: ArchiveTests.java From aeron with Apache License 2.0 | 6 votes |
public static File makeTestDirectory() { final File archiveDir = new File(SystemUtil.tmpDirName(), "archive-test"); if (archiveDir.exists()) { System.err.println("Warning archive directory exists, deleting: " + archiveDir.getAbsolutePath()); IoUtil.delete(archiveDir, false); } if (!archiveDir.mkdirs()) { throw new IllegalStateException("failed to make archive test directory: " + archiveDir.getAbsolutePath()); } return archiveDir; }
Example #3
Source File: ArchiveAuthenticationTest.java From aeron with Apache License 2.0 | 6 votes |
private void launchArchivingMediaDriver(final AuthenticatorSupplier authenticatorSupplier) { mediaDriver = TestMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(aeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(false) .dirDeleteOnStart(true), testWatcher); archive = Archive.launch( new Archive.Context() .maxCatalogEntries(Common.MAX_CATALOG_ENTRIES) .aeronDirectoryName(aeronDirectoryName) .deleteArchiveOnStart(true) .archiveDir(new File(SystemUtil.tmpDirName(), "archive")) .fileSyncLevel(0) .authenticatorSupplier(authenticatorSupplier) .threadingMode(ArchiveThreadingMode.SHARED)); }
Example #4
Source File: PersistentSequenceNumberResendRequestSystemTest.java From artio with Apache License 2.0 | 6 votes |
@Parameterized.Parameters(name = "shutdownCleanly={0}") public static Collection<Object[]> data() { if (SystemUtil.osName().startsWith("win")) { return Arrays.asList(new Object[][]{ {true} }); } else { return Arrays.asList(new Object[][]{ {true} }); } }
Example #5
Source File: ManageRecordingHistoryTest.java From aeron with Apache License 2.0 | 5 votes |
@BeforeEach public void before() { archivingMediaDriver = TestMediaDriver.launch( new MediaDriver.Context() .publicationTermBufferLength(Common.TERM_LENGTH) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(true) .dirDeleteOnStart(true), testWatcher); archive = Archive.launch( new Archive.Context() .maxCatalogEntries(Common.MAX_CATALOG_ENTRIES) .segmentFileLength(SEGMENT_LENGTH) .deleteArchiveOnStart(true) .archiveDir(new File(SystemUtil.tmpDirName(), "archive")) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); aeron = Aeron.connect(); aeronArchive = AeronArchive.connect( new AeronArchive.Context() .aeron(aeron)); }
Example #6
Source File: PublicationParams.java From aeron with Apache License 2.0 | 5 votes |
private void getLingerTimeoutNs(final ChannelUri channelUri) { final String lingerParam = channelUri.get(LINGER_PARAM_NAME); if (null != lingerParam) { lingerTimeoutNs = SystemUtil.parseDuration(LINGER_PARAM_NAME, lingerParam); Configuration.validatePublicationLingerTimeoutNs(lingerTimeoutNs, lingerTimeoutNs); } }
Example #7
Source File: PublicationParams.java From aeron with Apache License 2.0 | 5 votes |
private void getMtuLength(final ChannelUri channelUri) { final String mtuParam = channelUri.get(MTU_LENGTH_PARAM_NAME); if (null != mtuParam) { final int mtuLength = (int)SystemUtil.parseSize(MTU_LENGTH_PARAM_NAME, mtuParam); Configuration.validateMtuLength(mtuLength); validateMtuLength(this, mtuLength); this.mtuLength = mtuLength; } }
Example #8
Source File: PublicationParams.java From aeron with Apache License 2.0 | 5 votes |
private void getTermBufferLength(final ChannelUri channelUri) { final String termLengthParam = channelUri.get(TERM_LENGTH_PARAM_NAME); if (null != termLengthParam) { final int termLength = (int)SystemUtil.parseSize(TERM_LENGTH_PARAM_NAME, termLengthParam); LogBufferDescriptor.checkTermLength(termLength); validateTermLength(this, termLength); this.termLength = termLength; } }
Example #9
Source File: AeronStat.java From aeron with Apache License 2.0 | 5 votes |
private static void clearScreen() throws Exception { if (SystemUtil.isWindows()) { new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); } else { System.out.print(ANSI_CLS + ANSI_HOME); } }
Example #10
Source File: CommonContext.java From aeron with Apache License 2.0 | 5 votes |
/** * Override the supplied timeout with the debug value if it has been set and we are in debug mode. * * @param timeout The timeout value currently in use. * @param timeUnit The units of the timeout value. Debug timeout is specified in ns, so will be converted to this * unit. * @return The debug timeout if specified and we are being debugged or the supplied value if not. Will be in * timeUnit units. */ public static long checkDebugTimeout(final long timeout, final TimeUnit timeUnit) { final String debugTimeoutString = getProperty(DEBUG_TIMEOUT_PROP_NAME); if (null == debugTimeoutString || !SystemUtil.isDebuggerAttached()) { return timeout; } try { final long debugTimeoutNs = SystemUtil.parseDuration(DEBUG_TIMEOUT_PROP_NAME, debugTimeoutString); final long debugTimeout = timeUnit.convert(debugTimeoutNs, TimeUnit.NANOSECONDS); final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); final String methodName = stackTrace[2].getMethodName(); final String className = stackTrace[2].getClassName(); final String debugFieldName = className + "." + methodName; if (null == DEBUG_FIELDS_SEEN.putIfAbsent(debugFieldName, true)) { final String message = "Using debug timeout [" + debugTimeout + "] for " + debugFieldName + " replacing [" + timeout + "]"; System.out.println(message); } return debugTimeout; } catch (final NumberFormatException ignore) { return timeout; } }
Example #11
Source File: ClusterTests.java From aeron with Apache License 2.0 | 5 votes |
public static ErrorHandler errorHandler(final int nodeId) { return (ex) -> { if (ex instanceof AeronException) { if (((AeronException)ex).category() == AeronException.Category.WARN) { //final String message = ex.getMessage(); //final String name = ex.getClass().getName(); //System.err.println("Warning in node " + nodeId + " " + name + " : " + message); return; } } if (ex instanceof AgentTerminationException) { return; } addError(ex); System.err.println("\n*** Error in node " + nodeId + " followed by system thread dump ***\n\n"); ex.printStackTrace(); System.err.println(); System.err.println(SystemUtil.threadDump()); }; }
Example #12
Source File: ReplayMergeTest.java From aeron with Apache License 2.0 | 5 votes |
@BeforeEach public void before() { final File archiveDir = new File(SystemUtil.tmpDirName(), "archive"); mediaDriver = TestMediaDriver.launch( mediaDriverContext .termBufferSparseFile(true) .publicationTermBufferLength(TERM_LENGTH) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(false) .dirDeleteOnStart(true), testWatcher); archive = Archive.launch( new Archive.Context() .maxCatalogEntries(MAX_CATALOG_ENTRIES) .aeronDirectoryName(mediaDriverContext.aeronDirectoryName()) .errorHandler(Tests::onError) .archiveDir(archiveDir) .recordingEventsEnabled(false) .threadingMode(ArchiveThreadingMode.SHARED) .deleteArchiveOnStart(true)); aeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(mediaDriverContext.aeronDirectoryName())); aeronArchive = AeronArchive.connect( new AeronArchive.Context() .errorHandler(Tests::onError) .aeron(aeron)); }
Example #13
Source File: BasicArchiveTest.java From aeron with Apache License 2.0 | 5 votes |
@BeforeEach public void before() { final String aeronDirectoryName = CommonContext.generateRandomDirName(); mediaDriver = TestMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(aeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(false) .dirDeleteOnStart(true), testWatcher); archive = Archive.launch( new Archive.Context() .maxCatalogEntries(Common.MAX_CATALOG_ENTRIES) .aeronDirectoryName(aeronDirectoryName) .deleteArchiveOnStart(true) .archiveDir(new File(SystemUtil.tmpDirName(), "archive")) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); aeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(aeronDirectoryName)); aeronArchive = AeronArchive.connect( new AeronArchive.Context() .aeron(aeron)); }
Example #14
Source File: EchoServer.java From benchmarks with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { SystemUtil.loadPropertiesFiles(args); try (EchoServer server = new EchoServer(getServerBuilder())) { server.start(); new ShutdownSignalBarrier().await(); } }
Example #15
Source File: ArchiveNode.java From benchmarks with Apache License 2.0 | 5 votes |
public static void main(final String[] args) { SystemUtil.loadPropertiesFiles(args); final AtomicBoolean running = new AtomicBoolean(true); installSignalHandler(running); try (ArchiveNode server = new ArchiveNode(running)) { server.run(); } }
Example #16
Source File: EchoNode.java From benchmarks with Apache License 2.0 | 5 votes |
public static void main(final String[] args) { SystemUtil.loadPropertiesFiles(args); final AtomicBoolean running = new AtomicBoolean(true); installSignalHandler(running); try (EchoNode server = new EchoNode(running)) { server.run(); } }
Example #17
Source File: LiveReplayNode.java From benchmarks with Apache License 2.0 | 5 votes |
public static void main(final String[] args) { SystemUtil.loadPropertiesFiles(args); final AtomicBoolean running = new AtomicBoolean(true); installSignalHandler(running); try (LiveReplayNode server = new LiveReplayNode(running)) { server.run(); } }
Example #18
Source File: LoadTestRig.java From benchmarks with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { SystemUtil.loadPropertiesFiles(args); final Configuration configuration = Configuration.fromSystemProperties(); new LoadTestRig(configuration).run(); }
Example #19
Source File: ReplicateRecordingTest.java From aeron with Apache License 2.0 | 4 votes |
@BeforeEach public void before() { final String srcAeronDirectoryName = generateRandomDirName(); final String dstAeronDirectoryName = generateRandomDirName(); srcMediaDriver = TestMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(srcAeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(true) .dirDeleteOnStart(true), testWatcher); srcArchive = Archive.launch( new Archive.Context() .maxCatalogEntries(MAX_CATALOG_ENTRIES) .aeronDirectoryName(srcAeronDirectoryName) .controlChannel(SRC_CONTROL_REQUEST_CHANNEL) .archiveClientContext(new AeronArchive.Context().controlResponseChannel(SRC_CONTROL_RESPONSE_CHANNEL)) .recordingEventsEnabled(false) .replicationChannel(SRC_REPLICATION_CHANNEL) .deleteArchiveOnStart(true) .archiveDir(new File(SystemUtil.tmpDirName(), "src-archive")) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); dstMediaDriver = TestMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(dstAeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Tests::onError) .spiesSimulateConnection(true) .dirDeleteOnStart(true), testWatcher); dstArchive = Archive.launch( new Archive.Context() .maxCatalogEntries(MAX_CATALOG_ENTRIES) .aeronDirectoryName(dstAeronDirectoryName) .controlChannel(DST_CONTROL_REQUEST_CHANNEL) .archiveClientContext(new AeronArchive.Context().controlResponseChannel(DST_CONTROL_RESPONSE_CHANNEL)) .recordingEventsEnabled(false) .replicationChannel(DST_REPLICATION_CHANNEL) .deleteArchiveOnStart(true) .archiveDir(new File(SystemUtil.tmpDirName(), "dst-archive")) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); srcAeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(srcAeronDirectoryName)); dstAeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(dstAeronDirectoryName)); srcAeronArchive = AeronArchive.connect( new AeronArchive.Context() .idleStrategy(YieldingIdleStrategy.INSTANCE) .controlRequestChannel(SRC_CONTROL_REQUEST_CHANNEL) .controlResponseChannel(SRC_CONTROL_RESPONSE_CHANNEL) .aeron(srcAeron)); dstAeronArchive = AeronArchive.connect( new AeronArchive.Context() .idleStrategy(YieldingIdleStrategy.INSTANCE) .controlRequestChannel(DST_CONTROL_REQUEST_CHANNEL) .controlResponseChannel(DST_CONTROL_RESPONSE_CHANNEL) .aeron(dstAeron)); }
Example #20
Source File: IndexedReplicatedRecording.java From aeron with Apache License 2.0 | 4 votes |
public IndexedReplicatedRecording() { final String srcAeronDirectoryName = getAeronDirectoryName() + "-src"; System.out.println("srcAeronDirectoryName=" + srcAeronDirectoryName); final String dstAeronDirectoryName = getAeronDirectoryName() + "-dst"; System.out.println("dstAeronDirectoryName=" + dstAeronDirectoryName); final File srcArchiveDir = new File(SystemUtil.tmpDirName(), "src-archive"); System.out.println("srcArchiveDir=" + srcArchiveDir); srcArchivingMediaDriver = ArchivingMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(srcAeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Throwable::printStackTrace) .spiesSimulateConnection(true) .dirDeleteOnShutdown(true) .dirDeleteOnStart(true), new Archive.Context() .maxCatalogEntries(MAX_CATALOG_ENTRIES) .controlChannel(SRC_CONTROL_REQUEST_CHANNEL) .archiveClientContext(new AeronArchive.Context().controlResponseChannel(SRC_CONTROL_RESPONSE_CHANNEL)) .recordingEventsEnabled(false) .replicationChannel(SRC_REPLICATION_CHANNEL) .deleteArchiveOnStart(true) .archiveDir(srcArchiveDir) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); final File dstArchiveDir = new File(SystemUtil.tmpDirName(), "dst-archive"); System.out.println("dstArchiveDir=" + dstArchiveDir); dstArchivingMediaDriver = ArchivingMediaDriver.launch( new MediaDriver.Context() .aeronDirectoryName(dstAeronDirectoryName) .termBufferSparseFile(true) .threadingMode(ThreadingMode.SHARED) .errorHandler(Throwable::printStackTrace) .spiesSimulateConnection(true) .dirDeleteOnShutdown(true) .dirDeleteOnStart(true), new Archive.Context() .maxCatalogEntries(MAX_CATALOG_ENTRIES) .controlChannel(DST_CONTROL_REQUEST_CHANNEL) .archiveClientContext(new AeronArchive.Context().controlResponseChannel(DST_CONTROL_RESPONSE_CHANNEL)) .recordingEventsEnabled(false) .replicationChannel(DST_REPLICATION_CHANNEL) .deleteArchiveOnStart(true) .archiveDir(dstArchiveDir) .fileSyncLevel(0) .threadingMode(ArchiveThreadingMode.SHARED)); srcAeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(srcAeronDirectoryName)); dstAeron = Aeron.connect( new Aeron.Context() .aeronDirectoryName(dstAeronDirectoryName)); srcAeronArchive = AeronArchive.connect( new AeronArchive.Context() .idleStrategy(YieldingIdleStrategy.INSTANCE) .controlRequestChannel(SRC_CONTROL_REQUEST_CHANNEL) .controlResponseChannel(SRC_CONTROL_RESPONSE_CHANNEL) .aeron(srcAeron)); dstAeronArchive = AeronArchive.connect( new AeronArchive.Context() .idleStrategy(YieldingIdleStrategy.INSTANCE) .controlRequestChannel(DST_CONTROL_REQUEST_CHANNEL) .controlResponseChannel(DST_CONTROL_RESPONSE_CHANNEL) .aeron(dstAeron)); }