001 /* 002 * Copyright 2011 Christian Kumpe http://kumpe.de/christian/java 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package de.kumpe.hadooptimizer.hadoop; 017 018 import org.apache.commons.logging.Log; 019 import org.apache.commons.logging.LogFactory; 020 import org.apache.hadoop.conf.Configuration; 021 import org.apache.hadoop.mapred.ClusterStatus; 022 import org.apache.hadoop.mapred.JobClient; 023 import org.apache.hadoop.mapred.JobConf; 024 import org.apache.hadoop.util.GenericOptionsParser; 025 026 @SuppressWarnings("deprecation") 027 public class ClusterInfo { 028 private static final Log log = LogFactory.getLog(ClusterInfo.class); 029 030 public static void main(final String[] args) throws Exception { 031 final Configuration conf = new Configuration(); 032 new GenericOptionsParser(conf, args); 033 034 final ClusterStatus status = new JobClient(new JobConf(conf)) 035 .getClusterStatus(); 036 if (log.isInfoEnabled()) { 037 log.info("getBlacklistedTrackers: " 038 + status.getBlacklistedTrackers()); 039 log.info("getJobTrackerState: " + status.getJobTrackerState()); 040 log.info("getMapTasks: " + status.getMapTasks()); 041 log.info("getMaxMapTasks: " + status.getMaxMapTasks()); 042 log.info("getMaxMemory: " + status.getMaxMemory()); 043 log.info("getMaxReduceTasks: " + status.getMaxReduceTasks()); 044 log.info("getReduceTasks: " + status.getReduceTasks()); 045 log.info("getTaskTrackers: " + status.getTaskTrackers()); 046 log.info("getTTExpiryInterval: " + status.getTTExpiryInterval()); 047 log.info("getUsedMemory: " + status.getUsedMemory()); 048 } 049 } 050 }