You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/08/05 16:54:38 UTC
[cassandra] branch trunk updated: Improve cassandra-stress logging
when using a profile file that doesn't exist.
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6d9465a Improve cassandra-stress logging when using a profile file that doesn't exist.
6d9465a is described below
commit 6d9465a00dc26ad0ba589252686de52b4a537bd9
Author: Alex Ott <al...@gmail.com>
AuthorDate: Sat Apr 28 19:35:17 2018 +0200
Improve cassandra-stress logging when using a profile file that doesn't
exist.
Patch by Alex Ott, reviewed by brandonwilliams for CASSANDRA-14425
---
CHANGES.txt | 1 +
tools/stress/src/org/apache/cassandra/stress/Stress.java | 12 ++++++++++++
.../cassandra/stress/settings/SettingsCommandUser.java | 13 ++++++++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 7287c0b..dcefef0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0-beta2
+ * Improve cassandra-stress logging when using a profile file that doesn't exist (CASSANDRA-14425)
* Improve logging for socket connection/disconnection (CASSANDRA-15980)
* Throw FSWriteError upon write failures in order to apply DiskFailurePolicy (CASSANDRA-15928)
* Forbid altering UDTs used in partition keys (CASSANDRA-15933)
diff --git a/tools/stress/src/org/apache/cassandra/stress/Stress.java b/tools/stress/src/org/apache/cassandra/stress/Stress.java
index 3c0fa96..1fd808f 100644
--- a/tools/stress/src/org/apache/cassandra/stress/Stress.java
+++ b/tools/stress/src/org/apache/cassandra/stress/Stress.java
@@ -26,6 +26,7 @@ import org.apache.cassandra.stress.settings.StressSettings;
import org.apache.cassandra.stress.util.MultiResultLogger;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.WindowsTimer;
+import org.apache.commons.lang3.exception.ExceptionUtils;
public final class Stress
{
@@ -87,6 +88,17 @@ public final class Stress
printHelpMessage();
return 1;
}
+ catch (Throwable e)
+ {
+ Throwable rc = ExceptionUtils.getRootCause(e);
+ if (rc instanceof FileNotFoundException)
+ {
+ System.out.printf("File '%s' doesn't exist!%n", rc.getMessage());
+ printHelpMessage();
+ return 1;
+ }
+ throw e;
+ }
MultiResultLogger logout = settings.log.getOutput();
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
index fd34d74..cbf8a3a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.stress.settings;
import java.io.File;
+import java.io.FileNotFoundException;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
@@ -73,7 +74,17 @@ public class SettingsCommandUser extends SettingsCommand
for (String curYamlPath : yamlPaths)
{
File yamlFile = new File(curYamlPath);
- StressProfile profile = StressProfile.load(yamlFile.exists() ? yamlFile.toURI() : URI.create(curYamlPath));
+ URI yamlURI;
+ if (yamlFile.exists()) {
+ yamlURI = yamlFile.toURI();
+ } else {
+ yamlURI = URI.create(curYamlPath);
+ String uriScheme = yamlURI.getScheme();
+ if (uriScheme == null || "file".equals(uriScheme)) {
+ throw new IllegalArgumentException("File '" + yamlURI.getPath() + "' doesn't exist!");
+ }
+ }
+ StressProfile profile = StressProfile.load(yamlURI);
String specName = profile.specName;
if (default_profile_name == null) {default_profile_name=specName;} //first file is default
if (profiles.containsKey(specName))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org