Beispiel #1
0
        private void TryMt(EPServiceProvider epService, int numEvents)
        {
            var epl =
                "create table varTotal (key string primary key, total sum(int));\n" +
                "into table varTotal select TheString, sum(IntPrimitive) as total from SupportBean group by TheString;\n" +
                "@Name('listen') select varTotal[p00].total as c0 from SupportBean_S0;\n";
            epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);
            epService.EPRuntime.SendEvent(new SupportBean("A", 10));

            var queueCreated = new LinkedBlockingQueue<string>();
            var writeRunnable = new WriteRunnable(epService, numEvents, queueCreated);
            var readRunnable = new ReadRunnable(epService, numEvents, queueCreated);

            // start
            var t1 = new Thread(writeRunnable.Run);
            var t2 = new Thread(readRunnable.Run);
            t1.Start();
            t2.Start();

            // join
            Log.Info("Waiting for completion");
            t1.Join();
            t2.Join();

            Assert.IsNull(writeRunnable.Exception);
            Assert.IsNull(readRunnable.Exception);
        }
 /// <summary> Constructor.</summary>
 /// <param name="tagger">- the POS tagger plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public PosTaggerThread(PosTagger tagger, LinkedBlockingQueue<SetOfSentences> in_Renamed,
 LinkedBlockingQueue<Sentence> out_Renamed)
 {
     this.tagger = tagger;
     this.in_Renamed = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
Beispiel #3
0
 /// <summary> Constructor.</summary>
 /// <param name="tagger">- the POS tagger plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public PosTaggerThread(PosTagger tagger, LinkedBlockingQueue <SetOfSentences> in_Renamed,
                        LinkedBlockingQueue <Sentence> out_Renamed)
 {
     this.tagger      = tagger;
     this.in_Renamed  = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
Beispiel #4
0
        /**
         * Carrega dados para troca de senha.
         * @param settings
         * @param filaNovaSenha
         */
        public SessaoFIX(
            SessionSettings settings,
            string novaSenha,
            LinkedBlockingQueue <string> filaNovaSenha)
        {
            this.filaNovaSenha = filaNovaSenha;
            this.novaSenha     = novaSenha;

            object[] objsessions = settings.getSessions().ToArray();
            foreach (object objsession in objsessions)
            {
                SessionID session = (SessionID)objsession;
                try
                {
                    Dictionary dictionary = settings.get(session);
                    if (dictionary.has(FIX_RAWDATA))
                    {
                        senha = dictionary.getString(FIX_RAWDATA);
                    }
                }

                catch (ConfigError e)
                {
                    logger.Error("Falha de configuracao: " + e.Message);
                }
                catch (FieldConvertError e)
                {
                    logger.Error("Falha de conversao: " + e.Message);
                }
            }
        }
Beispiel #5
0
            /// <exception cref="System.Exception"/>
            public override LinkedBlockingQueue <E> Load(string keyName)
            {
                LinkedBlockingQueue <E> keyQueue = new LinkedBlockingQueue <E>();

                refiller.FillQueueForKey(keyName, keyQueue, (int)(lowWatermark * numValues));
                return(keyQueue);
            }
        private static void TryMT(
            RegressionEnvironment env,
            int numEvents)
        {
            var epl =
                "create table varTotal (key string primary key, total sum(int));\n" +
                "into table varTotal select TheString, sum(IntPrimitive) as total from SupportBean group by TheString;\n" +
                "@Name('s0') select varTotal[P00].total as c0 from SupportBean_S0;\n";
            env.CompileDeploy(epl).AddListener("s0");
            env.SendEventBean(new SupportBean("A", 10));

            var queueCreated = new LinkedBlockingQueue<string>();
            var writeRunnable = new WriteRunnable(env, numEvents, queueCreated);
            var readRunnable = new ReadRunnable(env, numEvents, queueCreated);

            // start
            var t1 = new Thread(writeRunnable.Run);
            t1.Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteNewRowCreation).Name + "-write";
            var t2 = new Thread(readRunnable.Run);
            t2.Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteNewRowCreation).Name + "-read";
            t1.Start();
            t2.Start();

            // join
            log.Info("Waiting for completion");
            t1.Join();
            t2.Join();

            env.UndeployAll();
            Assert.IsNull(writeRunnable.Exception);
            Assert.IsNull(readRunnable.Exception);
        }
  private static BlockingQueue<long[]> queueItemIDsInBatches(DataModel dataModel, int batchSize) {

    longPrimitiveIterator itemIDs = dataModel.getItemIDs();
    int numItems = dataModel.getNumItems();

    BlockingQueue<long[]> itemIDBatches = new LinkedBlockingQueue<long[]>((numItems / batchSize) + 1);

    long[] batch = new long[batchSize];
    int pos = 0;
    while (itemIDs.hasNext()) {
      if (pos == batchSize) {
        itemIDBatches.add(batch.clone());
        pos = 0;
      }
      batch[pos] = itemIDs.nextlong();
      pos++;
    }
    int nonQueuedItemIDs = batchSize - pos;
    if (nonQueuedItemIDs > 0) {
      long[] lastBatch = new long[nonQueuedItemIDs];
      Array.Copy(batch, 0, lastBatch, 0, nonQueuedItemIDs);
      itemIDBatches.add(lastBatch);
    }

    log.info("Queued {} items in {} batches", numItems, itemIDBatches.Count);

    return itemIDBatches;
  }
 /// <summary> Constructor.</summary>
 /// <param name="plainTextProcessor">- the plain text processor plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public PlainTextProcThread(PlainTextProcessor plainTextProcessor, LinkedBlockingQueue <PlainSentence> in_Renamed,
                            LinkedBlockingQueue <PlainSentence> out_Renamed)
 {
     this.plainTextProcessor = plainTextProcessor;
     this.in_Renamed         = in_Renamed;
     this.out_Renamed        = out_Renamed;
 }
