typos and style nitpicks

License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
This commit is contained in:
Adrian Lanzafame 2018-04-09 12:19:47 +10:00 committed by Hector Sanjuan
parent a0a0898719
commit 5316c3bb4c
4 changed files with 26 additions and 19 deletions

View File

@ -12,11 +12,10 @@ import (
// This file gathers allocation logic used when pinning or re-pinning
// to find which peers should be allocated to a Cid. Allocation is constrained
// by ReplicationFactorMin and ReplicationFactorMax parametres obtained
// by ReplicationFactorMin and ReplicationFactorMax parameters obtained
// from the Pin object.
//The allocation
// process has several steps:
// The allocation process has several steps:
//
// * Find which peers are pinning a CID
// * Obtain the last values for the configured informer metrics from the
@ -164,7 +163,7 @@ func (c *Cluster) obtainAllocations(
// Reminder: rplMin <= rplMax AND >0
if wanted < 0 { // alocations above maximum threshold: drop some
if wanted < 0 { // allocations above maximum threshold: drop some
// This could be done more intelligently by dropping them
// according to the allocator order (i.e. free-ing peers
// with most used space first).

View File

@ -1,4 +1,4 @@
// Package descendalloc implements an ipfscluster.util.Allocator returns
// Package descendalloc implements an ipfscluster.PinAllocator returns
// allocations based on sorting the metrics in descending order. Thus, peers
// with largest metrics are first in the list. This allocator can be used with a
// number of informers, as long as they provide a numeric metric value.

View File

@ -119,10 +119,10 @@ type PinTracker interface {
// Sync makes sure that the Cid status reflect the real IPFS status.
// It returns the local status of the Cid.
Sync(*cid.Cid) (api.PinInfo, error)
// Recover retriggers a Pin/Unpin operation in a Cids with error status.
Recover(*cid.Cid) (api.PinInfo, error)
// RecoverAll calls Recover() for all pins tracked.
RecoverAll() ([]api.PinInfo, error)
// Recover retriggers a Pin/Unpin operation in a Cids with error status.
Recover(*cid.Cid) (api.PinInfo, error)
}
// Informer provides Metric information from a peer. The metrics produced by
@ -142,7 +142,7 @@ type Informer interface {
type PinAllocator interface {
Component
// Allocate returns the list of peers that should be assigned to
// Pin content in oder of preference (from the most preferred to the
// Pin content in order of preference (from the most preferred to the
// least). The "current" map contains valid metrics for peers
// which are currently pinning the content. The candidates map
// contains the metrics for all peers which are eligible for pinning

View File

@ -74,6 +74,7 @@ func (mpt *MapPinTracker) pinWorker() {
for {
select {
case p := <-mpt.pinCh:
//TODO(ajl):
mpt.pin(p)
case <-mpt.ctx.Done():
return
@ -201,12 +202,13 @@ func (mpt *MapPinTracker) isRemote(c api.Pin) bool {
func (mpt *MapPinTracker) pin(c api.Pin) error {
logger.Debugf("issuing pin call for %s", c.Cid)
mpt.set(c.Cid, api.TrackerStatusPinning)
err := mpt.rpcClient.Call("",
err := mpt.rpcClient.Call(
"",
"Cluster",
"IPFSPin",
c.ToSerial(),
&struct{}{})
&struct{}{},
)
if err != nil {
mpt.setError(c.Cid, err)
return err
@ -219,22 +221,24 @@ func (mpt *MapPinTracker) pin(c api.Pin) error {
func (mpt *MapPinTracker) unpin(c api.Pin) error {
logger.Debugf("issuing unpin call for %s", c.Cid)
mpt.set(c.Cid, api.TrackerStatusUnpinning)
err := mpt.rpcClient.Call("",
err := mpt.rpcClient.Call(
"",
"Cluster",
"IPFSUnpin",
c.ToSerial(),
&struct{}{})
&struct{}{},
)
if err != nil {
mpt.setError(c.Cid, err)
return err
}
mpt.set(c.Cid, api.TrackerStatusUnpinned)
return nil
}
// Track tells the MapPinTracker to start managing a Cid,
// possibly trigerring Pin operations on the IPFS daemon.
// possibly triggering Pin operations on the IPFS daemon.
func (mpt *MapPinTracker) Track(c api.Pin) error {
logger.Debugf("tracking %s", c.Cid)
if mpt.isRemote(c) {
@ -301,11 +305,13 @@ func (mpt *MapPinTracker) StatusAll() []api.PinInfo {
// the IPFS daemon.
func (mpt *MapPinTracker) Sync(c *cid.Cid) (api.PinInfo, error) {
var ips api.IPFSPinStatus
err := mpt.rpcClient.Call("",
err := mpt.rpcClient.Call(
"",
"Cluster",
"IPFSPinLsCid",
api.PinCid(c).ToSerial(),
&ips)
&ips,
)
if err != nil {
mpt.setError(c, err)
return mpt.get(c), err
@ -324,11 +330,13 @@ func (mpt *MapPinTracker) Sync(c *cid.Cid) (api.PinInfo, error) {
func (mpt *MapPinTracker) SyncAll() ([]api.PinInfo, error) {
var ipsMap map[string]api.IPFSPinStatus
var pInfos []api.PinInfo
err := mpt.rpcClient.Call("",
err := mpt.rpcClient.Call(
"",
"Cluster",
"IPFSPinLs",
"recursive",
&ipsMap)
&ipsMap,
)
if err != nil {
mpt.mux.Lock()
for k := range mpt.status {