Links v2: Remove the graphdb. Replace with code and json structure.

This is a rewrite of the graphdb and replaces all naming and aliasing functionality. The new architecture is called a "container index" and was based 

**Bugs**: notably `docker ps -a` from earlier versions will panic if there are containers to list, because of a string handling bug. I really don't want to lose this patch over this, so suggestions for a workable fix are welcome.

More patches will likely need to be filed to deal with alias management and links. The focus here is to replace graphdb in a backwards-compatible fashion.

This code still imports graphdb for the purposes of the migrating data from one format to another. At some point this code should be removed, maybe in 1.5 or 1.6. It will improve build time dramatically. :)

The migration is not tested but many other features are. Tests for the index itself are largely a side-effect of the integration-cli tests and other integrations.

Many tests were rewritten to accommodate the new naming system (which contains no syntax) but otherwise are unchanged to preserve the tests. In a few minor cases tests were removed because they were no longer relevant, e.g., tests that turn the links structure into a graphdb path and then test that path.

Don't merge this until links is completely ready. Please let me know if you have any other questions.


Yeah. Argh. What do you suggest?

On Sep 22, 2014, at 12:57 PM, Alexandr Morozov <notifications@github.com> wrote:

> In daemon/index.go:
> 
> > +
> > +func (c *containerIndex) ChildrenByName(name string) map[string]*Container {
> > +	c.lock()
> > +
> > +	result := map[string]*Container{}
> > +
> > +	for name, id := range c.NameToChildren[name] {
> > +		result[name] = c.idToContainer[id]
> > +	}
> > +
> > +	c.unlock()
> > +
> > +	return result
> > +}
> > +
> > +func (c *containerIndex) SetAlias(parent, child *Container, alias string) error {
> But all idea this to be atomic. For example you tried alias in c.AliasInUse - all is okay, on call of c.AddAlias runtime can switch to another goroutine, which acquires this alias, you get back to your AddAlias and get some strange error instead of neat "Alias %s cannot be set for container ID %s, parent %s: name conflict".
> 
> —
> Reply to this email directly or view it on GitHub.
>