List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphanumeric
public static String randomAlphanumeric(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alpha-numeric characters.
From source file:org.apache.tez.history.TestATSFileParser.java
/** * Create sample file for wordcount program * * @param inputLoc/*from w w w . j a v a 2 s . com*/ * @throws IOException */ private static void createSampleFile(Path inputLoc) throws IOException { fs.deleteOnExit(inputLoc); FSDataOutputStream out = fs.create(inputLoc); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); for (int i = 0; i < 10; i++) { writer.write("Sample " + RandomStringUtils.randomAlphanumeric(5)); writer.newLine(); } writer.close(); }
From source file:org.apache.tez.mapreduce.examples.TestOrderedWordCount.java
private void setMaxDataLengthConf(Configuration config, int maxDataLengthThroughIPC, int exceedDataLimit) { /**//from w w w .j a va 2s. c om * if -Dtez.testorderedwordcount.ipc.maximum.data.length is set by user, * this function sets necessary configurations as below: * IS_MAX_IPC_DATA_SET_BY_USER is set to true * EXCEED_IPC_DATA_LIMIT = <N> MB is used to test successful dag submission when MAX_IPC_DATA_LENGTH exceeds by N * Each vertex processor payload can be set to IPC_PAYLOAD so that the cumulative dag payload exceeds * the tez.testorderedwordcount.ipc.maximum.data.length set */ if (maxDataLengthThroughIPC > 0) { config.setBoolean(IS_MAX_IPC_DATA_SET_BY_USER, true); config.setInt(EXCEED_IPC_DATA_LIMIT, exceedDataLimit); int payloadSize; payloadSize = (((maxDataLengthThroughIPC * 1024 * 1024) + (exceedDataLimit * 1024 * 1024)) / NO_OF_VERTICES); String payload = RandomStringUtils.randomAlphanumeric(payloadSize); config.set(IPC_PAYLOAD, payload); } }
From source file:org.apache.tez.runtime.library.common.sort.impl.dflt.TestDefaultSorter.java
private static Text[] generateData(int numKeys, int keyLen) { Text[] ret = new Text[numKeys]; for (int i = 0; i < numKeys; i++) { ret[i] = new Text(RandomStringUtils.randomAlphanumeric(keyLen)); }/*from w w w . j a v a2 s . co m*/ return ret; }
From source file:org.apache.tez.runtime.library.common.sort.impl.TestPipelinedSorter.java
public void testLargeDataWithMixedKV() throws IOException { this.numOutputs = 1; this.initialAvailableMem = 48 * 1024 * 1024; conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true); PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, initialAvailableMem); //write 10 MB KV Text key = new Text(RandomStringUtils.randomAlphanumeric(10 << 20)); Text value = new Text(RandomStringUtils.randomAlphanumeric(10 << 20)); sorter.write(key, value);// w w w . j ava 2 s. c o m //write 24 MB KV. This should cause single record spill key = new Text(RandomStringUtils.randomAlphanumeric(24 << 20)); value = new Text(RandomStringUtils.randomAlphanumeric(24 << 20)); sorter.write(key, value); //write 10 MB KV key = new Text(RandomStringUtils.randomAlphanumeric(10 << 20)); value = new Text(RandomStringUtils.randomAlphanumeric(10 << 20)); sorter.write(key, value); sorter.flush(); sorter.close(); verifyOutputPermissions(outputContext.getUniqueIdentifier()); }
From source file:org.apache.tez.runtime.library.common.sort.impl.TestPipelinedSorter.java
private void writeData2(ExternalSorter sorter, int[] numKeys, int[] keyLen) throws IOException { sortedDataMap.clear();//from w ww.j a v a 2s . c o m int counter = 0; for (int numkey : numKeys) { int curKeyLen = keyLen[counter]; for (int i = 0; i < numkey; i++) { Text key = new Text(RandomStringUtils.randomAlphanumeric(curKeyLen)); Text value = new Text(RandomStringUtils.randomAlphanumeric(curKeyLen)); sorter.write(key, value); } counter++; } sorter.flush(); sorter.close(); verifyOutputPermissions(outputContext.getUniqueIdentifier()); }
From source file:org.apache.tez.runtime.library.common.sort.impl.TestPipelinedSorter.java
private void writeSimilarKeys(ExternalSorter sorter, int numKeys, int keyLen, boolean autoClose) throws IOException { sortedDataMap.clear();/*w w w. j a v a 2 s .c o m*/ String keyStr = RandomStringUtils.randomAlphanumeric(keyLen); for (int i = 0; i < numKeys; i++) { if (i % 4 == 0) { keyStr = RandomStringUtils.randomAlphanumeric(keyLen); } Text key = new Text(keyStr); Text value = new Text(RandomStringUtils.randomAlphanumeric(keyLen)); sorter.write(key, value); sortedDataMap.put(key.toString(), value.toString()); //for verifying data later } if (autoClose) { closeSorter(sorter); } }
From source file:org.apache.tez.runtime.library.common.sort.impl.TestPipelinedSorter.java
private void writeData(ExternalSorter sorter, int numKeys, int keyLen, boolean autoClose) throws IOException { sortedDataMap.clear();/*from w ww.j ava 2 s . c o m*/ for (int i = 0; i < numKeys; i++) { Text key = new Text(RandomStringUtils.randomAlphanumeric(keyLen)); Text value = new Text(RandomStringUtils.randomAlphanumeric(keyLen)); sorter.write(key, value); sortedDataMap.put(key.toString(), value.toString()); //for verifying data later } if (autoClose) { closeSorter(sorter); } }
From source file:org.apache.usergrid.cassandra.CassandraResource.java
/** * Uses a project.properties file that Maven does substitution on to to replace the value of a property with the * path to the Maven build directory (a.k.a. target). It then uses this path to generate a random String which it * uses to append a path component to so a unique directory is selected. If already present it's deleted, then the * directory is created./*from www . j a v a 2 s . co m*/ * * @return a unique temporary directory * * @throws IOException if we cannot access the properties file */ public static File getTempDirectory() throws IOException { File tmpdir; Properties props = new Properties(); props.load(ClassLoader.getSystemResourceAsStream(PROPERTIES_FILE)); File basedir = new File((String) props.get(TARGET_DIRECTORY_KEY)); String comp = RandomStringUtils.randomAlphanumeric(7); tmpdir = new File(basedir, comp); if (tmpdir.exists()) { LOG.info("Deleting directory: {}", tmpdir); FileUtils.forceDelete(tmpdir); } else { LOG.info("Creating temporary directory: {}", tmpdir); FileUtils.forceMkdir(tmpdir); } return tmpdir; }
From source file:org.apache.usergrid.management.export.ExportServiceIT.java
@Before public void before() { boolean configured = !StringUtils.isEmpty(System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR)) && !StringUtils.isEmpty(System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR)) && !StringUtils.isEmpty(System.getProperty("bucketName")); if (!configured) { logger.warn(/*from w ww .ja v a 2s . com*/ "Skipping test because {}, {} and bucketName not " + "specified as system properties, e.g. in your Maven settings.xml file.", new Object[] { SDKGlobalConfiguration.SECRET_KEY_ENV_VAR, SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR }); } Assume.assumeTrue(configured); adminUser = newOrgAppAdminRule.getAdminInfo(); organization = newOrgAppAdminRule.getOrganizationInfo(); applicationId = newOrgAppAdminRule.getApplicationInfo().getId(); bucketPrefix = System.getProperty("bucketName"); bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase(); }