@@ -0,0 +1,2998 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.pinterest.secor.parser;%0A%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.TimeZone;%0Aimport java.util.Date;%0A%0Aimport net.minidev.json.JSONObject;%0Aimport net.minidev.json.JSONValue;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.pinterest.secor.common.SecorConfig;%0Aimport com.pinterest.secor.message.Message;%0Aimport com.pinterest.secor.message.ParsedMessage;%0A%0A%0A/**%0A * PerfMetricsDateParser extracts timestamp field (specified by 'message.timestamp.name')%0A * and creates custom output dirs based on a custom formatter, defined by defaultFormatter%0A * the output dir will look like s3://%3Cbucket%3E/%3Ctopic%3E/yyyy/MM/dd/HH/%3Cfile_name%3E%0A *%0A * @see http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html%0A *%0A * %0A *%0A */%0Apublic class PerfMetricsDateParser extends MessageParser %7B%0A    private static final Logger LOG = LoggerFactory.getLogger(PerfMetricsDateParser.class);%0A    protected static final String defaultFormatter = %22yyyy/MM/dd/HH%22;%0A%0A    public PerfMetricsDateParser(SecorConfig config) %7B%0A        super(config);%0A    %7D%0A%0A    @Override%0A    public String%5B%5D extractPartitions(Message message) %7B%0A        JSONObject jsonObject = (JSONObject) JSONValue.parse(message.getPayload());%0A        String result%5B%5D=%7B%7D;%0A        if (jsonObject != null) %7B%0A            Object fieldValue = jsonObject.get(mConfig.getMessageTimestampName());%0A            Object inputPattern = mConfig.getMessageTimestampInputPattern();%0A            if (fieldValue != null && inputPattern != null) %7B%0A                try %7B%0A                    SimpleDateFormat inputFormatter = new SimpleDateFormat(inputPattern.toString());%0A                    SimpleDateFormat outputFormatter = new SimpleDateFormat(defaultFormatter);%0A                    Date dateFormat = inputFormatter.parse(fieldValue.toString());%0A                    result%5B%5D = %7BoutputFormatter.format(dateFormat)%7D;%0A                    return result;%0A                %7D catch (Exception e) %7B%0A                    LOG.warn(%22Impossible to convert date = %22 + fieldValue.toString()%0A                            + %22 for the input pattern = %22 + inputPattern.toString());%0A                %7D%0A            %7D%0A        %7D%0A%0A        return result;%0A    %7D%0A%7D%0A

Add parser for parsing PerfMetrics msg date