Index: src/java/org/apache/hama/graph/JobStatus.java
===================================================================
--- src/java/org/apache/hama/graph/JobStatus.java (revision 884063)
+++ src/java/org/apache/hama/graph/JobStatus.java (working copy)
@@ -63,11 +63,11 @@
this(jobid, 0.0f, progress, cleanupProgress, runState);
}
- public JobStatus(JobID jobid, float setupProgress, float mapProgress,
+ public JobStatus(JobID jobid, float setupProgress, float progress,
float cleanupProgress, int runState) {
this.jobid = jobid;
this.setupProgress = setupProgress;
- this.progress = mapProgress;
+ this.progress = progress;
this.cleanupProgress = cleanupProgress;
this.runState = runState;
}
Index: src/java/org/apache/hama/graph/RecordWriter.java
===================================================================
--- src/java/org/apache/hama/graph/RecordWriter.java (revision 0)
+++ src/java/org/apache/hama/graph/RecordWriter.java (revision 0)
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+package org.apache.hama.graph;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * RecordWriter writes the output <key, value> pairs
+ * to an output file.
+
+ *
Typically, it presents a byte-oriented view on the input and is the
+ * responsibility of {@link RecordReader} of the job to process this and present
+ * a record-oriented view.
+ *
+ * @see InputFormat
+ * @see RecordReader
+ */
+public abstract class InputSplit {
+ /**
+ * Get the size of the split, so that the input splits can be sorted by size.
+ * @return the number of bytes in the split
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public abstract long getLength() throws IOException, InterruptedException;
+
+ /**
+ * Get the list of nodes by name where the data for the split would be local.
+ * The locations do not need to be serialized.
+ * @return a new array of the node nodes.
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public abstract
+ String[] getLocations() throws IOException, InterruptedException;
+}
\ No newline at end of file
Index: src/java/org/apache/hama/graph/OutputCommitter.java
===================================================================
--- src/java/org/apache/hama/graph/OutputCommitter.java (revision 0)
+++ src/java/org/apache/hama/graph/OutputCommitter.java (revision 0)
@@ -0,0 +1,85 @@
+/**
+ * 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.
+ */
+
+package org.apache.hama.graph;
+
+import java.io.IOException;
+
+
+ /**
+ *
+ * @see JobContext
+ * @see TaskAttemptContext
+ *
+ */
+public abstract class OutputCommitter {
+ /**
+ * For the framework to setup the job output during initialization
+ *
+ * @param jobContext Context of the job whose output is being written.
+ * @throws IOException if temporary output could not be created
+ */
+ public abstract void setupJob(JobContext jobContext) throws IOException;
+
+ /**
+ * For cleaning up the job's output after job completion
+ *
+ * @param jobContext Context of the job whose output is being written.
+ * @throws IOException
+ */
+ public abstract void cleanupJob(JobContext jobContext) throws IOException;
+
+ /**
+ * Sets up output for the task.
+ *
+ * @param taskContext Context of the task whose output is being written.
+ * @throws IOException
+ */
+ public abstract void setupTask(TaskAttemptContext taskContext)
+ throws IOException;
+
+ /**
+ * Check whether task needs a commit
+ *
+ * @param taskContext
+ * @return true/false
+ * @throws IOException
+ */
+ public abstract boolean needsTaskCommit(TaskAttemptContext taskContext)
+ throws IOException;
+
+ /**
+ * To promote the task's temporary output to final output location
+ *
+ * The task's output is moved to the job's output directory.
+ *
+ * @param taskContext Context of the task whose output is being written.
+ * @throws IOException if commit is not
+ */
+ public abstract void commitTask(TaskAttemptContext taskContext)
+ throws IOException;
+
+ /**
+ * Discard the task output
+ *
+ * @param taskContext
+ * @throws IOException
+ */
+ public abstract void abortTask(TaskAttemptContext taskContext)
+ throws IOException;
+}
Index: src/java/org/apache/hama/graph/JobContext.java
===================================================================
--- src/java/org/apache/hama/graph/JobContext.java (revision 0)
+++ src/java/org/apache/hama/graph/JobContext.java (revision 0)
@@ -0,0 +1,109 @@
+/**
+ * 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.
+ */
+
+package org.apache.hama.graph;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.io.Text;
+
+/**
+ * A read-only view of the job that is provided to the tasks while they
+ * are running.
+ */
+public class JobContext {
+ // Put all of the attribute names in here so that Job and JobContext are
+ // consistent.
+ protected static final String INPUT_FORMAT_CLASS_ATTR =
+ "angrapa.inputformat.class";
+ protected static final String WALKER_CLASS_ATTR = "angrapa.walker.class";
+ protected static final String OUTPUT_FORMAT_CLASS_ATTR =
+ "angrapa.outputformat.class";
+
+ protected final Configuration conf;
+ private final JobID jobId;
+
+ public JobContext(Configuration conf, JobID jobId) {
+ this.conf = conf;
+ this.jobId = jobId;
+ }
+
+ public Configuration getConfiguration() {
+ return conf;
+ }
+
+ public JobID getJobID() {
+ return jobId;
+ }
+
+ public Path getWorkingDirectory() throws IOException {
+ String name = conf.get("angrapa.working.dir");
+
+ if (name != null) {
+ return new Path(name);
+ } else {
+ try {
+ Path dir = FileSystem.get(conf).getWorkingDirectory();
+ conf.set("angrapa.working.dir", dir.toString());
+ return dir;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public Class> getOutputKeyClass() {
+ return conf.getClass("angrapa.output.key.class",
+ LongWritable.class, Object.class);
+ }
+
+ public Class> getOutputValueClass() {
+ return conf.getClass("angrapa.output.value.class", Text.class, Object.class);
+ }
+
+ public String getJobName() {
+ return conf.get("angrapa.job.name", "");
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class extends InputFormat,?>> getInputFormatClass()
+ throws ClassNotFoundException {
+ return (Class extends InputFormat,?>>)
+ conf.getClass(INPUT_FORMAT_CLASS_ATTR, InputFormat.class); // TODO: To be corrected to an implemented class
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class extends OutputFormat,?>> getOutputFormatClass()
+ throws ClassNotFoundException {
+ return (Class extends OutputFormat,?>>)
+ conf.getClass(OUTPUT_FORMAT_CLASS_ATTR, OutputFormat.class); // TODO: To be corrected to an implemented class
+ }
+
+ public RawComparator> getSortComparator() {
+ return null;
+ }
+
+ public String getJar() {
+ return conf.get("walker.jar");
+ }
+}
Index: src/java/org/apache/hama/graph/OutputFormat.java
===================================================================
--- src/java/org/apache/hama/graph/OutputFormat.java (revision 0)
+++ src/java/org/apache/hama/graph/OutputFormat.java (revision 0)
@@ -0,0 +1,84 @@
+/**
+ * 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.
+ */
+
+package org.apache.hama.graph;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * The Angrapa framework relies on the
+ * This is to validate the output specification for the job when it is
+ * a job is submitted. Typically checks that it does not already exist,
+ * throwing an exception when it already exists, so that output is not
+ * overwritten. Each {@link InputSplit} is then assigned to an individual {@link Walker}
+ * for processing. Note: The split is a logical split of the inputs and the
+ * input files are not physically split into chunks. For e.g. a split could
+ * be <input-file-path, start, offset> tuple. The InputFormat
+ * also creates the {@link RecordReader} to read the {@link InputSplit}.
+ *
+ * @param context job configuration.
+ * @return an array of {@link InputSplit}s for the job.
+ */
+ public abstract
+ ListRecordWriter implementations write the job outputs to the
+ * {@link FileSystem}.
+ *
+ * @see OutputFormat
+ */
+public abstract class RecordWriterRecordWriter to future operations.
+ *
+ * @param context the context of the task
+ * @throws IOException
+ */
+ public abstract void close(TaskAttemptContext context
+ ) throws IOException, InterruptedException;
+}
Index: src/java/org/apache/hama/graph/InputSplit.java
===================================================================
--- src/java/org/apache/hama/graph/InputSplit.java (revision 0)
+++ src/java/org/apache/hama/graph/InputSplit.java (revision 0)
@@ -0,0 +1,56 @@
+/**
+ * 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.
+ */
+
+package org.apache.hama.graph;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapreduce.InputFormat;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.RecordReader;
+
+/**
+ * InputSplit represents the data to be processed by an
+ * individual {@link Walker}.
+ *
+ * OutputFormat describes the output-specification for a
+ * Angrapa job.
+ *
+ * OutputFormat of the
+ * job to:
+ *
+ *
+ * @see RecordWriter
+ */
+public abstract class OutputFormat