Fix syncAll being triggered before cluster run(). Other small things.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
Hector Sanjuan 2016-12-12 13:54:58 +01:00
parent c342bbc09f
commit 98dc9f2289
4 changed files with 11 additions and 10 deletions

View File

@ -62,9 +62,9 @@ func NewCluster(cfg *ClusterConfig, api ClusterAPI, ipfs IPFSConnector, state Cl
logger.Info("Starting IPFS Cluster")
go cluster.run()
logger.Info("Performing State synchronization")
cluster.Sync()
go cluster.run()
return cluster, nil
}

View File

@ -99,8 +99,8 @@ type ClusterConsensus struct {
consensus consensus.OpLogConsensus
actor consensus.Actor
rpcCh chan ClusterRPC
baseOp clusterLogOp
rpcCh chan ClusterRPC
p2pRaft *libp2pRaftWrap
}
@ -113,7 +113,7 @@ func NewClusterConsensus(cfg *ClusterConfig, host host.Host, state ClusterState)
ctx := context.Background()
rpcCh := make(chan ClusterRPC, RPCMaxQueue)
op := clusterLogOp{
ctx: ctx,
ctx: context.Background(),
rpcCh: rpcCh,
}
con, actor, wrapper, err := makeLibp2pRaft(cfg, host, state, op)
@ -126,11 +126,13 @@ func NewClusterConsensus(cfg *ClusterConfig, host host.Host, state ClusterState)
cc := &ClusterConsensus{
ctx: ctx,
consensus: con,
baseOp: op,
actor: actor,
rpcCh: rpcCh,
p2pRaft: wrapper,
}
// FIXME: this is broken.
logger.Info("Waiting for Consensus state to catch up")
time.Sleep(1 * time.Second)
start := time.Now()

View File

@ -29,7 +29,7 @@ var RPCMaxQueue = 128
// MakeRPCRetryInterval specifies how long to wait before retrying
// to put a ClusterRPC request in the channel in MakeRPC().
var MakeRPCRetryInterval time.Duration = 1
var MakeRPCRetryInterval time.Duration = 1 * time.Second
// ClusterComponent represents a piece of ipfscluster. Cluster components
// usually run their own goroutines (a http server for example). They
@ -117,7 +117,7 @@ type PinTracker interface {
// The ctx parameter must be a cancellable context, and can be used to
// timeout requests.
// If the message cannot be placed in the ClusterRPC channel, retries will be
// issued every MakeRPCRetryInterval seconds.
// issued every MakeRPCRetryInterval.
func MakeRPC(ctx context.Context, rpcCh chan ClusterRPC, r ClusterRPC, waitForResponse bool) RPCResponse {
logger.Debugf("Sending RPC %d", r.Op())
exitLoop := false
@ -132,8 +132,8 @@ func MakeRPC(ctx context.Context, rpcCh chan ClusterRPC, r ClusterRPC, waitForRe
Error: errors.New("Operation timed out while sending RPC"),
}
default:
logger.Error("RPC channel is full. Will retry in 1 second.")
time.Sleep(MakeRPCRetryInterval * time.Second)
logger.Error("RPC channel is full. Will retry.")
time.Sleep(MakeRPCRetryInterval)
}
}
if !waitForResponse {

View File

@ -30,11 +30,10 @@ type PinMode int
type PinStatus int
type MapPinTracker struct {
mux sync.Mutex
status map[string]Pin
rpcCh chan ClusterRPC
mux sync.Mutex
shutdownCh chan struct{}
doneCh chan struct{}