writeByte(processNumber, OPERATIONAL_BYTE_OFFSET, OPERATIONAL);
}
- void ping(int processNumber) {
- writeLong(processNumber, PING_BYTE_OFFSET, System.currentTimeMillis());
- }
-
- long getLastPing(int processNumber) {
- return readLong(processNumber, PING_BYTE_OFFSET);
- }
-
String getSystemInfoUrl(int processNumber) {
byte[] urlBytes = readBytes(processNumber, SYSTEM_INFO_URL_BYTE_OFFSET, SYSTEM_INFO_URL_SIZE_IN_BYTES);
return new String(urlBytes, StandardCharsets.US_ASCII).trim();
AllProcessesCommands.this.setOperational(processNumber);
}
- @Override
- public void ping() {
- AllProcessesCommands.this.ping(processNumber);
- }
-
- @Override
- public long getLastPing() {
- return AllProcessesCommands.this.getLastPing(processNumber);
- }
-
@Override
public void setHttpUrl(String s) {
AllProcessesCommands.this.setSystemInfoUrl(processNumber, s);
}
}
- @Test
- public void write_and_read_ping() throws IOException {
- try (AllProcessesCommands commands = new AllProcessesCommands(temp.newFolder())) {
- int offset = 5;
-
- assertThat(readLong(commands, offset)).isZero();
-
- long currentTime = System.currentTimeMillis();
- commands.ping(PROCESS_NUMBER);
- assertThat(readLong(commands, offset)).isGreaterThanOrEqualTo(currentTime);
- }
- }
-
@Test
public void write_and_read_system_info_url() throws IOException {
try (AllProcessesCommands commands = new AllProcessesCommands(temp.newFolder())) {