コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveTaskQueueSizeEqualToMaxNumberOfProcessors() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaveTaskQueueSizeEqualToMaxNumberOfProcessors()
        {
            // GIVEN
            StageControl control = mock(typeof(StageControl));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);
            const int     processors    = 2;
            int           maxProcessors = 5;
            Configuration configuration = new ConfigurationAnonymousInnerClass(this, maxProcessors);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ProcessorStep<Void> step = new BlockingProcessorStep(control, configuration, processors, latch);
            ProcessorStep <Void> step = new BlockingProcessorStep(control, configuration, processors, latch);

            step.Start(ORDER_SEND_DOWNSTREAM);
            step.Processors(1);                 // now at 2
            // adding up to max processors should be fine
            for (int i = 0; i < processors + maxProcessors; i++)
            {
                step.Receive(i, null);
            }

            // WHEN
            Future <Void> receiveFuture = T2.execute(Receive(processors, step));

            T2.get().waitUntilThreadState(Thread.State.TIMED_WAITING);
            latch.Signal();

            // THEN
            receiveFuture.get();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCalculateCorrectMaxMemorySetting() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCalculateCorrectMaxMemorySetting()
        {
            long totalMachineMemory = OsBeanUtil.TotalPhysicalMemory;

            assumeTrue(totalMachineMemory != VALUE_UNAVAILABLE);

            // given
            int           percent = 70;
            Configuration config  = new ConfigurationAnonymousInnerClass(this, percent);

            // when
            long memory = config.MaxMemoryUsage();

            // then
            long expected = ( long )((totalMachineMemory - Runtime.Runtime.maxMemory()) * (percent / 100D));
            long diff     = abs(expected - memory);

            assertThat(diff, lessThan(( long )(expected / 10D)));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCapUndesiredSlaveCountPushLogging()
        public virtual void ShouldCapUndesiredSlaveCountPushLogging()
        {
            // GIVEN
            int serverId = 1;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.InstanceId instanceId = new org.neo4j.cluster.InstanceId(serverId);
            InstanceId    instanceId = new InstanceId(serverId);
            Configuration config     = new ConfigurationAnonymousInnerClass(this, instanceId);
            Log           logger     = mock(typeof(Log));
            Slaves        slaves     = mock(typeof(Slaves));

            when(slaves.GetSlaves()).thenReturn(Collections.emptyList());
            CommitPusher          pusher     = mock(typeof(CommitPusher));
            TransactionPropagator propagator = Life.add(new TransactionPropagator(config, logger, slaves, pusher));

            // WHEN
            for (int i = 0; i < 10; i++)
            {
                propagator.Committed(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID, serverId);
            }

            // THEN
            verify(logger, times(1)).info(anyString());
        }
コード例 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void main(String[] arguments) throws java.io.IOException
        public static void Main(string[] arguments)
        {
            Args          args                  = Args.parse(arguments);
            long          nodeCount             = Settings.parseLongWithUnit(args.Get("nodes", null));
            long          relationshipCount     = Settings.parseLongWithUnit(args.Get("relationships", null));
            int           labelCount            = args.GetNumber("labels", 4).intValue();
            int           relationshipTypeCount = args.GetNumber("relationship-types", 4).intValue();
            File          dir        = new File(args.Get(ImportTool.Options.StoreDir.key()));
            long          randomSeed = args.GetNumber("random-seed", currentTimeMillis()).longValue();
            Configuration config     = Configuration.COMMAS;

            Extractors extractors = new Extractors(config.ArrayDelimiter());
            IdType     idType     = IdType.valueOf(args.Get("id-type", IdType.INTEGER.name()));

            Groups groups             = new Groups();
            Header nodeHeader         = ParseNodeHeader(args, idType, extractors, groups);
            Header relationshipHeader = ParseRelationshipHeader(args, idType, extractors, groups);

            Config dbConfig;
            string dbConfigFileName = args.Get(ImportTool.Options.DatabaseConfig.key(), null);

            if (!string.ReferenceEquals(dbConfigFileName, null))
            {
                dbConfig = (new Config.Builder()).withFile(new File(dbConfigFileName)).build();
            }
            else
            {
                dbConfig = Config.defaults();
            }

            bool highIo = args.GetBoolean(ImportTool.Options.HighIo.key());

            LogProvider logging         = NullLogProvider.Instance;
            long        pageCacheMemory = args.GetNumber("pagecache-memory", [email protected]_Fields.MaxPageCacheMemory).longValue();

            [email protected] importConfig = new ConfigurationAnonymousInnerClass(args, highIo, pageCacheMemory);

            float factorBadNodeData         = args.GetNumber("factor-bad-node-data", 0).floatValue();
            float factorBadRelationshipData = args.GetNumber("factor-bad-relationship-data", 0).floatValue();

            Input input = new DataGeneratorInput(nodeCount, relationshipCount, idType, Collector.EMPTY, randomSeed, 0, nodeHeader, relationshipHeader, labelCount, relationshipTypeCount, factorBadNodeData, factorBadRelationshipData);

            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), Lifespan life = new Lifespan())
            {
                BatchImporter consumer;
                if (args.GetBoolean("to-csv"))
                {
                    consumer = new CsvOutput(dir, nodeHeader, relationshipHeader, config);
                }
                else
                {
                    Console.WriteLine("Seed " + randomSeed);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.scheduler.JobScheduler jobScheduler = life.add(createScheduler());
                    JobScheduler jobScheduler = life.Add(createScheduler());
                    consumer = BatchImporterFactory.withHighestPriority().instantiate(DatabaseLayout.of(dir), fileSystem, null, importConfig, new SimpleLogService(logging, logging), defaultVisible(jobScheduler), EMPTY, dbConfig, RecordFormatSelector.selectForConfig(dbConfig, logging), NO_MONITOR, jobScheduler);
                    ImportTool.PrintOverview(dir, Collections.emptyList(), Collections.emptyList(), importConfig, System.out);
                }
                consumer.DoImport(input);
            }
        }