org.springframework.cloud.dataflow.server.service.impl

## Class DefaultStreamService

- java.lang.Object
- - org.springframework.cloud.dataflow.server.service.impl.DefaultStreamService

- All Implemented Interfaces:
    StreamService

      @Transactional
      public class DefaultStreamService
      extends Object
      implements StreamService

  Performs manipulation on application and deployment properties, expanding shorthand application property values, resolving wildcard deployment properties, and creates a `StreamDeploymentRequest`.

  The `StreamService` deployer is agnostic. For deploying streams on Skipper use the `DefaultStreamService`.

  Author:
    Mark Pollack, Ilayaperumal Gopinathan, Christian Tzolov, Gunnar Hillert, Chris Schaefer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.springframework.cloud.dataflow.audit.service.AuditRecordService` | `auditRecordService`
    `protected org.springframework.cloud.dataflow.audit.service.AuditServiceUtils` | `auditServiceUtils`
    `static String` | `DEFAULT_SKIPPER_PACKAGE_VERSION`
    `protected StreamDefinitionRepository` | `streamDefinitionRepository` The repository this controller will use for stream CRUD operations.
    `protected StreamValidationService` | `streamValidationService`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultStreamService(StreamDefinitionRepository streamDefinitionRepository, SkipperStreamDeployer skipperStreamDeployer, AppDeploymentRequestCreator appDeploymentRequestCreator, StreamValidationService streamValidationService, org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService, StreamDefinitionService streamDefinitionService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `StreamDefinition` | `createStream(String streamName, String dsl, String description, boolean deploy)` Create a new stream.
    `StreamDefinition` | `createStreamDefinition(String streamName, String dsl, String description)`
    `void` | `deleteAll()` Delete all streams, including undeploying.
    `void` | `deleteStream(String streamName)` Delete the stream, including undeloying.
    `void` | `deployStream(String streamName, Map<String,String> deploymentProperties)` Deploys the stream with the user provided deployment properties.
    `org.springframework.cloud.deployer.spi.app.DeploymentState` | `doCalculateStreamState(String name)`
    `org.springframework.data.domain.Page<StreamDefinition>` | `findDefinitionByNameContains(org.springframework.data.domain.Pageable pageable, String search)` Find stream definitions where the findByTaskNameContains parameter
    `StreamDefinition` | `findOne(String streamDefinitionName)` Find a stream definition by name.
    `List<StreamDefinition>` | `findRelatedStreams(String streamName, boolean nested)` Find streams related to the given stream name.
    `Collection<org.springframework.cloud.skipper.domain.Release>` | `history(String releaseName)` Get stream's deployment history
    `StreamDeployment` | `info(String streamName)` Get stream information including the deployment properties etc.
    `String` | `manifest(String name, int version)` Return a manifest info of a release version.
    `Collection<org.springframework.cloud.skipper.domain.Deployer>` | `platformList()`
    `void` | `rollbackStream(String streamName, int releaseVersion)` Rollback the stream to the previous or a specific version of the stream.
    `void` | `scaleApplicationInstances(String streamName, String appName, int count, Map<String,String> properties)` Scale application instances in a deployed stream.
    `Map<StreamDefinition,org.springframework.cloud.deployer.spi.app.DeploymentState>` | `state(List<StreamDefinition> streamDefinitions)` Retrieve the deployment state for list of stream definitions.
    `void` | `undeployStream(String streamName)` Un-deploys the stream identified by the given stream name.
    `void` | `updateStream(String streamName, String releaseName, org.springframework.cloud.skipper.domain.PackageIdentifier packageIdentifier, Map<String,String> updateProperties, boolean force, List<String> appNames)`
    `void` | `updateStream(String streamName, UpdateStreamRequest updateStreamRequest)` Update the stream using the UpdateStreamRequest.
    `ValidationStatus` | `validateStream(String name)` Verifies that all apps in the stream are valid.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_SKIPPER_PACKAGE_VERSION

          public static final String DEFAULT_SKIPPER_PACKAGE_VERSION

      See Also:
        Constant Field Values

    - #### streamDefinitionRepository

          protected final StreamDefinitionRepository streamDefinitionRepository

      The repository this controller will use for stream CRUD operations.

    - #### auditRecordService

          protected final org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService

    - #### auditServiceUtils

          protected final org.springframework.cloud.dataflow.audit.service.AuditServiceUtils auditServiceUtils

    - #### streamValidationService

          protected final StreamValidationService streamValidationService

  - ### Constructor Detail

    - #### DefaultStreamService

          public DefaultStreamService(StreamDefinitionRepository streamDefinitionRepository,
                                      SkipperStreamDeployer skipperStreamDeployer,
                                      AppDeploymentRequestCreator appDeploymentRequestCreator,
                                      StreamValidationService streamValidationService,
                                      org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService,
                                      StreamDefinitionService streamDefinitionService)

  - ### Method Detail

    - #### doCalculateStreamState

          public org.springframework.cloud.deployer.spi.app.DeploymentState doCalculateStreamState(String name)

    - #### undeployStream

          public void undeployStream(String streamName)

      Description copied from interface: `StreamService`
      Un-deploys the stream identified by the given stream name.
      Specified by:
        `undeployStream` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream to un-deploy

    - #### scaleApplicationInstances

          public void scaleApplicationInstances(String streamName,
                                                String appName,
                                                int count,
                                                Map<String,String> properties)

      Description copied from interface: `StreamService`
      Scale application instances in a deployed stream.
      Specified by:
        `scaleApplicationInstances` in interface `StreamService`
      Parameters:
        `streamName` - the name of an existing stream definition (required)
        `appName` - in stream application name to scale (required)
        `count` - number of instances for the selected stream application (required)
        `properties` - scale deployment specific properties (optional)

    - #### updateStream

          public void updateStream(String streamName,
                                   UpdateStreamRequest updateStreamRequest)

      Description copied from interface: `StreamService`
      Update the stream using the UpdateStreamRequest.
      Specified by:
        `updateStream` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream to update
        `updateStreamRequest` - the UpdateStreamRequest to use during the update

    - #### updateStream

          public void updateStream(String streamName,
                                   String releaseName,
                                   org.springframework.cloud.skipper.domain.PackageIdentifier packageIdentifier,
                                   Map<String,String> updateProperties,
                                   boolean force,
                                   List<String> appNames)

    - #### rollbackStream

          public void rollbackStream(String streamName,
                                     int releaseVersion)

      Description copied from interface: `StreamService`
      Rollback the stream to the previous or a specific version of the stream.
      Specified by:
        `rollbackStream` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream to rollback
        `releaseVersion` - the version to rollback to (if not specified, rollback to the previous deleted/deployed release version of the stream.

    - #### state

          public Map<StreamDefinition,org.springframework.cloud.deployer.spi.app.DeploymentState> state(List<StreamDefinition> streamDefinitions)

      Description copied from interface: `StreamService`
      Retrieve the deployment state for list of stream definitions.
      Specified by:
        `state` in interface `StreamService`
      Parameters:
        `streamDefinitions` - the list of Stream definitions to calculate the deployment states.
      Returns:
        the map containing the stream definitions and their deployment states.

    - #### manifest

          public String manifest(String name,
                                 int version)

      Description copied from interface: `StreamService`
      Return a manifest info of a release version. For packages with dependencies, the manifest includes the contents of those dependencies.
      Specified by:
        `manifest` in interface `StreamService`
      Parameters:
        `name` - the release name
        `version` - the release version
      Returns:
        the manifest info of a release

    - #### history

          public Collection<org.springframework.cloud.skipper.domain.Release> history(String releaseName)

      Description copied from interface: `StreamService`
      Get stream's deployment history
      Specified by:
        `history` in interface `StreamService`
      Parameters:
        `releaseName` - Stream release name
      Returns:
        List or Releases for this release name

    - #### platformList

          public Collection<org.springframework.cloud.skipper.domain.Deployer> platformList()

      Specified by:
        `platformList` in interface `StreamService`
      Returns:
        list of supported deployment platforms

    - #### info

          public StreamDeployment info(String streamName)

      Description copied from interface: `StreamService`
      Get stream information including the deployment properties etc.
      Specified by:
        `info` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream
      Returns:
        the stream deployment information

    - #### createStream

          public StreamDefinition createStream(String streamName,
                                               String dsl,
                                               String description,
                                               boolean deploy)

      Create a new stream.
      Specified by:
        `createStream` in interface `StreamService`
      Parameters:
        `streamName` - stream name
        `dsl` - DSL definition for stream
        `description` - description of the stream definition
        `deploy` - if `true`, the stream is deployed upon creation (default is `false`)
      Returns:
        the created stream definition already exists
      Throws:
        `InvalidStreamDefinitionException` - if there are errors in parsing the stream DSL, resolving the name, or type of applications in the stream

    - #### createStreamDefinition

          public StreamDefinition createStreamDefinition(String streamName,
                                                         String dsl,
                                                         String description)

    - #### deployStream

          public void deployStream(String streamName,
                                   Map<String,String> deploymentProperties)

      Deploys the stream with the user provided deployment properties. Implementations are responsible for expanding deployment wildcard expressions.
      Specified by:
        `deployStream` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream
        `deploymentProperties` - deployment properties to use as passed in from the client.

    - #### deleteStream

          public void deleteStream(String streamName)

      Delete the stream, including undeloying.
      Specified by:
        `deleteStream` in interface `StreamService`
      Parameters:
        `streamName` - the name of the stream to delete

    - #### deleteAll

          public void deleteAll()

      Delete all streams, including undeploying.
      Specified by:
        `deleteAll` in interface `StreamService`

    - #### findRelatedStreams

          public List<StreamDefinition> findRelatedStreams(String streamName,
                                                           boolean nested)

      Find streams related to the given stream name.
      Specified by:
        `findRelatedStreams` in interface `StreamService`
      Parameters:
        `streamName` - name of the stream
        `nested` - if should recursively findByTaskNameContains for related stream definitions
      Returns:
        a list of related stream definitions

    - #### findDefinitionByNameContains

          public org.springframework.data.domain.Page<StreamDefinition> findDefinitionByNameContains(org.springframework.data.domain.Pageable pageable,
                                                                                                     String search)

      Find stream definitions where the findByTaskNameContains parameter
      Specified by:
        `findDefinitionByNameContains` in interface `StreamService`
      Parameters:
        `pageable` - Pagination information
        `search` - the findByTaskNameContains parameter to use
      Returns:
        Page of stream definitions

    - #### findOne

          public StreamDefinition findOne(String streamDefinitionName)

      Find a stream definition by name.
      Specified by:
        `findOne` in interface `StreamService`
      Parameters:
        `streamDefinitionName` - the name of the stream definition
      Returns:
        the stream definition
      Throws:
        `NoSuchStreamDefinitionException` - if the definition can not be found.

    - #### validateStream

          public ValidationStatus validateStream(String name)

      Verifies that all apps in the stream are valid.
      Specified by:
        `validateStream` in interface `StreamService`
      Parameters:
        `name` - the name of the definition
      Returns:
        `ValidationStatus` for a stream.

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.