List of usage examples for org.apache.hadoop.conf Configuration getInt
public int getInt(String name, int defaultValue)
name
property as an int
. From source file:com.ricemap.spateDB.mapred.SpatialRecordReader.java
License:Apache License
/** * Initialize from a path and range//from w w w . jav a 2s . c o m * @param job * @param s * @param l * @param p * @throws IOException */ public SpatialRecordReader(Configuration job, long s, long l, Path p) throws IOException { this.start = s; this.end = s + l; this.path = p; this.fs = this.path.getFileSystem(job); FSDataInputStream fileIn = fs.open(this.path); this.blockSize = fs.getFileStatus(this.path).getBlockSize(); this.cellMbr = new Prism(); LOG.info("Open a SpatialRecordReader to file: " + this.path); codec = new CompressionCodecFactory(job).getCodec(this.path); if (isCompressedInput()) { decompressor = CodecPool.getDecompressor(codec); if (codec instanceof SplittableCompressionCodec) { final SplitCompressionInputStream cIn = ((SplittableCompressionCodec) codec).createInputStream( fileIn, decompressor, start, end, SplittableCompressionCodec.READ_MODE.BYBLOCK); in = cIn; start = cIn.getAdjustedStart(); end = cIn.getAdjustedEnd(); filePosition = cIn; // take pos from compressed stream } else { in = codec.createInputStream(fileIn, decompressor); filePosition = fileIn; } } else { fileIn.seek(start); in = fileIn; filePosition = fileIn; } this.pos = start; this.maxShapesInOneRead = job.getInt(SpatialSite.MaxShapesInOneRead, 1000000); this.maxBytesInOneRead = job.getInt(SpatialSite.MaxBytesInOneRead, 32 * 1024 * 1024); initializeReader(); }
From source file:com.ricemap.spateDB.util.ImageOutputFormat.java
License:Apache License
public static int getImageWidth(Configuration conf) { return conf.getInt(ImageWidth, 1000); }
From source file:com.ricemap.spateDB.util.ImageOutputFormat.java
License:Apache License
public static int getImageHeight(Configuration conf) { return conf.getInt(ImageHeight, 1000); }
From source file:com.rockstor.core.io.RockWriterPool.java
License:Apache License
@Override public void init() { // writerQueue = new LinkedBlockingDeque<RockWriter>(); Configuration conf = RockConfiguration.getDefault(); int initWriteNum = conf.getInt("rockstor.threads.num.chunkWriter", 1); for (int idx = 0; idx < initWriteNum; ++idx) { createWriter();// w w w . j a v a2 s .co m } }
From source file:com.rockstor.memory.MemAllocatorFactory.java
License:Apache License
/** * rockstor.memory.allocator.class com.rockstor.memory.DefaultAllocator * rockstor.memory.minBufferSize 16384 16K rockstor.memory.poolSize * 1073741824 1G//from w w w .jav a 2 s . c o m */ private MemAllocatorFactory() { Configuration conf = RockConfiguration.getDefault(); long poolSize = conf.getLong("rockstor.memory.poolSize", defaultPoolSize); if (poolSize < (1L << 20)) { poolSize = (1L << 20); } long reservedSize = conf.getLong("rockstor.memory.reservedSize", defaultReservedSize); if (reservedSize < defaultReservedSize) { reservedSize = defaultReservedSize; } long leftSize = Runtime.getRuntime().maxMemory() - reservedSize; if (leftSize < 0) { LOG.fatal("configuration error, rockstor.memory.reservedSize=" + DefaultAllocator.readableSpace(reservedSize) + ", left memory(" + DefaultAllocator.readableSpace(leftSize) + ") is less than ZERO"); System.exit(-1); } if (leftSize < poolSize) { LOG.warn("configuration warning, reduce rockstor.memory.poolSize " + DefaultAllocator.readableSpace(poolSize) + ", to left meory Size " + DefaultAllocator.readableSpace(leftSize)); poolSize = leftSize; } int minBufSize = conf.getInt("rockstor.memory.minBufferSize", defaultMinBufSize); if (minBufSize < 1024 || minBufSize >= poolSize) { minBufSize = 1024; } String className = conf.get("rockstor.memory.allocator.class", defaultAllocatorClassName); try { allocator = (MemAllocatorInterface) Class.forName(className).newInstance(); } catch (Exception e) { ExceptionLogger.log(LOG, "new memory allocator (" + className + ") instance failed", e); System.exit(-1); } LOG.info("New Memory Allocator Instance (" + className + ") OK!"); allocator.init(poolSize, minBufSize); }
From source file:com.rockstor.rockserver.Main.java
License:Apache License
/** * @param args/*from w ww .j a v a 2 s. co m*/ */ public static void main(String[] args) { Configuration rockConf = RockConfiguration.getDefault(); int listenPort = 8080; listenPort = rockConf.getInt("rockstor.rockserver.listenPort", listenPort); String hostname = "0.0.0.0"; hostname = rockConf.get("rock.host.name", hostname); System.setProperty("jetty.host", hostname); System.setProperty("jetty.port", String.valueOf(listenPort)); try { XmlConfiguration jettyConf = new XmlConfiguration( new FileInputStream(Main.class.getClassLoader().getResource("jetty-rockserver.xml").getPath())); Server server = new Server(); jettyConf.configure(server); server.start(); System.out.println("Monitor Server listening on : " + listenPort); server.join(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { } }
From source file:com.rw.legion.input.LegionRecordReader.java
License:Apache License
public void initialize(InputSplit genericSplit, TaskAttemptContext context) throws IOException { /*//from ww w . j a v a 2 s.com * fileBroken tracks whether there's been an IOException while reading * this file. If there has, the record reader will simply stop reading * records for this particular file, rather than blowing up the whole * job. */ fileBroken = false; currentLine = new Text(); currentLineNumber = 0; FileSplit split = (FileSplit) genericSplit; if (split.getLength() == 0) { fileBroken = true; } // Load the Legion Objective. Configuration job = context.getConfiguration(); this.maxLineLength = job.getInt(MAX_LINE_LENGTH, Integer.MAX_VALUE); legionObjective = ObjectiveDeserializer.deserialize(job.get("legion_objective")); start = split.getStart(); end = start + split.getLength(); final Path file = split.getPath(); // Open the file and seek to the start of the split final FileSystem fs = file.getFileSystem(job); fileIn = fs.open(file); // Grab the file name to include with the data. fileName = file.toString(); // Does the Legion Objective specify an input codec to use? if (legionObjective.getCodecOverride() != null) { isCompressedInput = true; CompressionCodec codec = new CompressionCodecFactory(job) .getCodecByClassName(legionObjective.getCodecOverride()); decompressor = CodecPool.getDecompressor(codec); in = new SplitLineReader(codec.createInputStream(fileIn, decompressor), job, this.recordDelimiterBytes); filePosition = fileIn; } else { CompressionCodec codec = new CompressionCodecFactory(job).getCodec(file); if (null != codec) { isCompressedInput = true; decompressor = CodecPool.getDecompressor(codec); if (codec instanceof SplittableCompressionCodec) { final SplitCompressionInputStream cIn = ((SplittableCompressionCodec) codec).createInputStream( fileIn, decompressor, start, end, SplittableCompressionCodec.READ_MODE.BYBLOCK); in = new CompressedSplitLineReader(cIn, job, this.recordDelimiterBytes); start = cIn.getAdjustedStart(); end = cIn.getAdjustedEnd(); filePosition = cIn; } else { in = new SplitLineReader(codec.createInputStream(fileIn, decompressor), job, this.recordDelimiterBytes); filePosition = fileIn; } } else { fileIn.seek(start); in = new SplitLineReader(fileIn, job, this.recordDelimiterBytes); filePosition = fileIn; } } /* * If this is not the first split, we always throw away first record * because we always (except the last split) read one extra line in * next() method. */ if (start != 0) { start += in.readLine(new Text(), 0, maxBytesToConsume(start)); } this.pos = start; }
From source file:com.sa.npopa.samples.hbase.rest.client.RemoteAdmin.java
License:Apache License
/** * Constructor/*w w w . j a v a 2 s . c o m*/ * @param client * @param conf * @param accessToken */ public RemoteAdmin(Client client, Configuration conf, String accessToken) { this.client = client; this.conf = conf; this.accessToken = accessToken; this.maxRetries = conf.getInt("hbase.rest.client.max.retries", 10); this.sleepTime = conf.getLong("hbase.rest.client.sleep", 1000); }
From source file:com.sa.npopa.samples.hbase.rest.client.RemoteHTable.java
License:Apache License
/** * Constructor/*from w w w . j a v a 2 s. c om*/ * @param client * @param conf * @param name */ public RemoteHTable(Client client, Configuration conf, byte[] name) { this.client = client; this.conf = conf; this.name = name; this.maxRetries = conf.getInt("hbase.rest.client.max.retries", 10); this.sleepTime = conf.getLong("hbase.rest.client.sleep", 1000); }
From source file:com.scaleoutsoftware.soss.hserver.DatasetInputFormat.java
License:Apache License
/** * Creates a KVP-object with a fixed size key and value. * * @param configuration job configuration * @return KVP-object/*from w ww . j av a2 s. c om*/ */ static KeyValuePair createFixedKeyValueSizePair(Configuration configuration) { int keySize = configuration.getInt(keySizePropertyName, -1); int valueSize = configuration.getInt(valueSizePropertyName, -1); if (keySize > 0 && valueSize > 0) { return new KeyValuePair<Text, Text>(new Text(), keySize, new Text(), valueSize); } return null; }