public final class PortAllocationManager extends Object
Modifier and Type | Method and Description |
---|---|
int |
allocate(AbstractBuild owner,
int port)
Assigns the requested port.
|
int[] |
allocatePortRange(AbstractBuild owner,
int start,
int end,
int count,
boolean isConsecutive)
Allocate a continuous range of ports within specified limits.
|
int |
allocateRandom(AbstractBuild owner,
int prefPort)
Allocates a random port on the Computer where the jobs gets executed.
|
void |
free(int n) |
static PortAllocationManager |
getManager(Computer node) |
boolean |
isFree(int port) |
public int allocateRandom(AbstractBuild owner, int prefPort) throws InterruptedException, IOException
If the preferred port is not available, assigns a random available port.
prefPort
- Preffered port. This method trys to assign this port, and upon failing, fall back to
assigning a random port.InterruptedException
IOException
public int[] allocatePortRange(AbstractBuild owner, int start, int end, int count, boolean isConsecutive) throws InterruptedException, IOException
owner
- current buildstart
- first port in the range of allowable portsend
- the last entry in the range of allowable portscount
- the number of ports to allocateisConsecutive
- true if the allocated ports should be consecutiveInterruptedException
- if the allocation was interruptedIOException
- if the allocation failedpublic int allocate(AbstractBuild owner, int port) throws InterruptedException, IOException
InterruptedException
IOException
public boolean isFree(int port)
public static PortAllocationManager getManager(Computer node)
public void free(int n)
Copyright © 2016–2023. All rights reserved.