arpadboda commented on a change in pull request #573: minificpp-873 Implmented. URL: https://github.com/apache/nifi-minifi-cpp/pull/573#discussion_r288520844
########## File path: extensions/windows-event-log/CollectorInitiatedSubscription.cpp ########## @@ -0,0 +1,777 @@ +/** + * @file CollectorInitiatedSubscription.cpp + CollectorInitiatedSubscription class implementation + * + * 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. + */ + +#include "CollectorInitiatedSubscription.h" +#include <vector> +#include <queue> +#include <map> +#include <vector> +#include <set> +#include <sstream> +#include <stdio.h> +#include <string> +#include <iostream> +#include <memory> +#include <codecvt> + +#include "io/DataStream.h" +#include "core/ProcessContext.h" +#include "core/ProcessSession.h" + +#pragma comment(lib, "wevtapi.lib") +#pragma comment(lib, "Wecapi.lib") + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace processors { + +struct OnScopeExit +{ + std::function<void(void)> functor_; +public: + OnScopeExit(const decltype(functor_)& functor) : functor_(functor) {} + ~OnScopeExit() { functor_(); } +}; + +#define SCOPE_EXIT_CONCAT(x, y) x##y +#define SCOPE_EXIT_UNIQUE_NAME(name, counter) SCOPE_EXIT_CONCAT(name, counter) +#define ON_SCOPE_EXIT(f) OnScopeExit SCOPE_EXIT_UNIQUE_NAME(onScopeExit, __COUNTER__)([&]{f;}) + +static std::set<core::Property> s_supportedProperties; + +struct SupportedProperty: public core::Property +{ + template <typename ...Args> + SupportedProperty(const Args& ...args): core::Property(args...) { + s_supportedProperties.insert(*this); + } +}; + +const std::string ProcessorName("CollectorInitiatedSubscription"); + +//! Supported Properties +static SupportedProperty s_subscriptionName( + core::PropertyBuilder::createProperty("Subscription Name")-> + isRequired(true)-> + withDescription("The name of the subscription. The value provided for this parameter should be unique within the computer's scope.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_subscriptionDescription( + core::PropertyBuilder::createProperty("Subscription Description")-> + isRequired(true)-> + withDescription("A description of the subscription.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_sourceAddress( + core::PropertyBuilder::createProperty("Source Address")-> + isRequired(true)-> + withDescription("The IP address or fully qualified domain name (FQDN) of the local or remote computer (event source) from which the events are collected.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_sourceUserName( + core::PropertyBuilder::createProperty("Source User Name")-> + isRequired(true)-> + withDescription("The user name, which is used by the remote computer (event source) to authenticate the user.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_sourcePassword( + core::PropertyBuilder::createProperty("Source Password")-> + isRequired(true)-> + withDescription("The password, which is used by the remote computer (event source) to authenticate the user.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_sourceChannels( + core::PropertyBuilder::createProperty("Source Channels")-> + isRequired(true)-> + withDescription("The Windows Event Log Channels (on domain computer(s)) from which events are transferred.")-> + supportsExpressionLanguage(true)-> + build()); + +static SupportedProperty s_maxDeliveryItems( + core::PropertyBuilder::createProperty("Max Delivery Items")-> + isRequired(true)-> + withDefaultValue<core::DataSizeValue>("1000")-> + withDescription("Determines the maximum number of items that will forwarded from an event source for each request.")-> + build()); + +static SupportedProperty s_deliveryMaxLatencyTime( + core::PropertyBuilder::createProperty("Delivery MaxLatency Time")-> + isRequired(true)-> + withDefaultValue<core::DataSizeValue>("10 min")-> Review comment: I think TimePeriodValidator would be more appropriate for this usecase. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
