/** * Check environment for Hadoop security token location in case we are * executing the Giraph job on a MRv1 Hadoop cluster. */ public void configureHadoopSecurity() { String hadoopTokenFilePath = System.getenv("HADOOP_TOKEN_FILE_LOCATION"); if (hadoopTokenFilePath != null) { set("mapreduce.job.credentials.binary", hadoopTokenFilePath); } }
@Override public int run(String[] args) throws Exception { if (args.length != 2) { throw new IllegalArgumentException( "run: Must have 2 arguments <output path> <# of workers>"); } GiraphJob job = new GiraphJob(getConf(), getClass().getName()); job.getConfiguration().setComputationClass(SimpleComputation.class); job.getConfiguration().setVertexInputFormatClass( SimpleSuperstepVertexInputFormat.class); job.getConfiguration().setWorkerContextClass(EmitterWorkerContext.class); job.getConfiguration().set( SimpleVertexWithWorkerContext.OUTPUTDIR, args[0]); job.getConfiguration().setWorkerConfiguration(Integer.parseInt(args[1]), Integer.parseInt(args[1]), 100.0f); if (job.run(true)) { return 0; } else { return -1; } }
parts[1] + "] in GiraphConfiguration"); conf.set(parts[0], parts[1]);
GiraphConstants.ZOOKEEPER_SERVER_PORT.set(conf, 0); conf.set(GiraphConstants.ZOOKEEPER_DIR, zkDir.toString()); GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf, zkMgrDir.toString());
String prefix = conf.get(HBaseGraphConfiguration.Keys.GRAPH_TABLE_PREFIX); String tablePrefix = (ns != null ? ns + TableName.NAMESPACE_DELIM : "") + (prefix != null ? prefix : ""); conf.set(Constants.EDGE_INPUT_TABLE, tablePrefix + Constants.EDGES); conf.set(Constants.VERTEX_INPUT_TABLE, tablePrefix + Constants.VERTICES); GiraphConstants.LOCAL_TEST_MODE.set(conf, true); conf.set(GiraphConstants.ZOOKEEPER_DIR, zkDir.toString()); GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf, zkMgrDir.toString());
GiraphConstants.LOCAL_TEST_MODE.set(conf, true); conf.set(GiraphConstants.ZOOKEEPER_DIR, zkDir.toString()); GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf, zkMgrDir.toString());
@Override public void assign(String propertyKey, Object propertyValue, GiraphConfiguration giraphConfiguration) { giraphConfiguration.set(giraphConfigurationKey, propertyValue.toString()); } }
private void addUnrecognizedPropertiesToGiraph(GiraphConfiguration giraphConfiguration) { Set<String> unrecognizedKeys = new HashSet<>(properties.keySet()); unrecognizedKeys.removeAll(VALID_PROPERTIES.keySet()); for (String unrecognizedKey : unrecognizedKeys) { LOG.info("Invalid YAML key, assuming giraph -ca: " + unrecognizedKey); Object value = properties.get(unrecognizedKey); String valueStr; if (!(value instanceof Collection)) { valueStr = value.toString(); } else { Collection<Object> collection = (Collection<Object>) value; valueStr = StringUtils.join(collection, ','); } LOG.info("Setting custom argument [" + unrecognizedKey + "] to [" + valueStr + "] in GiraphConfiguration"); giraphConfiguration.set(unrecognizedKey, valueStr); } }
/** * Get the output directory to write YourKit snapshots to * * @param context Map context * @return output directory */ public String getYourKitOutputDir(Mapper.Context context) { final String cacheKey = "giraph.yourkit.outputDirCached"; String outputDir = get(cacheKey); if (outputDir == null) { outputDir = getStringVars(YOURKIT_OUTPUT_DIR, YOURKIT_OUTPUT_DIR_DEFAULT, context); set(cacheKey, outputDir); } return outputDir; }