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

ASF GitHub Bot commented on NIFI-2724:
--------------------------------------

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

    https://github.com/apache/nifi/pull/1016#discussion_r114889131
  
    --- Diff: 
nifi-nar-bundles/nifi-jmx-bundle/nifi-jmx-processors/src/main/java/org/apache/nifi/processors/jmx/ListFilter.java
 ---
    @@ -0,0 +1,123 @@
    +/*
    + * 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.
    + */
    +package org.apache.nifi.processors.jmx;
    +
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.Set;
    +
    +public class ListFilter {
    +    private String cachedListString = "";
    +    private Map<String,ArrayList<String>> listM = null;
    +
    +    public static final boolean WHITELIST = true;
    +    public static final boolean BLACKLIST = false;
    +
    +
    +    public ListFilter( String listString ) {
    +        setListString( listString );
    +    }
    +
    +
    +    public void setListString( String listString ) {
    +        if (listString == null || listString.isEmpty() ) listString = "";
    +
    +        if (!listString.equals(cachedListString) || listM == null) {
    +            buildList( listString );
    +        }
    +    }
    +
    +
    +    private void buildList(String listString) {
    +        listM = new HashMap<>();
    +
    +        if (!listString.isEmpty()) {
    +            String[] listElementsAr = listString.replaceAll("\\s+"," 
").split(",");
    +
    +            for (int i = 0; i < listElementsAr.length; i++) {
    +                String[] listPartsAr = listElementsAr[i].split(":");
    +                ArrayList<String> listTypesAL = new ArrayList<String>();
    +
    +                if (listPartsAr.length > 1) {
    +                    String[] listTypeElementsAr = listPartsAr[1].split(" 
");
    +
    +                    for (String s : listTypeElementsAr) {
    +                        if (!s.replaceAll("\\s+","").isEmpty()) {
    +                            listTypesAL.add(s);
    +                        }
    +                    }
    +                }
    +
    +                listM.put(listPartsAr[0], listTypesAL);
    +            }
    +        }
    +
    +        cachedListString = listString;
    +    }
    +
    +
    +
    +    /*
    +     * domain and type values can contain regular expressions
    +     * First check if the domain key in matched in the Map.  If yes then 
check if the type
    +     * is matched in the ArrayList pointed to by the domain key.
    +     * Is in list if...
    +     * domain key is not matched: false
    +     * domain key is matched and there are no entries in the ArrayList: 
true
    +     * domain key is matched and there are entries in the ArrayList but 
type value is not matched: false
    +     * domain key is matched and there are entries in the ArrayList and 
the type value is matched: true
    +     */
    +    public boolean isInList(boolean listStyle, String domain, String type) 
{
    +        // not in the list...
    +        // whitelist = true since not defining a value for this style 
means the everything is included
    +        // blacklist = false since not defining a value for this style 
means nothing is excluded
    +        if (listM.size() == 0) {
    +            return (listStyle) ? true : false;
    +        }
    +
    +        if (domain == null || domain.isEmpty()) {
    +            return (listStyle) ? true : false;
    +        }
    +
    +        if (type == null) type = "";
    --- End diff --
    
    Please avoid single line if statement.


> JMX Processor
> -------------
>
>                 Key: NIFI-2724
>                 URL: https://issues.apache.org/jira/browse/NIFI-2724
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Extensions
>    Affects Versions: 1.0.0
>         Environment: All platforms with Java RMI support for JMX
>            Reporter: Brian Burnett
>            Assignee: Andre F de Miranda
>            Priority: Minor
>              Labels: processor
>         Attachments: 0001-NIFI-2724-New-JMX-Processor.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> The JMX Processor feature addition includes only GetJMX without 
> SecurityManager capabilities at this time.  The processor in its current 
> state is capable of pulling MBean Property and Attribute values from a remote 
> RMI Server.  Each set of Mbean data is wrapped in a JSON formatted FlowFile 
> for downstream processing.  It has the ability to control content with 
> whitelist and blacklist properties.
> Possible use for this processor and the reason it was created is to help make 
> sense of Kafka server metrics.
> Will followup with a SecurityManager Context Service and PutJMX Processor.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to