Beispiel #9
0
 public SessaoFIXInstantaneo(
     LinkedBlockingQueue <MarketDataSnapshotFullRefresh> filaMensagensFIX,
     LinkedBlockingQueue <string> filaMensagensRetransmissorBMF)
 {
     this.filaMensagensFIX = filaMensagensFIX;
     this.filaMensagensRetransmissorBMF = filaMensagensRetransmissorBMF;
 }
Beispiel #10
0
        /// <summary> It adds the specified input text to the input queue of the work flow. After this method,
        /// you are allowed to get the analysis result by using one of the following methods:
        ///
        /// - getResultOfSentence() : to get the result for one sentence at the front of result queue
        /// - getResultOfDocument() : to get the entire result for all sentences
        ///
        /// If the input document is not small, getResultOfDocument() may show lower performance, and it
        /// could be better to call getResultOfSentence() repeatedly. You need to pay attention on this.
        ///
        /// </summary>
        /// <param name="document">- the path for the text file to be analyzed
        /// </param>
        /// <throws>  IOException </throws>
        public virtual void analyze(System.IO.FileInfo document)
        {
            System.IO.StreamReader br = new System.IO.StreamReader(document.FullName, System.Text.Encoding.UTF8);
            LinkedBlockingQueue <PlainSentence> queue = queuePhase1[0];

            if (queue == null)
            {
                return;
            }

            System.String line = null;
            int           i    = 0;

            while ((line = br.ReadLine()) != null)
            {
                if (br.Peek() != -1)
                {
                    queue.Add(new PlainSentence(0, i++, false, line.Trim()));
                }
                else
                {
                    queue.Add(new PlainSentence(0, i++, true, line.Trim()));
                    break;
                }
            }

            br.Close();

            if (!isThreadMode)
            {
                analyzeInSingleThread();
            }
        }
 /// <summary> Constructor.</summary>
 /// <param name="ma">- the morphological analyzer plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public MorphAnalyzerThread(MorphAnalyzer ma, LinkedBlockingQueue<PlainSentence> in_Renamed,
     LinkedBlockingQueue<SetOfSentences> out_Renamed)
 {
     this.ma = ma;
     this.in_Renamed = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
Beispiel #12
0
 /// <summary> Constructor.</summary>
 /// <param name="ma">- the morphological analyzer plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public MorphAnalyzerThread(MorphAnalyzer ma, LinkedBlockingQueue <PlainSentence> in_Renamed,
                            LinkedBlockingQueue <SetOfSentences> out_Renamed)
 {
     this.ma          = ma;
     this.in_Renamed  = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
Beispiel #13
0
 public Unit(Vector3 bronPoint)
 {
     this.bronPoint = bronPoint;
     actions        = new LinkedBlockingQueue <IAction>();
     effects        = new Queue <IEffect>();
     states         = new Dictionary <int, IState>();
 }
 /// <summary> Constructor.</summary>
 /// <param name="plainTextProcessor">- the plain text processor plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public PlainTextProcThread(PlainTextProcessor plainTextProcessor, LinkedBlockingQueue<PlainSentence> in_Renamed,
     LinkedBlockingQueue<PlainSentence> out_Renamed)
 {
     this.plainTextProcessor = plainTextProcessor;
     this.in_Renamed = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
Beispiel #15
0
        private static ExecutorService BuildExecutorService(JobScheduler scheduler)
        {
            BlockingQueue <ThreadStart> workQueue       = new LinkedBlockingQueue <ThreadStart>(_ioParallelism * 4);
            RejectedExecutionHandler    rejectionPolicy = new ThreadPoolExecutor.CallerRunsPolicy();
            ThreadFactory threadFactory = scheduler.ThreadFactory(Group.FILE_IO_HELPER);

            return(new ThreadPoolExecutor(0, _ioParallelism, 10, TimeUnit.SECONDS, workQueue, threadFactory, rejectionPolicy));
        }
Beispiel #16
0
 public SessaoFIXIncremental(
     LinkedBlockingQueue <MarketDataIncrementalRefresh> filaMensagensFIX,
     LinkedBlockingQueue <string> filaMensagensRetransmissorBMF)
 {
     this.filaMensagensFIX = filaMensagensFIX;
     this.filaMensagensRetransmissorBMF = filaMensagensRetransmissorBMF;
     return;
 }
Beispiel #17
0
        public void TestPerformance()
        {
            int numEvents  = 1;
            int numThreads = 2;

            Configuration config = new Configuration();

            config.EngineDefaults.Threading.IsListenerDispatchPreserveOrder = false;
            EPServiceProvider engine = EPServiceProviderManager.GetDefaultProvider(config);

            engine.EPAdministrator.Configuration.AddEventType(typeof(TransactionEvent));
            engine.EPAdministrator.Configuration.AddPlugInSingleRowFunction("MyDynModel", GetType().FullName, "MyDynModel");

            String      epl  = "select MyDynModel({Col_001, Col_002, Col_003}) as model_score from TransactionEvent";
            EPStatement stmt = engine.EPAdministrator.CreateEPL(epl);

            stmt.Subscriber = new MySubscriber();

            var queue = new LinkedBlockingQueue <Runnable>();
            var latch = new CountDownLatch(numEvents);

            for (int i = 0; i < numEvents; i++)
            {
                queue.Push((new MyRunnable(engine.EPRuntime, latch, new TransactionEvent(1, 2, 3))).Run);
            }

            var threads = Executors.NewFixedThreadPool(numThreads);

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int ii = 0; ii < numThreads; ii++)
                {
                    threads.Submit(
                        () =>
                    {
                        Runnable runnable;
                        while (queue.Pop(0, out runnable))
                        {
                            runnable.Invoke();
                        }
                    });
                }


                //ThreadPoolExecutor threads = new ThreadPoolExecutor(numThreads, numThreads, 10, TimeUnit.SECONDS, queue);
                //threads.PrestartAllCoreThreads();
                latch.Await(TimeSpan.FromMinutes(1));
                if (latch.Count > 0)
                {
                    throw new Exception("Failed to complete in 1 minute");
                }
            });

            Console.WriteLine("Took " + delta + " millis");
            threads.Shutdown();
            threads.AwaitTermination(TimeSpan.FromSeconds(10));
        }
