org.deeplearning4j.iterativereduce.irunit.IRUnitDriver Maven / Gradle / Ivy
/*
*
* * Copyright 2015 Skymind,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 org.deeplearning4j.iterativereduce.irunit;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.InputSplit;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.TextInputFormat;
import org.canova.api.records.reader.RecordReader;
import org.deeplearning4j.iterativereduce.impl.reader.CanovaRecordReader;
import org.deeplearning4j.iterativereduce.runtime.ComputableMaster;
import org.deeplearning4j.iterativereduce.runtime.ComputableWorker;
import org.deeplearning4j.scaleout.api.ir.Updateable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* IRUnitDriver. Simulate an iterative reduce engine on hadoop
*
* @author Josh Patterson
* @author Adam Gibson
*/
public class IRUnitDriver {
public final static String APP_OUTPUT_PATH = "app.output.path";
public final static String APP_NUM_ITERATIONS = "app.iteration.count";
public final static String APP_MAIN = "yarn.worker.main";
public final static String MASTER_MAIN = "yarn.master.main";
public final static String APP_INPUT_PATH = "app.input.path";
public final static String APP_RECORD_READER = "app.recordreader.class";
private static JobConf defaultConf = new JobConf();
private static FileSystem localFs = null;
private static final Logger log = LoggerFactory.getLogger(IRUnitDriver.class);
private Properties props;
private ComputableMaster master;
private ArrayList workers;
private String appPropertiesFile = "";
static {
try {
defaultConf.set("fs.defaultFS", "file:///");
localFs = FileSystem.getLocal(defaultConf);
} catch (IOException e) {
throw new RuntimeException("init failure", e);
}
}
/**
* need to load the app.properties file
*
* @return {@link Configuration}
*/
public Configuration getConfiguration() {
Configuration c = new Configuration();
for(Entry