/** * Returns an {@code Optional} with the specified present non-null value. * * @param <T> the class of the value * @param value the value to be present, which must be non-null * @return an {@code Optional} with the value present * @throws NullPointerException if value is null */ public static <T> Option<T> of(T value) { return new Option<>(value); }
/** * Returns an {@code Optional} describing the specified value, if non-null, * otherwise returns an empty {@code Optional}. * * @param <T> the class of the value * @param value the possibly-null value to describe * @return an {@code Optional} with a present value if the specified value is non-null, otherwise an empty {@code * Optional} */ public static <T> Option<T> ofNullable(T value) { return (value == null) ? (Option<T>) empty() : of(value); }
private Measurement(final String name, final MeasurementType type, final Double value, final long time, final TimeUnit timeUnit, final Map<String, String> tags, final Map<String, String> fields) { this.name = name; this.type = type; this.value = Option.ofNullable(value); this.time = time; this.timeUnit = timeUnit; this.tags = tags; this.fields = fields; }
public static void startEmbeddedCassandra(long timeout) throws TTransportException, IOException, InterruptedException, ConfigurationException { startEmbeddedCassandra(DEFAULT_CASSANDRA_YML_FILE, timeout); }
private static void cleanupAndLeaveDirs() throws IOException { mkdirs(); cleanup(); mkdirs(); CommitLog commitLog = CommitLog.instance; commitLog.getContext(); // wait for commit log allocator instantiation to avoid hanging on a race condition // commitLog.resetUnsafe(); // cleanup screws w/ CommitLog, this brings it back to safe state }
/** * drop all keyspaces (expect system). */ public static void cleanEmbeddedCassandra() { dropKeyspaces(); }
/** * If measurement contains a value, retrieve it or return a provided value. * * @param defaultValue default value in case measurement value is null. * @return measurement or default value */ public double getOrDefault(Double defaultValue) { return value.getOrDefault(defaultValue); }
public static void startEmbeddedCassandra(String yamlFile, String tmpDir) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, tmpDir, DEFAULT_STARTUP_TIMEOUT); }
/** * Encodes measurement into JSON. * * @return JSON-formatted string representation of measurement. */ public String toJson() { return "{\"name\":\"" + name + "\"" + ",\"type\":\"" + type + "\"" + ",\"value\":" + (value.hasValue() ? value.getValue() : "null") + ",\"time\":" + time + ",\"timeUnit\":\"" + timeUnit + "\"" + ",\"tags\":" + appendMap(tags) + ",\"fields\":" + appendMap(fields) + "}"; }
private static void cleanupAndLeaveDirs() throws IOException { mkdirs(); cleanup(); mkdirs(); CommitLog commitLog = CommitLog.instance; commitLog.getContext(); // wait for commit log allocator instantiation to avoid hanging on a race condition // commitLog.resetUnsafe(); // cleanup screws w/ CommitLog, this brings it back to safe state }
/** * drop all keyspaces (expect system). */ public static void cleanEmbeddedCassandra() { dropKeyspaces(); }
public static void startEmbeddedCassandra() throws TTransportException, IOException, InterruptedException, ConfigurationException { startEmbeddedCassandra(DEFAULT_STARTUP_TIMEOUT); }
public static void startEmbeddedCassandra(long timeout) throws TTransportException, IOException, InterruptedException, ConfigurationException { startEmbeddedCassandra(DEFAULT_CASSANDRA_YML_FILE, timeout); }
public static void startEmbeddedCassandra(String yamlFile) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, DEFAULT_STARTUP_TIMEOUT); }
public static void startEmbeddedCassandra() throws TTransportException, IOException, InterruptedException, ConfigurationException { startEmbeddedCassandra(DEFAULT_STARTUP_TIMEOUT); }
public static void startEmbeddedCassandra(String yamlFile, long timeout) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, DEFAULT_TMP_DIR, timeout); }
public static void startEmbeddedCassandra(String yamlFile, long timeout) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, DEFAULT_TMP_DIR, timeout); }
public static void startEmbeddedCassandra(String yamlFile, String tmpDir) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, tmpDir, DEFAULT_STARTUP_TIMEOUT); }
public static void startEmbeddedCassandra(String yamlFile) throws TTransportException, IOException, ConfigurationException { startEmbeddedCassandra(yamlFile, DEFAULT_STARTUP_TIMEOUT); }