Beispiel #18
0
        /// <summary>
        /// This removes the "num" values currently at the head of the Queue for the
        /// provided key.
        /// </summary>
        /// <remarks>
        /// This removes the "num" values currently at the head of the Queue for the
        /// provided key. Will immediately fire the Queue filler function if key
        /// does not exist
        /// How many values are actually returned is governed by the
        /// <code>SyncGenerationPolicy</code> specified by the user.
        /// </remarks>
        /// <param name="keyName">String key name</param>
        /// <param name="num">Minimum number of values to return.</param>
        /// <returns>List<E> values returned</returns>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="ExecutionException"/>
        public virtual IList <E> GetAtMost(string keyName, int num)
        {
            LinkedBlockingQueue <E> keyQueue = keyQueues.Get(keyName);
            // Using poll to avoid race condition..
            List <E> ekvs = new List <E>();

            try
            {
                for (int i = 0; i < num; i++)
                {
                    E val = keyQueue.Poll();
                    // If queue is empty now, Based on the provided SyncGenerationPolicy,
                    // figure out how many new values need to be generated synchronously
                    if (val == null)
                    {
                        // Synchronous call to get remaining values
                        int numToFill = 0;
                        switch (policy)
                        {
                        case ValueQueue.SyncGenerationPolicy.AtleastOne:
                        {
                            numToFill = (ekvs.Count < 1) ? 1 : 0;
                            break;
                        }

                        case ValueQueue.SyncGenerationPolicy.LowWatermark:
                        {
                            numToFill = Math.Min(num, (int)(lowWatermark * numValues)) - ekvs.Count;
                            break;
                        }

                        case ValueQueue.SyncGenerationPolicy.All:
                        {
                            numToFill = num - ekvs.Count;
                            break;
                        }
                        }
                        // Synchronous fill if not enough values found
                        if (numToFill > 0)
                        {
                            refiller.FillQueueForKey(keyName, ekvs, numToFill);
                        }
                        // Asynch task to fill > lowWatermark
                        if (i <= (int)(lowWatermark * numValues))
                        {
                            SubmitRefillTask(keyName, keyQueue);
                        }
                        return(ekvs);
                    }
                    ekvs.AddItem(val);
                }
            }
            catch (Exception e)
            {
                throw new IOException("Exeption while contacting value generator ", e);
            }
            return(ekvs);
        }
        private ExecutorService CreateThreadPool()
        {
            int threads = NumberOfPopulationWorkers;
            BlockingQueue <ThreadStart> workQueue             = new LinkedBlockingQueue <ThreadStart>(_taskQueueSize);
            ThreadFactory            threadFactory            = daemon(FLUSH_THREAD_NAME_PREFIX);
            RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();

            return(new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, workQueue, threadFactory, rejectedExecutionHandler));
        }
