Skip to content

Commit 9a44dcf

Browse files
committed
Update AeronStat.java
1 parent eec7b30 commit 9a44dcf

1 file changed

Lines changed: 0 additions & 125 deletions

File tree

  • remote/src/test/java/org/apache/pekko/remote/artery/aeron

remote/src/test/java/org/apache/pekko/remote/artery/aeron/AeronStat.java

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -91,83 +91,6 @@ public class AeronStat {
9191
/** Channel filter to be used for position counters. */
9292
private static final String COUNTER_CHANNEL = "channel";
9393

94-
/**
95-
* Main method for launching the process.
96-
*
97-
* @param args passed to the process.
98-
* @throws IOException if an error occurs writing to the console.
99-
* @throws InterruptedException if the thread sleep delay is interrupted.
100-
*/
101-
public static void main(final String[] args) throws IOException, InterruptedException {
102-
long delayMs = 1000L;
103-
boolean watch = true;
104-
Pattern typeFilter = null;
105-
Pattern identityFilter = null;
106-
Pattern sessionFilter = null;
107-
Pattern streamFilter = null;
108-
Pattern channelFilter = null;
109-
110-
if (0 != args.length) {
111-
checkForHelp(args);
112-
113-
for (final String arg : args) {
114-
final int equalsIndex = arg.indexOf('=');
115-
if (-1 == equalsIndex) {
116-
System.out.println("Arguments must be in name=pattern format: Invalid '" + arg + "'");
117-
return;
118-
}
119-
120-
final String argName = arg.substring(0, equalsIndex);
121-
final String argValue = arg.substring(equalsIndex + 1);
122-
123-
switch (argName) {
124-
case WATCH:
125-
watch = Boolean.parseBoolean(argValue);
126-
break;
127-
128-
case DELAY:
129-
delayMs = Long.parseLong(argValue) * 1000L;
130-
break;
131-
132-
case COUNTER_TYPE_ID:
133-
typeFilter = Pattern.compile(argValue);
134-
break;
135-
136-
case COUNTER_IDENTITY:
137-
identityFilter = Pattern.compile(argValue);
138-
break;
139-
140-
case COUNTER_SESSION_ID:
141-
sessionFilter = Pattern.compile(argValue);
142-
break;
143-
144-
case COUNTER_STREAM_ID:
145-
streamFilter = Pattern.compile(argValue);
146-
break;
147-
148-
case COUNTER_CHANNEL:
149-
channelFilter = Pattern.compile(argValue);
150-
break;
151-
152-
default:
153-
System.out.println("Unrecognised argument: '" + arg + "'");
154-
return;
155-
}
156-
}
157-
}
158-
159-
final CncFileReader cncFileReader = CncFileReader.map();
160-
161-
final CounterFilter counterFilter =
162-
new CounterFilter(typeFilter, identityFilter, sessionFilter, streamFilter, channelFilter);
163-
164-
if (watch) {
165-
workLoop(delayMs, () -> printOutput(cncFileReader, counterFilter));
166-
} else {
167-
printOutput(cncFileReader, counterFilter);
168-
}
169-
}
170-
17194
@SuppressWarnings("try")
17295
private static void workLoop(final long delayMs, final Runnable outputPrinter)
17396
throws IOException, InterruptedException {
@@ -181,54 +104,6 @@ private static void workLoop(final long delayMs, final Runnable outputPrinter)
181104
}
182105
}
183106

184-
private static void printOutput(
185-
final CncFileReader cncFileReader, final CounterFilter counterFilter) {
186-
System.out.print(DATE_FORMAT.format(new Date()));
187-
System.out.println(
188-
" - Aeron Stat (CnC v"
189-
+ cncFileReader.semanticVersion()
190-
+ ")"
191-
+ ", pid "
192-
+ cncFileReader.driverPid()
193-
+ ", heartbeat age "
194-
+ cncFileReader.driverHeartbeatAgeMs()
195-
+ "ms");
196-
System.out.println("======================================================================");
197-
198-
final CountersReader counters = cncFileReader.countersReader();
199-
final int maxIdWidth = AsciiEncoding.digitCount(counters.maxCounterId());
200-
final String formatString = "%" + maxIdWidth + "d: %,26d - %s%n";
201-
202-
counters.forEach(
203-
(counterId, typeId, keyBuffer, label) -> {
204-
if (counterFilter.filter(typeId, keyBuffer)) {
205-
final long value = counters.getCounterValue(counterId);
206-
System.out.format(formatString, counterId, value, label);
207-
}
208-
});
209-
210-
System.out.println("--");
211-
}
212-
213-
private static void checkForHelp(final String[] args) {
214-
for (final String arg : args) {
215-
if ("-?".equals(arg) || "-h".equals(arg) || "-help".equals(arg)) {
216-
System.out.format(
217-
"Usage: [-Daeron.dir=<directory containing CnC file>] AeronStat%n"
218-
+ "\t[delay=<seconds between updates>]%n"
219-
+ "\t[watch=<true|false>]%n"
220-
+ "filter by optional regex patterns:%n"
221-
+ "\t[type=<pattern>]%n"
222-
+ "\t[identity=<pattern>]%n"
223-
+ "\t[session=<pattern>]%n"
224-
+ "\t[stream=<pattern>]%n"
225-
+ "\t[channel=<pattern>]%n");
226-
227-
System.exit(0);
228-
}
229-
}
230-
}
231-
232107
private static void clearScreen() throws IOException, InterruptedException {
233108
if (SystemUtil.isWindows()) {
234109
new ProcessBuilder("C:\\Windows\\System32\\cmd.exe", "/c", "cls")

0 commit comments

Comments
 (0)