コード例 #1
0
 public override void CheckClientTrusted(X509Certificate[] x509Certificates, string s)
 {
     foreach (X509Certificate x509Certificate in x509Certificates)
     {
         _certSink.accept(x509Certificate);
     }
 }
コード例 #2
0
ファイル: DelayedBuffer.cs プロジェクト: Neo4Net/Neo4Net
        /// <summary>
        /// Should be called every now and then to check for safe thresholds of buffered chunks and potentially
        /// release them onto the <seealso cref="Consumer"/>.
        /// </summary>
        public virtual void Maintenance()
        {
            lock (this)
            {
                Flush();
            }

            if (!_chunks.Empty)
            {
                lock ( _chunks )
                {
                    // Potentially hand over chunks to the consumer
                    while (!_chunks.Empty)
                    {
                        Chunk <T> candidate = _chunks.peek();
                        if (_safeThreshold.test(candidate.Threshold))
                        {
                            _chunkConsumer.accept(candidate.Values);
                            _chunks.remove();
                        }
                        else
                        {
                            // The chunks are ordered by chunkThreshold, so we know that no more chunks will qualify anyway
                            break;
                        }
                    }
                }
            }
        }
コード例 #3
0
 public override void WaitingForCoreMembers(int minimumCount)
 {
     _binderLimit.accept(() =>
     {
         string message = "Waiting for a total of %d core members...";
         _user.info(format(message, minimumCount));
     });
 }
コード例 #4
0
ファイル: TimedRepository.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void begin(KEY key) throws ConcurrentAccessException
        public virtual void Begin(KEY key)
        {
            VALUE instance = _factory.newInstance();
            Entry existing;

            if ((existing = _repo.putIfAbsent(key, new Entry(this, instance))) != null)
            {
                _reaper.accept(instance);                           // Need to clear up our optimistically allocated value
                throw new ConcurrentAccessException(string.Format("Cannot begin '{0}', because {1} with that key already exists.", key, existing));
            }
        }
コード例 #5
0
        // The stamp is in two 32-bit parts:
        // The high bits are the number of IOs performed since the last pause.
        // The low bits is the 32-bit timestamp in milliseconds (~25 day range) since the last pause.
        // We keep adding summing up the IOs until either a quantum elapses, or we've exhausted the IOs we're allowed in
        // this quantum. If we've exhausted our IOs, we pause for the rest of the quantum.
        // We don't make use of the Flushable at this point, because IOs from fsyncs have a high priority, so they
        // might jump the IO queue and cause delays for transaction log IOs. Further, fsync on some file systems also
        // flush the entire IO queue, which can cause delays on IO rate limited cloud machines.
        // We need the Flushable to be implemented in terms of sync_file_range before we can make use of it.
        // NOTE: The check-pointer IOPS setting is documented as being a "best effort" hint. We are making use of that
        // wording here, and not compensating for over-counted IOs. For instance, if we receive 2 quantums worth of IOs
        // in one quantum, we are not going to sleep for two quantums. The reason is that such compensation algorithms
        // can easily over-compensate, and end up sleeping a lot more than what makes sense for other rate limiting factors
        // in the system, thus wasting IO bandwidth. No, "best effort" here means that likely end up doing a little bit
        // more IO than what we've been configured to allow, but that's okay. If it's a problem, people can just reduce
        // their IOPS limit setting a bit more.

        public override long MaybeLimitIO(long previousStamp, int recentlyCompletedIOs, Flushable flushable)
        {
            long state = _stateUpdater.get(this);

            if (GetDisabledCounter(state) > 0)
            {
                return(Org.Neo4j.Io.pagecache.IOLimiter_Fields.INITIAL_STAMP);
            }

            long now  = CurrentTimeMillis() & _timeMask;
            long then = previousStamp & _timeMask;

            if (now - then > QUANTUM_MILLIS)
            {
                return(now + ((( long )recentlyCompletedIOs) << TIME_BITS));
            }

            long ioSum = (previousStamp >> TIME_BITS) + recentlyCompletedIOs;

            if (ioSum >= GetIOPQ(state))
            {
                long millisLeftInQuantum = QUANTUM_MILLIS - (now - then);
                _pauseNanos.accept(this, TimeUnit.MILLISECONDS.toNanos(millisLeftInQuantum));
                return(CurrentTimeMillis() & _timeMask);
            }

            return(then + (ioSum << TIME_BITS));
        }
コード例 #6
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        public override OUTPUT Apply(INPUT retriableInput, System.Func <INPUT, OUTPUT> retriable, System.Predicate <OUTPUT> wasRetrySuccessful)
        {
            Log    log              = _logProvider.getLog(typeof(MultiRetryStrategy));
            OUTPUT result           = retriable(retriableInput);
            int    currentIteration = 0;

            while (!wasRetrySuccessful(result) && currentIteration++ < _retries)
            {
                log.Debug("Try attempt was unsuccessful for input: %s\n", retriableInput);
                _sleeper.accept(_delayInMillis);
                result = retriable(retriableInput);
            }
            return(result);
        }
コード例 #7
0
 /// <summary>
 /// Even if instances are meant to be accessed by a single thread at a time, lifecycle calls
 /// can guard for it nonetheless. Only the first call to close will perform close.
 /// </summary>
 public override void Close()
 {
     lock (this)
     {
         if (!_closed && _currentBatch != null)
         {
             long id;
             while ((id = _currentBatch.nextId()) != VALUE_REPRESENTING_NULL)
             {
                 _excessIdConsumer.accept(id);
             }
             _currentBatch = null;
         }
         _closed = true;
     }
 }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws java.net.URISyntaxException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            if (_portRegistryOverrider != null)
            {
                _portRegistryOverrider.accept(_portRegistry);
            }
            else
            {
                when(_portRegistry.getLocalAddress("bolt")).thenReturn(new HostnamePort("localhost", 7687));
            }

            DependencyResolver dependencyResolver = mock(typeof(DependencyResolver));

            when(dependencyResolver.ResolveDependency(typeof(ConnectorPortRegister))).thenReturn(_portRegistry);
            when(_neoServer.Database.Graph.DependencyResolver).thenReturn(dependencyResolver);
        }
コード例 #9
0
        private Config MockConfig()
        {
            Dictionary <string, string> settings = new Dictionary <string, string>();

            settings[GraphDatabaseSettings.auth_enabled.name()]  = "false";
            settings[(new BoltConnector("bolt")).type.name()]    = "BOLT";
            settings[(new BoltConnector("bolt")).enabled.name()] = "true";
            settings[ServerSettings.management_api_path.name()]  = _managementUri.ToString();
            settings[ServerSettings.rest_api_path.name()]        = _dataUri.ToString();

            Config config = Config.defaults(settings);

            if (_configOverrider != null)
            {
                _configOverrider.accept(config);
            }

            return(config);
        }
コード例 #10
0
ファイル: FacadeMethod.cs プロジェクト: Neo4Net/Neo4Net
 public override void Accept(T t)
 {
     _callable.accept(t);
 }
コード例 #11
0
 public override void WaitingToHearFromLeader()
 {
     _waiterLimit.accept(() => _user.info("Waiting to hear from leader..."));
 }
コード例 #12
0
 public override void Accept(PageCursor cursor)
 {
     cursor.PutByte(_state);
     _additionalHeaderWriter.accept(cursor);
 }