Beispiel #20
0
        public GeradorEventosBMFRetransmissor(
            EPServiceProvider epService,
            LinkedBlockingQueue <string> filaMensagensRetransmissorBMF)
        {
            this.epService = epService;
            this.filaMensagensRetransmissorBMF = filaMensagensRetransmissorBMF;

            return;
        }
Beispiel #21
0
        /**
         * Construtor que cria a fila e instancia a camada consumer.
         *
         * @param dadosGlobais Atributo que é repassado para a classe consumer.
         * @param maximoItens Quantidade maxima de itens no livro de ofertas.
         */
        public BMFLivroOfertasListener(DadosGlobais dadosGlobais, int maximoItens)
        {
            this.filaMensagensLivroOfertas = new LinkedBlockingQueue <EventoBMF>();

            BMFLivroOfertasConsumer consumer = new BMFLivroOfertasConsumer(dadosGlobais, filaMensagensLivroOfertas, maximoItens);

            consumer.Start();

            return;
        }
Beispiel #22
0
 public Unit(int cid, bool isControl, Shap shap, Vector3 bronPoint)
 {
     this.cid       = cid;
     this.isControl = isControl;
     this.shap      = shap;
     this.bronPoint = bronPoint;
     actions        = new LinkedBlockingQueue <IAction>();
     effects        = new Queue <IEffect>();
     states         = new Dictionary <int, IState>();
 }
Beispiel #23
0
 public BMFLivroOfertasConsumer(
     DadosGlobais dadosGlobais,
     LinkedBlockingQueue <EventoBMF> filaMensagensLivroOfertas,
     int maximoItens)
 {
     this.parametros                = dadosGlobais.Parametros;
     this.epService                 = dadosGlobais.EpService;
     this.todosLivrosBMF            = dadosGlobais.TodosLivrosBMF;
     this.filaMensagensLivroOfertas = filaMensagensLivroOfertas;
     this.maximoItens               = maximoItens;
     this.dadosGlobais              = dadosGlobais;
 }
