aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java
blob: 7337f4ae32469431cf75a0a395f01c86e946bf92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.vespa.model;

/**
 * Interface implemented by services using network ports, identifying its requirements.
 *
 * @author arnej
 */
public interface NetworkPortRequestor {

    /** Returns the type of service */
    String getServiceType();

   /** Returns the name that identifies this service for the config-sentinel, never null */
    String getServiceName();

    /** Returns the config id, never null */
    String getConfigId();

    /**
     * Returns the desired base port for this service, or '0' if this
     * service should use the default port allocation mechanism.
     *
     * @return The desired base port for this service.
     */
    default int getWantedPort() { return 0; }

    /** allocate the ports you need */
    void allocatePorts(int start, PortAllocBridge from);

    /**
     * Returns the number of ports needed by this service.
     * User-defined ports for container http servers should not be counted, as those
     * ports are required to be outside Vespa's port range.
     */
    int getPortCount();

    /**
     * Returns true if the desired base port (returned by
     * getWantedPort()) for this service is the only allowed base
     * port.
     *
     * @return true if this Service requires the wanted base port.
     */
    default boolean requiresWantedPort() { return false; }
}