@@ -0,0 +1,3718 @@
+/*%0A * Copyright 2010-2011 Ning, Inc.%0A *%0A * Ning 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 the%0A * 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, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage com.ning.metrics.eventtracker;%0A%0Aimport com.mogwee.executors.FailsafeScheduledExecutor;%0Aimport com.ning.metrics.serialization.writer.CallbackHandler;%0Aimport com.ning.metrics.serialization.writer.DiskSpoolEventWriter;%0Aimport com.ning.metrics.serialization.writer.EventHandler;%0Aimport com.ning.metrics.serialization.writer.SyncType;%0Aimport com.ning.metrics.serialization.writer.ThresholdEventWriter;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Apublic class HttpCollectorFactory%0A%7B%0A    private static CollectorController singletonController;%0A%0A    private final CollectorController controller;%0A    private static HttpSender eventSender;%0A%0A    public static synchronized CollectorController createHttpController(%0A        final String collectorHost,%0A        final int collectorPort,%0A        final EventType eventType,%0A        final long httpMaxWaitTimeInMillis,%0A        final String spoolDirectoryName,%0A        final boolean isFlushEnabled,%0A        final int flushIntervalInSeconds,%0A        final SyncType syncType,%0A        final int syncBatchSize,%0A        final long flushEventQueueSize,%0A        final int refreshDelayInSeconds%0A    ) throws IOException%0A    %7B%0A        if (singletonController == null) %7B%0A            singletonController = new HttpCollectorFactory(%0A                collectorHost,%0A                collectorPort,%0A                eventType,%0A                httpMaxWaitTimeInMillis,%0A                spoolDirectoryName,%0A                isFlushEnabled,%0A                flushIntervalInSeconds,%0A                syncType,%0A                syncBatchSize,%0A                flushEventQueueSize,%0A                refreshDelayInSeconds%0A            ).get();%0A        %7D%0A%0A        return singletonController;%0A    %7D%0A%0A    HttpCollectorFactory(%0A        final String collectorHost,%0A        final int collectorPort,%0A        final EventType eventType,%0A        final long httpMaxWaitTimeInMillis,%0A        final String spoolDirectoryName,%0A        final boolean isFlushEnabled,%0A        final int flushIntervalInSeconds,%0A        final SyncType syncType,%0A        final int syncBatchSize,%0A        final long flushEventQueueSize,%0A        final int refreshDelayInSeconds%0A    )%0A    %7B%0A        eventSender = new HttpSender(collectorHost, collectorPort, eventType, httpMaxWaitTimeInMillis);%0A%0A        final DiskSpoolEventWriter eventWriter = new DiskSpoolEventWriter(new EventHandler()%0A        %7B%0A            @Override%0A            public void handle(final File file, final CallbackHandler handler)%0A            %7B%0A                eventSender.send(file, handler);%0A            %7D%0A        %7D, spoolDirectoryName, isFlushEnabled, flushIntervalInSeconds,%0A            new FailsafeScheduledExecutor(1, %22EventtrackerFlusher%22), syncType, syncBatchSize, 5);%0A%0A        final ThresholdEventWriter thresholdEventWriter = new ThresholdEventWriter(eventWriter, flushEventQueueSize, refreshDelayInSeconds);%0A        controller = new CollectorController(thresholdEventWriter);%0A    %7D%0A%0A    private CollectorController get()%0A    %7B%0A        return controller;%0A    %7D%0A%0A    public static void shutdown()%0A    %7B%0A        eventSender.close();%0A    %7D%0A%7D%0A

add factory