@Test public void test_valueOf_with_valid_string() { Stream.of(".", ":").forEach(ns -> { Stream.of( tuple2(NODE_NAME, "foo"), tuple2(NODE_HOSTNAME, "foo"), tuple2(NODE_PORT, "9410") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); rejectInput(tuple.t1 + "=", "Invalid input: '" + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); rejectInput(tuple.t1 + "=" + tuple.t2, "Invalid input: '" + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' cannot be set at cluster level"); allowInput("stripe.1" + ns + tuple.t1, tuple.t1, STRIPE, 1, null, null, null); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' cannot be set at stripe level"); allowInput("stripe.1.node.1" + ns + tuple.t1, tuple.t1, NODE, 1, 1, null, null); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, tuple.t1, NODE, 1, 1, null, tuple.t2); }); Stream.of( tuple2(NODE_GROUP_PORT, "9410"), tuple2(NODE_BIND_ADDRESS, "0.0.0.0"), tuple2(NODE_GROUP_BIND_ADDRESS, "0.0.0.0"), tuple2(NODE_LOG_DIR, "foo/bar"), tuple2(NODE_METADATA_DIR, "foo/bar") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); rejectInput(tuple.t1 + "=", "Invalid input: '" + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput(tuple.t1 + "=" + tuple.t2, tuple.t1, CLUSTER, null, null, null, tuple.t2); allowInput("stripe.1" + ns + tuple.t1, tuple.t1, STRIPE, 1, null, null, null); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, tuple.t1, STRIPE, null, null, null, tuple.t2); allowInput("stripe.1.node.1" + ns + tuple.t1, tuple.t1, NODE, 1, 1, null, null); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, tuple.t1, NODE, 1, 1, null, tuple.t2); }); Stream.of( tuple2(NODE_BACKUP_DIR, "foo/bar"), tuple2(SECURITY_DIR, "foo/bar"), tuple2(SECURITY_AUDIT_LOG_DIR, "foo/bar") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=", tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=" + tuple.t2, tuple.t1, CLUSTER, null, null, null, tuple.t2); allowInput("stripe.1" + ns + tuple.t1, tuple.t1, STRIPE, 1, null, null, null); allowInput("stripe.1" + ns + tuple.t1 + "=", tuple.t1, STRIPE, null, null, null, null); allowInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, tuple.t1, STRIPE, null, null, null, tuple.t2); allowInput("stripe.1.node.1" + ns + tuple.t1, tuple.t1, NODE, 1, 1, null, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=", tuple.t1, NODE, 1, 1, null, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, tuple.t1, NODE, 1, 1, null, tuple.t2); }); Stream.of( tuple2(CLIENT_RECONNECT_WINDOW, "20s"), tuple2(FAILOVER_PRIORITY, "availability"), tuple2(CLIENT_LEASE_DURATION, "20s"), tuple2(SECURITY_SSL_TLS, "true"), tuple2(SECURITY_WHITELIST, "true") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); rejectInput(tuple.t1 + "=", "Invalid input: '" + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput(tuple.t1 + "=" + tuple.t2, tuple.t1, CLUSTER, null, null, null, tuple.t2); rejectInput("stripe.1" + ns + tuple.t1, "Invalid input: 'stripe.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1.node.1" + ns + tuple.t1, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); }); Stream.of( tuple2(CLUSTER_NAME, "foo"), tuple2(SECURITY_AUTHC, "certificate") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=", tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=" + tuple.t2, tuple.t1, CLUSTER, null, null, null, tuple.t2); rejectInput("stripe.1" + ns + tuple.t1, "Invalid input: 'stripe.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1.node.1" + ns + tuple.t1, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); }); Stream.of( tuple2(NODE_CONFIG_DIR, "foo/bar") ).forEach(tuple -> { rejectInput(tuple.t1.toString(), "Invalid input: '" + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at cluster level"); rejectInput(tuple.t1 + "=", "Invalid input: '" + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at cluster level"); rejectInput(tuple.t1 + "=" + tuple.t2, "Invalid input: '" + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at cluster level"); rejectInput("stripe.1" + ns + tuple.t1, "Invalid input: 'stripe.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1.node.1" + ns + tuple.t1, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); }); Stream.of( tuple2(LICENSE_FILE, "/path/to/license.xml") ).forEach(tuple -> { rejectInput(tuple.t1.toString(), "Invalid input: '" + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' cannot be read or cleared"); rejectInput(tuple.t1 + "=", "Invalid input: '" + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' requires a value"); allowInput(tuple.t1 + "=" + tuple.t2, tuple.t1, CLUSTER, null, null, null, tuple.t2); rejectInput("stripe.1" + ns + tuple.t1, "Invalid input: 'stripe.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1.node.1" + ns + tuple.t1, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); }); Stream.of( tuple3(TC_PROPERTIES, "a.b.c", "d.e.f"), tuple3(DATA_DIRS, "a.b.c", "foo/bar") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=", tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, tuple.t1, CLUSTER, null, null, null, tuple.t2 + ":" + tuple.t3); allowInput(tuple.t1 + "." + tuple.t2, tuple.t1, CLUSTER, null, null, tuple.t2, null); allowInput(tuple.t1 + "." + tuple.t2 + "=", tuple.t1, CLUSTER, null, null, tuple.t2, null); allowInput(tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, tuple.t1, CLUSTER, null, null, tuple.t2, tuple.t3); allowInput("stripe.1" + ns + tuple.t1, tuple.t1, STRIPE, 1, null, null, null); allowInput("stripe.1" + ns + tuple.t1 + "=", tuple.t1, STRIPE, null, null, null, null); allowInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, tuple.t1, STRIPE, null, null, null, tuple.t2 + ":" + tuple.t3); allowInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2, tuple.t1, STRIPE, 1, null, tuple.t2, null); allowInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "=", tuple.t1, STRIPE, null, null, tuple.t2, null); allowInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, tuple.t1, STRIPE, null, null, tuple.t2, tuple.t3); allowInput("stripe.1.node.1" + ns + tuple.t1, tuple.t1, NODE, 1, 1, null, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=", tuple.t1, NODE, 1, 1, null, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, tuple.t1, NODE, 1, 1, null, tuple.t2 + ":" + tuple.t3); allowInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2, tuple.t1, NODE, 1, 1, tuple.t2, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "=", tuple.t1, NODE, 1, 1, tuple.t2, null); allowInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, tuple.t1, NODE, 1, 1, tuple.t2, tuple.t3); }); Stream.of( tuple3(OFFHEAP_RESOURCES, "a.b.c", "1GB") ).forEach(tuple -> { allowInput(tuple.t1.toString(), tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=", tuple.t1, CLUSTER, null, null, null, null); allowInput(tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, tuple.t1, CLUSTER, null, null, null, tuple.t2 + ":" + tuple.t3); allowInput(tuple.t1 + "." + tuple.t2, tuple.t1, CLUSTER, null, null, tuple.t2, null); allowInput(tuple.t1 + "." + tuple.t2 + "=", tuple.t1, CLUSTER, null, null, tuple.t2, null); allowInput(tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, tuple.t1, CLUSTER, null, null, tuple.t2, tuple.t3); rejectInput("stripe.1" + ns + tuple.t1, "Invalid input: 'stripe.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, "Invalid input: 'stripe.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2, "Invalid input: 'stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "=", "Invalid input: 'stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, "Invalid input: 'stripe.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at stripe level"); rejectInput("stripe.1.node.1" + ns + tuple.t1, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "=" + tuple.t2 + ":" + tuple.t3 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "=", "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "='. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); rejectInput("stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3, "Invalid input: 'stripe.1.node.1" + ns + tuple.t1 + "." + tuple.t2 + "=" + tuple.t3 + "'. Reason: Setting '" + tuple.t1 + "' does not allow any operation at node level"); }); }); }
@Override public String toString() { return rawInput; }
Configuration { @Override public String toString() { return rawInput; } }
Configuration { @Override public String toString() { return rawInput; } private  Configuration(String rawInput, Setting setting, Scope level, Integer stripeId, Integer nodeId, String key, String value); }
Configuration { @Override public String toString() { return rawInput; } private  Configuration(String rawInput, Setting setting, Scope level, Integer stripeId, Integer nodeId, String key, String value); Scope getLevel(); int getStripeId(); int getNodeId(); Setting getSetting(); String getKey(); Optional<String> getValue(); void validate(ClusterState clusterState, Operation operation); boolean duplicates(Configuration other); boolean matchConfigPropertyKey(String key); Collection<? extends PropertyHolder> apply(PropertyHolder propertyHolder); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); Stream<? extends PropertyHolder> findTargets(PropertyHolder from); static Configuration valueOf(String key, String value); static Configuration valueOf(String input); static Configuration valueOf(Setting setting); static Configuration valueOf(Setting setting, int stripeId); static Configuration valueOf(Setting setting, int stripeId, int nodeId); }
Configuration { @Override public String toString() { return rawInput; } private  Configuration(String rawInput, Setting setting, Scope level, Integer stripeId, Integer nodeId, String key, String value); Scope getLevel(); int getStripeId(); int getNodeId(); Setting getSetting(); String getKey(); Optional<String> getValue(); void validate(ClusterState clusterState, Operation operation); boolean duplicates(Configuration other); boolean matchConfigPropertyKey(String key); Collection<? extends PropertyHolder> apply(PropertyHolder propertyHolder); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); Stream<? extends PropertyHolder> findTargets(PropertyHolder from); static Configuration valueOf(String key, String value); static Configuration valueOf(String input); static Configuration valueOf(Setting setting); static Configuration valueOf(Setting setting, int stripeId); static Configuration valueOf(Setting setting, int stripeId, int nodeId);  }