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

    https://github.com/apache/phoenix/pull/89#discussion_r32850605
  
    --- Diff: 
phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java
 ---
    @@ -0,0 +1,403 @@
    +/*
    + * 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.phoenix.pherf.workload;
    +
    +import org.apache.phoenix.pherf.PherfConstants;
    +import org.apache.phoenix.pherf.configuration.Column;
    +import org.apache.phoenix.pherf.configuration.Scenario;
    +import org.apache.phoenix.pherf.configuration.WriteParams;
    +import org.apache.phoenix.pherf.configuration.XMLConfigParser;
    +import org.apache.phoenix.pherf.exception.PherfException;
    +import org.apache.phoenix.pherf.result.DataLoadThreadTime;
    +import org.apache.phoenix.pherf.result.DataLoadTimeSummary;
    +import org.apache.phoenix.pherf.result.ResultUtil;
    +import org.apache.phoenix.pherf.rules.DataValue;
    +import org.apache.phoenix.pherf.rules.RulesApplier;
    +import org.apache.phoenix.pherf.util.PhoenixUtil;
    +import org.apache.phoenix.pherf.util.RowCalculator;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.math.BigDecimal;
    +import java.sql.*;
    +import java.text.SimpleDateFormat;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Properties;
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.ExecutorService;
    +import java.util.concurrent.Executors;
    +import java.util.concurrent.Future;
    +
    +public class WriteWorkload implements Workload {
    +    private static final Logger logger = 
LoggerFactory.getLogger(WriteWorkload.class);
    +    private final PhoenixUtil pUtil;
    +    private final XMLConfigParser parser;
    +    private final RulesApplier rulesApplier;
    +    private final ResultUtil resultUtil;
    +    private final ExecutorService pool;
    +    private final WriteParams writeParams;
    +    private final Scenario scenario;
    +    private final long threadSleepDuration;
    +
    +    private final int threadPoolSize;
    +    private final int batchSize;
    +
    +    public WriteWorkload(XMLConfigParser parser) throws Exception {
    +        this(PhoenixUtil.create(), parser);
    +    }
    +
    +    public WriteWorkload(PhoenixUtil util, XMLConfigParser parser) throws 
Exception {
    +        this(util, parser, null);
    +    }
    +
    +    public WriteWorkload(PhoenixUtil phoenixUtil, XMLConfigParser parser, 
Scenario scenario)
    +            throws Exception {
    +        this(phoenixUtil, 
PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES),
    +                parser, scenario);
    +    }
    +
    +    /**
    +     * Default the writers to use up all available cores for threads. If 
writeParams are used in
    +     * the config files, they will override the defaults. writeParams are 
used for read/write mixed
    +     * workloads.
    +     * TODO extract notion of the scenario list and have 1 write workload 
per scenario
    +     *
    +     * @param phoenixUtil {@link 
org.apache.phoenix.pherf.util.PhoenixUtil} Query helper
    +     * @param properties  {@link java.util.Properties} default properties 
to use
    +     * @param parser      {@link 
org.apache.phoenix.pherf.configuration.XMLConfigParser}
    +     * @param scenario    {@link 
org.apache.phoenix.pherf.configuration.Scenario} If null is passed
    +     *                    it will run against all scenarios in the parsers 
list.
    +     * @throws Exception
    +     */
    +    public WriteWorkload(PhoenixUtil phoenixUtil, Properties properties, 
XMLConfigParser parser,
    +            Scenario scenario) throws Exception {
    +        this.pUtil = phoenixUtil;
    +        this.parser = parser;
    +        this.rulesApplier = new RulesApplier(parser);
    +        this.resultUtil = new ResultUtil();
    +
    +        // Overwrite defaults properties with those given in the 
configuration. This indicates the
    +        // scenario is a R/W mixed workload.
    +        if (scenario != null) {
    +            this.scenario = scenario;
    +            writeParams = scenario.getWriteParams();
    +            threadSleepDuration = writeParams.getThreadSleepDuration();
    +        } else {
    +            writeParams = null;
    +            this.scenario = null;
    +            threadSleepDuration = 0;
    +        }
    +
    +        int size = 
Integer.parseInt(properties.getProperty("pherf.default.dataloader.threadpool"));
    +
    +        this.threadPoolSize = (size == 0) ? 
Runtime.getRuntime().availableProcessors() : size;
    +
    +        // TODO Move pool management up to WorkloadExecutor
    +        this.pool = Executors.newFixedThreadPool(this.threadPoolSize);
    --- End diff --
    
    Is the intent here to have a separate pool for write work load? I am not 
sure if the MonitorManager is running on this pool too. Would be good to 
monitor write activity too.


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