Beispiel #1
0
 public HazelcastClient(HazelcastConnector connector, JobScheduler scheduler, LogProvider logProvider, Config config, MemberId myself)
 {
     this._hzInstance                   = new RobustHazelcastWrapper(connector);
     this._config                       = config;
     this._log                          = logProvider.getLog(this.GetType());
     this._scheduler                    = new RobustJobSchedulerWrapper(scheduler, _log);
     this._connectorAddresses           = ClientConnectorAddresses.ExtractFromConfig(config);
     this._transactionSource            = config.Get(CausalClusteringSettings.transaction_advertised_address);
     this._timeToLive                   = config.Get(CausalClusteringSettings.read_replica_time_to_live).toMillis();
     this._refreshPeriod                = config.Get(CausalClusteringSettings.cluster_topology_refresh).toMillis();
     this._myself                       = myself;
     this._groups                       = config.Get(CausalClusteringSettings.server_groups);
     this._topologyServiceRetryStrategy = ResolveStrategy(_refreshPeriod, logProvider);
     this._dbName                       = config.Get(CausalClusteringSettings.database);
     this._coreRoles                    = emptyMap();
 }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReconnectIfHazelcastConnectionInvalidated() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReconnectIfHazelcastConnectionInvalidated()
        {
            // given
            HazelcastConnector connector  = mock(typeof(HazelcastConnector));
            HazelcastInstance  hzInstance = mock(typeof(HazelcastInstance));

            when(connector.ConnectToHazelcast()).thenReturn(hzInstance);

            RobustHazelcastWrapper hzWrapper = new RobustHazelcastWrapper(connector);

            // when
            hzWrapper.Perform(hz =>
            {
            });

            // then
            verify(connector, times(1)).connectToHazelcast();

            // then
            try
            {
                hzWrapper.Perform(hz =>
                {
                    throw new com.hazelcast.core.HazelcastInstanceNotActiveException();
                });
                fail();
            }
            catch (HazelcastInstanceNotActiveException)
            {
                // expected
            }

            // when
            hzWrapper.Perform(hz =>
            {
            });
            hzWrapper.Perform(hz =>
            {
            });

            // then
            verify(connector, times(2)).connectToHazelcast();
        }