/// <inheritdoc /> protected override void RunRoutine() { try { LinkedList <Result> results = new LinkedList <Result>(); Log(LogLevel.Debug, "Try to receive from PartitionRoutine"); // fetch nr of tuples int tuples = InPipe.ReadInt(); Log(LogLevel.Debug, $"{tuples} Tuples to process."); for (int i = 0; i < tuples; i++) { // receive partition-id, key and value from in stream string partition = InPipe.ReadString(); string key = InPipe.ReadString(); int size = InPipe.ReadInt(); byte[] data = InPipe.ReadBytes(size); // store key value pair Result result = Store(partition, key, data, i); results.AddLast(result); Log(LogLevel.Debug, $"Stored {i + 1}/{tuples}: key {key} and {size} data bytes to partition {partition}"); } // send ResultInfos to RoutineCommunicator (Worker) Log(LogLevel.Debug, $"Send {tuples} StoreResult object to RoutinesCommunicator (Worker)"); Order order = new Order { Command = Command.SEND_RESULT, Value = tuples.ToString() }; CtrlPipe.Store(order); foreach (Result result in results) { CtrlPipe.Store(result); } } catch (Exception e) when(e is TException || e is IOException) { Log(LogLevel.Error, $"Error while running StoreRoutine: {e.Message}"); throw new RoutineException(e); } }
/// <summary> /// Fetch an input parameter from the input pipe by its name. A command will be sent to the control pipe to /// feed the parameter to the input pipe, which will be read and mapped to the specific type T. /// </summary> /// <param name="name">The name of the input parameter to search for</param> /// <typeparam name="T">The type of the parameter to map to, which needs to be a Thrift generated type</typeparam> /// <returns>Returns an instance of type T created from the parameter</returns> /// <exception cref="AccessParameterException">If there is an error reading the parameter</exception> protected T GetParameter <T>(string name) where T : TBase { Log(LogLevel.Debug, $"Requesting Parameter {name}"); Order getParam = new Order { Command = Command.GET_PARAMATER, Value = name }; try { CtrlPipe.Store(getParam); T param = InPipe.Read(Activator.CreateInstance <T>()); Log(LogLevel.Debug, $"Received: {param}"); return(param); } catch (Exception e) { throw new AccessParameterException(e); } }