@@ -0,0 +1,2750 @@
+/**%0A * Copyright 2012 Julien Eluard%0A * This project includes software developed by Julien Eluard: https://github.com/jeluard/%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * 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.github.jeluard.stone;%0A%0Aimport com.github.jeluard.stone.api.Archive;%0Aimport com.github.jeluard.stone.api.BasePoller;%0Aimport com.github.jeluard.stone.api.ConsolidationListener;%0Aimport com.github.jeluard.stone.api.Database;%0Aimport com.github.jeluard.stone.api.Window;%0Aimport com.github.jeluard.stone.impl.consolidators.Percentile95Consolidator;%0Aimport com.github.jeluard.stone.storage.journalio.JournalIOStorageFactory;%0Aimport com.google.common.base.Optional;%0A%0Aimport java.net.URL;%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0A%0Aimport org.joda.time.Duration;%0A%0Apublic class Poller %7B%0A  public static void main(String%5B%5D args) throws Exception %7B%0A    final Database database = new Database(new JournalIOStorageFactory());%0A    final Archive archive = new Archive(Arrays.asList(Percentile95Consolidator.class), Arrays.asList(new Window(Duration.standardSeconds(10), Duration.standardDays(1))));%0A    final BasePoller%3CURL%3E poller = new BasePoller%3CURL%3E(database, Arrays.asList(new URL(%22http://google.com%22)), Duration.millis(100), Arrays.asList(archive)) %7B%0A      @Override%0A      protected String id(final URL url) %7B%0A        return url.toString();%0A      %7D%0A      @Override%0A      protected Optional%3CCollection%3CConsolidationListener%3E%3E createConsolidationListeners(final URL t, final String id) %7B%0A        final ConsolidationListener consolidationListener = new ConsolidationListener() %7B%0A          @Override%0A          public void onConsolidation(final Window window, final long timestamp, final int%5B%5D consolidates) %7B%0A            System.out.println(%22Got for %3C%22+id+%22%3E %22+Arrays.toString(consolidates));%0A          %7D%0A        %7D;%0A        final Collection%3CConsolidationListener%3E consolidationListeners = Arrays.asList(consolidationListener);%0A        return Optional.of(consolidationListeners);%0A      %7D%0A      @Override%0A      protected int metric(final URL url) throws Exception %7B%0A        long before = System.currentTimeMillis();%0A        url.openConnection().connect();%0A        return (int) (System.currentTimeMillis() - before);%0A      %7D%0A    %7D;%0A    poller.start();%0A  %7D%0A%7D

Test for polling abstraction.