br.com.objectos.git
Class GitService

java.lang.Object
  extended by br.com.objectos.git.GitService
All Implemented Interfaces:
GitExecutor

public final class GitService
extends Object
implements GitExecutor

A class for supporting the execution of GitCommand instances.

A GitService allows for the execution of Git commands by offering the required parameters of the GitCommand.submitAsync(GitCommandExecutor, CpuWorker) method.

Additionally, a GitService allows for configuring a number values that influence, among others, its memory footprint and concurrency level.

Applications will typically have one instance of this class per JVM.

Creation example

The following is a code example showing how to obtain a new instance of a GitService. It creates a new instance using the default values for all of the configuration options:
GitService service;
 service = GitService.create(cpuArray, ioWorker);
 

The next example explicitly sets all configuration options with the default values. Therefore, the previous and the next example are equivalent:

GitService service;
 service = GitService.create(
     cpuArray,

     ioWorker,

     GitService.bufferSize(4096),

     GitService.enginesPerWorker(1),

     GitService.logger(NoopLogger.getInstance())
 );
 

Since:
3

Nested Class Summary
static class GitService.Option
          A GitService configuration option.
 
Method Summary
static GitService.Option bufferSize(int size)
          The size in bytes of the internal buffers of each GitEngine in this service.
static GitService create(CpuArray cpuArray, IoWorker ioWorker, GitService.Option... options)
          Creates a new GitService instance configured with the provided values.
static GitService.Option enginesPerWorker(int value)
          The number of GitEngine instances per CpuWorker.
static GitService.Option logger(br.com.objectos.logging.Logger logger)
          The logger instance to be used by this service (and by all of the GitEngine instances).
<V> Computation<V>
submit(GitCommand<V> command)
          Submits the specified command to be executed asynchronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bufferSize

public static GitService.Option bufferSize(int size)
The size in bytes of the internal buffers of each GitEngine in this service.

Parameters:
size - the size in bytes
Returns:
a new option that sets the buffer size to the specified value
Throws:
IllegalArgumentException - if size < 64
See Also:
create(CpuArray, IoWorker, Option...), GitEngine.bufferSize(int)

create

public static GitService create(CpuArray cpuArray,
                                IoWorker ioWorker,
                                GitService.Option... options)
Creates a new GitService instance configured with the provided values.

Options are provided by static methods in this class. The available options are:

Options provided by the GitService class
Method name Description Default value
bufferSize The size in bytes of the buffers used by each GitEngine in this service 4096
enginesPerWorker The number of GitEngine instances per CpuWorker. It defines the concurrency level per CpuWorker. 1
logger The logger instance to use NoopLogger.getInstance()

Parameters:
cpuArray - the CPU worker array to be used by this Git service
ioWorker - the I/O worker
options - the additional configuration options
Returns:
a new GitService instance configured with the provided values

enginesPerWorker

public static GitService.Option enginesPerWorker(int value)
The number of GitEngine instances per CpuWorker.

For each CpuWorker in the CpuArray used to create this service, the specified value of GitEngines are created. For example, if a GitService is created with:

The service will contain a total of 12 GitEngine instances, three for each thread (cpu worker). Therefore, in this example, each thread will be able to run, at most, three concurrent Git tasks.

Parameters:
value - the number of engines per worker to set
Returns:
a new option that sets the engines per worker to the specified value
Throws:
IllegalArgumentException - if value <= 0
See Also:
create(CpuArray, IoWorker, Option...)

logger

public static GitService.Option logger(br.com.objectos.logging.Logger logger)
The logger instance to be used by this service (and by all of the GitEngine instances).

Parameters:
logger - the logger instance
Returns:
a new option that sets the logger instance to the specified value

submit

public final <V> Computation<V> submit(GitCommand<V> command)
Submits the specified command to be executed asynchronously.

Specified by:
submit in interface GitExecutor
Type Parameters:
V - the type of the command result
Parameters:
command - the command to be executed
Returns:
a GitComputation representing the possibly ongoing execution of the command


Copyright © 2020–2022 Objectos Software LTDA. All rights reserved.