@Test public void assertCreateCoordinatorRegistryCenterWithDigest() throws ReflectiveOperationException { ZookeeperConfiguration zkConfig = getZookeeperConfiguration(RegistryCenterFactory.createCoordinatorRegistryCenter(getConnectionString(), "namespace", "digest")); assertThat(zkConfig.getNamespace(), is("namespace")); assertThat(zkConfig.getDigest(), is("digest")); }
public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) { Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8); if (!Strings.isNullOrEmpty(digest)) { hasher.putString(digest, StandardCharsets.UTF_8); } HashCode hashCode = hasher.hash(); return REG_CENTER_REGISTRY.computeIfAbsent(hashCode, unused -> { final CoordinatorRegistryCenter coordinatorRegistryCenter = newCoordinatorRegistryCenter(connectString, namespace, digest); coordinatorRegistryCenter.init(); return coordinatorRegistryCenter; }); }
RegistryCenterFactory { public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) { Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8); if (!Strings.isNullOrEmpty(digest)) { hasher.putString(digest, StandardCharsets.UTF_8); } HashCode hashCode = hasher.hash(); return REG_CENTER_REGISTRY.computeIfAbsent(hashCode, unused -> { final CoordinatorRegistryCenter coordinatorRegistryCenter = newCoordinatorRegistryCenter(connectString, namespace, digest); coordinatorRegistryCenter.init(); return coordinatorRegistryCenter; }); } }
RegistryCenterFactory { public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) { Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8); if (!Strings.isNullOrEmpty(digest)) { hasher.putString(digest, StandardCharsets.UTF_8); } HashCode hashCode = hasher.hash(); return REG_CENTER_REGISTRY.computeIfAbsent(hashCode, unused -> { final CoordinatorRegistryCenter coordinatorRegistryCenter = newCoordinatorRegistryCenter(connectString, namespace, digest); coordinatorRegistryCenter.init(); return coordinatorRegistryCenter; }); }  }
RegistryCenterFactory { public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) { Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8); if (!Strings.isNullOrEmpty(digest)) { hasher.putString(digest, StandardCharsets.UTF_8); } HashCode hashCode = hasher.hash(); return REG_CENTER_REGISTRY.computeIfAbsent(hashCode, unused -> { final CoordinatorRegistryCenter coordinatorRegistryCenter = newCoordinatorRegistryCenter(connectString, namespace, digest); coordinatorRegistryCenter.init(); return coordinatorRegistryCenter; }); }  static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest); }
RegistryCenterFactory { public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) { Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8); if (!Strings.isNullOrEmpty(digest)) { hasher.putString(digest, StandardCharsets.UTF_8); } HashCode hashCode = hasher.hash(); return REG_CENTER_REGISTRY.computeIfAbsent(hashCode, unused -> { final CoordinatorRegistryCenter coordinatorRegistryCenter = newCoordinatorRegistryCenter(connectString, namespace, digest); coordinatorRegistryCenter.init(); return coordinatorRegistryCenter; }); }  static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest);  }