yifan-c commented on code in PR #31:
URL:
https://github.com/apache/cassandra-analytics/pull/31#discussion_r1468236613
##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/data/ClientConfig.java:
##########
@@ -109,6 +134,50 @@ private ClientConfig(Map<String, String> options)
this.quoteIdentifiers = MapUtils.getBoolean(options,
QUOTE_IDENTIFIERS, false);
}
+ private ClearSnapshotStrategy parseClearSnapshotStrategy(boolean
hasDeprecatedOption,
+ boolean
clearSnapshot,
+ String
clearSnapshotStrategyOption)
+ {
+ if (hasDeprecatedOption)
+ {
+ LOGGER.warn("The deprecated option 'clearSnapshot' is set. Please
set 'clearSnapshotStrategy' instead.");
+ if (clearSnapshotStrategyOption == null)
+ {
+ return clearSnapshot ? ClearSnapshotStrategy.defaultStrategy()
: new ClearSnapshotStrategy.NoOp();
+ }
+ }
+ if (clearSnapshotStrategyOption == null)
+ {
+ LOGGER.debug("No clearSnapshotStrategy is set. Using the default
strategy");
+ return ClearSnapshotStrategy.defaultStrategy();
+ }
+ String[] strategyParts = clearSnapshotStrategyOption.split(" ");
+ String strategyName;
+ String snapshotTTL = null;
+ if (strategyParts.length == 1)
+ {
+ strategyName = strategyParts[0].trim();
+ }
+ else if (strategyParts.length == 2)
+ {
+ strategyName = strategyParts[0].trim();
+ snapshotTTL = strategyParts[1].trim();
+ if (!Pattern.matches(SNAPSHOT_TTL_PATTERN, snapshotTTL))
+ {
+ String msg = "Incorrect value set for clearSnapshotStrategy,
expected format is " +
+ "{strategy [snapshotTTLvalue]}. TTL value
specified must contain unit along. " +
+ "For e.g. 2d represents a TTL for 2 days";
+ throw new IllegalArgumentException(msg);
+ }
+ }
+ else
+ {
+ LOGGER.error("Invalid value for ClearSnapshotStrategy: '{}'",
clearSnapshotStrategyOption);
+ throw new IllegalArgumentException("Invalid value: " +
clearSnapshotStrategyOption);
Review Comment:
Fail fast sounds good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]