/** * @return the created inconsistent property */ private static InconsistentProperty createInconsistentProperty() { Map<Optional<String>, List<String>> values = new HashMap<>(); values.put(Optional.ofNullable(null), Arrays.asList("workerHostname1:workerPort", "workerHostname2:workerPort")); values.put(Optional.of("some_value"), Arrays.asList("masterHostname1:port", "masterHostname2:port")); return new InconsistentProperty().setName("my_key").setValues(values); }
/** * Prints the inconsistent properties in server-side configuration. * * @param inconsistentProperties the inconsistent properties to print */ private void printInconsistentProperties( Map<Scope, List<InconsistentProperty>> inconsistentProperties) { for (List<InconsistentProperty> list : inconsistentProperties.values()) { for (InconsistentProperty prop : list) { mPrintStream.println("key: " + prop.getName()); for (Map.Entry<Optional<String>, List<String>> entry : prop.getValues().entrySet()) { mPrintStream.println(" value: " + String.format("%s (%s)", entry.getKey().orElse("no value set"), String.join(", ", entry.getValue()))); } } } } }
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("key", mName) .add("values", formatValues(mValues)) .toString(); }
/** * Creates a new instance of {@link InconsistentProperty} from proto representation. * * @param inconsistentProperty the proto representation of an inconsistent property * @return the instance */ public static InconsistentProperty fromProto( alluxio.grpc.InconsistentProperty inconsistentProperty) { return new InconsistentProperty(inconsistentProperty); } }
@Test public void testToString() { InconsistentProperty inconsistentProperty = createInconsistentProperty(); String result = inconsistentProperty.toString(); Assert.assertFalse(result.contains("Optional")); String expected = "InconsistentProperty{key=my_key, values=" + "no value set (workerHostname1:workerPort, workerHostname2:workerPort), " + "some_value (masterHostname1:port, masterHostname2:port)}"; Assert.assertEquals(expected, result); }
/** * Creates a new instance of {@link InconsistentProperty} from thrift representation. * * @param inconsistentProperty the thrift representation of an inconsistent property * @return the instance */ public static InconsistentProperty fromThrift( alluxio.thrift.InconsistentProperty inconsistentProperty) { return new InconsistentProperty(inconsistentProperty); } }
if (entry.getValue().size() >= 2) { PropertyKey key = entry.getKey(); InconsistentProperty inconsistentProperty = new InconsistentProperty() .setName(key.getName()).setValues(entry.getValue()); Scope scope = key.getScope().equals(Scope.ALL) ? Scope.SERVER : key.getScope(); if (entry.getKey().getConsistencyLevel().equals(ConsistencyCheckLevel.ENFORCE)) {
/** * Checks if the two InconsistentProperty objects are equal. * * @param a the first InconsistentProperty object to be checked * @param b the second InconsistentProperty object to be checked */ private void checkEquality(InconsistentProperty a, InconsistentProperty b) { Assert.assertEquals(a.getName(), b.getName()); Assert.assertEquals(a.getValues(), b.getValues()); Assert.assertEquals(a, b); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("key", mName) .add("values", formatValues(mValues)) .toString(); }
if (entry.getValue().size() >= 2) { PropertyKey key = entry.getKey(); InconsistentProperty inconsistentProperty = new InconsistentProperty() .setName(key.getName()).setValues(entry.getValue()); Scope scope = key.getScope().equals(Scope.ALL) ? Scope.SERVER : key.getScope(); if (entry.getKey().getConsistencyLevel().equals(ConsistencyCheckLevel.ENFORCE)) {