Documentation
¶
Index ¶
- Constants
- func CreateEmptyDir(path string) error
- func EditIPFSField(path, field, value string)
- func GetClusterVariables(path, ip, secret, peername, apiIPFSAddr string, replmin, replmax int, ...) string
- func GetEnvVar(field, value string) string
- func GetNextAvailablePorts(pmin, pmax, n int) (*[]int, error)
- func MakeJSONArray(elements []string) string
- func MakeJSONElem(elem string) string
- func NewClusterBootstrapProtocol(n *onet.TreeNodeInstance, getServ FnService) (onet.ProtocolInstance, error)
- func NewStartARAProtocol(n *onet.TreeNodeInstance, getServ FnService) (onet.ProtocolInstance, error)
- func NewStartIPFSProtocol(n *onet.TreeNodeInstance, getServ FnService) (onet.ProtocolInstance, error)
- func NewStartInstancesProtocol(n *onet.TreeNodeInstance, getServ FnService) (onet.ProtocolInstance, error)
- func ReadConfig(file string) (string, error)
- func ReadFileLineByLine(configFilePath string) func() string
- func WriteConfig(path string, config string) error
- type ClusterBootstrapAnnounce
- type ClusterBootstrapProtocol
- type ClusterBootstrapReply
- type ClusterInfo
- type ClusterInstance
- type FnService
- type IPFSInformation
- type InitRequest
- type InitResponse
- type NodeInfo
- type ReplyPings
- type ReqPings
- type Service
- func (s *Service) EditIPFSConfig(path string) string
- func (s *Service) ExecReplyPings(env *network.Envelope) error
- func (s *Service) ExecReqPings(env *network.Envelope) error
- func (s *Service) GetService() *Service
- func (s *Service) InitRequest(req *InitRequest) (*InitResponse, error)
- func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfig) (onet.ProtocolInstance, error)
- func (s *Service) PrintName()
- func (s *Service) SetClusterLeaderConfig(path, apiIPFSAddr string, replmin, replmax int, ports ClusterInstance) (string, string, error)
- func (s *Service) SetupClusterLeader(path, secret, apiIPFSAddr string, replmin, replmax int) (string, *ClusterInstance, error)
- func (s *Service) SetupClusterSlave(path, bootstrap, secret, apiIPFSAddr string, replmin, replmax int) (*ClusterInstance, error)
- func (s *Service) StartIPFS(secret string) string
- func (s *Service) StartIPFSAndCluster(leader, secret, bootstrap string) *ClusterInstance
- type StartARAAnnounce
- type StartARAProtocol
- type StartARAReply
- type StartIPFSAnnounce
- type StartIPFSProtocol
- type StartIPFSReply
- type StartInstancesAnnounce
- type StartInstancesProtocol
- type StartInstancesReply
Constants ¶
const ( // ClusterConsensusMode "raft" or "crdt" ClusterConsensusMode = "raft" // DefaultReplMin ipfs cluster minimal replication factor DefaultReplMin = 2 // DefaultReplMax ipfs cluster maximal replication factor DefaultReplMax = 2 // BaseHostPort first port allocated to a node BaseHostPort = 14000 // IPVersion default ip version IPVersion = "/ip4/" // TransportProtocol default transport protocol TransportProtocol = "/tcp/" // MaxPortNumberPerHost max number of ports that a host can use MaxPortNumberPerHost = 200 // IPFSPortNumber number of ports used by an IPFS instance IPFSPortNumber = 3 // ClusterPortNumber number of ports used by an ipfs cluster instance ClusterPortNumber = 3 // IPFSStartupTime IPFSStartupTime IPFSStartupTime = 13 * time.Second // ClusterStartupTime ClusterStartupTime ClusterStartupTime = 2 * time.Second // ConfigsFolder folder name ConfigsFolder = "configs" // IPFSFolder ipfs config folder name IPFSFolder = "ipfs" // ClusterFolderPrefix prefix of cluster configs folder name ClusterFolderPrefix = "cluster-" // NodeName name of a node instance NodeName = "node_" // Node0 name of the first node Node0 = NodeName + "0" // ServiceName name of the service ServiceName = "IPFS" // StartIPFSName name of StartIPFS protocol StartIPFSName = "StartIPFS" // ClusterBootstrapName name of ClusterBootstrap protocol ClusterBootstrapName = "ClusterBootstrap" // StartARAName name of the StartARA protocol StartARAName = "StartARA" // StartInstancesName name of the StartInstancesName protocol StartInstancesName = "StartInstances" // PingsFile File with stored pings PingsFile = "../pings.txt" )
Variables ¶
This section is empty.
Functions ¶
func CreateEmptyDir ¶
CreateEmptyDir create an empty directory at the given path
func EditIPFSField ¶
func EditIPFSField(path, field, value string)
EditIPFSField with the native IPFS config command
func GetClusterVariables ¶
func GetClusterVariables(path, ip, secret, peername, apiIPFSAddr string, replmin, replmax int, ports ClusterInstance) string
GetClusterVariables get the cluster variables
func GetNextAvailablePorts ¶
GetNextAvailablePorts return n available ports between pmin and pmax crash if error
func MakeJSONArray ¶
MakeJSONArray make a json array from the given elements
func NewClusterBootstrapProtocol ¶
func NewClusterBootstrapProtocol(n *onet.TreeNodeInstance, getServ FnService) ( onet.ProtocolInstance, error)
NewClusterBootstrapProtocol initialises the structure for use in one round
func NewStartARAProtocol ¶
func NewStartARAProtocol(n *onet.TreeNodeInstance, getServ FnService) ( onet.ProtocolInstance, error)
NewStartARAProtocol initialises the structure for use in one round
func NewStartIPFSProtocol ¶
func NewStartIPFSProtocol(n *onet.TreeNodeInstance, getServ FnService) ( onet.ProtocolInstance, error)
NewStartIPFSProtocol initialises the structure for use in one round
func NewStartInstancesProtocol ¶
func NewStartInstancesProtocol(n *onet.TreeNodeInstance, getServ FnService) ( onet.ProtocolInstance, error)
NewStartInstancesProtocol initialises the structure for use in one round
func ReadConfig ¶
ReadConfig read a config file given as parameter and returns a string
func ReadFileLineByLine ¶
ReadFileLineByLine reads a file line by line
func WriteConfig ¶
WriteConfig write string to a file
Types ¶
type ClusterBootstrapAnnounce ¶
ClusterBootstrapAnnounce is used to pass a message to all children.
type ClusterBootstrapProtocol ¶
type ClusterBootstrapProtocol struct { *onet.TreeNodeInstance Ready chan bool Info ClusterInfo GetService FnService // contains filtered or unexported fields }
ClusterBootstrapProtocol structure
func (*ClusterBootstrapProtocol) Dispatch ¶
func (p *ClusterBootstrapProtocol) Dispatch() error
Dispatch implements the main logic of the protocol. The function is only called once. The protocol is considered finished when Dispatch returns and Done is called.
func (*ClusterBootstrapProtocol) Start ¶
func (p *ClusterBootstrapProtocol) Start() error
Start sends the Announce-message to all children
type ClusterBootstrapReply ¶
type ClusterBootstrapReply struct {
Cluster *[]ClusterInstance
}
ClusterBootstrapReply returns true when ready.
type ClusterInfo ¶
type ClusterInfo struct { Leader string Secret string Size int Instances []ClusterInstance }
ClusterInfo information about a given cluster
type ClusterInstance ¶
type ClusterInstance struct { HostName string IP string IPFSAPIAddr string RestAPIPort int IPFSProxyPort int ClusterPort int }
ClusterInstance details of a cluster
type FnService ¶
type FnService func() *Service
FnService function that returns the service of that node
type IPFSInformation ¶
IPFSInformation structure containing information about an IPFS instance
type InitRequest ¶
type InitRequest struct { Nodes []*gentree.LocalityNode ServerIdentityToName map[*network.ServerIdentity]string OnetTree *onet.Tree Roster *onet.Roster Cruxified bool ComputePings bool Mode string }
InitRequest packet
type NodeInfo ¶
type NodeInfo struct { IPFS IPFSInformation Clusters []ClusterInfo }
NodeInfo contains ipfs and ipfs-cluster information for a given node
type ReplyPings ¶
ReplyPings reply packet for ping service
type Service ¶
type Service struct { // We need to embed the ServiceProcessor, so that incoming messages // are correctly handled. *onet.ServiceProcessor Nodes gentree.LocalityNodes LocalityTree *onet.Tree Parents []*onet.TreeNode GraphTree map[string][]gentree.GraphTree BinaryTree map[string][]*onet.Tree Distances map[*gentree.LocalityNode]map[*gentree.LocalityNode]float64 PortMutex *sync.Mutex W *bufio.Writer File *os.File BandwidthRx uint64 BandwidthTx uint64 NrMsgRx uint64 NrMsgTx uint64 NrProtocolsStarted uint64 OwnPings map[string]float64 DonePing bool PingDistances map[string]map[string]float64 NrPingAnswers int PingAnswerMtx sync.Mutex PingMapMtx sync.Mutex Name string // name of the service (node_2) MyIP string // IP address ConfigPath string // path to home config folder MyIPFSPath string // path to ipfs config folder of that service MinPort int // port range allocated to this node MaxPort int MyIPFS []IPFSInformation // own ipfs information OtherIPFS map[string]IPFSInformation // node_x -> IP, ports etc. OnetTree *onet.Tree StartIPFSProt onet.ProtocolInstance // contains filtered or unexported fields }
Service is our template-service
func (*Service) EditIPFSConfig ¶
EditIPFSConfig edit the ipfs configuration file (mainly the ip) returns the API address of the IPFS instance
func (*Service) ExecReplyPings ¶
ExecReplyPings handle replies of other nodes ping distances to get the full array of distances between each nodes
func (*Service) ExecReqPings ¶
ExecReqPings sends all its own pings distances to the node that requested it
func (*Service) GetService ¶
GetService Returns the Current SERVICE
func (*Service) InitRequest ¶
func (s *Service) InitRequest(req *InitRequest) ( *InitResponse, error)
InitRequest init the tree
func (*Service) NewProtocol ¶
func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfig) (onet.ProtocolInstance, error)
NewProtocol is called on all nodes of a Tree (except the root, since it is the one starting the protocol) so it's the Service that will be called to generate the PI on all others node. If you use CreateProtocolOnet, this will not be called, as the Onet will instantiate the protocol on its own. If you need more control at the instantiation of the protocol, use CreateProtocolService, and you can give some extra-configuration to your protocol in here.
func (*Service) SetClusterLeaderConfig ¶
func (s *Service) SetClusterLeaderConfig(path, apiIPFSAddr string, replmin, replmax int, ports ClusterInstance) ( string, string, error)
SetClusterLeaderConfig set the configs for the leader of a cluster
func (*Service) SetupClusterLeader ¶
func (s *Service) SetupClusterLeader(path, secret, apiIPFSAddr string, replmin, replmax int) (string, *ClusterInstance, error)
SetupClusterLeader setup a cluster instance for the ARA leader
func (*Service) SetupClusterSlave ¶
func (s *Service) SetupClusterSlave(path, bootstrap, secret, apiIPFSAddr string, replmin, replmax int) (*ClusterInstance, error)
SetupClusterSlave setup a cluster slave instance
func (*Service) StartIPFS ¶
StartIPFS starts an IPFS instance for the given service return the multiaddress of the IPFS API
func (*Service) StartIPFSAndCluster ¶
func (s *Service) StartIPFSAndCluster(leader, secret, bootstrap string) *ClusterInstance
StartIPFSAndCluster starts an IPFS instance along with the cluster instance empty secret means that this instance is the cluster leader if leader, returns secret and the started instance information containing bootstrap address for slaves
type StartARAAnnounce ¶
StartARAAnnounce is used to pass a message to all children.
type StartARAProtocol ¶
type StartARAProtocol struct { *onet.TreeNodeInstance Ready chan bool Info ClusterInfo GetService FnService // contains filtered or unexported fields }
StartARAProtocol structure
func (*StartARAProtocol) Dispatch ¶
func (p *StartARAProtocol) Dispatch() error
Dispatch implements the main logic of the protocol. The function is only called once. The protocol is considered finished when Dispatch returns and Done is called.
func (*StartARAProtocol) Start ¶
func (p *StartARAProtocol) Start() error
Start sends the Announce-message to all children
type StartARAReply ¶
type StartARAReply struct {
Cluster *[]ClusterInstance
}
StartARAReply returns true when ready.
type StartIPFSAnnounce ¶
type StartIPFSAnnounce struct {
Message string
}
StartIPFSAnnounce is used to pass a message to all children.
type StartIPFSProtocol ¶
type StartIPFSProtocol struct { *onet.TreeNodeInstance Ready chan bool GetService FnService Nodes map[string]*NodeInfo // contains filtered or unexported fields }
StartIPFSProtocol structure
func (*StartIPFSProtocol) Dispatch ¶
func (p *StartIPFSProtocol) Dispatch() error
Dispatch implements the main logic of the protocol. The function is only called once. The protocol is considered finished when Dispatch returns and Done is called.
func (*StartIPFSProtocol) Start ¶
func (p *StartIPFSProtocol) Start() error
Start sends the Announce-message to all children
type StartIPFSReply ¶
type StartIPFSReply struct { IPFS *IPFSInformation Clusters *[]ClusterInfo }
StartIPFSReply returns true when ready.
type StartInstancesAnnounce ¶
type StartInstancesAnnounce struct{}
StartInstancesAnnounce is used to pass a message to all children.
type StartInstancesProtocol ¶
type StartInstancesProtocol struct { *onet.TreeNodeInstance Ready chan bool GetService FnService Nodes map[string]*NodeInfo // contains filtered or unexported fields }
StartInstancesProtocol structure
func (*StartInstancesProtocol) Dispatch ¶
func (p *StartInstancesProtocol) Dispatch() error
Dispatch implements the main logic of the protocol. The function is only called once. The protocol is considered finished when Dispatch returns and Done is called.
func (*StartInstancesProtocol) Start ¶
func (p *StartInstancesProtocol) Start() error
Start sends the Announce-message to all children
type StartInstancesReply ¶
type StartInstancesReply struct {
Node *NodeInfo
}
StartInstancesReply returns true when ready.