veyron/runtimes/google/namimg: allow 'addresses' to be stored in the mounttable and other 'cleanups'
It seems more natural to me to allow 'addresses' rather than 'names' to be
stored in the mount table, so that a name resolves to an address. In practice
we put endpoints in the mount table, represented as strings - i.e. not typed.
Before this CL the mount table would insist that all addresses be rooted names.
As an aside, there was bug wherebe such errors would not be reported to
the client which is fixed in this CL. This CL changes the mount table to
so that endpoint strings can be used directly without being turned into
names, there is still validation of these strings to make sure they
contain a correctly formed address.
In addition to the above, this CL 'cleans up' various inconsistent
uses of 'address' vs 'name' and changes some uses of Resolve to
ResolveX. In particular:
- the Endpoint interface now has a 'Name' method that returns a rooted
name.
- the MountEntry type has two new methods:
a. Names: to obtain a slice of names (endpoint plus suffix) replacing the
ToStringSlice method
b. MountedServers: to obtain the server addresses as rooted names
- MountEntry.Names, MountedServers or the values in MountEntry now
cover all possible uses of the data returned by the Mount Table.
- Various 'modules' and tests have been updated to use 'names' exclusively.
We will need to push a new mount table for newly built clients to function.
Existing client/servers should work fine. I'll try this out on the new
'staging' setup if possible.
Change-Id: I4499fdf438a0e659c4fdc81ceed35c2b10fc596f
MultiPart: 1/3
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 850c601..432242e 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -161,7 +161,7 @@
if entry, err = s.ns.ResolveX(s.ctx, address); err != nil {
return "", err
}
- names = naming.ToStringSlice(entry)
+ names = entry.Names()
} else {
names = append(names, address)
}
@@ -472,7 +472,7 @@
}
eps := make([]naming.Endpoint, len(ieps))
for i, iep := range ieps {
- s.publisher.AddServer(naming.JoinAddressName(iep.String(), ""), s.servesMountTable)
+ s.publisher.AddServer(iep.String(), s.servesMountTable)
eps[i] = iep
}
return eps, nil
@@ -495,7 +495,7 @@
s.Lock()
s.listeners[ln] = struct{}{}
s.Unlock()
- s.publisher.AddServer(naming.JoinAddressName(iep.String(), ""), s.servesMountTable)
+ s.publisher.AddServer(iep.String(), s.servesMountTable)
return iep, ln, nil
}
@@ -524,7 +524,7 @@
s.listenLoop(ln, iep)
// The listener is done, so:
// (1) Unpublish its name
- s.publisher.RemoveServer(naming.JoinAddressName(iep.String(), ""))
+ s.publisher.RemoveServer(iep.String())
}
s.Lock()
@@ -611,7 +611,7 @@
// Publish all of the addresses
for _, pubAddr := range dhcpl.pubAddrs {
ep.Address = net.JoinHostPort(pubAddr.Address().String(), dhcpl.pubPort)
- s.publisher.AddServer(naming.JoinAddressName(ep.String(), ""), s.servesMountTable)
+ s.publisher.AddServer(ep.String(), s.servesMountTable)
}
for setting := range dhcpl.ch {
@@ -655,6 +655,7 @@
}
func (s *server) Serve(name string, obj interface{}, authorizer security.Authorizer) error {
+ defer vlog.LogCall()()
invoker, err := objectToInvoker(obj)
if err != nil {
return s.newBadArg(fmt.Sprintf("bad object: %v", err))
@@ -663,6 +664,7 @@
}
func (s *server) ServeDispatcher(name string, disp ipc.Dispatcher) error {
+ defer vlog.LogCall()()
s.Lock()
defer s.Unlock()
vtrace.GetSpan(s.ctx).Annotate("Serving under name: " + name)
@@ -686,6 +688,7 @@
}
func (s *server) AddName(name string) error {
+ defer vlog.LogCall()()
s.Lock()
defer s.Unlock()
vtrace.GetSpan(s.ctx).Annotate("Serving under name: " + name)
@@ -706,6 +709,7 @@
}
func (s *server) RemoveName(name string) error {
+ defer vlog.LogCall()()
s.Lock()
defer s.Unlock()
vtrace.GetSpan(s.ctx).Annotate("Removed name: " + name)