Beispiel #24
0
        public RetransmissorBMF(DadosGlobais dadosGlobais)
        {
            this.dadosGlobais = dadosGlobais;
            this.epService    = dadosGlobais.EpService;
            this.parametros   = dadosGlobais.Parametros;
            this.filaFeeder   = dadosGlobais.getFilaFeeder();
            this._config      = parametros.BMFMarketDataConfig;

            filaMensagensRetransmissorBMF = new LinkedBlockingQueue <string>();
            filaMensagensFIXInstantaneo   = new LinkedBlockingQueue <MarketDataSnapshotFullRefresh>();
            filaMensagensFIXIncremental   = new LinkedBlockingQueue <MarketDataIncrementalRefresh>();
            return;
        }
 private LinkedBlockingQueue<String> PopulatedDeque(int n)
 {
     LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(n);
     Assert.IsTrue(q.IsEmpty());
     for(int i = 0; i < n; i++)
     {
         Assert.IsTrue(q.Offer(i.ToString()));
     }
     Assert.IsFalse(q.IsEmpty());
     Assert.AreEqual(0, q.RemainingCapacity());
     Assert.AreEqual(n, q.Size());
     return q;
 }
        private void TryMT(int numInserted)
        {
            var epl = "create table MyTable (key int primary key, p0 int);";

            _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);

            var runnables = new List <BaseRunnable>();

            var insertOutQ = new LinkedBlockingQueue <int>();
            var insert     = new InsertRunnable(_epService, numInserted, insertOutQ);

            runnables.Add(insert);

            var selectOutQ = new LinkedBlockingQueue <int>();
            var select     = new SelectRunnable(_epService, insertOutQ, selectOutQ);

            runnables.Add(select);

            var updateOutQ = new LinkedBlockingQueue <int>();
            var update     = new UpdateRunnable(_epService, selectOutQ, updateOutQ);

            runnables.Add(update);

            var deleteOutQ = new LinkedBlockingQueue <int>();
            var delete     = new DeleteRunnable(_epService, updateOutQ, deleteOutQ);

            runnables.Add(delete);

            // start
            var threads = new Thread[runnables.Count];

            for (var i = 0; i < runnables.Count; i++)
            {
                threads[i] = new Thread(runnables[i].Run);
                threads[i].Start();
            }

            // join
            foreach (var t in threads)
            {
                t.Join();
            }

            // assert
            foreach (var runnable in runnables)
            {
                Assert.IsNull(runnable.Exception);
                Assert.AreEqual(numInserted + 1, runnable.NumberOfOperations, "failed for " + runnable);    // account for -1 indicator
            }
        }
        private static void TryMT(
            RegressionEnvironment env,
            int numInserted)
        {
            var path = new RegressionPath();
            var epl = "create table MyTable (key int primary key, p0 int);";
            env.CompileDeploy(epl, path);

            IList<BaseRunnable> runnables = new List<BaseRunnable>();

            var insertOutQ = new LinkedBlockingQueue<int>();
            var insert = new InsertRunnable(env, path, numInserted, insertOutQ);
            runnables.Add(insert);

            var selectOutQ = new LinkedBlockingQueue<int>();
            var select = new SelectRunnable(env, path, insertOutQ, selectOutQ);
            runnables.Add(select);

            var updateOutQ = new LinkedBlockingQueue<int>();
            var update = new UpdateRunnable(env, path, selectOutQ, updateOutQ);
            runnables.Add(update);

            IBlockingQueue<int> deleteOutQ = new LinkedBlockingQueue<int>();
            var delete = new DeleteRunnable(env, path, updateOutQ, deleteOutQ);
            runnables.Add(delete);

            // start
            var threads = new Thread[runnables.Count];
            for (var i = 0; i < runnables.Count; i++) {
                threads[i] = new Thread(runnables[i].Run);
                threads[i].Name = typeof(InfraTableMTGroupedFAFReadFAFWriteChain).Name + "-" + i;
                threads[i].Start();
            }

            // join
            foreach (var t in threads) {
                t.Join(TimeSpan.FromSeconds(60));
            }

            env.UndeployAll();

            // assert
            foreach (var runnable in runnables) {
                Assert.IsNull(runnable.Exception);
                Assert.AreEqual(
                    numInserted + 1,
                    runnable.NumberOfOperations,
                    "failed for " + runnable); // account for -1 indicator
            }
        }
        internal ILoopResult ForEach(IEnumerable <T> source, int maxDegreeOfParallelism)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            _maxDegreeOfParallelism = OptimizeMaxDegreeOfParallelism(source, maxDegreeOfParallelism);

            var iterator = source.GetEnumerator();

            if (!iterator.MoveNext())
            {
                return(this);
            }
            if (_maxDegreeOfParallelism == 1)
            {
                Process(iterator);
                return(this);
            }
            // avoid running out of memory.
            var capacity = Math.Min(512, _maxDegreeOfParallelism);

            _itemQueue = new LinkedBlockingQueue <KeyValuePair <long, T> >(capacity);
            _futures   = new List <IFuture <Void> >(capacity);

            try
            {
                Submit(StartParallel);
            }
            catch (RejectedExecutionException)
            {
                Process(iterator);
                return(this);
            }

            bool success;
            long count = 0;

            do
            {
                success = _itemQueue.TryPut(new KeyValuePair <long, T>(count++, iterator.Current));
            }while (success && iterator.MoveNext());

            _itemQueue.Break();

            WaitForAllTaskToComplete();
            return(this);
        }
