List of usage examples for org.apache.hadoop.conf Configuration iterator
@Override
public Iterator<Map.Entry<String, String>> iterator()
String
key-value pairs in the configuration. From source file:org.apache.phoenix.util.MetaDataUtil.java
License:Apache License
/** * Encode HBase and Phoenix version along with some server-side config information such as whether WAL codec is * installed (necessary for non transactional, mutable secondar indexing), and whether systemNamespace mapping is enabled. * /*ww w .jav a 2s . co m*/ * @param env * RegionCoprocessorEnvironment to access HBase version and Configuration. * @return long value sent back during initialization of a cluster connection. */ public static long encodeVersion(String hbaseVersionStr, Configuration config) { long hbaseVersion = VersionUtil.encodeVersion(hbaseVersionStr); long isTableNamespaceMappingEnabled = SchemaUtil.isNamespaceMappingEnabled(PTableType.TABLE, new ReadOnlyProps(config.iterator())) ? 1 : 0; long phoenixVersion = VersionUtil.encodeVersion(MetaDataProtocol.PHOENIX_MAJOR_VERSION, MetaDataProtocol.PHOENIX_MINOR_VERSION, MetaDataProtocol.PHOENIX_PATCH_NUMBER); long walCodec = IndexManagementUtil.isWALEditCodecSet(config) ? 0 : 1; long version = // Encode HBase major, minor, patch version (hbaseVersion << (Byte.SIZE * 5)) // Encode if systemMappingEnabled are enabled on the server side | (isTableNamespaceMappingEnabled << (Byte.SIZE * 4)) // Encode Phoenix major, minor, patch version | (phoenixVersion << (Byte.SIZE * 1)) // Encode whether or not non transactional, mutable secondary indexing was configured properly. | walCodec; return version; }
From source file:org.apache.phoenix.util.PropertiesUtil.java
License:Apache License
/** * Add properties from the given Configuration to the provided Properties. Note that only those * configuration properties will be added to the provided properties whose values are already * not set. The method doesn't modify the passed in properties instead makes a clone of them * before combining.//from w w w.j av a2 s . c om * @return properties object that is a combination of properties contained in props and * properties contained in conf */ public static Properties combineProperties(Properties props, final Configuration conf) { Iterator<Map.Entry<String, String>> iterator = conf.iterator(); Properties copy = deepCopy(props); if (iterator != null) { while (iterator.hasNext()) { Map.Entry<String, String> entry = iterator.next(); // set the property from config only if props doesn't have it already if (copy.getProperty(entry.getKey()) == null) { copy.setProperty(entry.getKey(), entry.getValue()); } } } return copy; }
From source file:org.apache.phoenix.util.PropertiesUtil.java
License:Apache License
/** * Utility to work around the limitation of the copy constructor * {@link Configuration#Configuration(Configuration)} provided by the {@link Configuration} * class. See https://issues.apache.org/jira/browse/HBASE-18378. * The copy constructor doesn't copy all the config settings, so we need to resort to * iterating through all the settings and setting it on the cloned config. * @param toCopy configuration to copy * @return//from w w w . jav a 2s. c om */ public static Configuration cloneConfig(Configuration toCopy) { Configuration clone = new Configuration(); Iterator<Entry<String, String>> iterator = toCopy.iterator(); while (iterator.hasNext()) { Entry<String, String> entry = iterator.next(); clone.set(entry.getKey(), entry.getValue()); } return clone; }
From source file:org.apache.pig.backend.hadoop.accumulo.TestAbstractAccumuloStorage.java
License:Apache License
public static void assertConfigurationsEqual(Configuration expectedConf, Configuration actualConf) { // Make sure the values in both confs are equal Iterator<Entry<String, String>> expectedIter = expectedConf.iterator(); while (expectedIter.hasNext()) { Entry<String, String> e = expectedIter.next(); assertEquals("Values differed for " + e.getKey(), expectedConf.get(e.getKey()), actualConf.get(e.getKey())); }// www . j av a2s .com Iterator<Entry<String, String>> actualIter = actualConf.iterator(); while (actualIter.hasNext()) { Entry<String, String> e = actualIter.next(); assertEquals("Values differed for " + e.getKey(), expectedConf.get(e.getKey()), actualConf.get(e.getKey())); } }
From source file:org.apache.pig.backend.hadoop.accumulo.TestAccumuloStorageConfiguration.java
License:Apache License
protected Map<String, String> getContents(Configuration conf) { Map<String, String> contents = new HashMap<String, String>(); Iterator<Entry<String, String>> iter = conf.iterator(); while (iter.hasNext()) { Entry<String, String> entry = iter.next(); contents.put(entry.getKey(), entry.getValue()); }//from w w w. j a v a2s . c o m return contents; }
From source file:org.apache.pig.backend.hadoop.datastorage.ConfigurationUtil.java
License:Apache License
public static Properties toProperties(Configuration configuration) { Properties properties = new Properties(); assert configuration != null; Iterator<Map.Entry<String, String>> iter = configuration.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); properties.put(entry.getKey(), entry.getValue()); }//from ww w .java 2 s . c om return properties; }
From source file:org.apache.pig.backend.hadoop.datastorage.HConfiguration.java
License:Apache License
public HConfiguration(Configuration other) { if (other != null) { Iterator<Map.Entry<String, String>> iter = other.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); put(entry.getKey(), entry.getValue()); }/*from w w w . jav a 2 s .com*/ } }
From source file:org.apache.pig.piggybank.test.storage.TestPathPartitionHelper.java
License:Apache License
@Test public void testListStatusPartitionFilterNotFound() throws Exception { PathPartitionHelper partitionHelper = new PathPartitionHelper(); Job job = new Job(conf); job.setJobName("TestJob"); job.setInputFormatClass(FileInputFormat.class); Configuration conf = job.getConfiguration(); FileInputFormat.setInputPaths(job, new Path(baseDir.getAbsolutePath())); Iterator<Map.Entry<String, String>> iter = conf.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); System.out.println(entry.getKey() + ": " + entry.getValue()); }//www. j a v a 2s.co m JobContext jobContext = HadoopShims.createJobContext(conf, job.getJobID()); partitionHelper.setPartitionFilterExpression("year < '2010'", PigStorage.class, "1"); partitionHelper.setPartitionKeys(baseDir.getAbsolutePath(), conf, PigStorage.class, "1"); List<FileStatus> files = partitionHelper.listStatus(jobContext, PigStorage.class, "1"); assertEquals(0, files.size()); }
From source file:org.apache.tajo.catalog.store.HCatalogStoreClientPool.java
License:Apache License
public void setParameters(Configuration conf) { for (Iterator<Entry<String, String>> iter = conf.iterator(); iter.hasNext();) { Map.Entry<String, String> entry = iter.next(); this.hiveConf.set(entry.getKey(), entry.getValue()); }/*from w w w . j a v a 2 s .co m*/ }
From source file:org.apache.tez.common.TezUtils.java
License:Apache License
private static void writeConfInPB(OutputStream dos, Configuration conf) throws IOException { DAGProtos.ConfigurationProto.Builder confProtoBuilder = DAGProtos.ConfigurationProto.newBuilder(); Iterator<Map.Entry<String, String>> iter = conf.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); DAGProtos.PlanKeyValuePair.Builder kvp = DAGProtos.PlanKeyValuePair.newBuilder(); kvp.setKey(entry.getKey());//from w w w . j a v a 2s. co m kvp.setValue(entry.getValue()); confProtoBuilder.addConfKeyValues(kvp); } DAGProtos.ConfigurationProto confProto = confProtoBuilder.build(); confProto.writeTo(dos); }