@@ -0,0 +1,3043 @@
+/*%0D%0A * Copyright 2014 Informatica Corp.%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *      http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0A%0D%0Apackage com.informatica.surf.sample;%0D%0A%0D%0Aimport com.amazonaws.auth.AWSCredentials;%0D%0Aimport com.amazonaws.auth.AWSCredentialsProvider;%0D%0Aimport com.amazonaws.auth.BasicAWSCredentials;%0D%0Aimport com.amazonaws.services.kinesis.clientlibrary.lib.worker.KinesisClientLibConfiguration;%0D%0Aimport com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker;%0D%0Aimport com.lmax.disruptor.EventHandler;%0D%0Aimport com.lmax.disruptor.RingBuffer;%0D%0Aimport com.lmax.disruptor.dsl.Disruptor;%0D%0Aimport java.io.File;%0D%0Aimport java.io.FileReader;%0D%0Aimport java.net.InetAddress;%0D%0Aimport java.util.Properties;%0D%0Aimport java.util.UUID;%0D%0Aimport java.util.concurrent.Executor;%0D%0Aimport java.util.concurrent.Executors;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author Informatica Corp%0D%0A */%0D%0Apublic class Util %7B%0D%0A    %0D%0A    public static Worker createWorker(File conf, EventHandler%3CKinesisEvent%3E handler, String appName)throws IOException%7B%0D%0A        Executor executor = Executors.newCachedThreadPool();%0D%0A        Disruptor%3CKinesisEvent%3E disruptor = new Disruptor%3C%3E(KinesisEvent.EVENT_FACTORY, 128, executor);%0D%0A%0D%0A        disruptor.handleEventsWith(handler);%0D%0A        RingBuffer%3CKinesisEvent%3E buffer = disruptor.start();%0D%0A%0D%0A        Properties props = new Properties();%0D%0A        props.load(new FileReader(conf));%0D%0A        // Generate a unique worker ID%0D%0A        String workerId = InetAddress.getLocalHost().getCanonicalHostName() + %22:%22 + UUID.randomUUID();%0D%0A        String accessid = props.getProperty(%22aws-access-key-id%22);%0D%0A        String secretkey = props.getProperty(%22aws-secret-key%22);%0D%0A        String streamname = props.getProperty(%22aws-kinesis-stream-name%22);%0D%0A        BasicAWSCredentials creds = new BasicAWSCredentials(accessid, secretkey);%0D%0A        CredProvider credprovider = new CredProvider(creds);%0D%0A        KinesisClientLibConfiguration config = new KinesisClientLibConfiguration(appName, streamname,  credprovider, workerId);%0D%0A        %0D%0A        Worker worker = new Worker(new RecordProcessorFactory(buffer), config, new MetricsFactory());%0D%0A        return worker;%0D%0A    %7D%0D%0A    static class CredProvider implements AWSCredentialsProvider%7B%0D%0A        AWSCredentials _creds;%0D%0A        public CredProvider(AWSCredentials creds)%7B%0D%0A            _creds = creds;%0D%0A        %7D%0D%0A        @Override%0D%0A        public AWSCredentials getCredentials() %7B%0D%0A            return _creds;%0D%0A        %7D%0D%0A%0D%0A        @Override%0D%0A        public void refresh() %7B%0D%0A            // NOOP%0D%0A        %7D%0D%0A        %0D%0A    %7D%0D%0A    %0D%0A%7D%0D%0A

Refactor in preparation for PageCount sample