public void SetOwner(DadTuple tuple, int ownerId) { Group.SetOwner(tuple, ownerId); if (ownerId == ReplicaID) { Console.WriteLine("[OWNERSHIP] Ownership acquired for {0}.", tuple); TupleProcessor.Post(tuple); } }
public void Flow(DadTuple tuple) { Console.WriteLine("[IN] Received tuple {0}.", tuple); if (Group.HasShare(tuple)) { Console.WriteLine("[IN] Tuple {0} had been received before. Ignoring.", tuple); return; } Group.RMSend(p => p.Share(tuple, ReplicaID)); // Sleep for a certain interval (0 by default) System.Threading.Thread.Sleep(Interval); }
public void SaveShare(DadTuple tuple, int interestedId) { Queue <int> interestedSet; if (Shared.TryGetValue(tuple, out interestedSet)) { interestedSet.Enqueue(interestedId); } else { interestedSet = new Queue <int>(); interestedSet.Enqueue(interestedId); Shared.Add(tuple, interestedSet); } }
public void Share(DadTuple tuple, int senderId) { Console.WriteLine("[Share] Received share {0}.", tuple); if (Group.IsLeader(ReplicaID)) { if (!Group.HasShare(tuple)) { Console.WriteLine("[LEADER] Setting the owner of tuple {0}.", tuple); Group.RMSend(p => p.SetOwner(tuple, senderId)); } } Group.SaveShare(tuple, senderId); }
public bool Flow(DadTuple tuple, bool isLogging) { Console.WriteLine("[OUT] Sending tuple {0} to {1}", tuple, this); var sent = false; try { Proxy.Flow(tuple); sent = true; } catch (Exception e) { Console.WriteLine("[OUT] Unable to send tuple to replica {0}. Reason: {1}.", this, e.Message); } return(sent); }
public void Flow(DadTuple tuple, bool isLogging) { var sent = false; while (!sent && AliveReplicas.Count > 0) { var chosenReplicaIdx = Router.Route(tuple.Content, AliveReplicas.Count); var chosenReplica = AliveReplicas[chosenReplicaIdx]; sent = chosenReplica.Flow(tuple, isLogging); if (!sent) { AliveReplicas.Remove(chosenReplica); } } if (!sent) { Console.WriteLine("[OUT] WARNING: Unable to send tuple to any replica of {0}.", Id); } }
private void Process(DadTuple inputTuple) { Console.WriteLine("[CONSUMER] Starting computation of {0}.", inputTuple); // Process the tuple var computedTuples = Kernel.execute(inputTuple.Content); if (computedTuples.Count == 0) { return; } var outTuples = computedTuples.Select(t => new DadTuple(TupleIdGenerator.NextTupleId(), t)).ToList(); Console.WriteLine("[CONSUMER] Sharing results of computation of {0} to group.", inputTuple); Group.RMSend(p => p.SaveProcessedTuples(inputTuple.Id, outTuples)); //Group.LocalReplica.SaveProcessedTuples(inputTuple.Id, outTuples); // Is the last operator in the acyclic graph if (DownstreamOperators.Count == 0) { // Output to a file (if we are the leader) OutputToFile(outTuples); } else { // Send the tuples SendOutputTuples(outTuples); } // Log LogToPuppetMaster(outTuples); Group.RMSend(p => p.DeliveredTuples(inputTuple.Id, outTuples.Select(ot => ot.Id).ToList())); }
public void TupleWasProcessed(DadTuple upstreamTupleThatWasProcessed) { Kernel.TupleWasProcessed(upstreamTupleThatWasProcessed); }
public async Task <bool> SendAsync(DadTuple tuple) { return(await TupleBuffer.SendAsync(tuple)); }
public bool Post(DadTuple tuple) { return(TupleBuffer.Post(tuple)); }
public override void TupleWasProcessed(DadTuple upstreamTupleThatWasProcessed) { history.Add(upstreamTupleThatWasProcessed.Content[fieldNum]); }
public void SetOwner(DadTuple tuple, int ownerId) { Proxy.SetOwner(tuple, ownerId); }
public bool HasShare(DadTuple tuple) { return(Shared.ContainsKey(tuple)); }
public void SetOwner(DadTuple tuple, int ownerId) { NoOwner.Remove(tuple); AllMembers[ownerId].AddOwnedTuple(tuple); }
public void AddOwnedTuple(DadTuple tuple) { OwnedTuples.Add(tuple); }
public virtual void TupleWasProcessed(DadTuple upstreamTupleThatWasProcessed) { }
public void Share(DadTuple tuple, int senderId) { Proxy.Share(tuple, senderId); }