private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { if (annotation is RemarkableTree) { var marker = annotation as RemarkableTree; var view = mapView.DequeueReusableAnnotation(MKMapViewDefault.AnnotationViewReuseIdentifier) as RemarkableTreeView; if (view == null) { view = new RemarkableTreeView(marker, MKMapViewDefault.AnnotationViewReuseIdentifier); } return(view); } else if (annotation is MKClusterAnnotation) { var cluster = annotation as MKClusterAnnotation; var view = mapView.DequeueReusableAnnotation(MKMapViewDefault.ClusterAnnotationViewReuseIdentifier) as ClusterView; if (view == null) { view = new ClusterView(cluster, MKMapViewDefault.ClusterAnnotationViewReuseIdentifier); } return(view); } else if (annotation != null) { var unwrappedAnnotation = MKAnnotationWrapperExtensions.UnwrapClusterAnnotation(annotation); return(GetViewForAnnotation(mapView, unwrappedAnnotation)); } return(null); }
public void JoinWithin(RoleName joinNode, TimeSpan?max = null, TimeSpan?interval = null) { if (max == null) { max = RemainingOrDefault; } if (interval == null) { interval = TimeSpan.FromSeconds(1); } Cluster.Join(GetAddress(joinNode)); AwaitCondition(() => { ClusterView.RefreshCurrentState(); if (MemberInState(GetAddress(joinNode), new[] { MemberStatus.Up }) && MemberInState(GetAddress(Myself), new[] { MemberStatus.Joining, MemberStatus.Up })) { return(true); } Cluster.Join(GetAddress(joinNode)); return(false); }, max, interval); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnNoWriteEndpointsIfThereIsNoAddressForTheLeader() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturnNoWriteEndpointsIfThereIsNoAddressForTheLeader() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopologyService topologyService = mock(org.neo4j.causalclustering.discovery.CoreTopologyService.class); CoreTopologyService topologyService = mock(typeof(CoreTopologyService)); IDictionary <MemberId, CoreServerInfo> coreMembers = new Dictionary <MemberId, CoreServerInfo>(); coreMembers[member(0)] = addressesForCore(0, false); when(topologyService.LocalCoreServers()).thenReturn(new CoreTopology(_clusterId, false, coreMembers)); when(topologyService.LocalReadReplicas()).thenReturn(new ReadReplicaTopology(emptyMap())); LeaderLocator leaderLocator = mock(typeof(LeaderLocator)); when(leaderLocator.Leader).thenReturn(member(1)); LegacyGetServersProcedure procedure = new LegacyGetServersProcedure(topologyService, leaderLocator, Config, Instance); // when ClusterView clusterView = Run(procedure); // then ClusterView.Builder builder = new ClusterView.Builder(); builder.ReadAddress(addressesForCore(0, false).connectors().boltAddress()); builder.RouteAddress(addressesForCore(0, false).connectors().boltAddress()); assertEquals(builder.Build(), clusterView); }
private void AwaitMemberStatus(Address address, MemberStatus status) { AwaitAssert(() => { ClusterView.RefreshCurrentState(); MemberStatus(address).Should().Be(status); }); }
private void AwaitMembers(params Address[] addresses) { AwaitAssert(() => { ClusterView.RefreshCurrentState(); MemberAddresses().Should().BeEquivalentTo(addresses.ToImmutableHashSet()); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") private ClusterView run(LegacyGetServersProcedure proc) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: private ClusterView Run(LegacyGetServersProcedure proc) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Object[] rows = asList(proc.apply(null, new Object[0], null)).get(0); object[] rows = asList(proc.Apply(null, new object[0], null)).get(0); assertEquals(Config.get(cluster_routing_ttl).Seconds, ( long )rows[0]); return(ClusterView.parse((IList <IDictionary <string, object> >)rows[1])); }
protected void TestWaitMovingMembersToUp() { var onUpLatch = new TestLatch(1); Cluster.RegisterOnMemberUp(() => { onUpLatch.CountDown(); }); RunOn(() => { Cluster.Join(GetAddress(Myself)); AwaitAssert(() => { ClusterView.RefreshCurrentState(); ClusterView.Status.ShouldBe(MemberStatus.Joining); }); }, First); EnterBarrier("first-started"); onUpLatch.IsOpen.ShouldBeFalse(); RunOn(() => { Cluster.Join(GetAddress(First)); }, Second); RunOn(() => { var expectedAddresses = new List <Address> { GetAddress(First), GetAddress(Second) }; AwaitAssert(() => { ClusterView.RefreshCurrentState(); ClusterView.Members.Select(c => c.Address).Except(expectedAddresses).Count().ShouldBe(0); }); ClusterView.Members.All(c => c.Status == MemberStatus.Joining).ShouldBeTrue(); // and it should not change foreach (var _ in Enumerable.Range(1, 5)) { Thread.Sleep(1000); ClusterView.Members.Select(c => c.Address).Except(expectedAddresses).Count().ShouldBe(0); ClusterView.Members.All(c => c.Status == MemberStatus.Joining).ShouldBeTrue(); } }, First, Second); EnterBarrier("second-joined"); RunOn(() => { Cluster.Join(GetAddress(First)); }, Third); AwaitClusterUp(First, Second, Third); onUpLatch.Ready(TestKitSettings.DefaultTimeout); EnterBarrier("after-1"); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } ClusterView that = ( ClusterView )o; return(Objects.Equals(ClusterViewConflict, that.ClusterViewConflict)); }
public async Task <S2SPeer> GetNodePeer(ulong nodeId) { NodeRemoteInfo info = ClusterView.GetNode(nodeId); if (info.LocalConnectionId.HasValue) { return(InternalNet.GetPeer(info.LocalConnectionId.Value)); } else { var peer = (S2SPeer)await InternalNet.Connect(info.InternalEndpoint); info.LocalConnectionId = peer.Channel.Id; return(peer); } }
private void OnClusterViewChanged(ClusterView view) { var removedActors = new List <ActorRemoteInfo>(); foreach (NodeRemoteInfo leaver in view.Leavers) { foreach (ActorRemoteInfo actor in _actorsByName.Values) { if (actor.Key.OwnerNodeId == leaver.NodeId) { ActorRemoteInfo dummy; if (_actorsByName.TryRemove(actor.Name, out dummy)) { removedActors.Add(actor); } } } } foreach (ActorRemoteInfo actor in removedActors) { _actorRemovedEvent.OnNext(actor); } }
public ClusterViewItem(ClusterView value) { this.Value = value; }
private void ClusterViewChanged(ClusterView view) { Log.Info("New Cluster View: \n\t {0}", view); ClusterView = view; }