veyron/services: continue the migration to ListenX.
Change-Id: Ifa1c0f807b2d5bd9ad01bb524c8dcc992ce77250
diff --git a/profiles/roaming/init.go b/profiles/roaming/init.go
index 754eae5..7a06306 100644
--- a/profiles/roaming/init.go
+++ b/profiles/roaming/init.go
@@ -33,14 +33,16 @@
listenProtocolFlag = flags.TCPProtocolFlag{"tcp"}
listenAddressFlag = flags.IPHostPortFlag{Port: "0"}
listenProxyFlag string
- ListenSpec *ipc.ListenSpec
+
+ // ListenSpec is an initialized instance of ipc.ListenSpec that can
+ // be used with ipc.Listen.
+ ListenSpec *ipc.ListenSpec
)
func init() {
flag.Var(&listenProtocolFlag, "veyron.tcp.protocol", "protocol to listen with")
flag.Var(&listenAddressFlag, "veyron.tcp.address", "address to listen on")
flag.StringVar(&listenProxyFlag, "veyron.proxy", "", "proxy to use")
-
rt.RegisterProfile(New())
}
diff --git a/services/identity/revocation/revoker_test.go b/services/identity/revocation/revoker_test.go
index 6e440e4..5a5c18d 100644
--- a/services/identity/revocation/revoker_test.go
+++ b/services/identity/revocation/revoker_test.go
@@ -4,13 +4,16 @@
"os"
"path/filepath"
"testing"
- services "veyron.io/veyron/veyron/services/security"
- "veyron.io/veyron/veyron/services/security/discharger"
+
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
+
+ "veyron.io/veyron/veyron/profiles"
+ services "veyron.io/veyron/veyron/services/security"
+ "veyron.io/veyron/veyron/services/security/discharger"
)
func revokerSetup(t *testing.T) (dischargerID security.PublicID, dischargerEndpoint string, revoker *RevocationManager, closeFunc func(), runtime veyron2.Runtime) {
@@ -25,7 +28,7 @@
if err != nil {
t.Fatalf("rt.R().NewServer: %s", err)
}
- dischargerEP, err := dischargerServer.Listen("tcp", "127.0.0.1:0")
+ dischargerEP, err := dischargerServer.ListenX(profiles.LocalListenSpec)
if err != nil {
t.Fatalf("dischargerServer.Listen failed: %v", err)
}
diff --git a/services/mgmt/logreader/impl/common_test.go b/services/mgmt/logreader/impl/common_test.go
index 00e2f73..1d96792 100644
--- a/services/mgmt/logreader/impl/common_test.go
+++ b/services/mgmt/logreader/impl/common_test.go
@@ -2,8 +2,11 @@
import (
"testing"
+
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/rt"
+
+ "veyron.io/veyron/veyron/profiles"
)
func startServer(t *testing.T, disp ipc.Dispatcher) (ipc.Server, string, error) {
@@ -12,7 +15,7 @@
t.Fatalf("NewServer failed: %v", err)
return nil, "", err
}
- endpoint, err := server.Listen("tcp", "localhost:0")
+ endpoint, err := server.ListenX(profiles.LocalListenSpec)
if err != nil {
t.Fatalf("Listen failed: %v", err)
return nil, "", err
diff --git a/services/mgmt/node/impl/util_test.go b/services/mgmt/node/impl/util_test.go
index c107d42..ad9e22a 100644
--- a/services/mgmt/node/impl/util_test.go
+++ b/services/mgmt/node/impl/util_test.go
@@ -79,10 +79,9 @@
if err != nil {
vlog.Fatalf("NewServer() failed: %v", err)
}
- protocol, hostname := "tcp", "127.0.0.1:0"
- endpoint, err := server.Listen(protocol, hostname)
+ endpoint, err := server.ListenX(profiles.LocalListenSpec)
if err != nil {
- vlog.Fatalf("Listen(%v, %v) failed: %v", protocol, hostname, err)
+ vlog.Fatalf("Listen(%s) failed: %v", profiles.LocalListenSpec, err)
}
return server, endpoint.String()
}
diff --git a/services/mgmt/pprof/client/proxy_test.go b/services/mgmt/pprof/client/proxy_test.go
index b600e80..31ae371 100644
--- a/services/mgmt/pprof/client/proxy_test.go
+++ b/services/mgmt/pprof/client/proxy_test.go
@@ -6,13 +6,14 @@
"net/http"
"testing"
- "veyron.io/veyron/veyron/services/mgmt/pprof/client"
- "veyron.io/veyron/veyron/services/mgmt/pprof/impl"
-
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
+
+ "veyron.io/veyron/veyron/profiles"
+ "veyron.io/veyron/veyron/services/mgmt/pprof/client"
+ "veyron.io/veyron/veyron/services/mgmt/pprof/impl"
)
type dispatcher struct {
@@ -32,7 +33,7 @@
t.Fatalf("failed to start server: %v", err)
}
defer s.Stop()
- endpoint, err := s.Listen("tcp", "127.0.0.1:0")
+ endpoint, err := s.ListenX(profiles.LocalListenSpec)
if err != nil {
t.Fatalf("failed to listen: %v", err)
}
diff --git a/services/mounttable/mounttabled/mounttable.go b/services/mounttable/mounttabled/mounttable.go
index bb450a8..fa7c27a 100644
--- a/services/mounttable/mounttabled/mounttable.go
+++ b/services/mounttable/mounttabled/mounttable.go
@@ -3,7 +3,6 @@
import (
"flag"
- "fmt"
"net"
"os"
@@ -13,48 +12,18 @@
"veyron.io/veyron/veyron2/vlog"
"veyron.io/veyron/veyron/lib/signals"
-
- "veyron.io/veyron/veyron/services/mounttable/lib"
+ "veyron.io/veyron/veyron/profiles/roaming"
+ mounttable "veyron.io/veyron/veyron/services/mounttable/lib"
)
var (
- // TODO(rthellend): Remove the protocol and address flags when the config
- // manager is working.
- protocol = flag.String("protocol", "tcp", "protocol to listen on")
- address = flag.String("address", ":0", "address to listen on")
-
- mountName = flag.String("name", "", "Name to mount this mountable as. Empty means don't mount.")
-
- aclFile = flag.String("acls", "", "ACL file. Default is to allow all access.")
- nhName = flag.String("neighborhood_name", "", "If non-empty, publish in the local neighborhood under this name.")
+ mountName = flag.String("name", "", `<name>, if provided, causes the mount table to mount itself under that name. The name may be absolute for a remote mount table service (e.g., "/<remote mt address>//some/suffix") or could be relative to this process' default mount table (e.g., "some/suffix").`)
+ aclFile = flag.String("acls", "", "ACL file. Default is to allow all access.")
+ nhName = flag.String("neighborhood_name", "", `<nh name>, if provided, will enable sharing with the local neighborhood with the provided name. The address of this mounttable will be published to the neighboorhood and everything in the neighborhood will be visible on this mounttable.`)
)
-const usage = `%s is a mount table daemon.
-
-Usage:
-
- %s [--address=<local address>] [--name=<name>] [--neighborhood_name=<nh name>]
-
- <local address> is the the local address to listen on. By default, it will
- use a random port.
-
- <name>, if provided, causes the mount table to mount itself under that name.
- The name may be absolute for a remote mount table service (e.g., "/<remote mt
- address>//some/suffix") or could be relative to this process' default mount
- table (e.g., "some/suffix").
-
- <nh name>, if provided, will enable sharing with the local neighborhood with
- the provided name. The address of this mounttable will be published to the
- neighboorhood and everything in the neighborhood will be visible on this
- mounttable.
-`
-
-func Usage() {
- fmt.Fprintf(os.Stderr, usage, os.Args[0], os.Args[0])
-}
-
func main() {
- flag.Usage = Usage
+ //flag.Usage = Usage
r := rt.Init()
defer r.Cleanup()
@@ -69,7 +38,7 @@
vlog.Errorf("r.NewMountTable failed: %v", err)
os.Exit(1)
}
- mtEndpoint, err := mtServer.Listen(*protocol, *address)
+ mtEndpoint, err := mtServer.ListenX(roaming.ListenSpec)
if err != nil {
vlog.Errorf("mtServer.Listen failed: %v", err)
os.Exit(1)
@@ -85,18 +54,19 @@
naming.JoinAddressName(mtEndpoint.String(), ""))
if len(*nhName) > 0 {
+ neighborhoodListenSpec := *roaming.ListenSpec
+ // The ListenSpec code ensures that we have a valid address here.
+ host, port, _ := net.SplitHostPort(roaming.ListenSpec.Address)
+ if port != "" {
+ neighborhoodListenSpec.Address = net.JoinHostPort(host, "0")
+ }
nhServer, err := r.NewServer(veyron2.ServesMountTableOpt(true))
if err != nil {
vlog.Errorf("r.NewServer failed: %v", err)
os.Exit(1)
}
defer nhServer.Stop()
- host, _, err := net.SplitHostPort(*address)
- if err != nil {
- vlog.Errorf("parsing of address(%q) failed: %v", *address, err)
- os.Exit(1)
- }
- if _, err = nhServer.Listen(*protocol, net.JoinHostPort(host, "0")); err != nil {
+ if _, err := nhServer.ListenX(&neighborhoodListenSpec); err != nil {
vlog.Errorf("nhServer.Listen failed: %v", err)
os.Exit(1)
}
diff --git a/services/mounttable/mounttabled/test.sh b/services/mounttable/mounttabled/test.sh
index 144633b..d8620e2 100755
--- a/services/mounttable/mounttabled/test.sh
+++ b/services/mounttable/mounttabled/test.sh
@@ -23,7 +23,7 @@
# Start mounttabled and find its endpoint.
local -r NHNAME=test-$(hostname)-$$
local -r MTLOG="${TMPDIR}/mt.log"
- ./mounttabled --address=127.0.0.1:0 -vmodule=publisher=2 --neighborhood_name="${NHNAME}" > "${MTLOG}" 2>&1 &
+ ./mounttabled --veyron.tcp.address=127.0.0.1:0 -vmodule=publisher=2 --neighborhood_name="${NHNAME}" > "${MTLOG}" 2>&1 &
shell::wait_for "${MTLOG}" "ipc pub: mount"
local -r EP=$(grep "Mount table service at:" "${MTLOG}" | sed -e 's/^.*endpoint: //')
diff --git a/tools/debug/test.sh b/tools/debug/test.sh
index 4779639..dc949c6 100755
--- a/tools/debug/test.sh
+++ b/tools/debug/test.sh
@@ -35,7 +35,7 @@
# Start mounttabled and find its endpoint.
local -r MTLOG="${WORKDIR}/mt.log"
touch "${MTLOG}"
- ./mounttabled --address=127.0.0.1:0 > "${MTLOG}" 2>&1 &
+ ./mounttabled --veyron.tcp.address=127.0.0.1:0 > "${MTLOG}" 2>&1 &
shell::wait_for "${MTLOG}" "Mount table service at:"
local EP=$(grep "Mount table service at:" "${MTLOG}" | sed -e 's/^.*endpoint: //')
[[ -z "${EP}" ]] && shell_test::fail "line ${LINENO}: no mounttable server"
@@ -62,7 +62,7 @@
# Test logs size
echo "This is a log file" > "${TMPDIR}/my-test-log-file"
GOT=$(./debug logs size "${EP}/__debug/logs/my-test-log-file" 2> "${DBGLOG}")
- WANT=$(echo "This is a log file" | wc -c)
+ WANT=$(echo "This is a log file" | wc -c | tr -d ' ')
if [[ "${GOT}" != "${WANT}" ]]; then
dumplogs "${DBGLOG}" "${MTLOG}"
shell_test::fail "line ${LINENO}: unexpected output. Got ${GOT}, want ${WANT}"