/*
 * Licensed to Elastic Search and Shay Banon under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Elastic Search licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.elasticsearch.test.stress.leaks;

import org.elasticsearch.monitor.jvm.JvmService;
import org.elasticsearch.monitor.network.NetworkService;
import org.elasticsearch.monitor.os.OsService;
import org.elasticsearch.monitor.process.ProcessService;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalNode;

public class GenericStatsLeak {

    public static void main(String[] args) {
        InternalNode node = (InternalNode) NodeBuilder.nodeBuilder().node();

        JvmService jvmService = node.injector().getInstance(JvmService.class);
        OsService osService = node.injector().getInstance(OsService.class);
        ProcessService processService = node.injector().getInstance(ProcessService.class);
        NetworkService networkService = node.injector().getInstance(NetworkService.class);

        while (true) {
            jvmService.stats();
            osService.stats();
            processService.stats();
            networkService.stats();
        }
    }
}
@@ -848,16 +848,76 @@
 leaks;%0A%0A
+import org.elasticsearch.common.settings.ImmutableSettings;%0A
 import o
@@ -1360,16 +1360,246 @@
 Builder(
+).settings(ImmutableSettings.settingsBuilder()%0A                .put(%22monitor.os.refresh_interval%22, 0)%0A                .put(%22monitor.process.refresh_interval%22, 0)%0A                .put(%22monitor.network.refresh_interval%22, 0)%0A        
 ).node()

set 0 refresh interval for the test