List of usage examples for java.io FileNotFoundException getMessage
public String getMessage()
From source file:com.cmput301w15t15.travelclaimsapp.FileManager.java
/** * Saves user to file and attempts to save online if there is an internet connection. * /*from w w w. ja v a 2 s.co m*/ * @param User user */ public void saveUserInFile(User user) { Thread thread = new onlineSaveUserThread(user); thread.start(); try { //openFileOutput is a Activity method FileOutputStream fos = context.openFileOutput(USERFILENAME, 0); OutputStreamWriter osw = new OutputStreamWriter(fos); gson.toJson(user, osw); osw.flush(); fos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Log.d(TAG, "saveClaimLInFile could not find file: " + e.getMessage()); } catch (IOException e) { // TODO Auto-generated catch block Log.d(TAG, "saveClaimLInFile could not find file: " + e.getMessage()); } }
From source file:net.pms.configuration.WindowsProgramPaths.java
/** * Not to be instantiated, call {@link PlatformProgramPaths#get()} instead. *//*from ww w.jav a2 s . c o m*/ protected WindowsProgramPaths() { // FFmpeg Path ffmpeg = null; if (Platform.is64Bit()) { if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { ffmpeg = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("ffmpeg64.exe"); } if (ffmpeg == null || !Files.exists(ffmpeg)) { ffmpeg = PLATFORM_BINARIES_FOLDER.resolve("ffmpeg64.exe"); } try { if (!new FilePermissions(ffmpeg).isExecutable()) { LOGGER.trace("Insufficient permission to executable \"{}\"", ffmpeg); LOGGER.trace("Looking for non-64 version"); ffmpeg = null; } } catch (FileNotFoundException e) { LOGGER.trace("Executable \"{}\" not found: {}", ffmpeg, e.getMessage()); LOGGER.trace("Looking for non-64 version"); ffmpeg = null; } } if (ffmpeg == null) { if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { ffmpeg = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("ffmpeg.exe"); } if (ffmpeg == null || !Files.exists(ffmpeg)) { ffmpeg = PLATFORM_BINARIES_FOLDER.resolve("ffmpeg.exe"); } try { if (!new FilePermissions(ffmpeg).isExecutable()) { LOGGER.trace("Insufficient permission to executable \"{}\"", ffmpeg); if (Platform.is64Bit()) { ffmpeg = PLATFORM_BINARIES_FOLDER.resolve("ffmpeg64.exe"); } } } catch (FileNotFoundException e) { LOGGER.trace("Executable \"{}\" not found: {}", ffmpeg, e.getMessage()); if (Platform.is64Bit()) { ffmpeg = PLATFORM_BINARIES_FOLDER.resolve("ffmpeg64.exe"); } } } ffmpegInfo = new FFmpegProgramInfo("FFmpeg", ProgramExecutableType.BUNDLED); ffmpegInfo.setPath(ProgramExecutableType.BUNDLED, ffmpeg); ffmpeg = null; if (Platform.is64Bit()) { ffmpeg = FileUtil.findExecutableInOSPath(Paths.get("ffmpeg64.exe")); } if (ffmpeg == null) { ffmpeg = FileUtil.findExecutableInOSPath(Paths.get("ffmpeg.exe")); } if (ffmpeg != null) { ffmpegInfo.setPath(ProgramExecutableType.INSTALLED, ffmpeg); } // MPlayer Path mPlayer = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { mPlayer = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("mplayer.exe"); } if (mPlayer == null || !Files.exists(mPlayer)) { mPlayer = PLATFORM_BINARIES_FOLDER.resolve("mplayer.exe"); } mPlayerInfo = new ExternalProgramInfo("MPlayer", ProgramExecutableType.BUNDLED); mPlayerInfo.setPath(ProgramExecutableType.BUNDLED, mPlayer); mPlayer = FileUtil.findExecutableInOSPath(Paths.get("mplayer.exe")); if (mPlayer != null) { mPlayerInfo.setPath(ProgramExecutableType.INSTALLED, mPlayer); } // VLC Path vlcPath = BasicSystemUtils.INSTANCE.getVlcPath(); if (vlcPath == null || !Files.exists(vlcPath)) { vlcPath = FileUtil.findExecutableInOSPath(Paths.get("vlc.exe")); } if (vlcPath != null) { vlcInfo = new ExternalProgramInfo("VLC", ProgramExecutableType.INSTALLED); vlcInfo.setPath(ProgramExecutableType.INSTALLED, vlcPath); } else { vlcInfo = new ExternalProgramInfo("VLC", null); } // MEncoder Path mEncoder = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { mEncoder = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("mencoder.exe"); } if (mEncoder == null || !Files.exists(mEncoder)) { mEncoder = PLATFORM_BINARIES_FOLDER.resolve("mencoder.exe"); } mEncoderInfo = new ExternalProgramInfo("MEncoder", ProgramExecutableType.BUNDLED); mEncoderInfo.setPath(ProgramExecutableType.BUNDLED, mEncoder); mEncoder = FileUtil.findExecutableInOSPath(Paths.get("mencoder.exe")); if (mEncoder != null) { mEncoderInfo.setPath(ProgramExecutableType.INSTALLED, mEncoder); } // tsMuxeR Path tsMuxeR = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { tsMuxeR = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("tsMuxeR.exe"); } if (tsMuxeR == null || !Files.exists(tsMuxeR)) { tsMuxeR = PLATFORM_BINARIES_FOLDER.resolve("tsMuxeR.exe"); } tsMuxeRInfo = new ExternalProgramInfo("tsMuxeR", ProgramExecutableType.BUNDLED); tsMuxeRInfo.setPath(ProgramExecutableType.BUNDLED, tsMuxeR); tsMuxeR = FileUtil.findExecutableInOSPath(Paths.get("tsMuxeR.exe")); if (tsMuxeR != null) { tsMuxeRInfo.setPath(ProgramExecutableType.INSTALLED, tsMuxeR); } // tsMuxeRNew Path tsMuxeRNew = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { tsMuxeRNew = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("tsMuxeR-new.exe"); } if (tsMuxeRNew == null || !Files.exists(tsMuxeRNew)) { tsMuxeRNew = PLATFORM_BINARIES_FOLDER.resolve("tsMuxeR-new.exe"); } tsMuxeRNewInfo = new ExternalProgramInfo("tsMuxeRNew", ProgramExecutableType.BUNDLED); tsMuxeRNewInfo.setPath(ProgramExecutableType.BUNDLED, tsMuxeRNew); // FLAC Path flac = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { flac = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("flac.exe"); } if (flac == null || !Files.exists(flac)) { flac = PLATFORM_BINARIES_FOLDER.resolve("flac.exe"); } flacInfo = new ExternalProgramInfo("FLAC", ProgramExecutableType.BUNDLED); flacInfo.setPath(ProgramExecutableType.BUNDLED, flac); // DCRaw Path dcRaw = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { dcRaw = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("dcrawMS.exe"); } if (dcRaw == null || !Files.exists(dcRaw)) { dcRaw = PLATFORM_BINARIES_FOLDER.resolve("dcrawMS.exe"); } dcRawInfo = new ExternalProgramInfo("DCRaw", ProgramExecutableType.BUNDLED); dcRawInfo.setPath(ProgramExecutableType.BUNDLED, dcRaw); dcRaw = FileUtil.findExecutableInOSPath(Paths.get("dcrawMS.exe")); if (dcRaw != null) { dcRawInfo.setPath(ProgramExecutableType.INSTALLED, dcRaw); } // InterFrame Path interframe = null; if (PLATFORM_DEVELOPMENT_BINARIES_FOLDER != null) { interframe = PLATFORM_DEVELOPMENT_BINARIES_FOLDER.resolve("interframe"); } if (interframe == null || !Files.exists(interframe)) { interframe = PLATFORM_BINARIES_FOLDER.resolve("interframe"); } interFrameInfo = new ExternalProgramInfo("InterFrame", ProgramExecutableType.BUNDLED); interFrameInfo.setPath(ProgramExecutableType.BUNDLED, interframe); // CtrlSender Path tmpCtrlSender = Paths.get("src/main/external-resources/lib/ctrlsender/ctrlsender.exe"); if (!Files.exists(tmpCtrlSender)) { tmpCtrlSender = PLATFORM_BINARIES_FOLDER.resolve("ctrlsender.exe"); } try { if (!new FilePermissions(tmpCtrlSender).isExecutableFile()) { tmpCtrlSender = null; } } catch (FileNotFoundException e) { tmpCtrlSender = null; } ctrlSender = tmpCtrlSender; taskKill = FileUtil.findExecutableInOSPath(Paths.get("taskkill.exe")); }
From source file:com.mnxfst.testing.server.cfg.PTestServerConfigurationParser.java
/** * Parses the contents of the referenced configuration file into an object * @param filename//from w w w.j ava2 s.co m * @return * @throws ServerConfigurationFailedException */ public PTestServerConfiguration parseServerConfiguration(String filename) throws ServerConfigurationFailedException { if (filename == null || filename.isEmpty()) throw new ServerConfigurationFailedException("Missing required config filename"); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { FileInputStream fIn = new FileInputStream(filename); int c = 0; while ((c = fIn.read()) != -1) bOut.write(c); } catch (FileNotFoundException e) { throw new ServerConfigurationFailedException("Referenced configuration file does not exist"); } catch (IOException e) { throw new ServerConfigurationFailedException( "Failed to read contents from configuration file '" + filename + "'. Error: " + e.getMessage()); } return parseServerConfiguration(bOut.toByteArray()); }
From source file:edu.harvard.mcz.dwcaextractor.DwCaExtractor.java
/** * Setup conditions to run./*from www. ja v a 2 s . co m*/ * * @param args command line arguments * @return true if setup was successful, false otherwise. */ protected boolean setup(String[] args) { boolean setupOK = false; CmdLineParser parser = new CmdLineParser(this); //parser.setUsageWidth(4096); try { parser.parseArgument(args); if (help) { parser.printUsage(System.out); System.exit(0); } if (archiveFilePath != null) { String filePath = archiveFilePath; logger.debug(filePath); File file = new File(filePath); if (!file.exists()) { // Error logger.error(filePath + " not found."); } if (!file.canRead()) { // error logger.error("Unable to read " + filePath); } if (file.isDirectory()) { // check if it is an unzipped dwc archive. dwcArchive = openArchive(file); } if (file.isFile()) { // unzip it File outputDirectory = new File(file.getName().replace(".", "_") + "_content"); if (!outputDirectory.exists()) { outputDirectory.mkdir(); try { byte[] buffer = new byte[1024]; ZipInputStream inzip = new ZipInputStream(new FileInputStream(file)); ZipEntry entry = inzip.getNextEntry(); while (entry != null) { String fileName = entry.getName(); File expandedFile = new File(outputDirectory.getPath() + File.separator + fileName); new File(expandedFile.getParent()).mkdirs(); FileOutputStream expandedfileOutputStream = new FileOutputStream(expandedFile); int len; while ((len = inzip.read(buffer)) > 0) { expandedfileOutputStream.write(buffer, 0, len); } expandedfileOutputStream.close(); entry = inzip.getNextEntry(); } inzip.closeEntry(); inzip.close(); logger.debug("Unzipped archive into " + outputDirectory.getPath()); } catch (FileNotFoundException e) { logger.error(e.getMessage()); } catch (IOException e) { logger.error(e.getMessage(), e); } } // look into the unzipped directory dwcArchive = openArchive(outputDirectory); } if (dwcArchive != null) { if (checkArchive()) { // Check output csvPrinter = new CSVPrinter(new FileWriter(outputFilename, append), CSVFormat.DEFAULT.withQuoteMode(QuoteMode.NON_NUMERIC)); // no exception thrown setupOK = true; } } else { System.out.println("Problem opening archive."); logger.error("Unable to unpack archive file."); } logger.debug(setupOK); } } catch (CmdLineException e) { logger.error(e.getMessage()); parser.printUsage(System.err); } catch (IOException e) { logger.error(e.getMessage()); System.out.println(e.getMessage()); parser.printUsage(System.err); } return setupOK; }
From source file:kg.apc.jmeter.vizualizers.SynthesisReportGui.java
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("synthesis.csv"); if (chooser == null) { return; }//from ww w .j a va 2 s .c o m FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats(getAllTableData(model, FORMATS), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
From source file:org.deegree.securityproxy.service.commons.responsefilter.clipping.AbstractClippingResponseFilterManager.java
private String readExceptionBodyFromFile(String pathToExceptionFile) { LOG.info("Reading exception body from " + pathToExceptionFile); if (pathToExceptionFile != null && pathToExceptionFile.length() > 0) { InputStream exceptionAsStream = null; try {//from w ww. j a v a 2 s.c om File exceptionFile = new File(pathToExceptionFile); exceptionAsStream = new FileInputStream(exceptionFile); return IOUtils.toString(exceptionAsStream); } catch (FileNotFoundException e) { LOG.warn("Could not read exception message from file: File not found! Defaulting to " + DEFAULT_BODY); } catch (IOException e) { LOG.warn("Could not read exception message from file. Defaulting to " + DEFAULT_BODY + "Reason: " + e.getMessage()); } finally { closeQuietly(exceptionAsStream); } } return DEFAULT_BODY; }
From source file:com.aionemu.commons.scripting.AionScriptEngineManager.java
private void executeAllScriptsInDirectory(File dir, boolean recurseDown, int maxDepth, int currentDepth) { if (dir.isDirectory()) { for (File file : dir.listFiles()) { if (file.isDirectory() && recurseDown && maxDepth > currentDepth) { if (VERBOSE_LOADING) { log.info("Entering folder: " + file.getName()); }//from ww w. ja v a 2 s . c o m this.executeAllScriptsInDirectory(file, recurseDown, maxDepth, currentDepth + 1); } else if (file.isFile()) { try { String name = file.getName(); int lastIndex = name.lastIndexOf('.'); String extension; if (lastIndex != -1) { extension = name.substring(lastIndex + 1); ScriptEngine engine = getEngineByExtension(extension); if (engine != null) { this.executeScript(engine, file); } } } catch (FileNotFoundException e) { // should never happen log.error(e.getMessage(), e); } catch (ScriptException e) { reportScriptFileError(file, e); // _log.error(e.getMessage(),e); } } } } else { throw new IllegalArgumentException( "The argument directory either doesnt exists or is not an directory."); } }
From source file:com.plugin.base64.Base64ImagePlugin.java
private boolean convertImageToBase64FromUrl(JSONArray imageUrls, CallbackContext callbackContext) { boolean result = false; JSONArray base64StringArray = new JSONArray(); //String[] base64StringArray=new String[imageUrls.length()]; try {// w w w . ja v a 2 s .co m Log.v(TAG, "array count ---" + imageUrls.length()); for (int i = 0; i < imageUrls.length(); i++) { Log.v(TAG, "start 1"); Log.v(TAG, imageUrls.toString()); // JSONObject imageObject = imageUrls.getJSONObject(i); Log.v(TAG, "start 2"); String fileUrl = imageUrls.getString(i).substring(7); Log.v(TAG, "file url ---" + fileUrl); File file = new File(fileUrl); byte[] bFile = new byte[(int) file.length()]; FileInputStream inputstream = new FileInputStream(file); inputstream.read(bFile); inputstream.close(); //Log.v(TAG,Arrays.toString(bFile)); String base64String = new String(Base64.encodeBase64(bFile)); //String base64String=Base64.encodeBase64String(bFile); /*String filename=file.getName(); int extensionIndex = filename.lastIndexOf("."); String extension = filename.substring(extensionIndex + 1); if("jpeg".equals(extension)){ base64String="data:image/jpeg;base64,"+base64String; }else if("png".equals(extension)){ base64String="data:image/png;base64,"+base64String; }else if("gif".equals(extension)){ base64String="data:image/gif;base64,"+base64String; } /* switch (extension) { case "jpeg":base64String="data:image/jpeg;base64,"+base64String; break; case "png":base64String="data:image/png;base64,"+base64String; break; case "gif":base64String="data:image/gif;base64,"+base64String; break; }*/ base64String = "data:image/png;base64," + base64String; Log.v(TAG, base64String); JSONObject object = new JSONObject(); object.put("url", base64String); base64StringArray.put(object); } callbackContext.success(base64StringArray); } catch (FileNotFoundException e) { Log.v(TAG, "File not Found"); // return new PluginResult(PluginResult.Status.ERROR, "File not Found!"); callbackContext.error("File not Found!"); result = false; } catch (IOException e) { Log.v(TAG, e.getMessage()); // return new PluginResult(PluginResult.Status.ERROR, e.getMessage()); callbackContext.error("Exception :" + e.getMessage()); result = false; } catch (JSONException e) { Log.v(TAG, "my json exception"); Log.v(TAG, e.getMessage()); callbackContext.error("Exception :" + e.getMessage()); result = false; } return result; }
From source file:com.diversityarrays.update.UpdateDialog.java
private void checkForUpdates(PrintStream ps) { StringBuilder sb = new StringBuilder(updateCheckRequest.updateBaseUrl); sb.append(updateCheckRequest.versionCode); if (RunMode.getRunMode().isDeveloper()) { sb.append("-dev"); //$NON-NLS-1$ }/*from ww w. ja va 2 s .co m*/ sb.append(".json"); //$NON-NLS-1$ final String updateUrl; updateUrl = sb.toString(); // updateUrl = "NONEXISTENT"; // Uncomment to check error final ProgressMonitor progressMonitor = new ProgressMonitor(updateCheckRequest.owner, Msg.PROGRESS_CHECKING(), null, 0, 0); worker = new SwingWorker<String, Void>() { @Override protected String doInBackground() throws Exception { // Thread.sleep(3000); // Uncomment to check delay BufferedReader reader = null; StringBuffer buffer = new StringBuffer(); try { URL url = new URL(updateUrl); reader = new BufferedReader(new InputStreamReader(url.openStream())); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) { if (progressMonitor.isCanceled()) { cancel(true); return null; } buffer.append(chars, 0, read); } } catch (IOException e) { System.err.println("checkForUpdates: " + e.getMessage()); //$NON-NLS-1$ } finally { if (reader != null) { reader.close(); } } return buffer.toString(); } @Override protected void done() { try { String json = get(); Gson gson = new Gson(); setKDXploreUpdate(gson.fromJson(json, KDXploreUpdate.class)); } catch (CancellationException ignore) { } catch (InterruptedException ignore) { } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof UnknownHostException) { String site = extractSite(updateUrl); ps.println(Msg.ERRMSG_UNABLE_TO_CONTACT_UPDATE_SITE(site)); } else { cause.printStackTrace(ps); } if (cause instanceof FileNotFoundException) { FileNotFoundException fnf = (FileNotFoundException) cause; if (updateUrl.equals(fnf.getMessage())) { // Well maybe someone forgot to create the file on // the server! System.err.println("Maybe someone forgot to create the file!"); //$NON-NLS-1$ System.err.println(fnf.getMessage()); setKDXploreUpdate(new KDXploreUpdate(Msg.ERRMSG_PROBLEMS_CONTACTING_UPDATE_SERVER_1())); return; } } String msg = Msg.HTML_PROBLEMS_CONTACTING_UPDATE_2(StringUtil.htmlEscape(updateUrl), cause.getClass().getSimpleName(), StringUtil.htmlEscape(cause.getMessage())); kdxploreUpdate = new KDXploreUpdate(msg); kdxploreUpdate.unknownHost = (cause instanceof UnknownHostException); return; } } private String extractSite(final String updateUrl) { String site = null; int spos = updateUrl.indexOf("://"); if (spos > 0) { int epos = updateUrl.indexOf('/', spos + 1); if (epos > 0) { site = updateUrl.substring(0, epos); } } if (site == null) { site = updateUrl; } return site; } }; Closure<JDialog> onComplete = new Closure<JDialog>() { @Override public void execute(JDialog d) { if (!processReadUrlResult(updateUrl)) { d.dispose(); } else { d.setVisible(true); } } }; SwingWorkerCompletionWaiter waiter = new SwingWorkerCompletionWaiter(this, onComplete); worker.addPropertyChangeListener(waiter); worker.execute(); }
From source file:com.datastax.brisk.demo.pricer.Session.java
public Session(String[] arguments) throws IllegalArgumentException { float STDev = 0.1f; CommandLineParser parser = new PosixParser(); try {//from w w w. ja v a 2 s . c o m CommandLine cmd = parser.parse(availableOptions, arguments); if (cmd.hasOption("h")) throw new IllegalArgumentException("help"); if (cmd.hasOption("n")) numKeys = Integer.parseInt(cmd.getOptionValue("n")); if (cmd.hasOption("N")) skipKeys = Float.parseFloat(cmd.getOptionValue("N")); if (cmd.hasOption("t")) threads = Integer.parseInt(cmd.getOptionValue("t")); if (cmd.hasOption("c")) columns = Integer.parseInt(cmd.getOptionValue("c")); if (cmd.hasOption("S")) columnSize = Integer.parseInt(cmd.getOptionValue("S")); if (cmd.hasOption("C")) cardinality = Integer.parseInt(cmd.getOptionValue("C")); if (cmd.hasOption("d")) nodes = cmd.getOptionValue("d").split(","); if (cmd.hasOption("D")) { try { String node = null; List<String> tmpNodes = new ArrayList<String>(); BufferedReader in = new BufferedReader( new InputStreamReader(new FileInputStream(cmd.getOptionValue("D")))); while ((node = in.readLine()) != null) { if (node.length() > 0) tmpNodes.add(node); } nodes = tmpNodes.toArray(new String[tmpNodes.size()]); in.close(); } catch (IOException ioe) { throw new RuntimeException(ioe); } } if (cmd.hasOption("s")) STDev = Float.parseFloat(cmd.getOptionValue("s")); if (cmd.hasOption("r")) random = true; if (cmd.hasOption("f")) { try { out = new PrintStream(new FileOutputStream(cmd.getOptionValue("f"))); } catch (FileNotFoundException e) { System.out.println(e.getMessage()); } } if (cmd.hasOption("p")) port = Integer.parseInt(cmd.getOptionValue("p")); if (cmd.hasOption("m")) unframed = Boolean.parseBoolean(cmd.getOptionValue("m")); if (cmd.hasOption("o")) operation = Pricer.Operations.valueOf(cmd.getOptionValue("o").toUpperCase()); if (cmd.hasOption("u")) superColumns = Integer.parseInt(cmd.getOptionValue("u")); if (cmd.hasOption("y")) columnFamilyType = ColumnFamilyType.valueOf(cmd.getOptionValue("y")); if (cmd.hasOption("K")) { retryTimes = Integer.valueOf(cmd.getOptionValue("K")); if (retryTimes <= 0) { throw new RuntimeException("--keep-trying option value should be > 0"); } } if (cmd.hasOption("k")) { retryTimes = 1; ignoreErrors = true; } if (cmd.hasOption("i")) progressInterval = Integer.parseInt(cmd.getOptionValue("i")); if (cmd.hasOption("g")) keysPerCall = Integer.parseInt(cmd.getOptionValue("g")); if (cmd.hasOption("l")) replicationFactor = Integer.parseInt(cmd.getOptionValue("l")); if (cmd.hasOption("e")) consistencyLevel = ConsistencyLevel.valueOf(cmd.getOptionValue("e").toUpperCase()); if (cmd.hasOption("x")) indexType = IndexType.valueOf(cmd.getOptionValue("x").toUpperCase()); if (cmd.hasOption("R")) replicationStrategy = cmd.getOptionValue("R"); if (cmd.hasOption("O")) { String[] pairs = StringUtils.split(cmd.getOptionValue("O"), ','); for (String pair : pairs) { String[] keyAndValue = StringUtils.split(pair, ':'); if (keyAndValue.length != 2) throw new RuntimeException("Invalid --strategy-properties value."); replicationStrategyOptions.put(keyAndValue[0], keyAndValue[1]); } } } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage(), e); } mean = numKeys / 2; sigma = numKeys * STDev; operations = new AtomicInteger(); keys = new AtomicInteger(); latency = new AtomicLong(); }