You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ac...@apache.org on 2012/02/16 23:12:36 UTC
svn commit: r1245205 [1/18] - in /incubator/giraph/trunk: ./
src/main/java/org/apache/giraph/ src/main/java/org/apache/giraph/benchmark/
src/main/java/org/apache/giraph/bsp/ src/main/java/org/apache/giraph/comm/
src/main/java/org/apache/giraph/examples...
Author: aching
Date: Thu Feb 16 22:12:31 2012
New Revision: 1245205
URL: http://svn.apache.org/viewvc?rev=1245205&view=rev
Log:
GIRAPH-40: Added checkstyle for enforcement of code conventions. All
Giraph source files now pass checkstyle. (aching).
Added:
incubator/giraph/trunk/checkstyle.xml
incubator/giraph/trunk/license-header.txt
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/hadoop/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/integration/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/package-info.java
- copied, changed from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
Modified:
incubator/giraph/trunk/CHANGELOG
incubator/giraph/trunk/pom.xml
incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/HashMapVertexPageRankBenchmark.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankComputation.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PseudoRandomVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/RandomMessageBenchmark.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspInputSplit.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordWriter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/CentralizedService.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/CentralizedServiceMaster.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/CentralizedServiceWorker.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ImmutableOutputCommitter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/SuperstepState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/ArrayListWritable.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/BasicRPCCommunications.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/CommunicationsInterface.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/MsgList.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/ServerInterface.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/VertexIdMessages.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/VertexIdMessagesList.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/VertexList.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/WorkerCommunications.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/ConnectedComponentsVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/GeneratedVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/GeneratedVertexReader.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/IntIntNullIntTextInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/LongSumAggregator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/MaxAggregator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/MinAggregator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/MinimumIntCombiner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleAggregatorWriter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleCheckpointVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleCombinerVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleFailVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleMsgVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleMutateGraphVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimplePageRankVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleShortestPathsVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleSumCombiner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleSuperstepVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleTextVertexOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SimpleVertexWithWorkerContext.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/SumAggregator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/VerifyMessage.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/examples/VertexWithComponentTextOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/Aggregator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/AggregatorUsage.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/AggregatorWriter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BasicVertexResolver.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BspService.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceMaster.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BspServiceWorker.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/BspUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/DefaultWorkerContext.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/Edge.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/EdgeListVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/GiraphJob.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/GlobalStats.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/GraphMapper.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/GraphState.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/HashMapVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/MasterThread.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/MutableVertex.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/TextAggregatorWriter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexChanges.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexCombiner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexEdgeCount.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexMutations.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexReader.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexResolver.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/VertexWriter.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/WorkerContext.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/WorkerInfo.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/BasicPartitionOwner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/GraphPartitionerFactory.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/HashMasterPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/HashPartitionerFactory.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/HashRangePartitionerFactory.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/HashRangeWorkerPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/HashWorkerPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/MasterGraphPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/Partition.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/PartitionBalancer.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/PartitionExchange.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/PartitionOwner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/PartitionStats.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/PartitionUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/RangeMasterPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/RangePartitionOwner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/RangePartitionStats.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/RangeSplitHint.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/RangeWorkerPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/partition/WorkerGraphPartitioner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/hadoop/BspPolicyProvider.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/hadoop/BspTokenSelector.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/integration/SuperstepHashPartitionerFactory.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/AdjacencyListTextVertexOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/AdjacencyListVertexReader.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/IdWithValueTextOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/JsonBase64VertexFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/JsonBase64VertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/JsonBase64VertexOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/LongDoubleDoubleAdjacencyListVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/SequenceFileVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/TextDoubleDoubleAdjacencyListVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/TextVertexInputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/lib/TextVertexOutputFormat.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/ComparisonUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/EmptyIterable.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/InternalVertexRunner.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/MemoryUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/ReflectionUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/UnmodifiableIntArrayIterator.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/utils/WritableUtils.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/BspEvent.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ContextLock.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/PredicateLock.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperExt.java
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/TestBspBasic.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/TestJsonBase64Format.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/TestManualCheckpoint.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/examples/SimpleShortestPathVertexTest.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java
incubator/giraph/trunk/src/test/java/org/apache/giraph/utils/MockUtils.java
incubator/giraph/trunk/src/test/java/zk/TestZooKeeperManager.java
Modified: incubator/giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Thu Feb 16 22:12:31 2012
@@ -1,6 +1,9 @@
Giraph Change Log
Release 0.2.0 - unreleased
+
+ GIRAPH-40: Added checkstyle for enforcement of code conventions.
+ All Giraph source files now pass checkstyle. (aching)
GIRAPH-148: giraph-site.xml needs Apache header. (jghoman)
Added: incubator/giraph/trunk/checkstyle.xml
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/checkstyle.xml?rev=1245205&view=auto
==============================================================================
--- incubator/giraph/trunk/checkstyle.xml (added)
+++ incubator/giraph/trunk/checkstyle.xml Thu Feb 16 22:12:31 2012
@@ -0,0 +1,296 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF 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.
+-->
+
+<!--
+ This version of checkstyle is based on the Hadoop and common-math
+ checkstyle configurations. It is a best effort attempt to try to match
+ the CODE_CONVENTIONS and Oracle "Code Conventions for the Java
+ Programming Language". See the following link:
+
+ http://www.oracle.com/technetwork/java/codeconvtoc-136057.html
+
+ The documentation for checkstyle is available at
+
+ http://checkstyle.sourceforge.net
+-->
+
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!-- Apache giraph customization of default Checkstyle behavior -->
+<module name="Checker">
+ <property name="localeLanguage" value="en"/>
+
+ <!-- Checks for headers -->
+ <!-- See http://checkstyle.sf.net/config_header.html -->
+ <!-- Verify that EVERY source file has the appropriate license -->
+ <module name="Header">
+ <property name="headerFile" value="${checkstyle.header.file}"/>
+ </module>
+
+ <!-- Checks for Javadoc comments (checker). -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!-- Require package javadoc -->
+ <module name="JavadocPackage"/>
+
+ <!-- Miscellaneous other checks (checker). -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Require files to end with newline characters -->
+ <module name="NewlineAtEndOfFile"/>
+
+ <!-- Checks for whitespace (tree walker) -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- No tabs allowed! -->
+ <module name="FileTabCharacter"/>
+
+ <module name="TreeWalker">
+ <property name="cacheFile" value="target/checkstyle-cachefile"/>
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- No empty blocks (i.e. catch) -->
+ <module name="EmptyBlock"/>
+ <module name="AvoidNestedBlocks"/>
+ <module name="LeftCurly"/>
+ <!-- No if/else/do/for/while without braces -->
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Utility class should not be instantiated, they must have a
+ private constructor -->
+ <module name="HideUtilityClassConstructor"/>
+ <!-- Interfaces must be types (not just constants) -->
+ <module name="InterfaceIsType"/>
+ <!-- No public fields -->
+ <module name="VisibilityModifier">
+ <property name="protectedAllowed" value="true"/>
+ <property name="publicMemberPattern" value="^$"/>
+ </module>
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <!-- Require hash code override when equals is -->
+ <module name="EqualsHashCode"/>
+ <!-- Method parameters and local variables should not hide
+ fields, except in constructors and setters -->
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true" />
+ <property name="ignoreSetter" value="true" />
+ <property name="tokens" value="VARIABLE_DEF"/>
+ </module>
+ <!-- Disallow unnecessary instantiation of Boolean, String -->
+ <module name="IllegalInstantiation">
+ <property name="classes" value="java.lang.Boolean, java.lang.String"/>
+ </module>
+ <module name="InnerAssignment"/>
+ <!-- Switch statements should be complete and with independent cases -->
+ <module name="FallThrough" />
+ <module name="MissingSwitchDefault" />
+ <module name="RedundantThrows"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+ <!-- Only one statment per line allowed -->
+ <module name="OneStatementPerLine"/>
+ <!-- Use a consistent way to put declarations -->
+ <module name="DeclarationOrder" />
+ <!-- Don't add up parentheses when they are not required -->
+ <module name="UnnecessaryParentheses" />
+ <!-- Don't use too widespread catch (Exception, Throwable,
+ RuntimeException) -->
+ <module name="IllegalCatch" />
+ <!-- Don't use = or != for string comparisons -->
+ <module name="StringLiteralEquality" />
+ <!-- Don't declare multiple variables in the same statement -->
+ <module name="MultipleVariableDeclarations" />
+ <!-- String literals more than one character long should not be
+ repeated several times -->
+ <!-- the "unchecked" string is also accepted to allow
+ @SuppressWarnings("unchecked") -->
+ <!-- Disabling for now until we have a better ignoreStringsRegexp -->
+ <!--
+ <module name="MultipleStringLiterals" >
+ <property name="ignoreStringsRegexp" value='^(("")|(".")|("unchecked"))$'/>
+ </module>
+ -->
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="RedundantImport"/>
+ <!-- Import should be explicit, really needed and only from pure
+ java packages -->
+ <module name="AvoidStarImport" />
+ <module name="UnusedImports" />
+ <module name="IllegalImport" />
+
+ <!-- Checks for Javadoc comments (tree walker). -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!-- Javadoc must be formatted correctly -->
+ <module name="JavadocStyle">
+ <property name="checkFirstSentence" value="false"/>
+ </module>
+ <!-- Must have class / interface header comments -->
+ <module name="JavadocType"/>
+ <!-- Require method javadocs, allow undeclared RTE, allow missing
+ javadoc on getters and setters -->
+ <module name="JavadocMethod">
+ <property name="allowUndeclaredRTE" value="true"/>
+ <property name="allowMissingThrowsTags" value="true"/>
+ <property name="allowMissingPropertyJavadoc" value="true"/>
+ </module>
+ <!-- Require field javadoc -->
+ <module name="JavadocVariable"/>
+
+ <!-- Miscellaneous other checks (tree walker). -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Java style arrays -->
+ <module name="ArrayTypeStyle"/>
+ <!-- Indentation -->
+ <module name="Indentation">
+ <property name="caseIndent" value="0"/>
+ <property name="basicOffset" value="2"/>
+ <property name="braceAdjustment" value="0"/>
+ </module>
+ <!-- Turn this on to see what needs to be done
+ <module name="TodoComment"/>
+ -->
+ <module name="UpperEll"/>
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <!-- Use a consistent way to put modifiers -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Constant names should obey the traditional all uppercase
+ naming convention -->
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName">
+ <property name="format" value="^[A-Z0-9_]*$"/>
+ </module>
+ <module name="TypeName"/>
+
+ <!-- Checks for regexp expressions. -->
+ <!-- See http://checkstyle.sf.net/config_regexp.html -->
+ <!-- No trailing whitespace -->
+ <module name="Regexp">
+ <property name="format" value="[ \t]+$"/>
+ <property name="illegalPattern" value="true"/>
+ <property name="message" value="Trailing whitespace"/>
+ </module>
+ <!-- No System.out.println() statements -->
+ <module name="Regexp">
+ <!-- No sysouts -->
+ <property name="format" value="System\.out\.println"/>
+ <property name="illegalPattern" value="true"/>
+ </module>
+ <!-- Authors should be in pom.xml file -->
+ <module name="Regexp">
+ <property name="format" value="@author"/>
+ <property name="illegalPattern" value="true"/>
+ <property name="message" value="developers names should be in pom file"/>
+ </module>
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Lines cannot exceed 80 chars -->
+ <module name="LineLength">
+ <property name="max" value="80"/>
+ </module>
+ <!-- Over time, we will revised this down -->
+ <module name="MethodLength">
+ <property name="max" value="200"/>
+ </module>
+ <module name="ParameterNumber"/>
+
+ <!-- Checks for whitespace (tree walker) -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad"/>
+ <!-- Spacing around methods -->
+ <module name="MethodParamPad">
+ <property name="option" value="nospace"/>
+ <property name="allowLineBreaks" value="true"/>
+ </module>
+ <!-- No whitespace before a token -->
+ <module name="NoWhitespaceBefore"/>
+ <!-- Whitespace after tokens is required -->
+ <module name="WhitespaceAfter"/>
+ <!-- Whitespace around tokens is required -->
+ <module name="WhitespaceAround"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <!-- No extra whitespace around types -->
+ <module name="GenericWhitespace"/>
+ <!-- Operator must be at end of wrapped line -->
+ <module name="OperatorWrap">
+ <property name="option" value="eol"/>
+ </module>
+
+ <!-- Required for SuppressionCommentFilter below -->
+ <module name="FileContentsHolder"/>
+ </module>
+
+ <!-- Setup special comments to suppress specific checks from source files -->
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocVariable"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume JavadocVariable"/>
+ <property name="checkFormat" value="JavadocVariable"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocMethodCheck"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume JavadocMethodCheck"/>
+ <property name="checkFormat" value="JavadocMethodCheck"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop ConstantName"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume ConstantName"/>
+ <property name="checkFormat" value="ConstantName"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop HideUtilityClassConstructor"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume HideUtilityClassConstructor"/>
+ <property name="checkFormat" value="HideUtilityClassConstructor"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop MultipleVariableDeclarations"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume MultipleVariableDeclarations"/>
+ <property name="checkFormat" value="MultipleVariableDeclarations"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop IllegalCatch"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume IllegalCatch"/>
+ <property name="checkFormat" value="IllegalCatch"/>
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\: stop DeclarationOrder"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\: resume DeclarationOrder"/>
+ <property name="checkFormat" value="DeclarationOrder"/>
+ </module>
+</module>
+
Copied: incubator/giraph/trunk/license-header.txt (from r1243701, incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java)
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/license-header.txt?p2=incubator/giraph/trunk/license-header.txt&p1=incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java&r1=1243701&r2=1245205&rev=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/ApplicationState.java (original)
+++ incubator/giraph/trunk/license-header.txt Thu Feb 16 22:12:31 2012
@@ -15,15 +15,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package org.apache.giraph.bsp;
-
-/**
- * State of the BSP application
- */
-public enum ApplicationState {
- UNKNOWN, ///< Shouldn't be seen, just an initial state
- START_SUPERSTEP, ///< Start from a desired superstep
- FAILED, ///< Unrecoverable
- FINISHED ///< Successful completion
-}
Modified: incubator/giraph/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/pom.xml?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/pom.xml (original)
+++ incubator/giraph/trunk/pom.xml Thu Feb 16 22:12:31 2012
@@ -183,7 +183,26 @@ under the License.
<build>
<plugins>
-
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+ <configLocation>checkstyle.xml</configLocation>
+ <enableRulesSummary>false</enableRulesSummary>
+ <headerLocation>license-header.txt</headerLocation>
+ <failOnError>true</failOnError>
+ <includeTestSourceDirectory>false</includeTestSourceDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@@ -346,7 +365,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.6</version>
+ <version>2.9</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -391,6 +410,7 @@ under the License.
<!-- generated content -->
<exclude>**/target/**</exclude>
<exclude>_bsp/**</exclude>
+ <exclude>.checkstyle</exclude>
<!-- source control and IDEs -->
<exclude>.git/**</exclude>
<exclude>.idea/**</exclude>
@@ -398,6 +418,39 @@ under the License.
</configuration>
</plugin>
</plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.maven.plugins
+ </groupId>
+ <artifactId>
+ maven-assembly-plugin
+ </artifactId>
+ <versionRange>[2.2,)</versionRange>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<profiles>
Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/GiraphRunner.java Thu Feb 16 22:12:31 2012
@@ -31,19 +31,33 @@ import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.apache.log4j.Logger;
+/**
+ * Helper class to run Giraph applications by specifying the actual class name
+ * to use (i.e. vertex, vertex input/output format, combiner, etc.).
+ */
public class GiraphRunner implements Tool {
static {
Configuration.addDefaultResource("giraph-site.xml");
}
+ /** Class logger */
private static final Logger LOG = Logger.getLogger(GiraphRunner.class);
+ /** Writable conf */
private Configuration conf;
- final String [][] requiredOptions =
- {{"w", "Need to choose the number of workers (-w)"},
- {"if", "Need to set inputformat (-if)"}};
-
- private Options getOptions() {
+ /**
+ * Required options.
+ */
+ private final String [][] requiredOptions =
+ {{"w", "Need to choose the number of workers (-w)"},
+ {"if", "Need to set inputformat (-if)"}};
+
+ /**
+ * Get the options available.
+ *
+ * @return Options available.
+ */
+ private static Options getOptions() {
Options options = new Options();
options.addOption("h", "help", false, "Help");
options.addOption("q", "quiet", false, "Quiet output");
@@ -78,7 +92,7 @@ public class GiraphRunner implements Too
}
String vertexClassName = args[0];
- if(LOG.isDebugEnabled()) {
+ if (LOG.isDebugEnabled()) {
LOG.debug("Attempting to run Vertex: " + vertexClassName);
}
@@ -87,8 +101,8 @@ public class GiraphRunner implements Too
// Verify all the options have been provided
for (String[] requiredOption : requiredOptions) {
- if(!cmd.hasOption(requiredOption[0])) {
- System.out.println(requiredOption[1]);
+ if (!cmd.hasOption(requiredOption[0])) {
+ LOG.info(requiredOption[1]);
return -1;
}
}
@@ -99,30 +113,30 @@ public class GiraphRunner implements Too
job.setVertexInputFormatClass(Class.forName(cmd.getOptionValue("if")));
job.setVertexOutputFormatClass(Class.forName(cmd.getOptionValue("of")));
- if(cmd.hasOption("ip")) {
+ if (cmd.hasOption("ip")) {
FileInputFormat.addInputPath(job, new Path(cmd.getOptionValue("ip")));
} else {
LOG.info("No input path specified. Ensure your InputFormat does not " +
- "require one.");
+ "require one.");
}
- if(cmd.hasOption("op")) {
+ if (cmd.hasOption("op")) {
FileOutputFormat.setOutputPath(job, new Path(cmd.getOptionValue("op")));
} else {
LOG.info("No output path specified. Ensure your OutputFormat does not " +
- "require one.");
+ "require one.");
}
if (cmd.hasOption("c")) {
- job.setVertexCombinerClass(Class.forName(cmd.getOptionValue("c")));
+ job.setVertexCombinerClass(Class.forName(cmd.getOptionValue("c")));
}
if (cmd.hasOption("wc")) {
- job.setWorkerContextClass(Class.forName(cmd.getOptionValue("wc")));
+ job.setWorkerContextClass(Class.forName(cmd.getOptionValue("wc")));
}
if (cmd.hasOption("aw")) {
- job.setAggregatorWriterClass(Class.forName(cmd.getOptionValue("aw")));
+ job.setAggregatorWriterClass(Class.forName(cmd.getOptionValue("aw")));
}
job.setWorkerConfiguration(workers, workers, 100.0f);
@@ -132,6 +146,12 @@ public class GiraphRunner implements Too
return job.run(isQuiet) ? 0 : -1;
}
+ /**
+ * Execute GiraphRunner.
+ *
+ * @param args Typically command line arguments.
+ * @throws Exception Any exceptions thrown.
+ */
public static void main(String[] args) throws Exception {
System.exit(ToolRunner.run(new GiraphRunner(), args));
}
Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/HashMapVertexPageRankBenchmark.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/HashMapVertexPageRankBenchmark.java?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/HashMapVertexPageRankBenchmark.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/HashMapVertexPageRankBenchmark.java Thu Feb 16 22:12:31 2012
@@ -25,13 +25,12 @@ import java.io.IOException;
import java.util.Iterator;
/**
- * Same benchmark code as {@link PageRankBenchmark}, but uses Hashmap-backed Vertex
- * implementation rather than {@link org.apache.giraph.graph.EdgeListVertex}
+ * Same benchmark code as {@link PageRankBenchmark}, but uses
+ * Hashmap-backed Vertex implementation rather than
+ * {@link org.apache.giraph.graph.EdgeListVertex}
*/
public class HashMapVertexPageRankBenchmark extends HashMapVertex<
LongWritable, DoubleWritable, DoubleWritable, DoubleWritable> {
- public final static String SUPERSTEP_COUNT = PageRankComputation.SUPERSTEP_COUNT;
-
@Override
public void compute(Iterator<DoubleWritable> msgIterator) throws IOException {
PageRankComputation.computePageRank(this, msgIterator);
Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankBenchmark.java Thu Feb 16 22:12:31 2012
@@ -23,6 +23,7 @@ import org.apache.commons.cli.CommandLin
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
+import org.apache.giraph.graph.BspUtils;
import org.apache.giraph.graph.EdgeListVertex;
import org.apache.giraph.graph.GiraphJob;
import org.apache.hadoop.conf.Configuration;
@@ -30,6 +31,7 @@ import org.apache.hadoop.io.DoubleWritab
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.Logger;
import java.io.IOException;
import java.util.Iterator;
@@ -38,121 +40,125 @@ import java.util.Iterator;
* Default Pregel-style PageRank computation using a {@link EdgeListVertex}.
*/
public class PageRankBenchmark extends EdgeListVertex<
- LongWritable, DoubleWritable, DoubleWritable, DoubleWritable> implements Tool {
- public final static String SUPERSTEP_COUNT = PageRankComputation.SUPERSTEP_COUNT;
-
- /** Configuration from Configurable */
- private Configuration conf;
-
- @Override
- public void compute(Iterator<DoubleWritable> msgIterator) throws IOException {
- PageRankComputation.computePageRank(this, msgIterator);
- }
-
- @Override
- public Configuration getConf() {
- return conf;
- }
-
- @Override
- public void setConf(Configuration conf) {
- this.conf = conf;
- }
-
- @Override
- public int run(String[] args) throws Exception {
- Options options = new Options();
- options.addOption("h", "help", false, "Help");
- options.addOption("v", "verbose", false, "Verbose");
- options.addOption("w",
- "workers",
- true,
- "Number of workers");
- options.addOption("s",
- "supersteps",
- true,
- "Supersteps to execute before finishing");
- options.addOption("V",
- "aggregateVertices",
- true,
- "Aggregate vertices");
- options.addOption("e",
- "edgesPerVertex",
- true,
- "Edges per vertex");
- options.addOption("c",
- "vertexClass",
- true,
- "Vertex class (0 for HashMapVertex, 1 for EdgeListVertex)");
- HelpFormatter formatter = new HelpFormatter();
- if (args.length == 0) {
- formatter.printHelp(getClass().getName(), options, true);
- return 0;
- }
- CommandLineParser parser = new PosixParser();
- CommandLine cmd = parser.parse(options, args);
- if (cmd.hasOption('h')) {
- formatter.printHelp(getClass().getName(), options, true);
- return 0;
- }
- if (!cmd.hasOption('w')) {
- System.out.println("Need to choose the number of workers (-w)");
- return -1;
- }
- if (!cmd.hasOption('s')) {
- System.out.println("Need to set the number of supersteps (-s)");
- return -1;
- }
- if (!cmd.hasOption('V')) {
- System.out.println("Need to set the aggregate vertices (-V)");
- return -1;
- }
- if (!cmd.hasOption('e')) {
- System.out.println("Need to set the number of edges " +
- "per vertex (-e)");
- return -1;
- }
-
- int workers = Integer.parseInt(cmd.getOptionValue('w'));
- GiraphJob job = new GiraphJob(getConf(), getClass().getName());
- if (!cmd.hasOption('c') ||
- (Integer.parseInt(cmd.getOptionValue('c')) == 0)) {
- System.out.println("Using " +
- HashMapVertexPageRankBenchmark.class.getName());
- job.setVertexClass(HashMapVertexPageRankBenchmark.class);
- } else {
- System.out.println("Using " +
- PageRankBenchmark.class.getName());
- job.setVertexClass(PageRankBenchmark.class);
- }
- job.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
- job.setWorkerConfiguration(workers, workers, 100.0f);
- job.getConfiguration().setLong(
- PseudoRandomVertexInputFormat.AGGREGATE_VERTICES,
- Long.parseLong(cmd.getOptionValue('V')));
- job.getConfiguration().setLong(
- PseudoRandomVertexInputFormat.EDGES_PER_VERTEX,
- Long.parseLong(cmd.getOptionValue('e')));
- job.getConfiguration().setInt(
- SUPERSTEP_COUNT,
- Integer.parseInt(cmd.getOptionValue('s')));
-
- boolean isVerbose = false;
- if (cmd.hasOption('v')) {
- isVerbose = true;
- }
- if (cmd.hasOption('s')) {
- getConf().setInt(SUPERSTEP_COUNT,
- Integer.parseInt(cmd.getOptionValue('s')));
- }
- if (job.run(isVerbose) == true) {
- return 0;
- } else {
- return -1;
- }
+ LongWritable, DoubleWritable, DoubleWritable, DoubleWritable>
+ implements Tool {
+ /** Class logger */
+ private static final Logger LOG = Logger.getLogger(PageRankBenchmark.class);
+ /** Configuration from Configurable */
+ private Configuration conf;
+
+ @Override
+ public void compute(Iterator<DoubleWritable> msgIterator) throws IOException {
+ PageRankComputation.computePageRank(this, msgIterator);
+ }
+
+ @Override
+ public Configuration getConf() {
+ return conf;
+ }
+
+ @Override
+ public void setConf(Configuration conf) {
+ this.conf = conf;
+ }
+
+ @Override
+ public final int run(final String[] args) throws Exception {
+ Options options = new Options();
+ options.addOption("h", "help", false, "Help");
+ options.addOption("v", "verbose", false, "Verbose");
+ options.addOption("w",
+ "workers",
+ true,
+ "Number of workers");
+ options.addOption("s",
+ "supersteps",
+ true,
+ "Supersteps to execute before finishing");
+ options.addOption("V",
+ "aggregateVertices",
+ true,
+ "Aggregate vertices");
+ options.addOption("e",
+ "edgesPerVertex",
+ true,
+ "Edges per vertex");
+ options.addOption("c",
+ "vertexClass",
+ true,
+ "Vertex class (0 for Vertex, 1 for EdgeListVertex)");
+ HelpFormatter formatter = new HelpFormatter();
+ if (args.length == 0) {
+ formatter.printHelp(getClass().getName(), options, true);
+ return 0;
+ }
+ CommandLineParser parser = new PosixParser();
+ CommandLine cmd = parser.parse(options, args);
+ if (cmd.hasOption('h')) {
+ formatter.printHelp(getClass().getName(), options, true);
+ return 0;
+ }
+ if (!cmd.hasOption('w')) {
+ LOG.info("Need to choose the number of workers (-w)");
+ return -1;
+ }
+ if (!cmd.hasOption('s')) {
+ LOG.info("Need to set the number of supersteps (-s)");
+ return -1;
+ }
+ if (!cmd.hasOption('V')) {
+ LOG.info("Need to set the aggregate vertices (-V)");
+ return -1;
+ }
+ if (!cmd.hasOption('e')) {
+ LOG.info("Need to set the number of edges " +
+ "per vertex (-e)");
+ return -1;
}
- public static void main(String[] args) throws Exception {
- System.exit(ToolRunner.run(new PageRankBenchmark(), args));
+ int workers = Integer.parseInt(cmd.getOptionValue('w'));
+ GiraphJob job = new GiraphJob(getConf(), getClass().getName());
+ if (!cmd.hasOption('c') ||
+ (Integer.parseInt(cmd.getOptionValue('c')) == 0)) {
+ job.setVertexClass(HashMapVertexPageRankBenchmark.class);
+ } else {
+ job.setVertexClass(PageRankBenchmark.class);
+ }
+ LOG.info("Using class " + BspUtils.getVertexClass(getConf()).getName());
+ job.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
+ job.setWorkerConfiguration(workers, workers, 100.0f);
+ job.getConfiguration().setLong(
+ PseudoRandomVertexInputFormat.AGGREGATE_VERTICES,
+ Long.parseLong(cmd.getOptionValue('V')));
+ job.getConfiguration().setLong(
+ PseudoRandomVertexInputFormat.EDGES_PER_VERTEX,
+ Long.parseLong(cmd.getOptionValue('e')));
+ job.getConfiguration().setInt(
+ PageRankComputation.SUPERSTEP_COUNT,
+ Integer.parseInt(cmd.getOptionValue('s')));
+
+ boolean isVerbose = false;
+ if (cmd.hasOption('v')) {
+ isVerbose = true;
+ }
+ if (cmd.hasOption('s')) {
+ getConf().setInt(PageRankComputation.SUPERSTEP_COUNT,
+ Integer.parseInt(cmd.getOptionValue('s')));
}
+ if (job.run(isVerbose)) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * Execute the benchmark.
+ *
+ * @param args Typically the command line arguments.
+ * @throws Exception Any exception from the computation.
+ */
+ public static void main(final String[] args) throws Exception {
+ System.exit(ToolRunner.run(new PageRankBenchmark(), args));
+ }
}
Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankComputation.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankComputation.java?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankComputation.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PageRankComputation.java Thu Feb 16 22:12:31 2012
@@ -28,11 +28,24 @@ import java.util.Iterator;
* classes.
*/
public class PageRankComputation {
- public final static String SUPERSTEP_COUNT = "PageRankBenchmark.superstepCount";
+ /** Number of supersteps */
+ public static final String SUPERSTEP_COUNT =
+ "PageRankBenchmark.superstepCount";
+ /**
+ * Do not construct.
+ */
+ private PageRankComputation() { }
+
+ /**
+ * Generic page rank algorithm.
+ *
+ * @param vertex Vertex to compute on.
+ * @param msgIterator Iterator of messages from previous superstep.
+ */
public static void computePageRank(
- MutableVertex<LongWritable, DoubleWritable, DoubleWritable, DoubleWritable>
- vertex, Iterator<DoubleWritable> msgIterator) {
+ MutableVertex<LongWritable, DoubleWritable, DoubleWritable,
+ DoubleWritable> vertex, Iterator<DoubleWritable> msgIterator) {
if (vertex.getSuperstep() >= 1) {
double sum = 0;
while (msgIterator.hasNext()) {
Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PseudoRandomVertexInputFormat.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PseudoRandomVertexInputFormat.java?rev=1245205&r1=1245204&r2=1245205&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PseudoRandomVertexInputFormat.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/benchmark/PseudoRandomVertexInputFormat.java Thu Feb 16 22:12:31 2012
@@ -44,147 +44,148 @@ import java.util.Random;
* to create an input data source that a variable number of aggregate vertices
* and edges per vertex that is repeatable for the exact same parameter
* (pseudo-random).
+ *
+ * @param <M> Message data
*/
public class PseudoRandomVertexInputFormat<M extends Writable> extends
- VertexInputFormat<LongWritable, DoubleWritable, DoubleWritable, M> {
- /** Set the number of aggregate vertices */
- public static final String AGGREGATE_VERTICES =
- "pseudoRandomVertexReader.aggregateVertices";
- /** Set the number of edges per vertex (pseudo-random destination) */
- public static final String EDGES_PER_VERTEX =
- "pseudoRandomVertexReader.edgesPerVertex";
-
- @Override
- public List<InputSplit> getSplits(JobContext context, int numWorkers)
- throws IOException, InterruptedException {
- // This is meaningless, the PseudoRandomVertexReader will generate
- // all the test data
- List<InputSplit> inputSplitList = new ArrayList<InputSplit>();
- for (int i = 0; i < numWorkers; ++i) {
- inputSplitList.add(new BspInputSplit(i, numWorkers));
- }
- return inputSplitList;
+ VertexInputFormat<LongWritable, DoubleWritable, DoubleWritable, M> {
+ /** Set the number of aggregate vertices. */
+ public static final String AGGREGATE_VERTICES =
+ "pseudoRandomVertexReader.aggregateVertices";
+ /** Set the number of edges per vertex (pseudo-random destination). */
+ public static final String EDGES_PER_VERTEX =
+ "pseudoRandomVertexReader.edgesPerVertex";
+
+ @Override
+ public final List<InputSplit> getSplits(final JobContext context,
+ final int numWorkers) throws IOException, InterruptedException {
+ // This is meaningless, the PseudoRandomVertexReader will generate
+ // all the test data
+ List<InputSplit> inputSplitList = new ArrayList<InputSplit>();
+ for (int i = 0; i < numWorkers; ++i) {
+ inputSplitList.add(new BspInputSplit(i, numWorkers));
}
+ return inputSplitList;
+ }
- @Override
- public VertexReader<LongWritable, DoubleWritable, DoubleWritable, M>
- createVertexReader(InputSplit split, TaskAttemptContext context)
- throws IOException {
- return new PseudoRandomVertexReader<M>();
- }
+ @Override
+ public VertexReader<LongWritable, DoubleWritable, DoubleWritable, M>
+ createVertexReader(InputSplit split, TaskAttemptContext context)
+ throws IOException {
+ return new PseudoRandomVertexReader<M>();
+ }
+
+ /**
+ * Used by {@link PseudoRandomVertexInputFormat} to read
+ * pseudo-randomly generated data.
+ */
+ private static class PseudoRandomVertexReader<M extends Writable> implements
+ VertexReader<LongWritable, DoubleWritable, DoubleWritable, M> {
+ /** Logger. */
+ private static final Logger LOG =
+ Logger.getLogger(PseudoRandomVertexReader.class);
+ /** Starting vertex id. */
+ private long startingVertexId = -1;
+ /** Vertices read so far. */
+ private long verticesRead = 0;
+ /** Total vertices to read (on this split alone). */
+ private long totalSplitVertices = -1;
+ /** Aggregate vertices (all input splits). */
+ private long aggregateVertices = -1;
+ /** Edges per vertex. */
+ private long edgesPerVertex = -1;
+ /** BspInputSplit (used only for index). */
+ private BspInputSplit bspInputSplit;
+ /** Saved configuration */
+ private Configuration configuration;
/**
- * Used by {@link PseudoRandomVertexInputFormat} to read
- * pseudo-randomly generated data
+ * Default constructor for reflection.
*/
- private static class PseudoRandomVertexReader<M extends Writable> implements
- VertexReader<LongWritable, DoubleWritable, DoubleWritable, M> {
- /** Logger */
- private static final Logger LOG =
- Logger.getLogger(PseudoRandomVertexReader.class);
- /** Starting vertex id */
- private long startingVertexId = -1;
- /** Vertices read so far */
- private long verticesRead = 0;
- /** Total vertices to read (on this split alone) */
- private long totalSplitVertices = -1;
- /** Aggregate vertices (all input splits) */
- private long aggregateVertices = -1;
- /** Edges per vertex */
- private long edgesPerVertex = -1;
- /** BspInputSplit (used only for index) */
- private BspInputSplit bspInputSplit;
-
- private Configuration configuration;
-
- public PseudoRandomVertexReader() {
- }
+ public PseudoRandomVertexReader() {
+ }
- @Override
- public void initialize(InputSplit inputSplit,
- TaskAttemptContext context) throws IOException {
- configuration = context.getConfiguration();
- aggregateVertices =
- configuration.getLong(
- PseudoRandomVertexInputFormat.AGGREGATE_VERTICES, 0);
- if (aggregateVertices <= 0) {
- throw new IllegalArgumentException(
- "initialize: " +
- PseudoRandomVertexInputFormat.AGGREGATE_VERTICES + " <= 0");
- }
- if (inputSplit instanceof BspInputSplit) {
- bspInputSplit = (BspInputSplit) inputSplit;
- long extraVertices =
- aggregateVertices % bspInputSplit.getNumSplits();
- totalSplitVertices =
- aggregateVertices / bspInputSplit.getNumSplits();
- if (bspInputSplit.getSplitIndex() < extraVertices) {
- ++totalSplitVertices;
- }
- startingVertexId = (bspInputSplit.getSplitIndex() *
- (aggregateVertices / bspInputSplit.getNumSplits())) +
- Math.min(bspInputSplit.getSplitIndex(),
- extraVertices);
- } else {
- throw new IllegalArgumentException(
- "initialize: Got " + inputSplit.getClass() +
- " instead of " + BspInputSplit.class);
- }
- edgesPerVertex =
- configuration.getLong(
- PseudoRandomVertexInputFormat.EDGES_PER_VERTEX, 0);
- if (edgesPerVertex <= 0) {
- throw new IllegalArgumentException(
- "initialize: " +
- PseudoRandomVertexInputFormat.EDGES_PER_VERTEX + " <= 0");
- }
- }
+ @Override
+ public void initialize(InputSplit inputSplit,
+ TaskAttemptContext context) throws IOException {
+ configuration = context.getConfiguration();
+ aggregateVertices =
+ configuration.getLong(
+ PseudoRandomVertexInputFormat.AGGREGATE_VERTICES, 0);
+ if (aggregateVertices <= 0) {
+ throw new IllegalArgumentException(
+ PseudoRandomVertexInputFormat.AGGREGATE_VERTICES + " <= 0");
+ }
+ if (inputSplit instanceof BspInputSplit) {
+ bspInputSplit = (BspInputSplit) inputSplit;
+ long extraVertices =
+ aggregateVertices % bspInputSplit.getNumSplits();
+ totalSplitVertices =
+ aggregateVertices / bspInputSplit.getNumSplits();
+ if (bspInputSplit.getSplitIndex() < extraVertices) {
+ ++totalSplitVertices;
+ }
+ startingVertexId = (bspInputSplit.getSplitIndex() *
+ (aggregateVertices / bspInputSplit.getNumSplits())) +
+ Math.min(bspInputSplit.getSplitIndex(),
+ extraVertices);
+ } else {
+ throw new IllegalArgumentException(
+ "initialize: Got " + inputSplit.getClass() +
+ " instead of " + BspInputSplit.class);
+ }
+ edgesPerVertex = configuration.getLong(
+ PseudoRandomVertexInputFormat.EDGES_PER_VERTEX, 0);
+ if (edgesPerVertex <= 0) {
+ throw new IllegalArgumentException(
+ PseudoRandomVertexInputFormat.EDGES_PER_VERTEX + " <= 0");
+ }
+ }
- @Override
- public boolean nextVertex() throws IOException, InterruptedException {
- return totalSplitVertices > verticesRead;
- }
+ @Override
+ public boolean nextVertex() throws IOException, InterruptedException {
+ return totalSplitVertices > verticesRead;
+ }
- @Override
- public BasicVertex<LongWritable, DoubleWritable, DoubleWritable, M> getCurrentVertex()
- throws IOException, InterruptedException {
- BasicVertex<LongWritable, DoubleWritable, DoubleWritable, M>
- vertex = BspUtils.createVertex(configuration);
- long vertexId = startingVertexId + verticesRead;
- // Seed on the vertex id to keep the vertex data the same when
- // on different number of workers, but other parameters are the
- // same.
- Random rand = new Random(vertexId);
- DoubleWritable vertexValue = new DoubleWritable(rand.nextDouble());
- Map<LongWritable, DoubleWritable> edges = Maps.newHashMap();
- for (long i = 0; i < edgesPerVertex; ++i) {
- LongWritable destVertexId = null;
- do {
- destVertexId =
- new LongWritable(Math.abs(rand.nextLong()) %
- aggregateVertices);
- } while (edges.containsKey(destVertexId));
- edges.put(destVertexId, new DoubleWritable(rand.nextDouble()));
- }
- vertex.initialize(
- new LongWritable(vertexId), vertexValue, edges, null);
- ++verticesRead;
- if (LOG.isDebugEnabled()) {
- LOG.debug("next: Return vertexId=" +
- vertex.getVertexId().get() +
- ", vertexValue=" + vertex.getVertexValue() +
- ", edgeMap=" + vertex.iterator());
- }
- return vertex;
- }
+ @Override
+ public BasicVertex<LongWritable, DoubleWritable, DoubleWritable, M>
+ getCurrentVertex() throws IOException, InterruptedException {
+ BasicVertex<LongWritable, DoubleWritable, DoubleWritable, M>
+ vertex = BspUtils.createVertex(configuration);
+ long vertexId = startingVertexId + verticesRead;
+ // Seed on the vertex id to keep the vertex data the same when
+ // on different number of workers, but other parameters are the
+ // same.
+ Random rand = new Random(vertexId);
+ DoubleWritable vertexValue = new DoubleWritable(rand.nextDouble());
+ Map<LongWritable, DoubleWritable> edges = Maps.newHashMap();
+ for (long i = 0; i < edgesPerVertex; ++i) {
+ LongWritable destVertexId = null;
+ do {
+ destVertexId =
+ new LongWritable(Math.abs(rand.nextLong()) %
+ aggregateVertices);
+ } while (edges.containsKey(destVertexId));
+ edges.put(destVertexId, new DoubleWritable(rand.nextDouble()));
+ }
+ vertex.initialize(new LongWritable(vertexId), vertexValue, edges, null);
+ ++verticesRead;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("next: Return vertexId=" +
+ vertex.getVertexId().get() +
+ ", vertexValue=" + vertex.getVertexValue() +
+ ", edgeMap=" + vertex.iterator());
+ }
+ return vertex;
+ }
- @Override
- public void close() throws IOException {
- }
+ @Override
+ public void close() throws IOException {
+ }
- @Override
- public float getProgress() throws IOException {
- return verticesRead * 100.0f / totalSplitVertices;
- }
+ @Override
+ public float getProgress() throws IOException {
+ return verticesRead * 100.0f / totalSplitVertices;
}
+ }
}