Swarm source Analysis (2)---manage process and store

Source: Internet
Author: User

The original of this article QQ Space link: http://user.qzone.qq.com/29185807/blog/1462853926

The original article csdn blog link: http://blog.csdn.net/screscent/article/details/51362116

In the previous article, the analysis of Create and join was created and joined to the swarm cluster. So how the Swarm cluster works and manages it.

Let's analyze it below. 1, Swarm manage main body construction process

Let's see how the Manage command was built.

Code in Swarm\main.go


The action here is the Manage function.

Let's take a look at this function

Code in Swarm\manage.go


The above is mainly TLS configuration


It builds a store.


It builds a cluster


It builds a strategy


The above constructs a filter



It builds a discovery


It builds a scheduler


Finally, the API service is turned on

The overall build process is clear and modular is clear.

Here we have a module to analyze

2, Store

Code in Swarm\state\store.go

Let's look at the structure first.


The annotation here is very clear, is to have a simple key "--" requestedstate map storage

Let's see requestedstate.

Code in Swarm\state\state.go


Let's see Containerconfig again.

Code in Github.com\samalba\dockerclient\types.go


It's clear here that the store keeps the container information.

Here's what the store offers.

Newstore


Initializing directory paths and map Initialize


Called the Restore

Restore


Traverse all files in the directory and use JSON to load

Load


Using JSON to parse a file get


Find the corresponding information from the map Add


Called the set set


Write the information to the file and save the information to the map remove


Delete the file and delete the information in the map Replace


Replace

Summary

Stroe is also very simple, mainly maintaining a directory file and a map store.

If there is a place where the explanation is wrong, please forgive me and look at it.

Hao Haohua

QQ Crescent moon Lonely Road length 29185807

May 10, 2016

(Copyright statement: This article for the author original, if you need to reprint, please notify me, and indicate the source and author.) Reproduced without authorization, reserve the right to pursue its infringement. )



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.