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

ASF GitHub Bot commented on METRON-684:
---------------------------------------

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

    https://github.com/apache/incubator-metron/pull/435#discussion_r99368863
  
    --- Diff: 
metron-analytics/metron-profiler-client/src/main/java/org/apache/metron/profiler/client/stellar/Util.java
 ---
    @@ -0,0 +1,117 @@
    +/*
    + *
    + *  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.metron.profiler.client.stellar;
    +
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.metron.common.dsl.Context;
    +import org.apache.metron.common.dsl.ParseException;
    +import org.apache.metron.common.utils.ConversionUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.stream.Collectors;
    +import java.util.stream.Stream;
    +
    +import static java.lang.String.format;
    +import static 
org.apache.metron.common.dsl.Context.Capabilities.GLOBAL_CONFIG;
    +
    +public class Util {
    +  private static final Logger LOG = LoggerFactory.getLogger(Util.class);
    +
    +  /**
    +   * Ensure that the required capabilities are defined.
    +   * @param context The context to validate.
    +   * @param required The required capabilities.
    +   * @throws IllegalStateException if all of the required capabilities are 
not present in the Context.
    +   */
    +  public static void validateCapabilities(Context context, 
Context.Capabilities[] required) throws IllegalStateException {
    +
    +    // collect the name of each missing capability
    +    String missing = Stream
    +            .of(required)
    +            .filter(c -> !context.getCapability(c).isPresent())
    +            .map(c -> c.toString())
    +            .collect(Collectors.joining(", "));
    +
    +    if(StringUtils.isNotBlank(missing) || context == null) {
    +      throw new IllegalStateException("missing required context: " + 
missing);
    +    }
    +  }
    +  /**
    --- End diff --
    
    Minor spacing issues (1 empty line between methods) here and later in the 
file.


> Decouple Timestamp calculation from PROFILE_GET
> -----------------------------------------------
>
>                 Key: METRON-684
>                 URL: https://issues.apache.org/jira/browse/METRON-684
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: Casey Stella
>            Assignee: Casey Stella
>
> Currently PROFILE_GET only supports a static lookback of a fixed duration.  
> As we have more complicated, potentially sparse, lookbacks (e.g. the same 
> time slice every tuesday for a month), it would be nice to decouple the 
> construction of timestamps from PROFILE_GET into its own set of functions.



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

Reply via email to