Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("Duplicates") @Test public void stressCache() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StressCache()
        {
            StringFactory factory             = new StringFactory();
            TemporalIndexCache <string> cache = new TemporalIndexCache <string>(factory);

            ExecutorService pool = Executors.newFixedThreadPool(20);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?>[] futures = new java.util.concurrent.Future[100];
            Future <object>[] futures        = new Future[100];
            AtomicBoolean     shouldContinue = new AtomicBoolean(true);

            try
            {
                for (int i = 0; i < futures.Length; i++)
                {
                    futures[i] = pool.submit(new CacheStresser(cache, shouldContinue));
                }

                Thread.Sleep(5_000);

                shouldContinue.set(false);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.concurrent.Future<?> future : futures)
                foreach (Future <object> future in futures)
                {
                    future.get(10, TimeUnit.SECONDS);
                }
            }
            finally
            {
                pool.shutdown();
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: <T> void loadExistingIndexes(TemporalIndexCache<T> indexCache) throws java.io.IOException
        internal virtual void LoadExistingIndexes <T>(TemporalIndexCache <T> indexCache)
        {
            foreach (FileLayout fileLayout in Existing())
            {
                indexCache.Select(fileLayout.valueGroup);
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void stressInstantiationWithClose() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StressInstantiationWithClose()
        {
            // given
            StringFactory factory             = new StringFactory();
            TemporalIndexCache <string> cache = new TemporalIndexCache <string>(factory);
            Race       race = (new Race()).withRandomStartDelays();
            MutableInt instantiatedAtClose = new MutableInt();

            race.AddContestant(() =>
            {
                try
                {
                    cache.UncheckedSelect(_valueGroups[0]);
                    cache.UncheckedSelect(_valueGroups[1]);
                }
                catch (System.InvalidOperationException)
                {
                    // This exception is OK since it may have been closed
                }
            }, 1);
            race.AddContestant(() =>
            {
                cache.CloseInstantiateCloseLock();
                instantiatedAtClose.Value = count(cache);
            }, 1);

            // when
            race.Go();

            // then
            try
            {
                cache.UncheckedSelect(_valueGroups[2]);
                fail("No instantiation after closed");
            }
            catch (System.InvalidOperationException)
            {
                // good
            }
            assertEquals(instantiatedAtClose.intValue(), count(cache));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIterateOverCreatedParts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIterateOverCreatedParts()
        {
            StringFactory factory             = new StringFactory();
            TemporalIndexCache <string> cache = new TemporalIndexCache <string>(factory);

            assertEquals(Iterables.count(cache), 0);

            cache.Select(LOCAL_DATE_TIME);
            cache.Select(ZONED_TIME);

            assertThat(cache, containsInAnyOrder("LocalDateTime", "ZonedTime"));

            cache.Select(DATE);
            cache.Select(LOCAL_TIME);
            cache.Select(LOCAL_DATE_TIME);
            cache.Select(ZONED_TIME);
            cache.Select(ZONED_DATE_TIME);
            cache.Select(DURATION);

            assertThat(cache, containsInAnyOrder("Date", "LocalDateTime", "ZonedDateTime", "LocalTime", "ZonedTime", "Duration"));
        }
Esempio n. 5
0
 internal CacheStresser(TemporalIndexCache <string> cache, AtomicBoolean shouldContinue)
 {
     this.Cache          = cache;
     this.ShouldContinue = shouldContinue;
 }