PortAllocator would need to become a SimpleBuildWrapper. There are various places AbstractBuild would need to be replaced by Run, and similar minor changes. To survive Jenkins restarts, that means Port must become Serializable, cleanUp needs to be passed in sufficient context that Port need not keep unserializable state, and PortAllocationManager needs to become a persistent Extension (using load/save) with ports keeping only Run.externalizableId and INSTANCES being keyed by Node.name. Pool probably also needs to be come Serializable, enabling PooledPortType to work, and then other types like TomcatShutdownPortType needs to be modified to use static Serializable nested classes for cleanup work. Overall a fairly major refactoring, akin to what I had to do for JENKINS-26477.
PortAllocator would need to become a SimpleBuildWrapper. There are various places AbstractBuild would need to be replaced by Run, and similar minor changes. To survive Jenkins restarts, that means Port must become Serializable, cleanUp needs to be passed in sufficient context that Port need not keep unserializable state, and PortAllocationManager needs to become a persistent Extension (using load/save) with ports keeping only Run.externalizableId and INSTANCES being keyed by Node.name. Pool probably also needs to be come Serializable, enabling PooledPortType to work, and then other types like TomcatShutdownPortType needs to be modified to use static Serializable nested classes for cleanup work. Overall a fairly major refactoring, akin to what I had to do for
JENKINS-26477.