Repository: beam Updated Branches: refs/heads/master ed00299cc -> 63b54a5b0
http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/model/org_apache_beam_fn_v1/beam_provision_api.pb.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/model/org_apache_beam_fn_v1/beam_provision_api.pb.go b/sdks/go/pkg/beam/model/org_apache_beam_fn_v1/beam_provision_api.pb.go new file mode 100644 index 0000000..534f65c --- /dev/null +++ b/sdks/go/pkg/beam/model/org_apache_beam_fn_v1/beam_provision_api.pb.go @@ -0,0 +1,219 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: beam_provision_api.proto + +/* +Package org_apache_beam_fn_v1 is a generated protocol buffer package. + +It is generated from these files: + beam_provision_api.proto + +It has these top-level messages: + GetProvisionInfoRequest + GetProvisionInfoResponse + ProvisionInfo +*/ +package org_apache_beam_fn_v1 + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/ptypes/struct" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// A request to get the provision info of a SDK harness worker instance. +type GetProvisionInfoRequest struct { +} + +func (m *GetProvisionInfoRequest) Reset() { *m = GetProvisionInfoRequest{} } +func (m *GetProvisionInfoRequest) String() string { return proto.CompactTextString(m) } +func (*GetProvisionInfoRequest) ProtoMessage() {} +func (*GetProvisionInfoRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +// A response containing the provision info of a SDK harness worker instance. +type GetProvisionInfoResponse struct { + Info *ProvisionInfo `protobuf:"bytes,1,opt,name=info" json:"info,omitempty"` +} + +func (m *GetProvisionInfoResponse) Reset() { *m = GetProvisionInfoResponse{} } +func (m *GetProvisionInfoResponse) String() string { return proto.CompactTextString(m) } +func (*GetProvisionInfoResponse) ProtoMessage() {} +func (*GetProvisionInfoResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *GetProvisionInfoResponse) GetInfo() *ProvisionInfo { + if m != nil { + return m.Info + } + return nil +} + +// Runtime provisioning information for a SDK harness worker instance, +// such as pipeline options, resource constraints and other job metadata +type ProvisionInfo struct { + // (required) The job ID. + JobId string `protobuf:"bytes,1,opt,name=job_id,json=jobId" json:"job_id,omitempty"` + // (required) The job name. + JobName string `protobuf:"bytes,2,opt,name=job_name,json=jobName" json:"job_name,omitempty"` + // (required) Pipeline options. For non-template jobs, the options are + // identical to what is passed to job submission. + PipelineOptions *google_protobuf.Struct `protobuf:"bytes,3,opt,name=pipeline_options,json=pipelineOptions" json:"pipeline_options,omitempty"` +} + +func (m *ProvisionInfo) Reset() { *m = ProvisionInfo{} } +func (m *ProvisionInfo) String() string { return proto.CompactTextString(m) } +func (*ProvisionInfo) ProtoMessage() {} +func (*ProvisionInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *ProvisionInfo) GetJobId() string { + if m != nil { + return m.JobId + } + return "" +} + +func (m *ProvisionInfo) GetJobName() string { + if m != nil { + return m.JobName + } + return "" +} + +func (m *ProvisionInfo) GetPipelineOptions() *google_protobuf.Struct { + if m != nil { + return m.PipelineOptions + } + return nil +} + +func init() { + proto.RegisterType((*GetProvisionInfoRequest)(nil), "org.apache.beam.fn.v1.GetProvisionInfoRequest") + proto.RegisterType((*GetProvisionInfoResponse)(nil), "org.apache.beam.fn.v1.GetProvisionInfoResponse") + proto.RegisterType((*ProvisionInfo)(nil), "org.apache.beam.fn.v1.ProvisionInfo") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for ProvisionService service + +type ProvisionServiceClient interface { + // Get provision information for the SDK harness worker instance. + GetProvisionInfo(ctx context.Context, in *GetProvisionInfoRequest, opts ...grpc.CallOption) (*GetProvisionInfoResponse, error) +} + +type provisionServiceClient struct { + cc *grpc.ClientConn +} + +func NewProvisionServiceClient(cc *grpc.ClientConn) ProvisionServiceClient { + return &provisionServiceClient{cc} +} + +func (c *provisionServiceClient) GetProvisionInfo(ctx context.Context, in *GetProvisionInfoRequest, opts ...grpc.CallOption) (*GetProvisionInfoResponse, error) { + out := new(GetProvisionInfoResponse) + err := grpc.Invoke(ctx, "/org.apache.beam.fn.v1.ProvisionService/GetProvisionInfo", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for ProvisionService service + +type ProvisionServiceServer interface { + // Get provision information for the SDK harness worker instance. + GetProvisionInfo(context.Context, *GetProvisionInfoRequest) (*GetProvisionInfoResponse, error) +} + +func RegisterProvisionServiceServer(s *grpc.Server, srv ProvisionServiceServer) { + s.RegisterService(&_ProvisionService_serviceDesc, srv) +} + +func _ProvisionService_GetProvisionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProvisionInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProvisionServiceServer).GetProvisionInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/org.apache.beam.fn.v1.ProvisionService/GetProvisionInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProvisionServiceServer).GetProvisionInfo(ctx, req.(*GetProvisionInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _ProvisionService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "org.apache.beam.fn.v1.ProvisionService", + HandlerType: (*ProvisionServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetProvisionInfo", + Handler: _ProvisionService_GetProvisionInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "beam_provision_api.proto", +} + +func init() { proto.RegisterFile("beam_provision_api.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xcf, 0x4b, 0xc3, 0x30, + 0x14, 0xc7, 0xa9, 0x3f, 0xa6, 0x46, 0xc5, 0x12, 0x18, 0xeb, 0x86, 0x07, 0x29, 0x0a, 0x9e, 0x52, + 0x9c, 0x17, 0xaf, 0xf6, 0x22, 0xbb, 0xa8, 0x74, 0xde, 0x4b, 0xd2, 0xbd, 0xd6, 0x94, 0x35, 0x2f, + 0x36, 0x69, 0xff, 0x03, 0xf1, 0xdf, 0x96, 0xa5, 0x74, 0x30, 0xdd, 0x60, 0xd7, 0xf7, 0x3e, 0xdf, + 0x97, 0xf7, 0x79, 0x21, 0x81, 0x00, 0x5e, 0xa5, 0xba, 0xc6, 0x56, 0x1a, 0x89, 0x2a, 0xe5, 0x5a, + 0x32, 0x5d, 0xa3, 0x45, 0x3a, 0xc4, 0xba, 0x60, 0x5c, 0xf3, 0xec, 0x13, 0xd8, 0x0a, 0x62, 0xb9, + 0x62, 0xed, 0xc3, 0xe4, 0xba, 0x40, 0x2c, 0x96, 0x10, 0x39, 0x48, 0x34, 0x79, 0x64, 0x6c, 0xdd, + 0x64, 0xb6, 0x0b, 0x85, 0x63, 0x32, 0x7a, 0x01, 0xfb, 0xde, 0x8f, 0x9b, 0xa9, 0x1c, 0x13, 0xf8, + 0x6a, 0xc0, 0xd8, 0xf0, 0x83, 0x04, 0xff, 0x5b, 0x46, 0xa3, 0x32, 0x40, 0x9f, 0xc8, 0x91, 0x54, + 0x39, 0x06, 0xde, 0x8d, 0x77, 0x7f, 0x3e, 0xbd, 0x65, 0x5b, 0x9f, 0x66, 0x9b, 0x59, 0x97, 0x08, + 0xbf, 0x3d, 0x72, 0xb9, 0x51, 0xa7, 0x43, 0x32, 0x28, 0x51, 0xa4, 0x72, 0xe1, 0xa6, 0x9d, 0x25, + 0xc7, 0x25, 0x8a, 0xd9, 0x82, 0x8e, 0xc9, 0xe9, 0xaa, 0xac, 0x78, 0x05, 0xc1, 0x81, 0x6b, 0x9c, + 0x94, 0x28, 0x5e, 0x79, 0x05, 0x34, 0x26, 0xbe, 0x96, 0x1a, 0x96, 0x52, 0x41, 0x8a, 0xda, 0x4a, + 0x54, 0x26, 0x38, 0x74, 0x9b, 0x8c, 0x58, 0x67, 0xcb, 0x7a, 0x5b, 0x36, 0x77, 0xb6, 0xc9, 0x55, + 0x1f, 0x78, 0xeb, 0xf8, 0xe9, 0x8f, 0x47, 0xfc, 0xf5, 0x1e, 0x73, 0xa8, 0x5b, 0x99, 0x01, 0x35, + 0xc4, 0xff, 0xab, 0x4c, 0xd9, 0x0e, 0xb9, 0x1d, 0x67, 0x9b, 0x44, 0x7b, 0xf3, 0xdd, 0x2d, 0xe3, + 0x3b, 0xb2, 0xfd, 0xe7, 0xe2, 0x8b, 0x35, 0xff, 0xac, 0xa5, 0x18, 0x38, 0xa5, 0xc7, 0xdf, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x97, 0x2b, 0xbd, 0x57, 0x01, 0x02, 0x00, 0x00, +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/model/org_apache_beam_runner_v1/beam_artifact_api.pb.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/model/org_apache_beam_runner_v1/beam_artifact_api.pb.go b/sdks/go/pkg/beam/model/org_apache_beam_runner_v1/beam_artifact_api.pb.go new file mode 100644 index 0000000..e8cc800 --- /dev/null +++ b/sdks/go/pkg/beam/model/org_apache_beam_runner_v1/beam_artifact_api.pb.go @@ -0,0 +1,729 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: beam_artifact_api.proto + +/* +Package org_apache_beam_runner_api_v1 is a generated protocol buffer package. + +It is generated from these files: + beam_artifact_api.proto + +It has these top-level messages: + ArtifactMetadata + Manifest + ProxyManifest + GetManifestRequest + GetManifestResponse + GetArtifactRequest + ArtifactChunk + PutArtifactRequest + PutArtifactResponse + CommitManifestRequest + CommitManifestResponse +*/ +package org_apache_beam_runner_api_v1 + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// An artifact identifier and associated metadata. +type ArtifactMetadata struct { + // (Required) The name of the artifact. + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // (Optional) The Unix-like permissions of the artifact + Permissions uint32 `protobuf:"varint,2,opt,name=permissions" json:"permissions,omitempty"` + // (Optional) The md5 checksum of the artifact. Used, among other things, by harness boot code to + // validate the integrity of the artifact. + Md5 string `protobuf:"bytes,3,opt,name=md5" json:"md5,omitempty"` +} + +func (m *ArtifactMetadata) Reset() { *m = ArtifactMetadata{} } +func (m *ArtifactMetadata) String() string { return proto.CompactTextString(m) } +func (*ArtifactMetadata) ProtoMessage() {} +func (*ArtifactMetadata) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *ArtifactMetadata) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ArtifactMetadata) GetPermissions() uint32 { + if m != nil { + return m.Permissions + } + return 0 +} + +func (m *ArtifactMetadata) GetMd5() string { + if m != nil { + return m.Md5 + } + return "" +} + +// A collection of artifacts. +type Manifest struct { + Artifact []*ArtifactMetadata `protobuf:"bytes,1,rep,name=artifact" json:"artifact,omitempty"` +} + +func (m *Manifest) Reset() { *m = Manifest{} } +func (m *Manifest) String() string { return proto.CompactTextString(m) } +func (*Manifest) ProtoMessage() {} +func (*Manifest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *Manifest) GetArtifact() []*ArtifactMetadata { + if m != nil { + return m.Artifact + } + return nil +} + +// A manifest with location information. +type ProxyManifest struct { + Manifest *Manifest `protobuf:"bytes,1,opt,name=manifest" json:"manifest,omitempty"` + Location []*ProxyManifest_Location `protobuf:"bytes,2,rep,name=location" json:"location,omitempty"` +} + +func (m *ProxyManifest) Reset() { *m = ProxyManifest{} } +func (m *ProxyManifest) String() string { return proto.CompactTextString(m) } +func (*ProxyManifest) ProtoMessage() {} +func (*ProxyManifest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *ProxyManifest) GetManifest() *Manifest { + if m != nil { + return m.Manifest + } + return nil +} + +func (m *ProxyManifest) GetLocation() []*ProxyManifest_Location { + if m != nil { + return m.Location + } + return nil +} + +type ProxyManifest_Location struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Uri string `protobuf:"bytes,2,opt,name=uri" json:"uri,omitempty"` +} + +func (m *ProxyManifest_Location) Reset() { *m = ProxyManifest_Location{} } +func (m *ProxyManifest_Location) String() string { return proto.CompactTextString(m) } +func (*ProxyManifest_Location) ProtoMessage() {} +func (*ProxyManifest_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } + +func (m *ProxyManifest_Location) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ProxyManifest_Location) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +// A request to get the manifest of a Job. +type GetManifestRequest struct { +} + +func (m *GetManifestRequest) Reset() { *m = GetManifestRequest{} } +func (m *GetManifestRequest) String() string { return proto.CompactTextString(m) } +func (*GetManifestRequest) ProtoMessage() {} +func (*GetManifestRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +// A response containing a job manifest. +type GetManifestResponse struct { + Manifest *Manifest `protobuf:"bytes,1,opt,name=manifest" json:"manifest,omitempty"` +} + +func (m *GetManifestResponse) Reset() { *m = GetManifestResponse{} } +func (m *GetManifestResponse) String() string { return proto.CompactTextString(m) } +func (*GetManifestResponse) ProtoMessage() {} +func (*GetManifestResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *GetManifestResponse) GetManifest() *Manifest { + if m != nil { + return m.Manifest + } + return nil +} + +// A request to get an artifact. The artifact must be present in the manifest for the job. +type GetArtifactRequest struct { + // (Required) The name of the artifact to retrieve. + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` +} + +func (m *GetArtifactRequest) Reset() { *m = GetArtifactRequest{} } +func (m *GetArtifactRequest) String() string { return proto.CompactTextString(m) } +func (*GetArtifactRequest) ProtoMessage() {} +func (*GetArtifactRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *GetArtifactRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// Part of an artifact. +type ArtifactChunk struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *ArtifactChunk) Reset() { *m = ArtifactChunk{} } +func (m *ArtifactChunk) String() string { return proto.CompactTextString(m) } +func (*ArtifactChunk) ProtoMessage() {} +func (*ArtifactChunk) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *ArtifactChunk) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +// A request to stage an artifact. +type PutArtifactRequest struct { + // (Required) + // + // Types that are valid to be assigned to Content: + // *PutArtifactRequest_Metadata + // *PutArtifactRequest_Data + Content isPutArtifactRequest_Content `protobuf_oneof:"content"` +} + +func (m *PutArtifactRequest) Reset() { *m = PutArtifactRequest{} } +func (m *PutArtifactRequest) String() string { return proto.CompactTextString(m) } +func (*PutArtifactRequest) ProtoMessage() {} +func (*PutArtifactRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +type isPutArtifactRequest_Content interface { + isPutArtifactRequest_Content() +} + +type PutArtifactRequest_Metadata struct { + Metadata *ArtifactMetadata `protobuf:"bytes,1,opt,name=metadata,oneof"` +} +type PutArtifactRequest_Data struct { + Data *ArtifactChunk `protobuf:"bytes,2,opt,name=data,oneof"` +} + +func (*PutArtifactRequest_Metadata) isPutArtifactRequest_Content() {} +func (*PutArtifactRequest_Data) isPutArtifactRequest_Content() {} + +func (m *PutArtifactRequest) GetContent() isPutArtifactRequest_Content { + if m != nil { + return m.Content + } + return nil +} + +func (m *PutArtifactRequest) GetMetadata() *ArtifactMetadata { + if x, ok := m.GetContent().(*PutArtifactRequest_Metadata); ok { + return x.Metadata + } + return nil +} + +func (m *PutArtifactRequest) GetData() *ArtifactChunk { + if x, ok := m.GetContent().(*PutArtifactRequest_Data); ok { + return x.Data + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*PutArtifactRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _PutArtifactRequest_OneofMarshaler, _PutArtifactRequest_OneofUnmarshaler, _PutArtifactRequest_OneofSizer, []interface{}{ + (*PutArtifactRequest_Metadata)(nil), + (*PutArtifactRequest_Data)(nil), + } +} + +func _PutArtifactRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*PutArtifactRequest) + // content + switch x := m.Content.(type) { + case *PutArtifactRequest_Metadata: + b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Metadata); err != nil { + return err + } + case *PutArtifactRequest_Data: + b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Data); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("PutArtifactRequest.Content has unexpected type %T", x) + } + return nil +} + +func _PutArtifactRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*PutArtifactRequest) + switch tag { + case 1: // content.metadata + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(ArtifactMetadata) + err := b.DecodeMessage(msg) + m.Content = &PutArtifactRequest_Metadata{msg} + return true, err + case 2: // content.data + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(ArtifactChunk) + err := b.DecodeMessage(msg) + m.Content = &PutArtifactRequest_Data{msg} + return true, err + default: + return false, nil + } +} + +func _PutArtifactRequest_OneofSizer(msg proto.Message) (n int) { + m := msg.(*PutArtifactRequest) + // content + switch x := m.Content.(type) { + case *PutArtifactRequest_Metadata: + s := proto.Size(x.Metadata) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case *PutArtifactRequest_Data: + s := proto.Size(x.Data) + n += proto.SizeVarint(2<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type PutArtifactResponse struct { +} + +func (m *PutArtifactResponse) Reset() { *m = PutArtifactResponse{} } +func (m *PutArtifactResponse) String() string { return proto.CompactTextString(m) } +func (*PutArtifactResponse) ProtoMessage() {} +func (*PutArtifactResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } + +// A request to commit the manifest for a Job. All artifacts must have been successfully uploaded +// before this call is made. +type CommitManifestRequest struct { + // (Required) The manifest to commit. + Manifest *Manifest `protobuf:"bytes,1,opt,name=manifest" json:"manifest,omitempty"` +} + +func (m *CommitManifestRequest) Reset() { *m = CommitManifestRequest{} } +func (m *CommitManifestRequest) String() string { return proto.CompactTextString(m) } +func (*CommitManifestRequest) ProtoMessage() {} +func (*CommitManifestRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } + +func (m *CommitManifestRequest) GetManifest() *Manifest { + if m != nil { + return m.Manifest + } + return nil +} + +// The result of committing a manifest. +type CommitManifestResponse struct { + // (Required) An opaque token representing the entirety of the staged artifacts. + StagingToken string `protobuf:"bytes,1,opt,name=staging_token,json=stagingToken" json:"staging_token,omitempty"` +} + +func (m *CommitManifestResponse) Reset() { *m = CommitManifestResponse{} } +func (m *CommitManifestResponse) String() string { return proto.CompactTextString(m) } +func (*CommitManifestResponse) ProtoMessage() {} +func (*CommitManifestResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } + +func (m *CommitManifestResponse) GetStagingToken() string { + if m != nil { + return m.StagingToken + } + return "" +} + +func init() { + proto.RegisterType((*ArtifactMetadata)(nil), "org.apache.beam.runner_api.v1.ArtifactMetadata") + proto.RegisterType((*Manifest)(nil), "org.apache.beam.runner_api.v1.Manifest") + proto.RegisterType((*ProxyManifest)(nil), "org.apache.beam.runner_api.v1.ProxyManifest") + proto.RegisterType((*ProxyManifest_Location)(nil), "org.apache.beam.runner_api.v1.ProxyManifest.Location") + proto.RegisterType((*GetManifestRequest)(nil), "org.apache.beam.runner_api.v1.GetManifestRequest") + proto.RegisterType((*GetManifestResponse)(nil), "org.apache.beam.runner_api.v1.GetManifestResponse") + proto.RegisterType((*GetArtifactRequest)(nil), "org.apache.beam.runner_api.v1.GetArtifactRequest") + proto.RegisterType((*ArtifactChunk)(nil), "org.apache.beam.runner_api.v1.ArtifactChunk") + proto.RegisterType((*PutArtifactRequest)(nil), "org.apache.beam.runner_api.v1.PutArtifactRequest") + proto.RegisterType((*PutArtifactResponse)(nil), "org.apache.beam.runner_api.v1.PutArtifactResponse") + proto.RegisterType((*CommitManifestRequest)(nil), "org.apache.beam.runner_api.v1.CommitManifestRequest") + proto.RegisterType((*CommitManifestResponse)(nil), "org.apache.beam.runner_api.v1.CommitManifestResponse") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for ArtifactStagingService service + +type ArtifactStagingServiceClient interface { + // Stage an artifact to be available during job execution. The first request must contain the + // name of the artifact. All future requests must contain sequential chunks of the content of + // the artifact. + PutArtifact(ctx context.Context, opts ...grpc.CallOption) (ArtifactStagingService_PutArtifactClient, error) + // Commit the manifest for a Job. All artifacts must have been successfully uploaded + // before this call is made. + // + // Throws error INVALID_ARGUMENT if not all of the members of the manifest are present + CommitManifest(ctx context.Context, in *CommitManifestRequest, opts ...grpc.CallOption) (*CommitManifestResponse, error) +} + +type artifactStagingServiceClient struct { + cc *grpc.ClientConn +} + +func NewArtifactStagingServiceClient(cc *grpc.ClientConn) ArtifactStagingServiceClient { + return &artifactStagingServiceClient{cc} +} + +func (c *artifactStagingServiceClient) PutArtifact(ctx context.Context, opts ...grpc.CallOption) (ArtifactStagingService_PutArtifactClient, error) { + stream, err := grpc.NewClientStream(ctx, &_ArtifactStagingService_serviceDesc.Streams[0], c.cc, "/org.apache.beam.runner_api.v1.ArtifactStagingService/PutArtifact", opts...) + if err != nil { + return nil, err + } + x := &artifactStagingServicePutArtifactClient{stream} + return x, nil +} + +type ArtifactStagingService_PutArtifactClient interface { + Send(*PutArtifactRequest) error + CloseAndRecv() (*PutArtifactResponse, error) + grpc.ClientStream +} + +type artifactStagingServicePutArtifactClient struct { + grpc.ClientStream +} + +func (x *artifactStagingServicePutArtifactClient) Send(m *PutArtifactRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *artifactStagingServicePutArtifactClient) CloseAndRecv() (*PutArtifactResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(PutArtifactResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *artifactStagingServiceClient) CommitManifest(ctx context.Context, in *CommitManifestRequest, opts ...grpc.CallOption) (*CommitManifestResponse, error) { + out := new(CommitManifestResponse) + err := grpc.Invoke(ctx, "/org.apache.beam.runner_api.v1.ArtifactStagingService/CommitManifest", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for ArtifactStagingService service + +type ArtifactStagingServiceServer interface { + // Stage an artifact to be available during job execution. The first request must contain the + // name of the artifact. All future requests must contain sequential chunks of the content of + // the artifact. + PutArtifact(ArtifactStagingService_PutArtifactServer) error + // Commit the manifest for a Job. All artifacts must have been successfully uploaded + // before this call is made. + // + // Throws error INVALID_ARGUMENT if not all of the members of the manifest are present + CommitManifest(context.Context, *CommitManifestRequest) (*CommitManifestResponse, error) +} + +func RegisterArtifactStagingServiceServer(s *grpc.Server, srv ArtifactStagingServiceServer) { + s.RegisterService(&_ArtifactStagingService_serviceDesc, srv) +} + +func _ArtifactStagingService_PutArtifact_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ArtifactStagingServiceServer).PutArtifact(&artifactStagingServicePutArtifactServer{stream}) +} + +type ArtifactStagingService_PutArtifactServer interface { + SendAndClose(*PutArtifactResponse) error + Recv() (*PutArtifactRequest, error) + grpc.ServerStream +} + +type artifactStagingServicePutArtifactServer struct { + grpc.ServerStream +} + +func (x *artifactStagingServicePutArtifactServer) SendAndClose(m *PutArtifactResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *artifactStagingServicePutArtifactServer) Recv() (*PutArtifactRequest, error) { + m := new(PutArtifactRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _ArtifactStagingService_CommitManifest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CommitManifestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArtifactStagingServiceServer).CommitManifest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/org.apache.beam.runner_api.v1.ArtifactStagingService/CommitManifest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArtifactStagingServiceServer).CommitManifest(ctx, req.(*CommitManifestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _ArtifactStagingService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "org.apache.beam.runner_api.v1.ArtifactStagingService", + HandlerType: (*ArtifactStagingServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CommitManifest", + Handler: _ArtifactStagingService_CommitManifest_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "PutArtifact", + Handler: _ArtifactStagingService_PutArtifact_Handler, + ClientStreams: true, + }, + }, + Metadata: "beam_artifact_api.proto", +} + +// Client API for ArtifactRetrievalService service + +type ArtifactRetrievalServiceClient interface { + // Get the manifest for the job + GetManifest(ctx context.Context, in *GetManifestRequest, opts ...grpc.CallOption) (*GetManifestResponse, error) + // Get an artifact staged for the job. The requested artifact must be within the manifest + GetArtifact(ctx context.Context, in *GetArtifactRequest, opts ...grpc.CallOption) (ArtifactRetrievalService_GetArtifactClient, error) +} + +type artifactRetrievalServiceClient struct { + cc *grpc.ClientConn +} + +func NewArtifactRetrievalServiceClient(cc *grpc.ClientConn) ArtifactRetrievalServiceClient { + return &artifactRetrievalServiceClient{cc} +} + +func (c *artifactRetrievalServiceClient) GetManifest(ctx context.Context, in *GetManifestRequest, opts ...grpc.CallOption) (*GetManifestResponse, error) { + out := new(GetManifestResponse) + err := grpc.Invoke(ctx, "/org.apache.beam.runner_api.v1.ArtifactRetrievalService/GetManifest", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *artifactRetrievalServiceClient) GetArtifact(ctx context.Context, in *GetArtifactRequest, opts ...grpc.CallOption) (ArtifactRetrievalService_GetArtifactClient, error) { + stream, err := grpc.NewClientStream(ctx, &_ArtifactRetrievalService_serviceDesc.Streams[0], c.cc, "/org.apache.beam.runner_api.v1.ArtifactRetrievalService/GetArtifact", opts...) + if err != nil { + return nil, err + } + x := &artifactRetrievalServiceGetArtifactClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ArtifactRetrievalService_GetArtifactClient interface { + Recv() (*ArtifactChunk, error) + grpc.ClientStream +} + +type artifactRetrievalServiceGetArtifactClient struct { + grpc.ClientStream +} + +func (x *artifactRetrievalServiceGetArtifactClient) Recv() (*ArtifactChunk, error) { + m := new(ArtifactChunk) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for ArtifactRetrievalService service + +type ArtifactRetrievalServiceServer interface { + // Get the manifest for the job + GetManifest(context.Context, *GetManifestRequest) (*GetManifestResponse, error) + // Get an artifact staged for the job. The requested artifact must be within the manifest + GetArtifact(*GetArtifactRequest, ArtifactRetrievalService_GetArtifactServer) error +} + +func RegisterArtifactRetrievalServiceServer(s *grpc.Server, srv ArtifactRetrievalServiceServer) { + s.RegisterService(&_ArtifactRetrievalService_serviceDesc, srv) +} + +func _ArtifactRetrievalService_GetManifest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetManifestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArtifactRetrievalServiceServer).GetManifest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/org.apache.beam.runner_api.v1.ArtifactRetrievalService/GetManifest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArtifactRetrievalServiceServer).GetManifest(ctx, req.(*GetManifestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ArtifactRetrievalService_GetArtifact_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetArtifactRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ArtifactRetrievalServiceServer).GetArtifact(m, &artifactRetrievalServiceGetArtifactServer{stream}) +} + +type ArtifactRetrievalService_GetArtifactServer interface { + Send(*ArtifactChunk) error + grpc.ServerStream +} + +type artifactRetrievalServiceGetArtifactServer struct { + grpc.ServerStream +} + +func (x *artifactRetrievalServiceGetArtifactServer) Send(m *ArtifactChunk) error { + return x.ServerStream.SendMsg(m) +} + +var _ArtifactRetrievalService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "org.apache.beam.runner_api.v1.ArtifactRetrievalService", + HandlerType: (*ArtifactRetrievalServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetManifest", + Handler: _ArtifactRetrievalService_GetManifest_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetArtifact", + Handler: _ArtifactRetrievalService_GetArtifact_Handler, + ServerStreams: true, + }, + }, + Metadata: "beam_artifact_api.proto", +} + +func init() { proto.RegisterFile("beam_artifact_api.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 540 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x5f, 0x6b, 0xdb, 0x3c, + 0x14, 0xc6, 0xeb, 0xe4, 0xe5, 0x9d, 0x73, 0xdc, 0x8c, 0xa0, 0xae, 0x9d, 0x09, 0x0c, 0x82, 0x3a, + 0x58, 0x2e, 0x86, 0xd7, 0xa4, 0xcb, 0xe5, 0x2e, 0x9a, 0x5c, 0xac, 0xb0, 0x05, 0x3a, 0x77, 0x30, + 0x28, 0x83, 0xa0, 0x3a, 0x6a, 0x2a, 0x52, 0x49, 0x9e, 0xac, 0x98, 0xed, 0x62, 0x37, 0xfb, 0x02, + 0xfb, 0x2e, 0xfb, 0x36, 0xfb, 0x36, 0xc3, 0xb2, 0xec, 0xe5, 0x1f, 0x73, 0x03, 0xbd, 0x3b, 0x9c, + 0x9c, 0xe7, 0xd1, 0xcf, 0xcf, 0x91, 0x08, 0x3c, 0xbd, 0xa6, 0x84, 0x4f, 0x88, 0xd2, 0xec, 0x86, + 0x44, 0x7a, 0x42, 0x62, 0x16, 0xc4, 0x4a, 0x6a, 0x89, 0x9e, 0x49, 0x35, 0x0b, 0x48, 0x4c, 0xa2, + 0x5b, 0x1a, 0x64, 0x33, 0x81, 0x5a, 0x08, 0x41, 0x95, 0x99, 0x48, 0x7b, 0xf8, 0x0a, 0x5a, 0x67, + 0x56, 0x34, 0xa6, 0x9a, 0x4c, 0x89, 0x26, 0x08, 0xc1, 0x7f, 0x82, 0x70, 0xea, 0x3b, 0x1d, 0xa7, + 0xdb, 0x08, 0x4d, 0x8d, 0x3a, 0xe0, 0xc5, 0x54, 0x71, 0x96, 0x24, 0x4c, 0x8a, 0xc4, 0xaf, 0x75, + 0x9c, 0x6e, 0x33, 0x5c, 0x6e, 0xa1, 0x16, 0xd4, 0xf9, 0x74, 0xe0, 0xd7, 0x8d, 0x28, 0x2b, 0xf1, + 0x27, 0x70, 0xc7, 0x44, 0xb0, 0x1b, 0x9a, 0x68, 0xf4, 0x0e, 0xdc, 0x02, 0xce, 0x77, 0x3a, 0xf5, + 0xae, 0xd7, 0x7f, 0x15, 0xfc, 0x93, 0x2c, 0x58, 0xc7, 0x0a, 0x4b, 0x03, 0xfc, 0xdb, 0x81, 0xe6, + 0x85, 0x92, 0x5f, 0xbf, 0x95, 0xf6, 0x23, 0x70, 0xb9, 0xad, 0x0d, 0xb6, 0xd7, 0x7f, 0x51, 0x61, + 0x5f, 0x48, 0xc3, 0x52, 0x88, 0x3e, 0x80, 0x7b, 0x27, 0x23, 0xa2, 0x99, 0x14, 0x7e, 0xcd, 0x30, + 0x0e, 0x2a, 0x4c, 0x56, 0x20, 0x82, 0xf7, 0x56, 0x1c, 0x96, 0x36, 0xed, 0x13, 0x70, 0x8b, 0xee, + 0xd6, 0x58, 0x5b, 0x50, 0x5f, 0x28, 0x66, 0xe2, 0x6c, 0x84, 0x59, 0x89, 0x9f, 0x00, 0x7a, 0x4b, + 0x75, 0x49, 0x47, 0xbf, 0x2c, 0x68, 0xa2, 0xf1, 0x15, 0x1c, 0xac, 0x74, 0x93, 0x58, 0x8a, 0x84, + 0x3e, 0xc8, 0x67, 0xe3, 0xae, 0x39, 0xb1, 0x88, 0xdb, 0x9e, 0xb8, 0x8d, 0x16, 0x1f, 0x43, 0xb3, + 0x18, 0x1b, 0xdd, 0x2e, 0xc4, 0x3c, 0x1b, 0xca, 0x56, 0x63, 0x86, 0xf6, 0x43, 0x53, 0xe3, 0x5f, + 0x0e, 0xa0, 0x8b, 0xc5, 0x86, 0xdf, 0x18, 0x5c, 0x6e, 0x37, 0x69, 0x51, 0x77, 0xbd, 0x00, 0xe7, + 0x7b, 0x61, 0x69, 0x81, 0x86, 0xf6, 0xe4, 0x9a, 0xb1, 0x7a, 0x79, 0x4f, 0x2b, 0x43, 0x7d, 0xbe, + 0x97, 0x93, 0x0e, 0x1b, 0xf0, 0x28, 0x92, 0x42, 0x53, 0xa1, 0xf1, 0x21, 0x1c, 0xac, 0x30, 0xe7, + 0xf9, 0xe2, 0xcf, 0x70, 0x38, 0x92, 0x9c, 0xb3, 0xf5, 0x7d, 0x3c, 0x4c, 0xf0, 0x6f, 0xe0, 0x68, + 0xdd, 0xdd, 0xee, 0xf5, 0x18, 0x9a, 0x89, 0x26, 0x33, 0x26, 0x66, 0x13, 0x2d, 0xe7, 0x54, 0xd8, + 0x2d, 0xec, 0xdb, 0xe6, 0xc7, 0xac, 0xd7, 0xff, 0x59, 0x83, 0xa3, 0x82, 0xf8, 0x32, 0xff, 0xe1, + 0x92, 0xaa, 0x94, 0x45, 0x14, 0xa5, 0xe0, 0x2d, 0x7d, 0x0e, 0xea, 0x55, 0x5d, 0xe3, 0x8d, 0x75, + 0xb5, 0xfb, 0xbb, 0x48, 0x72, 0xea, 0xae, 0x83, 0xbe, 0xc3, 0xe3, 0xd5, 0x2f, 0x42, 0xaf, 0x2b, + 0x7c, 0xb6, 0xc6, 0xdb, 0x1e, 0xec, 0xa8, 0xca, 0x01, 0xfa, 0x3f, 0x6a, 0xe0, 0xff, 0xa5, 0xd2, + 0x8a, 0xd1, 0x94, 0xdc, 0x15, 0x99, 0x68, 0xf0, 0x96, 0x9e, 0x50, 0x65, 0x26, 0x9b, 0x8f, 0xb0, + 0x32, 0x93, 0x6d, 0x2f, 0x34, 0x36, 0xa7, 0xde, 0x7b, 0x13, 0x9b, 0x0f, 0xb1, 0xbd, 0xd3, 0xdd, + 0x3e, 0x71, 0x86, 0xa7, 0xf0, 0x7c, 0x5d, 0x90, 0x4c, 0xe7, 0x41, 0x24, 0x39, 0x97, 0xc2, 0x6a, + 0x83, 0xb4, 0x37, 0xf4, 0x0a, 0xe1, 0x59, 0xcc, 0xae, 0xff, 0x37, 0x7f, 0x16, 0xa7, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x72, 0x5b, 0xc8, 0xd5, 0x47, 0x06, 0x00, 0x00, +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/provision/provision_test.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/provision/provision_test.go b/sdks/go/pkg/beam/provision/provision_test.go new file mode 100644 index 0000000..f29bc9b --- /dev/null +++ b/sdks/go/pkg/beam/provision/provision_test.go @@ -0,0 +1,54 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package provision + +import ( + "reflect" + "testing" +) + +type s struct { + A int `json:"a,omitempty"` + B string `json:"b,omitempty"` + C bool `json:"c,omitempty"` + D *s `json:"d,omitempty"` +} + +// TestConversions verifies that we can process proto structs via JSON. +func TestConversions(t *testing.T) { + tests := []s{ + s{}, + s{A: 2}, + s{B: "foo"}, + s{C: true}, + s{D: &s{A: 3}}, + s{A: 1, B: "bar", C: true, D: &s{A: 3, B: "baz"}}, + } + + for _, test := range tests { + enc, err := OptionsToProto(test) + if err != nil { + t.Errorf("Failed to marshal %v: %v", test, err) + } + var ret s + if err := ProtoToOptions(enc, &ret); err != nil { + t.Errorf("Failed to unmarshal %v from %v: %v", test, enc, err) + } + if !reflect.DeepEqual(test, ret) { + t.Errorf("Unmarshal(Marshal(%v)) = %v, want %v", test, ret, test) + } + } +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/provision/provison.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/provision/provison.go b/sdks/go/pkg/beam/provision/provison.go new file mode 100644 index 0000000..efc418f --- /dev/null +++ b/sdks/go/pkg/beam/provision/provison.go @@ -0,0 +1,80 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package provision contains utilities for obtaining runtime provision, +// information -- such as pipeline options. +package provision + +import ( + "context" + "encoding/json" + "fmt" + + "time" + + pb "github.com/apache/beam/sdks/go/pkg/beam/model/org_apache_beam_fn_v1" + "github.com/apache/beam/sdks/go/pkg/beam/util/grpcx" + "github.com/golang/protobuf/jsonpb" + google_protobuf "github.com/golang/protobuf/ptypes/struct" +) + +// Info returns the runtime provisioning info for the worker. +func Info(ctx context.Context, endpoint string) (*pb.ProvisionInfo, error) { + cc, err := grpcx.Dial(ctx, endpoint, 2*time.Minute) + if err != nil { + return nil, err + } + defer cc.Close() + + client := pb.NewProvisionServiceClient(cc) + + resp, err := client.GetProvisionInfo(ctx, &pb.GetProvisionInfoRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to get manifest: %v", err) + } + return resp.GetInfo(), nil +} + +// OptionsToProto converts pipeline options to a proto struct via JSON. +func OptionsToProto(v interface{}) (*google_protobuf.Struct, error) { + data, err := json.Marshal(v) + if err != nil { + return nil, err + } + return JSONToProto(string(data)) +} + +// JSONToProto converts JSON-encoded pipeline options to a proto struct. +func JSONToProto(data string) (*google_protobuf.Struct, error) { + var out google_protobuf.Struct + if err := jsonpb.UnmarshalString(string(data), &out); err != nil { + return nil, err + } + return &out, nil +} + +// ProtoToOptions converts pipeline options from a proto struct via JSON. +func ProtoToOptions(opt *google_protobuf.Struct, v interface{}) error { + data, err := ProtoToJSON(opt) + if err != nil { + return err + } + return json.Unmarshal([]byte(data), v) +} + +// ProtoToJSON converts pipeline options from a proto struct to JSON. +func ProtoToJSON(opt *google_protobuf.Struct) (string, error) { + return (&jsonpb.Marshaler{}).MarshalToString(opt) +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/util/errorx/guarded.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/util/errorx/guarded.go b/sdks/go/pkg/beam/util/errorx/guarded.go new file mode 100644 index 0000000..cc0b07b --- /dev/null +++ b/sdks/go/pkg/beam/util/errorx/guarded.go @@ -0,0 +1,47 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package errorx contains utilities for handling errors. +package errorx + +import "sync" + +// GuardedError is a concurrency-safe error wrapper. It is sticky +// in that the first error won't be overwritten. +type GuardedError struct { + err error + mu sync.Mutex +} + +// Error returns the guarded error. +func (g *GuardedError) Error() error { + g.mu.Lock() + defer g.mu.Unlock() + + return g.err +} + +// TrySetError sets the error, if not already set. Returns true iff the +// error was set. +func (g *GuardedError) TrySetError(err error) bool { + g.mu.Lock() + defer g.mu.Unlock() + + upd := g.err == nil + if upd { + g.err = err + } + return upd +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/util/execx/exec.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/util/execx/exec.go b/sdks/go/pkg/beam/util/execx/exec.go new file mode 100644 index 0000000..b4978ef --- /dev/null +++ b/sdks/go/pkg/beam/util/execx/exec.go @@ -0,0 +1,33 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package execx contains wrappers and utilities for the exec package. +package execx + +import ( + "os" + "os/exec" +) + +// Execute runs the program with the given arguments. It attaches stdio to the +// child process. +func Execute(prog string, args ...string) error { + cmd := exec.Command(prog, args...) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/util/gcsx/gcs.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/util/gcsx/gcs.go b/sdks/go/pkg/beam/util/gcsx/gcs.go new file mode 100644 index 0000000..2e04be0 --- /dev/null +++ b/sdks/go/pkg/beam/util/gcsx/gcs.go @@ -0,0 +1,88 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package gcsx contains utilities for working with Google Cloud Storage (GCS). +package gcsx + +import ( + "context" + "fmt" + "io" + "io/ioutil" + "net/url" + + "golang.org/x/oauth2/google" + "google.golang.org/api/storage/v1" +) + +// NewClient creates a new GCS client with default application credentials. +func NewClient(ctx context.Context, scope string) (*storage.Service, error) { + cl, err := google.DefaultClient(ctx, scope) + if err != nil { + return nil, err + } + return storage.New(cl) +} + +// WriteObject writes the given content to the specified object. If the object +// already exist, it is overwritten. +func WriteObject(client *storage.Service, bucket, object string, r io.Reader) error { + obj := &storage.Object{ + Name: object, + Bucket: bucket, + } + _, err := client.Objects.Insert(bucket, obj).Media(r).Do() + return err +} + +// ReadObject reads the content of the given object in full. +func ReadObject(client *storage.Service, bucket, object string) ([]byte, error) { + resp, err := client.Objects.Get(bucket, object).Download() + if err != nil { + return nil, err + } + return ioutil.ReadAll(resp.Body) +} + +// MakeObject creates a object location from bucket and path. For example, +// MakeObject("foo", "bar/baz") returns "gs://foo/bar/baz". The bucket +// must be non-empty. +func MakeObject(bucket, path string) string { + if bucket == "" { + panic("bucket must be non-empty") + } + return fmt.Sprintf("gs://%v/%v", bucket, path) +} + +// ParseObject deconstructs a GCS object name into (bucket, name). +func ParseObject(object string) (bucket, path string, err error) { + parsed, err := url.Parse(object) + if err != nil { + return "", "", err + } + + if parsed.Scheme != "gs" { + return "", "", fmt.Errorf("object %s must have 'gs' scheme", object) + } + if parsed.Host == "" { + return "", "", fmt.Errorf("object %s must have bucket", object) + } + if parsed.Path == "" { + return parsed.Host, "", nil + } + + // remove leading "/" in URL path + return parsed.Host, parsed.Path[1:], nil +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/util/grpcx/dial.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/util/grpcx/dial.go b/sdks/go/pkg/beam/util/grpcx/dial.go new file mode 100644 index 0000000..8467ace --- /dev/null +++ b/sdks/go/pkg/beam/util/grpcx/dial.go @@ -0,0 +1,37 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package grpcx + +import ( + "context" + "fmt" + "time" + + "google.golang.org/grpc" +) + +// Dial is a convenience wrapper over grpc.Dial that specifies an insecure, +// blocking connection with a timeout. +func Dial(ctx context.Context, endpoint string, timeout time.Duration) (*grpc.ClientConn, error) { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + cc, err := grpc.DialContext(ctx, endpoint, grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + return nil, fmt.Errorf("failed to dial server at %v: %v", endpoint, err) + } + return cc, nil +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pkg/beam/util/grpcx/metadata.go ---------------------------------------------------------------------- diff --git a/sdks/go/pkg/beam/util/grpcx/metadata.go b/sdks/go/pkg/beam/util/grpcx/metadata.go new file mode 100644 index 0000000..08512c7 --- /dev/null +++ b/sdks/go/pkg/beam/util/grpcx/metadata.go @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package grpcx contains utilities for working with gRPC. +package grpcx + +import ( + "context" + "errors" + "fmt" + + "google.golang.org/grpc/metadata" +) + +const idKey = "id" + +// ReadWorkerID reads the worker ID from an incoming gRPC request context. +func ReadWorkerId(ctx context.Context) (string, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return "", errors.New("failed to read metadata from context") + } + id, ok := md[idKey] + if !ok || len(id) < 1 { + return "", fmt.Errorf("failed to find worker id in metadata %v", md) + } + if len(id) > 1 { + return "", fmt.Errorf("multiple worker ids in metadata: %v", id) + } + return id[0], nil +} + +// WriteWorkerID write the worker ID to an outgoing gRPC request context. It +// merges the information with any existing gRPC metadata. +func WriteWorkerId(ctx context.Context, id string) context.Context { + md := metadata.New(map[string]string{ + idKey: id, + }) + if old, ok := metadata.FromOutgoingContext(ctx); ok { + md = metadata.Join(md, old) + } + return metadata.NewOutgoingContext(ctx, md) +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/go/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/go/pom.xml b/sdks/go/pom.xml new file mode 100644 index 0000000..c072b9f --- /dev/null +++ b/sdks/go/pom.xml @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.beam</groupId> + <artifactId>beam-sdks-parent</artifactId> + <version>2.2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>beam-sdks-go</artifactId> + + <packaging>pom</packaging> + + <name>Apache Beam :: SDKs :: Go</name> + + <properties> + <!-- Add full path directory structure for 'go get' compatibility --> + <go.source.base>${project.basedir}/target/src</go.source.base> + <go.source.dir>${go.source.base}/github.com/apache/beam/sdks/go</go.source.dir> + </properties> + + <build> + <sourceDirectory>${go.source.base}</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-go-pkg-source</id> + <phase>generate-sources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${go.source.dir}/pkg</outputDirectory> + <resources> + <resource> + <directory>pkg</directory> + <filtering>false</filtering> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-go-cmd-source</id> + <phase>generate-sources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${go.source.base}/github.com/apache/beam/cmd</outputDirectory> + <resources> + <resource> + <directory>cmd</directory> + <filtering>false</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + + <!-- export pkg/ sources as zip for inclusion elsewhere --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>export-go-pkg-sources</id> + <phase>generate-sources</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <descriptors> + <descriptor>descriptor.xml</descriptor> + </descriptors> + </configuration> + </plugin> + + <plugin> + <groupId>com.igormaznitsa</groupId> + <artifactId>mvn-golang-wrapper</artifactId> + <executions> + <execution> + <id>go-get-imports</id> + <goals> + <goal>get</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>google.golang.org/grpc</package> + <package>golang.org/x/oauth2/google</package> + <package>google.golang.org/api/storage/v1</package> + <package>github.com/spf13/cobra</package> + </packages> + </configuration> + </execution> + <execution> + <id>go-build</id> + <goals> + <goal>build</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>github.com/apache/beam/cmd/beamctl</package> + </packages> + <resultName>beamctl</resultName> + </configuration> + </execution> + <execution> + <id>go-build-linux-amd64</id> + <goals> + <goal>build</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>github.com/apache/beam/cmd/beamctl</package> + </packages> + <resultName>linux_amd64/beamctl</resultName> + <targetArch>amd64</targetArch> + <targetOs>linux</targetOs> + </configuration> + </execution> + <execution> + <id>go-test</id> + <goals> + <goal>test</goal> + </goals> + <phase>test</phase> + <configuration> + <packages> + <folder>./...</folder> + </packages> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/java/container/Dockerfile ---------------------------------------------------------------------- diff --git a/sdks/java/container/Dockerfile b/sdks/java/container/Dockerfile new file mode 100644 index 0000000..7fb325d --- /dev/null +++ b/sdks/java/container/Dockerfile @@ -0,0 +1,28 @@ +############################################################################### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + +FROM openjdk:8 +MAINTAINER "Apache Beam <[email protected]>" + +ADD target/slf4j-api.jar /opt/apache/beam/jars/ +ADD target/slf4j-jdk14.jar /opt/apache/beam/jars/ +ADD target/beam-sdks-java-harness.jar /opt/apache/beam/jars/ + +ADD target/linux_amd64/boot /opt/apache/beam/ + +ENTRYPOINT ["/opt/apache/beam/boot"] http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/java/container/boot.go ---------------------------------------------------------------------- diff --git a/sdks/java/container/boot.go b/sdks/java/container/boot.go new file mode 100644 index 0000000..8c465c3 --- /dev/null +++ b/sdks/java/container/boot.go @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// boot is the boot code for the Java SDK harness container. It is responsible +// for retrieving staged files and invoking the JVM correctly. +package main + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "path/filepath" + "strings" + + "github.com/apache/beam/sdks/go/pkg/beam/artifact" + "github.com/apache/beam/sdks/go/pkg/beam/provision" + "github.com/apache/beam/sdks/go/pkg/beam/util/execx" + "github.com/apache/beam/sdks/go/pkg/beam/util/grpcx" +) + +var ( + // Contract: https://s.apache.org/beam-fn-api-container-contract. + + id = flag.String("id", "", "Local identifier (required).") + loggingEndpoint = flag.String("logging_endpoint", "", "Logging endpoint (required).") + artifactEndpoint = flag.String("artifact_endpoint", "", "Artifact endpoint (required).") + provisionEndpoint = flag.String("provision_endpoint", "", "Provision endpoint (required).") + controlEndpoint = flag.String("control_endpoint", "", "Control endpoint (required).") + semiPersistDir = flag.String("semi_persist_dir", "/tmp", "Local semi-persistent directory (optional).") +) + +func main() { + flag.Parse() + if *id == "" { + log.Fatal("No id provided.") + } + if *loggingEndpoint == "" { + log.Fatal("No logging endpoint provided.") + } + if *artifactEndpoint == "" { + log.Fatal("No artifact endpoint provided.") + } + if *provisionEndpoint == "" { + log.Fatal("No provision endpoint provided.") + } + if *controlEndpoint == "" { + log.Fatal("No control endpoint provided.") + } + + log.Printf("Initializing java harness: %v", strings.Join(os.Args, " ")) + + ctx := grpcx.WriteWorkerId(context.Background(), *id) + + // (1) Obtain the pipeline options + + info, err := provision.Info(ctx, *provisionEndpoint) + if err != nil { + log.Fatalf("Failed to obtain provisioning information: %v", err) + } + options, err := provision.ProtoToJSON(info.GetPipelineOptions()) + if err != nil { + log.Fatalf("Failed to convert pipeline options: %v", err) + } + + // (2) Retrieve the staged user jars. + + dir := filepath.Join(*semiPersistDir, "staged") + + artifacts, err := artifact.Materialize(ctx, *artifactEndpoint, dir) + if err != nil { + log.Fatalf("Failed to retrieve staged files: %v", err) + } + + // (3) Invoke the Java harness, preserving artifact ordering in classpath. + + os.Setenv("PIPELINE_OPTIONS", options) + os.Setenv("LOGGING_API_SERVICE_DESCRIPTOR", fmt.Sprintf("id: \"1\"\nurl: \"%v\"\n", *loggingEndpoint)) + os.Setenv("CONTROL_API_SERVICE_DESCRIPTOR", fmt.Sprintf("id: \"2\"\nurl: \"%v\"\n", *controlEndpoint)) + + const jarsDir = "/opt/apache/beam/jars" + cp := []string{ + filepath.Join(jarsDir, "slf4j-api.jar"), + filepath.Join(jarsDir, "slf4j-jdk14.jar"), + filepath.Join(jarsDir, "beam-sdks-java-harness.jar"), + } + for _, md := range artifacts { + cp = append(cp, filepath.Join(dir, filepath.FromSlash(md.Name))) + } + + args := []string{ + "-cp", strings.Join(cp, ":"), + "org.apache.beam.fn.harness.FnHarness", + } + log.Printf("Executing: java %v", strings.Join(args, " ")) + + log.Fatalf("Java exited: %v", execx.Execute("java", args...)) +} http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/java/container/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/java/container/pom.xml b/sdks/java/container/pom.xml new file mode 100644 index 0000000..dd970a4 --- /dev/null +++ b/sdks/java/container/pom.xml @@ -0,0 +1,184 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.beam</groupId> + <artifactId>beam-sdks-java-parent</artifactId> + <version>2.2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>beam-sdks-java-container</artifactId> + + <packaging>pom</packaging> + + <name>Apache Beam :: SDKs :: Java :: Container</name> + + <properties> + <!-- Add full path directory structure for 'go get' compatibility --> + <go.source.base>${project.basedir}/target/src</go.source.base> + <go.source.dir>${go.source.base}/github.com/apache/beam/sdks/go</go.source.dir> + </properties> + + <build> + <sourceDirectory>${go.source.base}</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-go-cmd-source</id> + <phase>generate-sources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${go.source.base}/github.com/apache/beam/cmd/boot</outputDirectory> + <resources> + <resource> + <directory>.</directory> + <includes> + <include>*.go</include> + </includes> + <filtering>false</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + + <!-- CAVEAT: for latest shared files, run mvn install in sdks/go --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependency</id> + <phase>generate-sources</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.apache.beam</groupId> + <artifactId>beam-sdks-go</artifactId> + <version>${project.version}</version> + <type>zip</type> + <classifier>pkg-sources</classifier> + <overWrite>true</overWrite> + <outputDirectory>${go.source.dir}</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + + <execution> + <id>copy-dependent-jars</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <outputDirectory>${project.basedir}/target</outputDirectory> + <stripVersion>true</stripVersion> + <artifactItems> + <artifactItem> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <overWrite>true</overWrite> + </artifactItem> + <artifactItem> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jdk14</artifactId> + <version>${slf4j.version}</version> + <overWrite>true</overWrite> + </artifactItem> + <artifactItem> + <groupId>org.apache.beam</groupId> + <artifactId>beam-sdks-java-harness</artifactId> + <overWrite>true</overWrite> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>com.igormaznitsa</groupId> + <artifactId>mvn-golang-wrapper</artifactId> + <executions> + <execution> + <id>go-get-imports</id> + <goals> + <goal>get</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>google.golang.org/grpc</package> + <package>golang.org/x/oauth2/google</package> + <package>google.golang.org/api/storage/v1</package> + </packages> + </configuration> + </execution> + <execution> + <id>go-build</id> + <goals> + <goal>build</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>github.com/apache/beam/cmd/boot</package> + </packages> + <resultName>boot</resultName> + </configuration> + </execution> + <execution> + <id>go-build-linux-amd64</id> + <goals> + <goal>build</goal> + </goals> + <phase>compile</phase> + <configuration> + <packages> + <package>github.com/apache/beam/cmd/boot</package> + </packages> + <resultName>linux_amd64/boot</resultName> + <targetArch>amd64</targetArch> + <targetOs>linux</targetOs> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>com.spotify</groupId> + <artifactId>dockerfile-maven-plugin</artifactId> + <configuration> + <repository>${docker-repository-root}/java</repository> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/java/harness/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/java/harness/pom.xml b/sdks/java/harness/pom.xml index fe5c2f1..c8ac651 100644 --- a/sdks/java/harness/pom.xml +++ b/sdks/java/harness/pom.xml @@ -32,6 +32,71 @@ <description>This contains the SDK Fn Harness for Beam Java</description> <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <executions> + <execution> + <id>bundle-and-repackage</id> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <shadeTestJar>true</shadeTestJar> + <artifactSet> + <includes> + <include>com.google.guava:guava</include> + <!-- java harness dependencies that are not staged --> + <include>org.apache.beam:beam-runners-core-construction-java</include> + <include>org.apache.beam:beam-runners-core-java</include> + <include>org.apache.beam:beam-runners-google-cloud-dataflow-java</include> + <include>org.apache.beam:beam-sdks-common-runner-api</include> + <include>org.apache.beam:beam-sdks-common-fn-api</include> + </includes> + </artifactSet> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + <relocations> + <relocation> + <pattern>com.google.common</pattern> + <excludes> + <!-- com.google.common is too generic, need to exclude guava-testlib --> + <exclude>com.google.common.**.testing.*</exclude> + </excludes> + <!--suppress MavenModelInspection --> + <shadedPattern> + org.apache.beam.sdks.harness.repackaged.com.google.common + </shadedPattern> + </relocation> + <relocation> + <pattern>com.google.thirdparty</pattern> + <!--suppress MavenModelInspection --> + <shadedPattern> + org.apache.beam.sdks.harness.repackaged.com.google.thirdparty + </shadedPattern> + </relocation> + </relocations> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + <plugins> <plugin> <!-- Override Beam parent to allow Java8 --> @@ -87,6 +152,7 @@ </dependency> <dependency> + <!-- TODO: BEAM-2566 remove this dependency --> <groupId>org.apache.beam</groupId> <artifactId>beam-runners-google-cloud-dataflow-java</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/java/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/java/pom.xml b/sdks/java/pom.xml index f0cf8d9..12d09b3 100644 --- a/sdks/java/pom.xml +++ b/sdks/java/pom.xml @@ -54,6 +54,7 @@ </activation> <modules> <module>harness</module> + <module>container</module> <module>java8tests</module> </modules> </profile> http://git-wip-us.apache.org/repos/asf/beam/blob/c18f15cd/sdks/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/pom.xml b/sdks/pom.xml index aec8762..0de5648 100644 --- a/sdks/pom.xml +++ b/sdks/pom.xml @@ -34,6 +34,7 @@ <modules> <module>common</module> + <module>go</module> <module>java</module> <module>python</module> </modules>