Beispiel #29
0
        /**
         * Carrega dados do arquivo de configuracao quickfix.
         * @param settings
         * @param dadosGlobais
         */
        public SessaoFIX(
            SessionSettings settings,
            DadosGlobais dadosGlobais,
            LinkedBlockingQueue <MarketDataSnapshotFullRefresh> filaMensagensFIXInstantaneo,
            LinkedBlockingQueue <MarketDataIncrementalRefresh> filaMensagensFIXIncremental,
            LinkedBlockingQueue <string> filaMensagensRetransmissorBMF)
        {
            instrumentosAssinados =
                new SortedDictionary <string, DadosInstrumentosBMF>();

            this.filaMensagensFIXInstantaneo   = filaMensagensFIXInstantaneo;
            this.filaMensagensFIXIncremental   = filaMensagensFIXIncremental;
            this.filaMensagensRetransmissorBMF = filaMensagensRetransmissorBMF;

            object [] objsessions = settings.getSessions().ToArray();
            foreach (object objsession in objsessions)
            {
                SessionID session = (SessionID)objsession;
                try
                {
                    Dictionary dictionary = settings.get(session);

                    if (dictionary.has(FIX_RAWDATA))
                    {
                        senha = dictionary.getString(FIX_RAWDATA);
                    }

                    if (dictionary.has(FIX_NEWPASSWORD))
                    {
                        novaSenha = dictionary.getString(FIX_NEWPASSWORD);
                    }

                    if (dictionary.has(FIX_FILTRO_LISTA_INSTRUMENTOS))
                    {
                        padraoInstrumentos = new Regex(
                            dictionary.getString(FIX_FILTRO_LISTA_INSTRUMENTOS));
                    }
                }

                catch (ConfigError e)
                {
                    logger.Error("Falha de configuracao: " + e.Message);
                }
                catch (FieldConvertError e)
                {
                    logger.Error("Falha de conversao: " + e.Message);
                }
            }
        }
        public BovespaLivroOfertasListener(DadosGlobais dadosGlobais, int maximoItens)
        {
            filaMensagensLivroOfertas = new LinkedBlockingQueue <EventoBovespa>();

            BovespaLivroOfertasConsumer consumer = new BovespaLivroOfertasConsumer(
                dadosGlobais,
                filaMensagensLivroOfertas,
                maximoItens);

            Thread thconsumer = new Thread(new ThreadStart(consumer.Run));

            thconsumer.Start();

            return;
        }
