List of usage examples for org.apache.hadoop.conf Configuration set
public void set(String name, String value)
value
of the name
property. From source file:co.cask.tephra.TransactionExecutorTest.java
License:Apache License
@BeforeClass public static void setup() throws IOException { final Configuration conf = new Configuration(); conf.set(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES, DefaultSnapshotCodec.class.getName()); conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, tmpFolder.newFolder().getAbsolutePath()); Injector injector = Guice.createInjector(new ConfigModule(conf), new DiscoveryModules().getInMemoryModules(), Modules.override(new TransactionModules().getInMemoryModules()).with(new AbstractModule() { @Override/*from w ww. j a va 2 s . com*/ protected void configure() { TransactionManager txManager = new TransactionManager(conf); txManager.startAndWait(); bind(TransactionManager.class).toInstance(txManager); bind(TransactionSystemClient.class).to(DummyTxClient.class).in(Singleton.class); } })); txClient = (DummyTxClient) injector.getInstance(TransactionSystemClient.class); factory = injector.getInstance(TransactionExecutorFactory.class); }
From source file:co.cask.tephra.TransactionServiceMainTest.java
License:Apache License
@Test public void testClientServer() throws Exception { // Simply start a transaction server and connect to it with the client. InMemoryZKServer zkServer = InMemoryZKServer.builder().setDataDir(tmpFolder.newFolder()).build(); zkServer.startAndWait();/*from www . ja va 2 s . co m*/ try { Configuration conf = new Configuration(); conf.set(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM, zkServer.getConnectionStr()); conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, tmpFolder.newFolder().getAbsolutePath()); final TransactionServiceMain main = new TransactionServiceMain(conf); final CountDownLatch latch = new CountDownLatch(1); Thread t = new Thread() { @Override public void run() { try { main.start(); latch.countDown(); } catch (Exception e) { throw Throwables.propagate(e); } } }; try { t.start(); // Wait for service to startup latch.await(); TransactionServiceClient.doMain(true, conf); } finally { main.stop(); t.join(); } } finally { zkServer.stopAndWait(); } }
From source file:co.cask.tephra.util.AbstractConfigurationProviderTest.java
License:Apache License
@Test public void testConfigurationProvider() { Configuration conf = new Configuration(); conf.set("foo", "bar"); Configuration newConf = new ConfigurationFactory().get(conf); assertNotNull(newConf);/*w ww . jav a2 s.c o m*/ assertEquals("bar", newConf.get("foo")); }
From source file:co.cask.tigon.data.hbase.HBaseTestBase.java
License:Apache License
public Path createHBaseRootDir(Configuration conf) throws IOException { FileSystem fs = FileSystem.get(conf); Path hbaseRootdir = new Path(fs.makeQualified(fs.getHomeDirectory()), "hbase"); conf.set(HConstants.HBASE_DIR, hbaseRootdir.toString()); fs.mkdirs(hbaseRootdir);// w ww . j a va 2s .c om FSUtils.setVersion(fs, hbaseRootdir); return hbaseRootdir; }
From source file:co.nubetech.apache.hadoop.DataDrivenDBInputFormat.java
License:Apache License
/** * Set the user-defined bounding query to use with a user-defined query. * This *must* include the substring "$CONDITIONS" * (DataDrivenDBInputFormat.SUBSTITUTE_TOKEN) inside the WHERE clause, so * that DataDrivenDBInputFormat knows where to insert split clauses. e.g., * "SELECT foo FROM mytable WHERE $CONDITIONS" This will be expanded to * something like: SELECT foo FROM mytable WHERE (id > 100) AND (id < * 250) inside each split./*w w w.ja v a2 s. c o m*/ */ public static void setBoundingQuery(Configuration conf, String query) { if (null != query) { // If the user's settng a query, warn if they don't allow // conditions. if (query.indexOf(SUBSTITUTE_TOKEN) == -1) { LOG.warn("Could not find " + SUBSTITUTE_TOKEN + " token in query: " + query + "; splits may not partition data."); } } conf.set(DBConfiguration.INPUT_BOUNDING_QUERY, query); }
From source file:co.nubetech.apache.hadoop.DBConfiguration.java
License:Apache License
/** * Sets the DB access related fields in the {@link Configuration}. * @param conf the configuration/* w ww . ja v a 2s . c om*/ * @param driverClass JDBC Driver class name * @param dbUrl JDBC DB access URL. * @param userName DB access username * @param passwd DB access passwd */ public static void configureDB(Configuration conf, String driverClass, String dbUrl, String userName, String passwd) { conf.set(DRIVER_CLASS_PROPERTY, driverClass); conf.set(URL_PROPERTY, dbUrl); if (userName != null) { conf.set(USERNAME_PROPERTY, userName); } if (passwd != null) { conf.set(PASSWORD_PROPERTY, passwd); } }
From source file:co.nubetech.crux.util.Utility.java
License:Apache License
public static Configuration getConfiguration(Connection conn) { Configuration conf = new Configuration(); String propertyValue = conn.getProperties().get(CruxConstants.HBASE_ZOOKEEPER_PROPERTY).getValue(); String[] propertyValueArray = propertyValue.split(","); logger.debug("propertyValueArray.length is: " + propertyValueArray.length); for (int i = 0; i < 1; i++) { String[] hbaseServerHostAndPort = propertyValueArray[i].split(":"); String host = hbaseServerHostAndPort[0]; String port = hbaseServerHostAndPort[1]; logger.debug("Host is: " + host); logger.debug("Port is: " + port); conf.set("hbase.zookeeper.quorum", host); conf.set("hbase.zookeeper.property.clientPort", port); }// w w w. jav a2 s. c o m logger.debug("Returning Configuration: "); return conf; }
From source file:co.nubetech.hiho.hive.TestHiveUtility.java
License:Apache License
@Test public void testGetSelectQuery() throws HIHOException { Configuration conf = new Configuration(); Configuration conf1 = new Configuration(); conf.set(DBConfiguration.INPUT_FIELD_NAMES_PROPERTY, "id,name"); conf.set(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, "student"); // conf.set(DBConfiguration.INPUT_CONDITIONS_PROPERTY,""); // conf.set(DBConfiguration.INPUT_QUERY,"select * from student"); conf1.set(DBConfiguration.INPUT_FIELD_NAMES_PROPERTY, "empId,empName,empAddress"); conf1.set(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, "employee"); // conf1.set(DBConfiguration.INPUT_CONDITIONS_PROPERTY,""); conf1.set(DBConfiguration.INPUT_QUERY, "select * from employee"); String dbProductName = "MYSQL"; assertEquals("SELECT id, name FROM student AS student", DBQueryInputJob.getSelectQuery(conf, dbProductName)); assertEquals("select * from employee", DBQueryInputJob.getSelectQuery(conf1, dbProductName)); }
From source file:co.nubetech.hiho.hive.TestHiveUtility.java
License:Apache License
@Test public void testGetTableName() throws HIHOException { Configuration conf = new Configuration(); Configuration conf1 = new Configuration(); Configuration conf2 = new Configuration(); conf.set(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, "student"); conf.set(DBConfiguration.INPUT_QUERY, "select * from student"); // conf.set(HIHOConf.HIVE_MULTIPLE_PARTITION_BY, // "country:string:us,ca"); conf.set(HIHOConf.HIVE_TABLE_NAME, "hive"); conf1.set(DBConfiguration.INPUT_QUERY, "select * from student"); conf2.set(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, "employee"); assertEquals("hive", HiveUtility.getTableName(conf)); assertEquals("student", HiveUtility.getTableName(conf1)); assertEquals("employee", HiveUtility.getTableName(conf2)); }
From source file:co.nubetech.hiho.hive.TestHiveUtility.java
License:Apache License
@Test public void testGetInsertQuery() throws HIHOException { ColumnInfo intColumn = new ColumnInfo(0, Types.INTEGER, "intColumn"); ColumnInfo stringColumn = new ColumnInfo(1, Types.VARCHAR, "stringColumn"); ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>(); columns.add(intColumn);/*from w w w . j av a 2 s .c o m*/ columns.add(stringColumn); // HiveUtility.tableName = "employee"; GenericDBWritable writable = new GenericDBWritable(columns, null); Configuration conf = new Configuration(); conf.set(HIHOConf.HIVE_PARTITION_BY, "country:string:us,name:string"); conf.set(DBConfiguration.INPUT_TABLE_NAME_PROPERTY, "employee"); assertEquals( "FROM `employeetmp` tmp INSERT OVERWRITE TABLE `employee` PARTITION ( country='us',name) SELECT `tmp`.`intColumn`,`tmp`.`stringColumn`", HiveUtility.getInsertQueryFromTmpToMain(conf, writable, conf.get(HIHOConf.HIVE_PARTITION_BY))); }