[BEAM-3114] Generate text proto config properly in container boot code

Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/fcd864ac
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/fcd864ac
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/fcd864ac

Branch: refs/heads/mr-runner
Commit: fcd864ac2c987b4d059ca324903091876b9f4f1f
Parents: 15db1dd
Author: Henning Rohde <[email protected]>
Authored: Fri Oct 27 14:20:10 2017 -0700
Committer: Thomas Groh <[email protected]>
Committed: Mon Nov 6 11:02:27 2017 -0800

----------------------------------------------------------------------
 sdks/java/container/boot.go   | 11 ++++++-----
 sdks/python/container/boot.go | 31 ++++++++++++++++---------------
 2 files changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/fcd864ac/sdks/java/container/boot.go
----------------------------------------------------------------------
diff --git a/sdks/java/container/boot.go b/sdks/java/container/boot.go
index 144c4ac..1c80e0b 100644
--- a/sdks/java/container/boot.go
+++ b/sdks/java/container/boot.go
@@ -20,7 +20,6 @@ package main
 import (
        "context"
        "flag"
-       "fmt"
        "log"
        "os"
        "path/filepath"
@@ -28,11 +27,13 @@ import (
        "strings"
 
        "github.com/apache/beam/sdks/go/pkg/beam/artifact"
-       pb "github.com/apache/beam/sdks/go/pkg/beam/model/fnexecution_v1"
+       fnpb "github.com/apache/beam/sdks/go/pkg/beam/model/fnexecution_v1"
+       pb "github.com/apache/beam/sdks/go/pkg/beam/model/pipeline_v1"
        "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"
        "github.com/apache/beam/sdks/go/pkg/beam/util/syscallx"
+       "github.com/golang/protobuf/proto"
 )
 
 var (
@@ -92,8 +93,8 @@ func main() {
        // (3) Invoke the Java harness, preserving artifact ordering in 
classpath.
 
        os.Setenv("PIPELINE_OPTIONS", options)
-       os.Setenv("LOGGING_API_SERVICE_DESCRIPTOR", fmt.Sprintf("url: 
\"%v\"\n", *loggingEndpoint))
-       os.Setenv("CONTROL_API_SERVICE_DESCRIPTOR", fmt.Sprintf("url: 
\"%v\"\n", *controlEndpoint))
+       os.Setenv("LOGGING_API_SERVICE_DESCRIPTOR", 
proto.MarshalTextString(&pb.ApiServiceDescriptor{Url: *loggingEndpoint}))
+       os.Setenv("CONTROL_API_SERVICE_DESCRIPTOR", 
proto.MarshalTextString(&pb.ApiServiceDescriptor{Url: *controlEndpoint}))
 
        const jarsDir = "/opt/apache/beam/jars"
        cp := []string{
@@ -122,7 +123,7 @@ func main() {
 // that value, it returns 1GB. This is an imperfect heuristic. It aims to
 // ensure there is memory for non-heap use and other overhead, while also not
 // underutilizing the machine.
-func heapSizeLimit(info *pb.ProvisionInfo) uint64 {
+func heapSizeLimit(info *fnpb.ProvisionInfo) uint64 {
        if provided := info.GetResourceLimits().GetMemory().GetSize(); provided 
> 0 {
                return (provided * 80) / 100
        }

http://git-wip-us.apache.org/repos/asf/beam/blob/fcd864ac/sdks/python/container/boot.go
----------------------------------------------------------------------
diff --git a/sdks/python/container/boot.go b/sdks/python/container/boot.go
index 18b9900..fea0935 100644
--- a/sdks/python/container/boot.go
+++ b/sdks/python/container/boot.go
@@ -18,18 +18,19 @@
 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"
+       "context"
+       "flag"
+       "log"
+       "os"
+       "path/filepath"
+       "strings"
+
+       "github.com/apache/beam/sdks/go/pkg/beam/artifact"
+       pb "github.com/apache/beam/sdks/go/pkg/beam/model/pipeline_v1"
+       "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"
+       "github.com/golang/protobuf/proto"
 )
 
 var (
@@ -94,8 +95,8 @@ func main() {
        // (3) Invoke python
 
        os.Setenv("PIPELINE_OPTIONS", options)
-       os.Setenv("LOGGING_API_SERVICE_DESCRIPTOR", fmt.Sprintf("url: 
\"%v\"\n", *loggingEndpoint))
-       os.Setenv("CONTROL_API_SERVICE_DESCRIPTOR", fmt.Sprintf("url: 
\"%v\"\n", *controlEndpoint))
+       os.Setenv("LOGGING_API_SERVICE_DESCRIPTOR", 
proto.MarshalTextString(&pb.ApiServiceDescriptor{Url: *loggingEndpoint}))
+       os.Setenv("CONTROL_API_SERVICE_DESCRIPTOR", 
proto.MarshalTextString(&pb.ApiServiceDescriptor{Url: *controlEndpoint}))
 
        args := []string{
                "-m",
@@ -119,4 +120,4 @@ func joinPaths(dir string, paths ...string) []string {
                ret = append(ret, filepath.Join(dir, filepath.FromSlash(p)))
        }
        return ret
-}
\ No newline at end of file
+}

Reply via email to