Beispiel #31
0
        /// <summary> Returns the analysis result for one sentence at the top of the result queue. You can call this method
        /// repeatedly to get the result for remaining sentences in the input document. If there is no result,
        /// this method will be blocked until a new result comes.
        ///
        /// It stores the specified object with the analysis result. The return type of the object depends on the
        /// analysis phase of the work flow so you must give the relevant type of parameter.
        ///
        /// In this way, you can get the analysis result with a relevant object, so you don't need to parse the result string
        /// again. If you just want to see the result, consider to use "String getResultOfSentence()" instead.
        ///
        /// </summary>
        /// <param name="<T>">- One of PlainSentence (for the first phase), Sentence (for the second phase), and SetOfSentences (for the third phase).
        /// </param>
        /// <param name="a">- the object to get the result
        /// </param>
        /// <returns> the analysis result for one sentence at front
        /// </returns>
        /// <throws>  ResultTypeException </throws>
        public T getResultOfSentence <T>(T a) where T : class
        {
            Type objClass = a.GetType();

            try
            {
                if (typeof(PlainSentence).Equals(objClass))
                {
                    if (outputPhaseNum != 1)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <PlainSentence> queue = queuePhase1[outputQueueNum];
                    a = queue.Take() as T;
                }
                else if (typeof(SetOfSentences).Equals(objClass))
                {
                    if (outputPhaseNum != 2)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <SetOfSentences> queue = queuePhase2[outputQueueNum];
                    a = queue.Take() as T;
                }
                else if (typeof(Sentence).Equals(objClass))
                {
                    if (outputPhaseNum != 3)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <Sentence> queue = queuePhase3[outputQueueNum];
                    a = queue.Take() as T;
                }
                else
                {
                    throw new ResultTypeException(outputPhaseNum);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }

            return(a);
        }
Beispiel #32
0
 public DadosGlobais()
 {
     mapaInstrumento       = new SortedDictionary <string, DadosInstrumentos>();
     listaComposicaoIndice = new HashSet <string>();
     //listaGrupoCotacao = new SortedDictionary<string, DadosGrupoCotacao>();
     //todosLivrosBMF =  new SortedDictionary<string, BMFLivroOfertas>();
     TodosLOF                = new SortedDictionary <string, BovespaLivroOfertas>();
     TodosLivrosBMF          = new SortedDictionary <string, BMFLivroOfertas>();
     todosLivrosPersistencia = new SortedDictionary <string, BovespaLivroOfertas>();
     //maioresVolumes = new SortedDictionary<DadosRanking, string>(new ComparadorRankingDecrescente());
     //maioresVolumesPorMsgID = new SortedDictionary<string, DadosRanking>();
     //maisNegociadas = new SortedDictionary<DadosRanking, string>(new ComparadorRankingDecrescente());
     //maisNegociadasPorMsgID = new SortedDictionary<string, DadosRanking>();
     //maioresBaixas = new SortedDictionary<DadosRanking, string>();
     //maioresAltas = new SortedDictionary<DadosRanking, string>(new ComparadorRankingDecrescente());
     //maioresMenoresPorMsgID = new SortedDictionary<string, DadosRanking>();
     filaFeeder = new LinkedBlockingQueue <string>();
 }
Beispiel #33
0
        public BovespaLivroOfertasConsumer(
            DadosGlobais dadosGlobais,
            LinkedBlockingQueue <EventoBovespa> filaMensagensLivroOfertas,
            int maximoItens)
        {
            this._dadosGlobais             = dadosGlobais;
            this.epService                 = dadosGlobais.EpService;
            this.todosLivros               = dadosGlobais.TodosLOF;
            this.filaMensagensLivroOfertas = filaMensagensLivroOfertas;
            this.maximoItens               = maximoItens;
            normalizador = new NormalizadorNumero();

            papeisReenvio = new HashSet <string>();
            emReenvio     = false;


            return;
        }
        // Test dispatcher should timeout on draining events.
        /// <exception cref="System.Exception"/>
        public virtual void TestDispatchStopOnTimeout()
        {
            BlockingQueue <Org.Apache.Hadoop.Yarn.Event.Event> eventQueue = new LinkedBlockingQueue
                                                                            <Org.Apache.Hadoop.Yarn.Event.Event>();

            eventQueue = Org.Mockito.Mockito.Spy(eventQueue);
            // simulate dispatcher is not drained.
            Org.Mockito.Mockito.When(eventQueue.IsEmpty()).ThenReturn(false);
            YarnConfiguration conf = new YarnConfiguration();

            conf.SetInt(YarnConfiguration.DispatcherDrainEventsTimeout, 2000);
            DrainDispatcher disp = new DrainDispatcher(eventQueue);

            disp.Init(conf);
            disp.SetDrainEventsOnStop();
            disp.Start();
            disp.WaitForEventThreadToWait();
            disp.Close();
        }
 public void TestPut()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         for (int i = 0; i < SIZE; ++i)
         {
              q.Put(i.ToString());
              Assert.IsTrue(q.Contains(i.ToString()));
          }
          Assert.AreEqual(0, q.RemainingCapacity());
     }
     catch (Exception)
     {
         UnexpectedException();
     }
 }
        public void TestAddAll5()
        {
            ArrayList<String> empty = new ArrayList<String>();
            ArrayList<String> strings = new ArrayList<String>(SIZE);

            for (int i = 0; i < SIZE; ++i)
            {
                strings.Add(i.ToString());
            }
            LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
            Assert.IsFalse(q.AddAll(empty));
            Assert.IsTrue(q.AddAll(strings));
            for (int i = 0; i < SIZE; ++i)
            {
                Assert.AreEqual(strings.Get(i), q.Poll());
            }
        }
 public void TestPutNull()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         q.Put(null);
         ShouldThrow();
     }
     catch (NullReferenceException)
     {
     }
     catch (Exception)
     {
         UnexpectedException();
     }
 }
 public void TestAddAll4()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(1);
         ArrayList<String> strings = new ArrayList<String>();
         for (int i = 0; i < SIZE-1; ++i)
         {
             strings.Add(i.ToString());
         }
         q.AddAll(strings);
         ShouldThrow();
     }
     catch (IllegalStateException) {}
 }
