Class CentralDogmaBuilder

java.lang.Object
com.linecorp.centraldogma.server.CentralDogmaBuilder

public final class CentralDogmaBuilder extends Object
Builds a CentralDogma server.

 CentralDogmaBuilder builder = new CentralDogmaBuilder(new File("/tmp/dogma"));
 builder.numRepositoryWorkers(32);
 builder...;
 CentralDogma dogma = builder.build();
 dogma.start();
 
  • Constructor Details

    • CentralDogmaBuilder

      public CentralDogmaBuilder(File dataDir)
      Creates a new builder with the specified data directory.
  • Method Details

    • port

      public CentralDogmaBuilder port(int port, SessionProtocol protocol)
      Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used.
      Parameters:
      port - the TCP/IP port number
      protocol - SessionProtocol.HTTP or SessionProtocol.HTTPS
    • port

      public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol)
      Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used.
      Parameters:
      localAddress - the TCP/IP load address to bind
      protocol - SessionProtocol.HTTP or SessionProtocol.HTTPS
    • port

      public CentralDogmaBuilder port(ServerPort port)
      Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used.
    • tls

      public CentralDogmaBuilder tls(TlsConfig tls)
      Sets a TlsConfig for supporting TLS on the server.
    • trustedProxyAddresses

      public CentralDogmaBuilder trustedProxyAddresses(String... exactOrCidrAddresses)
      Adds addresses or ranges of Classless Inter-domain Routing (CIDR) blocks of trusted proxy servers.
      Parameters:
      exactOrCidrAddresses - a list of addresses and CIDR blocks, e.g. 10.0.0.1 for a single address or 10.0.0.0/8 for a CIDR block
    • trustedProxyAddresses

      public CentralDogmaBuilder trustedProxyAddresses(Iterable<String> exactOrCidrAddresses)
      Adds addresses or ranges of Classless Inter-domain Routing (CIDR) blocks of trusted proxy servers.
      Parameters:
      exactOrCidrAddresses - a list of addresses and CIDR blocks, e.g. 10.0.0.1 for a single address or 10.0.0.0/8 for a CIDR block
    • clientAddressSources

      public CentralDogmaBuilder clientAddressSources(String... clientAddressSources)
      Adds the HTTP header names to be used for retrieving a client address.

      Note that "PROXY_PROTOCOL" indicates the source address specified in a PROXY protocol message.

      Also note that if you configured trusted proxy addresses, "forwarded", "x-forwarded-for" and "PROXY_PROTOCOL" will be used as client address sources by default.

      Parameters:
      clientAddressSources - the HTTP header names or "PROXY_PROTOCOL" to be used for retrieving a client address
    • clientAddressSources

      public CentralDogmaBuilder clientAddressSources(Iterable<String> clientAddressSources)
      Adds the HTTP header names to be used for retrieving a client address.

      Note that "PROXY_PROTOCOL" indicates the source address specified in a PROXY protocol message.

      Also note that if you configured trusted proxy addresses, "forwarded", "x-forwarded-for" and "PROXY_PROTOCOL" will be used as client address sources by default.

      Parameters:
      clientAddressSources - the HTTP header names or "PROXY_PROTOCOL" to be used for retrieving a client address
    • numWorkers

      public CentralDogmaBuilder numWorkers(int numWorkers)
      Sets the number of I/O worker threads. Armeria default is used if unspecified.
    • maxNumConnections

      public CentralDogmaBuilder maxNumConnections(int maxNumConnections)
      Sets the maximum allowed number of TCP/IP connections. If unspecified, no limit is enforced.
    • requestTimeout

      public CentralDogmaBuilder requestTimeout(Duration requestTimeout)
      Sets the timeout for handling an incoming request. If it takes more than the specified timeout to handle a request, the server may respond with '503 Service Unavailable' or fail to respond. Armeria default is used if unspecified.
    • requestTimeoutMillis

      public CentralDogmaBuilder requestTimeoutMillis(long requestTimeoutMillis)
      Sets the timeout for handling an incoming request, in milliseconds. If it takes more than the specified timeout to handle a request, the server may respond with '503 Service Unavailable' or fail to respond. Armeria default is used if unspecified.
    • idleTimeout

      public CentralDogmaBuilder idleTimeout(Duration idleTimeout)
      Sets the timeout for keeping an idle connection. A connection is automatically closed when it stays idle without any requests in progress for more than the specified timeout. Armeria default is used if unspecified.
    • idleTimeoutMillis

      public CentralDogmaBuilder idleTimeoutMillis(long idleTimeoutMillis)
      Sets the timeout for keeping an idle connection, in milliseconds. A connection is automatically closed when it stays idle without any requests in progress for more than the specified timeout.
    • maxFrameLength

      public CentralDogmaBuilder maxFrameLength(int maxFrameLength)
      Sets the maximum allowed content length of an incoming request.
    • numRepositoryWorkers

      public CentralDogmaBuilder numRepositoryWorkers(int numRepositoryWorkers)
      Sets the number of worker threads dedicated to repository access. If unspecified, 16 threads are created at maximum.
    • maxRemovedRepositoryAge

      public CentralDogmaBuilder maxRemovedRepositoryAge(Duration maxRemovedRepositoryAge)
      Sets the maximum allowed age of removed projects and repositories before they are purged. Set 0 to disable automatic purge. If unspecified, the default of 604800000L milliseconds is used.
    • maxRemovedRepositoryAgeMillis

      public CentralDogmaBuilder maxRemovedRepositoryAgeMillis(long maxRemovedRepositoryAgeMillis)
      Sets the maximum allowed age, in milliseconds of removed projects and repositories before they are purged. Set 0 to disable automatic purge. If unspecified, the default of 604800000L milliseconds is used.
    • cacheSpec

      @Deprecated public CentralDogmaBuilder cacheSpec(String cacheSpec)
      Deprecated.
      Sets the cache specification which determines the capacity and behavior of the cache for the return values of methods in Repository of the server. See CaffeineSpec for the syntax of the spec. If unspecified, the default cache spec of "maximumWeight=134217728,expireAfterAccess=5m" is used.
    • repositoryCacheSpec

      public CentralDogmaBuilder repositoryCacheSpec(String repositoryCacheSpec)
      Sets the cache specification which determines the capacity and behavior of the cache for the return values of methods in Repository of the server. See CaffeineSpec for the syntax of the spec. If unspecified, the default cache spec of "maximumWeight=134217728,expireAfterAccess=5m" is used.
    • webAppEnabled

      public CentralDogmaBuilder webAppEnabled(boolean webAppEnabled)
      Sets whether administrative web application is enabled or not. If unspecified, the administrative web application is enabled.
    • webAppTitle

      public CentralDogmaBuilder webAppTitle(String webAppTitle)
      Sets the title text which is displayed on the navigation bar of the administrative web application.
    • mirroringEnabled

      public CentralDogmaBuilder mirroringEnabled(boolean mirroringEnabled)
      Sets whether MirroringService is enabled or not. If unspecified, MirroringService is enabled.
    • numMirroringThreads

      public CentralDogmaBuilder numMirroringThreads(int numMirroringThreads)
      Sets the number of worker threads dedicated to mirroring between repositories. If unspecified, 16 threads are created at maximum.
    • maxNumFilesPerMirror

      public CentralDogmaBuilder maxNumFilesPerMirror(int maxNumFilesPerMirror)
      Sets the maximum allowed number of files in a mirrored tree. If unspecified, 8192 files are allowed at maximum.
    • maxNumBytesPerMirror

      public CentralDogmaBuilder maxNumBytesPerMirror(long maxNumBytesPerMirror)
      Sets the maximum allowed number of bytes in a mirrored tree. If unspecified, 33554432L bytes are allowed at maximum.
    • gracefulShutdownTimeout

      public CentralDogmaBuilder gracefulShutdownTimeout(GracefulShutdownTimeout gracefulShutdownTimeout)
      Sets the graceful shutdown timeout. If unspecified, graceful shutdown is disabled.
    • replication

      public CentralDogmaBuilder replication(ReplicationConfig replicationConfig)
      Configures the replication. If unspecified or ReplicationConfig.NONE is specified, replication is disabled.
    • accessLogFormat

      public CentralDogmaBuilder accessLogFormat(String accessLogFormat)
      Configures a format of an access log. It will work only if any logging framework is configured. Read the Writing an access log document for more information.
    • authProviderFactory

      public CentralDogmaBuilder authProviderFactory(AuthProviderFactory authProviderFactory)
      Sets an AuthProviderFactory instance which is used to create a new AuthProvider.
    • administrators

      public CentralDogmaBuilder administrators(String... administrators)
      Adds administrators to the set.
    • administrators

      public CentralDogmaBuilder administrators(Iterable<String> administrators)
      Adds administrators to the set.
    • caseSensitiveLoginNames

      public CentralDogmaBuilder caseSensitiveLoginNames(boolean caseSensitiveLoginNames)
      Sets whether case-sensitive matching is performed when login names are compared.
    • sessionCacheSpec

      public CentralDogmaBuilder sessionCacheSpec(String sessionCacheSpec)
      Sets the cache specification which determines the capacity and behavior of the cache for Session of the server. See CaffeineSpec for the syntax of the spec. If unspecified, the default cache spec of "maximumSize=8192,expireAfterWrite=604800s" is used.
    • sessionTimeoutMillis

      public CentralDogmaBuilder sessionTimeoutMillis(long sessionTimeoutMillis)
      Sets the session timeout for administrative web application, in milliseconds. If unspecified, 604800000L is used.
    • sessionTimeout

      public CentralDogmaBuilder sessionTimeout(Duration sessionTimeout)
      Sets the session timeout for administrative web application. If unspecified, 604800000L is used.
    • sessionValidationSchedule

      public CentralDogmaBuilder sessionValidationSchedule(String sessionValidationSchedule)
      Sets a schedule for validating sessions. If unspecified, "0 30 */4 ? * *" is used.
    • authProviderProperties

      public CentralDogmaBuilder authProviderProperties(Object authProviderProperties)
      Sets an additional properties for an AuthProviderFactory.
    • writeQuotaPerRepository

      public CentralDogmaBuilder writeQuotaPerRepository(int writeQuota, int timeWindowSeconds)
      Sets maximum allowed write requests per timeWindowSeconds for each Repository.
    • meterRegistry

      public CentralDogmaBuilder meterRegistry(MeterRegistry meterRegistry)
      Sets the MeterRegistry used to collect metrics.
    • cors

      public CentralDogmaBuilder cors(CorsConfig corsConfig)
      Sets CORS related configurations.
    • build

      public CentralDogma build()
      Returns a newly-created CentralDogma server.