/*
 * Copyright 2012 Metamarkets Group Inc.
 *
 * Licensed 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 com.metamx.metrics;

import java.util.List;

public class Monitors
{
  public static Monitor and(Monitor... monitors)
  {
    return new CompoundMonitor(monitors)
    {
      @Override
      public boolean shouldReschedule(List<Boolean> reschedules)
      {
        boolean b = true;
        for (boolean reschedule : reschedules) {
          b = b && reschedule;
        }
        return b;
      }
    };
  }

  public static Monitor or(Monitor... monitors)
  {
    return new CompoundMonitor(monitors)
    {
      @Override
      public boolean shouldReschedule(List<Boolean> reschedules)
      {
        boolean b = false;
        for (boolean reschedule : reschedules) {
          b = b || reschedule;
        }
        return b;
      }
    };
  }
}

@@ -651,16 +651,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -699,16 +699,1060 @@
 itors%0A%7B%0A
+  /**%0A   * Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide%0A   * monitors: %7B@link JvmMonitor%7D, %7B@link JvmCpuMonitor%7D and %7B@link JvmThreadsMonitor%7D (this list may%0A   * change in any future release of this library, including a minor release).%0A   *%0A   * @param dimensions common dimensions to configure the JVM monitor with%0A   * @return a universally useful JVM-wide monitor%0A   */%0A  public static Monitor createCompoundJvmMonitor(Map%3CString, String%5B%5D%3E dimensions)%0A  %7B%0A    // This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are%0A    // running on the same instance, so most of the time SysMonitor should be configured/set up differently than%0A    // %22simple%22 JVM monitors, created below.%0A    return and( // Could equally be or(), because all member monitors always return true from their monitor() methods.%0A        new JvmMonitor(dimensions),%0A        new JvmCpuMonitor(dimensions),%0A        new JvmThreadsMonitor(dimensions)%0A    );%0A  %7D%0A%0A
   public

Add Monitor.createProductionJvmMonitors() (#24)