예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public System.Nullable<long> call() throws Exception
        public override long?Call()
        {
            long lastCommittedTransactionId;

            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), Lifespan life = new Lifespan())
            {
                TransactionIdStore       transactionIdStore       = new SimpleTransactionIdStore();
                TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
                LogFiles logFiles = life.Add(CreateLogFiles(transactionIdStore, fileSystem));

                TransactionAppender transactionAppender = life.Add(CreateBatchingTransactionAppender(transactionIdStore, transactionMetadataCache, logFiles));

                ExecutorService executorService = Executors.newFixedThreadPool(_threads);
                try
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?>[] handlers = new java.util.concurrent.Future[threads];
                    Future <object>[] handlers = new Future[_threads];
                    for (int i = 0; i < _threads; i++)
                    {
                        TransactionRepresentationFactory factory = new TransactionRepresentationFactory();
                        Worker task = new Worker(transactionAppender, factory, _condition);
                        handlers[i] = executorService.submit(task);
                    }

                    // wait for all the workers to complete
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.concurrent.Future<?> handle : handlers)
                    foreach (Future <object> handle in handlers)
                    {
                        handle.get();
                    }
                }
                finally
                {
                    executorService.shutdown();
                }

                lastCommittedTransactionId = transactionIdStore.LastCommittedTransactionId;
            }

            return(lastCommittedTransactionId);
        }
예제 #2
0
 internal Worker(TransactionAppender transactionAppender, TransactionRepresentationFactory factory, System.Func <bool> condition)
 {
     this._transactionAppender = transactionAppender;
     this._factory             = factory;
     this._condition           = condition;
 }