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

    https://github.com/apache/storm/pull/2289#discussion_r135307748
  
    --- Diff: 
examples/storm-loadgen/src/main/java/org/apache/storm/loadgen/InputStream.java 
---
    @@ -0,0 +1,263 @@
    +/**
    + * 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.storm.loadgen;
    +
    +import java.io.ByteArrayInputStream;
    +import java.io.ObjectInputStream;
    +import java.io.Serializable;
    +import java.util.HashMap;
    +import java.util.Map;
    +import org.apache.storm.generated.GlobalStreamId;
    +import org.apache.storm.generated.Grouping;
    +import org.apache.storm.grouping.PartialKeyGrouping;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * A set of measurements about a stream so we can statistically reproduce 
it.
    + */
    +public class InputStream implements Serializable {
    +    private static final Logger LOG = 
LoggerFactory.getLogger(InputStream.class);
    +    public final String fromComponent;
    +    public final String toComponent;
    +    public final String id;
    +    public final NormalDistStats execTime;
    +    public final NormalDistStats processTime;
    +    public final GroupingType groupingType;
    +    //Cached GlobalStreamId
    +    private GlobalStreamId gsid = null;
    +
    +    /**
    +     * Create an output stream from a config.
    +     * @param conf the config to read from.
    +     * @return the read OutputStream.
    +     */
    +    public static InputStream fromConf(Map<String, Object> conf) {
    +        String component = (String) conf.get("from");
    +        String toComp = (String) conf.get("to");
    +        NormalDistStats execTime = NormalDistStats.fromConf((Map<String, 
Object>) conf.get("execTime"));
    +        NormalDistStats processTime = 
NormalDistStats.fromConf((Map<String, Object>) conf.get("processTime"));
    +        Map<String, Object> grouping = (Map<String, Object>) 
conf.get("grouping");
    +        GroupingType groupingType = GroupingType.fromConf((String) 
grouping.get("type"));
    +        String streamId = (String) grouping.getOrDefault("streamId", 
"default");
    +        return new InputStream(component, toComp, streamId, execTime, 
processTime, groupingType);
    +    }
    +
    +    /**
    +     * Convert this to a conf.
    +     * @return the conf.
    +     */
    +    public Map<String, Object> toConf() {
    +        Map<String, Object> ret = new HashMap<>();
    +        ret.put("from", fromComponent);
    +        ret.put("to", toComponent);
    +        ret.put("execTime", execTime.toConf());
    +        ret.put("processTime", processTime.toConf());
    +
    +        Map<String, Object> grouping = new HashMap<>();
    +        grouping.put("streamId", id);
    +        grouping.put("type", groupingType.toConf());
    +        ret.put("grouping", grouping);
    +
    +        return ret;
    +    }
    +
    +    public static class Builder {
    +        private String fromComponent;
    +        private String toComponent;
    +        private String id;
    +        private NormalDistStats execTime;
    +        private NormalDistStats processTime;
    +        private GroupingType groupingType = GroupingType.SHUFFLE;
    +
    +        public String getFromComponent() {
    --- End diff --
    
    No they don't but it was the most convenient way to pull out the needed 
information while still building the object.


---
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