@@ -0,0 +1,3096 @@
+/*%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 */%0A%0Apackage com.intel.hibench.streambench;%0A%0Aimport org.apache.hadoop.conf.Configuration;%0Aimport org.apache.kafka.clients.producer.ProducerRecord;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by liuxiany on 7/20/2016.%0A */%0Apublic class CachedData %7B%0A    private volatile static CachedData cachedData;%0A%0A    private String sourcePath;%0A    private Configuration dfsConf;%0A    private long startOffset;%0A    private int index;%0A    private int totalRecords;%0A    private List%3CString%3E data;%0A%0A    public static CachedData getInstance(String sourcePath,%0A                                         Configuration dfsConf,%0A                                         long startOffset,%0A                                         int totalRecords) %7B%0A        if(cachedData != null) %7B%0A            synchronized (CachedData.class) %7B%0A                if (cachedData == null) %7B%0A                    cachedData = new CachedData(sourcePath, dfsConf, startOffset, totalRecords);%0A                %7D%0A            %7D%0A        %7D%0A        return cachedData;%0A    %7D%0A%0A    private CachedData(String sourcePath,%0A                            Configuration dfsConf,%0A                            long startOffset,%0A                            int totalRecords)%7B%0A        this.totalRecords = totalRecords;%0A        this.sourcePath = sourcePath;%0A        this.dfsConf = dfsConf;%0A        this.startOffset = startOffset;%0A        this.index = 0;%0A        data = new ArrayList%3CString%3E(totalRecords);%0A%0A        init();%0A    %7D%0A%0A    private void init() %7B%0A        BufferedReader reader = SourceFileReader.getReader(dfsConf, sourcePath, startOffset);%0A        int sentRecords = 0;%0A%0A        try %7B%0A            while (sentRecords %3C totalRecords) %7B%0A                String line = reader.readLine();%0A                if (line == null) %7B%0A                    break; // no more data from source files%0A                %7D%0A                data.add(line);%0A                sentRecords ++;%0A            %7D%0A        %7D catch (IOException e) %7B%0A            System.err.println(%22Failed read records from Path: %22 + sourcePath);%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public synchronized String getRecord() %7B%0A        int nextIndex = (index + 1) %25 totalRecords;%0A        return data.get(nextIndex);%0A    %7D%0A%7D%0A

Create new class 'CachedData'