Beispiel #39
0
 /// <summary> Constructor.</summary>
 /// <param name="posProcessor">- the POS processor plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public PosProcThread(PosProcessor posProcessor, LinkedBlockingQueue<Sentence> in_Renamed, LinkedBlockingQueue<Sentence> out_Renamed)
 {
     this.posProcessor = posProcessor;
     this.in_Renamed = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
 public void TestAddAll2()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         ArrayList<String> strings = new ArrayList<String>();
         strings.Add(null);
         strings.Add(null);
         strings.Add(null);
         q.AddAll(strings);
         ShouldThrow();
     }
     catch (NullReferenceException) {}
 }
 public void TestAddAll3()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         ArrayList<String> strings = new ArrayList<String>();
         for (int i = 0; i < SIZE-1; ++i)
         {
             strings.Add(i.ToString());
         }
         strings.Add(null);
         q.AddAll(strings);
         ShouldThrow();
     }
     catch (NullReferenceException) {}
 }
 public void TestEmptyFull()
 {
     LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(2);
     Assert.IsTrue(q.IsEmpty());
     Assert.AreEqual(2, q.RemainingCapacity(), "should have room for 2");
     q.Add(one);
     Assert.IsFalse(q.IsEmpty());
     q.Add(two);
     Assert.IsFalse(q.IsEmpty());
     Assert.AreEqual(0, q.RemainingCapacity());
     Assert.IsFalse(q.Offer(three));
 }
 public void TestOfferNull()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>();
         q.Offer(null);
         ShouldThrow();
     }
     catch (NullReferenceException) {}
 }
 public void TestOffer()
 {
     LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(1);
     Assert.IsTrue(q.Offer(zero));
     Assert.IsFalse(q.Offer(one));
 }
 /// <summary> Constructor.</summary>
 /// <param name="morphProcessor">- the morpheme processor plug-in
 /// </param>
 /// <param name="in">- input queue
 /// </param>
 /// <param name="out">- output queue
 /// </param>
 public MorphemeProcThread(MorphemeProcessor morphProcessor, LinkedBlockingQueue<SetOfSentences> in_Renamed, LinkedBlockingQueue<SetOfSentences> out_Renamed)
 {
     this.morphProcessor = morphProcessor;
     this.in_Renamed = in_Renamed;
     this.out_Renamed = out_Renamed;
 }
 public void TestAddAll1()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(1);
         q.AddAll(null);
         ShouldThrow();
     }
     catch (NullReferenceException) {}
 }
 public void TestAdd()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         for (int i = 0; i < SIZE; ++i)
         {
             Assert.IsTrue(q.Add(i.ToString()));
         }
         Assert.AreEqual(0, q.RemainingCapacity());
         q.Add(SIZE.ToString());
     }
     catch (IllegalStateException)
     {
     }
 }
 public void TestConstructor6()
 {
     ArrayList<String> strings = new ArrayList<String>();
     for (int i = 0; i < SIZE; ++i)
     {
         strings.Add(i.ToString());
     }
     LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(strings);
     for (int i = 0; i < SIZE; ++i)
     {
         Assert.AreEqual(strings.Get(i), q.Poll());
     }
 }