Java 类com.codahale.metrics.graphite.PickledGraphite 实例源码

项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProvider.java   
@Override
public GraphiteSender get() {
    switch (configuration.getProtocol()) {
        case PICKLE:
            return new PickledGraphite(
                    configuration.getAddress(),
                    SocketFactory.getDefault(),
                    configuration.getCharset(),
                    configuration.getPickleBatchSize());
        case TCP:
            return new Graphite(configuration.getAddress(), SocketFactory.getDefault(), configuration.getCharset());
        case UDP:
            return new GraphiteUDP(configuration.getAddress());
        default:
            throw new IllegalArgumentException("Unknown Graphite protocol \"" + configuration.getProtocol() + "\"");
    }
}
项目:monitoring-center    文件:MonitoringCenter.java   
private static void initGraphiteReporter(final GraphiteReporterConfig graphiteReporterConfig) {
    HostAndPort hostAndPort = graphiteReporterConfig.getAddress();
    InetSocketAddress inetSocketAddress = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort());

    GraphiteSender graphiteSender = graphiteReporterConfig.isEnableBatching()
            ? new PickledGraphite(inetSocketAddress)
            : new Graphite(inetSocketAddress);

    graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
            .prefixedWith(prefix)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MICROSECONDS)
            .withClock(new Clock() {
                private long lastReportingTime = 0;

                @Override
                public long getTick() {
                    return System.nanoTime();
                }

                @Override
                public synchronized long getTime() {
                    if (lastReportingTime == 0) {
                        lastReportingTime = System.currentTimeMillis();
                        return lastReportingTime;
                    }
                    lastReportingTime += graphiteReporterConfig.getReportingIntervalInSeconds() * 1000;
                    return lastReportingTime;
                }
            })
            .filter(buildMetricFilter(graphiteReporterConfig.getStartsWithFilters(), graphiteReporterConfig.getBlockedStartsWithFilters()))
            .build(graphiteSender);

    graphiteReporter.start(graphiteReporterConfig.getReportingIntervalInSeconds(), TimeUnit.SECONDS);
}
项目:graylog-plugin-metrics-reporter    文件:GraphiteSenderProviderTest.java   
@Test
public void getReturnsGraphitePickledGraphite() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() {
        @Override
        public GraphiteProtocol getProtocol() {
            return GraphiteProtocol.PICKLE;
        }
    };
    final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration);

    final GraphiteSender graphiteSender = provider.get();
    assertTrue(graphiteSender instanceof PickledGraphite);
    assertFalse(graphiteSender.isConnected());
}
项目:gcplot    文件:GraphiteSender.java   
@Override
public void start() {
    LOG.info("Starting Graphite reporter to [host={}; port={}]", host, port);
    graphite = new PickledGraphite(new InetSocketAddress(host, port));
    reporter = GraphiteReporter.forRegistry(registry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite);
    reporter.start(reportEveryMillis, TimeUnit.MILLISECONDS);
}
项目:creeper    文件:Main.java   
public static void main(String[] args) throws Exception {

        CreeperConfiguration creeperConfiguration = new CreeperConfiguration(buildConfiguration(args));

        final JmxReporter jmxReporter = JmxReporter.forRegistry(metrics).build();
        jmxReporter.start();

        if (creeperConfiguration.isProduction) {
            final PickledGraphite pickledGraphite = new PickledGraphite(new InetSocketAddress(creeperConfiguration.graphiteHostname, creeperConfiguration.graphitePort));
            final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics)
                    .prefixedWith(creeperConfiguration.mudName)
                    .convertRatesTo(TimeUnit.SECONDS)
                    .convertDurationsTo(TimeUnit.MILLISECONDS)
                    .filter(MetricFilter.ALL)
                    .build(pickledGraphite);
            reporter.start(1, TimeUnit.MINUTES);
        }

        Files.isDirectory().apply(new File("world/"));

        DB db = DBMaker.fileDB(new File("world/" + creeperConfiguration.databaseFileName))
                .transactionEnable()
                .closeOnJvmShutdown()
                .make();

        MapDBCreeperStorage mapDBCreeperStorage = new MapDBCreeperStorage(db);
        mapDBCreeperStorage.startAsync();
        mapDBCreeperStorage.awaitRunning();

        PlayerManager playerManager = new PlayerManager(mapDBCreeperStorage, new SessionManager());
        playerManager.createAllGauges();

        RoomManager roomManager = new RoomManager(playerManager);

        startUpMessage("Configuring core systems.");
        MapsManager mapsManager = new MapsManager(creeperConfiguration, roomManager);
        ChannelUtils channelUtils = new ChannelUtils(playerManager, roomManager);
        EntityManager entityManager = new EntityManager(mapDBCreeperStorage, roomManager, playerManager);
        GameManager gameManager = new GameManager(mapDBCreeperStorage, creeperConfiguration, roomManager, playerManager, entityManager, mapsManager, channelUtils, HttpClients.createDefault());

        startUpMessage("Reading world from disk.");
        WorldStorage worldExporter = new WorldStorage(roomManager, mapsManager, gameManager.getFloorManager(), entityManager, gameManager);
        worldExporter.readWorldFromDisk();

        startUpMessage("Creating and registering Player Management MBeans.");
        PlayerManagementManager playerManagementManager = new PlayerManagementManager(gameManager);
        playerManagementManager.processPlayersMarkedForDeletion();
        playerManagementManager.createAndRegisterAllPlayerManagementMBeans();

        startUpMessage("Configuring commands");
        ConfigureCommands.configure(gameManager);

        startUpMessage("Configure Bank commands");
        ConfigureCommands.configureBankCommands(gameManager);

        startUpMessage("Configure Locker commands");
        ConfigureCommands.configureLockerCommands(gameManager);

        startUpMessage("Configure Player Class Selection commands");
        ConfigureCommands.configurePlayerClassSelector(gameManager);

        startUpMessage("Configuring npcs and merchants");
        ConfigureNpc.configure(entityManager, gameManager);
        CreeperServer creeperServer = new CreeperServer(creeperConfiguration.telnetPort);

        startUpMessage("Generating map data.");
        mapsManager.generateAllMaps();

        startUpMessage("Creeper MUD engine started");

        creeperServer.run(gameManager);
        startUpMessage("Creeper MUD engine online");

        if (creeperConfiguration.isIrcEnabled) {
            startUpMessage("Starting irc server.");
            configureIrc(gameManager);
        }
    }