internal static ReadReplicaTopology FakeReadReplicaTopology(MemberId[] readReplicaIds, System.Func <MemberId, ISet <string> > groupGenerator) { Debug.Assert(readReplicaIds.Length > 0); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger offset = new java.util.concurrent.atomic.AtomicInteger(10_000); AtomicInteger offset = new AtomicInteger(10_000); System.Func <MemberId, ReadReplicaInfo> toReadReplicaInfo = memberId => ReadReplicaInfo(memberId, offset, groupGenerator); IDictionary <MemberId, ReadReplicaInfo> readReplicas = Stream.of(readReplicaIds).collect(Collectors.toMap(System.Func.identity(), toReadReplicaInfo)); return(new ReadReplicaTopology(readReplicas)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expected = java.util.concurrent.TimeoutException.class) public void shouldTimeoutIfPublishContinuallyFailsWithTransientErrors() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTimeoutIfPublishContinuallyFailsWithTransientErrors() { // given //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other)); CoreTopology bootstrappableTopology = new CoreTopology(null, true, members); CoreTopologyService topologyService = mock(typeof(CoreTopologyService)); when(topologyService.SetClusterId(any(), anyString())).thenThrow(typeof(OperationTimeoutException)); // Causes a retry when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology); ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService); // when binder.BindToCluster(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBootstrapWhenBootstrappable() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBootstrapWhenBootstrappable() { // given //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other)); CoreTopology bootstrappableTopology = new CoreTopology(null, true, members); CoreTopologyService topologyService = mock(typeof(CoreTopologyService)); when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology); when(topologyService.SetClusterId(any(), eq("default"))).thenReturn(true); CoreSnapshot snapshot = mock(typeof(CoreSnapshot)); when(_coreBootstrapper.bootstrap(any())).thenReturn(snapshot); ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService); // when BoundState boundState = binder.BindToCluster(); // then verify(_coreBootstrapper).bootstrap(any()); Optional <ClusterId> clusterId = binder.Get(); assertTrue(clusterId.Present); verify(topologyService).setClusterId(clusterId.get(), "default"); assertTrue(boundState.Snapshot().Present); assertEquals(boundState.Snapshot().get(), snapshot); }
private IDictionary <string, long> CountTransactionsByUsername() { return(EnterpriseBuiltInDbmsProcedures.countTransactionByUsername(EnterpriseBuiltInDbmsProcedures.getActiveTransactions(Neo.LocalGraph.DependencyResolver).Where(tx => !tx.terminationReason().Present).Select(tx => tx.subject().username())).collect(Collectors.toMap(r => r.username, r => r.activeTransactions))); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: public static <K,V> java.util.stream.Collector<Pair<K,V>,?,java.util.Map<K,V>> pairsToMap() public static Collector <Pair <K, V>, ?, IDictionary <K, V> > PairsToMap <K, V>() { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: return(Collectors.toMap(Pair::first, Pair::other)); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: public static <K,V> java.util.stream.Collector<java.util.Map.Entry<K,V>,?,java.util.Map<K,V>> entriesToMap() public static Collector <KeyValuePair <K, V>, ?, IDictionary <K, V> > EntriesToMap <K, V>() { return(Collectors.toMap(DictionaryEntry.getKey, DictionaryEntry.getValue)); }
public static IDictionary <MemberId, ReadReplicaInfo> ReadReplicaInfoMap(params int[] ids) { return(Arrays.stream(ids).mapToObj(TestTopology.addressesForReadReplica).collect(Collectors.toMap(p => new MemberId(System.Guid.randomUUID()), System.Func.identity()))); }
internal static IDictionary <MemberId, ReadReplicaInfo> ReadReplicas(HazelcastInstance hazelcastInstance, Log log) { Pair <ISet <string>, IDictionary <string, IMap <string, string> > > validatedSimpleAttrMaps = validatedSimpleAttrMaps(hazelcastInstance); ISet <string> missingAttrKeys = validatedSimpleAttrMaps.First(); IDictionary <string, IMap <string, string> > simpleAttrMaps = validatedSimpleAttrMaps.Other(); MultiMap <string, string> serverGroupsMap = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP); if (serverGroupsMap == null) { missingAttrKeys.Add(SERVER_GROUPS_MULTIMAP); } if (missingAttrKeys.Count > 0) { // We might well not have any read replicas, in which case missing maps is not an error, but we *can't* have some maps and not others //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: bool missingAllKeys = missingAttrKeys.containsAll(RrAttrKeys) && missingAttrKeys.Contains(SERVER_GROUPS_MULTIMAP); if (!missingAllKeys) { string missingAttrs = string.join(", ", missingAttrKeys); log.Warn("Some, but not all, of the read replica attribute maps are null, including %s", missingAttrs); } return(emptyMap()); } Stream <string> readReplicaHzIds = simpleAttrMaps[READ_REPLICA_BOLT_ADDRESS_MAP].Keys.stream(); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IDictionary <MemberId, ReadReplicaInfo> validatedReadReplicas = readReplicaHzIds.flatMap(hzId => Streams.ofNullable(BuildReadReplicaFromAttrMap(hzId, simpleAttrMaps, serverGroupsMap, log))).collect(Collectors.toMap(Pair::first, Pair::other)); return(validatedReadReplicas); }