[ 
https://issues.apache.org/jira/browse/MINIFICPP-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16186098#comment-16186098
 ] 

ASF GitHub Bot commented on MINIFICPP-36:
-----------------------------------------

Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/134#discussion_r141920195
  
    --- Diff: libminifi/include/c2/C2Agent.h ---
    @@ -0,0 +1,203 @@
    +/**
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +#ifndef LIBMINIFI_INCLUDE_C2_C2AGENT_H_
    +#define LIBMINIFI_INCLUDE_C2_C2AGENT_H_
    +
    +#include <utility>
    +#include <functional>
    +#include <future>
    +#include <memory>
    +#include <mutex>
    +#include <thread>
    +#include "core/state/UpdateController.h"
    +#include "core/state/metrics/MetricsBase.h"
    +#include "C2Payload.h"
    +#include "C2Protocol.h"
    +#include "io/validation.h"
    +#include "protocols/Protocols.h"
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace c2 {
    +
    +/**
    + * Purpose and Justification: C2 agent will be the mechanism that will 
abstract the protocol to do the work.
    + *
    + * The protocol represents a transformation layer into the objects seen in 
C2Payload. That transformation may
    + * be minimal or extreme, depending on the protocol itself.
    + *
    + * Metrics Classes defined here:
    + *
    + *   0 HeartBeat --  RESERVED
    + *   1-255 Defined by the configuration file.
    + */
    +class C2Agent : public state::UpdateController, public 
state::metrics::MetricsSink, public std::enable_shared_from_this<C2Agent> {
    + public:
    +
    +  C2Agent(const 
std::shared_ptr<core::controller::ControllerServiceProvider> &controller,
    +          const std::shared_ptr<state::StateMonitor> &updateSink,
    +          const std::shared_ptr<Configure> &configure);
    +
    +  virtual ~C2Agent() {
    +
    +  }
    +
    +  /**
    +   * Sends the heartbeat to ths server. Will include metrics
    +   * in the payload if they exist.
    +   */
    +  void performHeartBeat();
    +
    +  virtual std::vector<std::function<state::Update()>> getFunctions() {
    +    return functions_;
    +  }
    +
    +  /**
    +   * Sets the metric within this sink
    +   * @param metric metric to set
    +   * @param return 0 on success, -1 on failure.
    +   */
    +  virtual int16_t setMetrics(const 
std::shared_ptr<state::metrics::Metrics> &metric);
    +
    + protected:
    +
    +  /**
    +   * Configure the C2 agent
    +   */
    +  void configure(const std::shared_ptr<Configure> &configure, bool 
reconfigure = true);
    +
    +  /**
    +   * Serializes metrics into a payload.
    +   * @parem parent_paylaod parent payload into which we insert the newly 
generated payload.
    +   * @param name name of this metric
    +   * @param metrics metrics to include.
    +   */
    +  void serializeMetrics(C2Payload &parent_payload, const std::string 
&name, const std::vector<state::metrics::MetricResponse> &metrics);
    +
    +  /**
    +   * Extract the payload
    +   * @param resp payload to be moved into the function.
    +   */
    +  void extractPayload(const C2Payload &&resp);
    +
    +  /**
    +   * Extract the payload
    +   * @param payload reference.
    +   */
    +  void extractPayload(const C2Payload &resp);
    +
    +  /**
    +   * Enqueues a C2 server response for us to evaluate and parse.
    +   */
    +  void enqueue_c2_server_response(C2Payload &&resp) {
    +    std::lock_guard<std::timed_mutex> lock(queue_mutex);
    +    responses.push_back(std::move(resp));
    --- End diff --
    
    We want to maintain ordering, which can't be guaranteed with a lock free 
queue. 


> Begin building controlling API to facilitate control of agents
> --------------------------------------------------------------
>
>                 Key: MINIFICPP-36
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-36
>             Project: NiFi MiNiFi C++
>          Issue Type: New Feature
>            Reporter: marco polo
>            Assignee: marco polo
>            Priority: Critical
>              Labels: Durability, Reliability, Statistics
>
> Begin building the controlling API in MiNiFi C++. This API will evolve and 
> likely have public and private elements. As development progresses we may 
> want more capabilities. 
> What I want to create as a straw man will be basic control and metrics 
> gathering
> -- Start
> -- Stop
> -- Pause
> -- Gather metrics
>    ** Throughput of of flow components
>    ** Execution time ( run time minus sleep time )
>    ** Memory consumption
> -- Drain repositories
> -- Switch repository types. 
> Better employ update listener within this controlling API



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to