Class JobServiceProtoConverter


  • public class JobServiceProtoConverter
    extends java.lang.Object
    Converter of proto messages for the JobServiceGrpc.JobServiceImplBase service to and from V4 DTO POJO's.
    Since:
    4.0.0
    See Also:
    com.netflix.genie.common.internal.dtos, com.netflix.genie.proto
    • Constructor Detail

      • JobServiceProtoConverter

        public JobServiceProtoConverter()
    • Method Detail

      • toReserveJobIdRequestProto

        public com.netflix.genie.proto.ReserveJobIdRequest toReserveJobIdRequestProto​(AgentJobRequest jobRequest,
                                                                                      AgentClientMetadata agentClientMetadata)
                                                                               throws GenieConversionException
        Convert a V4 Job Request DTO into a gRPC reserve job id request to be sent to the server.
        Parameters:
        jobRequest - The job request to convert
        agentClientMetadata - The metadata about the agent
        Returns:
        The request that should be sent to the server for a new Job Specification given the parameters
        Throws:
        GenieConversionException - if conversion fails
      • toJobSpecificationRequestProto

        public com.netflix.genie.proto.JobSpecificationRequest toJobSpecificationRequestProto​(java.lang.String id)
        Generate a JobSpecificationRequest from the given job id.
        Parameters:
        id - The job id to generate the request for
        Returns:
        The request instance
      • toJobRequestDto

        public JobRequest toJobRequestDto​(com.netflix.genie.proto.ReserveJobIdRequest request)
                                   throws GenieConversionException
        Convert a gRPC reserve job id request into a V4 Job Request DTO for use within Genie codebase.
        Parameters:
        request - The request to convert
        Returns:
        The job request
        Throws:
        GenieConversionException - if conversion fails
      • toDryRunJobSpecificationRequestProto

        public com.netflix.genie.proto.DryRunJobSpecificationRequest toDryRunJobSpecificationRequestProto​(AgentJobRequest jobRequest)
                                                                                                   throws GenieConversionException
        Convert a V4 Job Request DTO into a gRPC dry run resolve job specification request to be sent to the server.
        Parameters:
        jobRequest - The job request to convert
        Returns:
        The request that should be sent to the server for a new Job Specification given the parameters
        Throws:
        GenieConversionException - if conversion fails
      • toJobRequestDto

        public JobRequest toJobRequestDto​(com.netflix.genie.proto.DryRunJobSpecificationRequest request)
                                   throws GenieConversionException
        Convert a gRPC request to dry run a job specification resolution into a JobRequest for use within Genie server codebase.
        Parameters:
        request - The request to convert
        Returns:
        The job request
        Throws:
        GenieConversionException - if conversion fails
      • toAgentClientMetadataDto

        public AgentClientMetadata toAgentClientMetadataDto​(com.netflix.genie.proto.AgentMetadata agentMetadata)
        Convert a proto AgentMetadata to an AgentClientMetadata.
        Parameters:
        agentMetadata - The metadata to convert
        Returns:
        The immutable DTO representation
      • toJobSpecificationResponseProto

        public com.netflix.genie.proto.JobSpecificationResponse toJobSpecificationResponseProto​(JobSpecification jobSpecification)
        Build a JobSpecificationResponse out of the given JobSpecification.
        Parameters:
        jobSpecification - The job specification to serialize
        Returns:
        The response instance
      • toJobSpecificationDto

        public JobSpecification toJobSpecificationDto​(com.netflix.genie.proto.JobSpecification protoSpec)
        Convert a response from server into a Job Specification DTO which can be used in the codebase free of gRPC.
        Parameters:
        protoSpec - The protobuf specification message
        Returns:
        A job specification DTO
      • toJobSpecificationProto

        public com.netflix.genie.proto.JobSpecification toJobSpecificationProto​(JobSpecification jobSpecification)
        Convert a Job Specification DTO to a protobuf message representation.
        Parameters:
        jobSpecification - The JobSpecification to convert
        Returns:
        A JobSpecification instance
      • toClaimJobRequestProto

        public com.netflix.genie.proto.ClaimJobRequest toClaimJobRequestProto​(java.lang.String jobId,
                                                                              AgentClientMetadata agentClientMetadata)
        Convert agent metadata and job id into a ClaimJobRequest for the server.
        Parameters:
        jobId - job id
        agentClientMetadata - agent metadata
        Returns:
        a ClaimJobRequest
      • toChangeJobStatusRequestProto

        public com.netflix.genie.proto.ChangeJobStatusRequest toChangeJobStatusRequestProto​(@NotBlank
                                                                                            @NotBlank java.lang.String jobId,
                                                                                            JobStatus currentJobStatus,
                                                                                            JobStatus newJobStatus,
                                                                                            @Nullable
                                                                                            java.lang.String message)
        Convert parameters into ChangeJobStatusRequest for the server.
        Parameters:
        jobId - job id
        currentJobStatus - the expected current status on the server
        newJobStatus - the new current status for this job
        message - an optional message to record with the state change
        Returns:
        a ChangeJobStatusRequest
      • toHandshakeRequestProto

        public com.netflix.genie.proto.HandshakeRequest toHandshakeRequestProto​(AgentClientMetadata agentClientMetadata)
                                                                         throws GenieConversionException
        Convert parameters into HandshakeRequest for the server.
        Parameters:
        agentClientMetadata - agent client metadata
        Returns:
        a HandshakeRequest
        Throws:
        GenieConversionException - if the inputs are invalid
      • toConfigureRequestProto

        public com.netflix.genie.proto.ConfigureRequest toConfigureRequestProto​(AgentClientMetadata agentClientMetadata)
                                                                         throws GenieConversionException
        Convert parameters into ConfigureRequest for the server.
        Parameters:
        agentClientMetadata - agent client metadata
        Returns:
        a ConfigureRequest
        Throws:
        GenieConversionException - if the inputs are invalid
      • toGetJobStatusRequestProto

        public com.netflix.genie.proto.GetJobStatusRequest toGetJobStatusRequestProto​(java.lang.String jobId)
        Creates a request to fetch the job status currently seen by the server.
        Parameters:
        jobId - the job id
        Returns:
        A GetJobStatusRequest message instance
      • toChangeJobStatusArchiveRequestProto

        public com.netflix.genie.proto.ChangeJobArchiveStatusRequest toChangeJobStatusArchiveRequestProto​(java.lang.String jobId,
                                                                                                          ArchiveStatus archiveStatus)
        Creates a request to change the remote job archive status.
        Parameters:
        jobId - the job id
        archiveStatus - the new archive status
        Returns:
        a ChangeJobArchiveStatusRequest message instance