public class MachineResourceService extends Object
Constructor and Description |
---|
MachineResourceService() |
Modifier and Type | Method and Description |
---|---|
int |
findFreePortStartingFrom(int port)
Attempts to find a free port starting from the given port, then increasing by one until a free port is found.
|
Set<String> |
getLocalHostsAddresses()
Get addresses of the localhost
|
boolean |
isPortFree(int port)
To know if a port is free or used
|
boolean |
isValidPort(int port) |
protected ServerSocket |
socketOnPort(int port) |
FileLock |
tryAcquireLock(String lockName)
Try to acquire a lock.
|
public int findFreePortStartingFrom(int port) throws ReadyApiException
port
- the initial port to try. If (port < 0) or (port > 65535) ReadyApiException is thrown immediatelyReadyApiException
- if can't get any free portpublic boolean isPortFree(int port)
port
- public boolean isValidPort(int port)
port
- protected ServerSocket socketOnPort(int port) throws IOException
IOException
public FileLock tryAcquireLock(String lockName) throws OverlappingFileLockException
lockName
- will become a file at ${READY_API_HOME_DIR}/lockName.lockOverlappingFileLockException
- if cannot acquire lock for any reasonpublic Set<String> getLocalHostsAddresses() throws SocketException
SocketException
Copyright © 2019. All rights reserved.