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

    https://github.com/apache/metron/pull/622#discussion_r127326600
  
    --- Diff: 
metron-analytics/metron-profiler-client/src/main/java/org/apache/metron/profiler/client/stellar/RowKeyBuilderFactory.java
 ---
    @@ -0,0 +1,125 @@
    +/*
    + *
    + *  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.beanutils.PropertyUtils;
    +import org.apache.commons.lang3.ClassUtils;
    +import org.apache.metron.common.utils.ReflectionUtils;
    +import org.apache.metron.profiler.hbase.RowKeyBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import static 
org.apache.metron.profiler.client.stellar.ProfilerConfig.PROFILER_PERIOD;
    +import static 
org.apache.metron.profiler.client.stellar.ProfilerConfig.PROFILER_PERIOD_UNITS;
    +import static 
org.apache.metron.profiler.client.stellar.ProfilerConfig.PROFILER_ROW_KEY_BUILDER;
    +import static 
org.apache.metron.profiler.client.stellar.ProfilerConfig.PROFILER_SALT_DIVISOR;
    +
    +/**
    + * A Factory class that can create a RowKeyBuilder based on global 
property values.
    + */
    +public class RowKeyBuilderFactory {
    +
    +  private static final Logger LOG = 
LoggerFactory.getLogger(RowKeyBuilderFactory.class);
    +
    +  /**
    +   * Create a RowKeyBuilder.
    +   * @param global The global properties.
    +   * @return A RowKeyBuilder instantiated using the global property values.
    +   */
    +  public static RowKeyBuilder create(Map<String, Object> global) {
    +    String rowKeyBuilderClass = PROFILER_ROW_KEY_BUILDER.get(global, 
String.class);
    +    LOG.debug("profiler client: {}={}", PROFILER_ROW_KEY_BUILDER, 
rowKeyBuilderClass);
    +
    +    // instantiate the RowKeyBuilder
    +    RowKeyBuilder builder = 
ReflectionUtils.createInstance(rowKeyBuilderClass);
    +    setSaltDivisor(global, builder);
    +    setPeriodDuration(global, builder);
    --- End diff --
    
    But I think this actually turned out worse, than the alternative of just 
adding `RowKeyBuilder.setSaltDivisor` and polluting the interface.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to