Ejemplo n.º 1
0
 public void SetUp()
 {
     _variableService = new VariableServiceImpl(100, null, null, null);
     _variableService.CreateNewVariable(null, "var1", "string", true, false, false, null, null);
     _variableService.CreateNewVariable(null, "dummy", "string", true, false, false, null, null);
     _variableService.CreateNewVariable(null, "IntPrimitive", "int", true, false, false, null, null);
     _varNode = new ExprVariableNodeImpl(_variableService.GetVariableMetaData("var1"), null);
 }
Ejemplo n.º 2
0
        public void TestRollover()
        {
            _service = new VariableServiceImpl(
                VariableServiceImpl.ROLLOVER_READER_BOUNDARY - 100,
                10000,
                new SchedulingServiceImpl(new TimeSourceServiceImpl()),
                SupportEventAdapterService.Service,
                null);

            String[] variables = "a,b,c,d".Split(',');

            var readers = new VariableReader[variables.Length];

            for (int i = 0; i < variables.Length; i++)
            {
                _service.CreateNewVariable <long>(null, variables[i], false, 100L, null);
                _service.AllocateVariableState(variables[i], EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
                readers[i] = _service.GetReader(variables[i], EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID);
            }

            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < variables.Length; j++)
                {
                    _service.Write(readers[j].VariableMetaData.VariableNumber, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, 100L + i);
                    _service.Commit();
                }
                ReadCompare(variables, 100L + i);
            }
        }
 /// <summary>
 /// Adds configured variables to the variable service.
 /// </summary>
 /// <param name="variableService">service to add to</param>
 /// <param name="variables">configured variables</param>
 /// <param name="engineImportService">engine imports</param>
 internal static void InitVariables(
     VariableService variableService,
     IDictionary <string, ConfigurationVariable> variables,
     EngineImportService engineImportService)
 {
     foreach (var entry in variables)
     {
         try
         {
             var arrayType = TypeHelper.IsGetArrayType(entry.Value.VariableType);
             variableService.CreateNewVariable(
                 null, entry.Key, arrayType.First, entry.Value.IsConstant, arrayType.Second, false,
                 entry.Value.InitializationValue, engineImportService);
             variableService.AllocateVariableState(
                 entry.Key, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
         }
         catch (VariableExistsException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
         catch (VariableTypeException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
     }
 }
Ejemplo n.º 4
0
        // Start Count threads
        // each thread performs X loops
        // each loop gets a unique number Y from a shared object and performs setVersion in the synchronized block
        // then the thread performs reads, write and read of shared variables, writing the number Y
        // ==> the reads should not see any higher number (unless watemarks reached)
        // ==> reads should produce the exact same result unless setVersion called
        private void TryMT(int numThreads, int numLoops, int numVariables)
        {
            var coord = new VariableVersionCoord(_service);

            int ord = 'A';

            // create variables
            var variables = new String[numVariables];

            for (int i = 0; i < numVariables; i++)
            {
                variables[i] = String.Format("{0}", ((char)(ord + i)));
                _service.CreateNewVariable(null, variables[i], typeof(int).FullName, false, false, false, 0, null);
                _service.AllocateVariableState(variables[i], EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
            }

            BasicExecutorService threadPool = Executors.NewFixedThreadPool(numThreads);
            var callables = new VariableServiceCallable[numThreads];
            var future    = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                callables[i] = new VariableServiceCallable(variables, _service, coord, numLoops);
                future[i]    = threadPool.Submit(callables[i]);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(new TimeSpan(0, 0, 10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            //Console.Out.WriteLine(service.ToString());
            // Verify results per thread
            for (int i = 0; i < callables.Length; i++)
            {
                int[][] result = callables[i].Results;
                int[]   marks  = callables[i].Marks;
            }
        }
Ejemplo n.º 5
0
 public void AddVariable(string variableName, string type, Object initializationValue, bool constant)
 {
     try {
         Pair <string, bool> arrayType = TypeHelper.IsGetArrayType(type);
         _variableService.CreateNewVariable(null, variableName, arrayType.First, constant, arrayType.Second, false, initializationValue, _engineImportService);
         _variableService.AllocateVariableState(variableName, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID, null, false);
         _statementVariableRef.AddConfiguredVariable(variableName);
     } catch (VariableExistsException e) {
         throw new ConfigurationException("Error creating variable: " + e.Message, e);
     } catch (VariableTypeException e) {
         throw new ConfigurationException("Error creating variable: " + e.Message, e);
     }
 }
 public void AddVariable(String variableName, String type, Object initializationValue, bool constant)
 {
     try
     {
         var arrayType = TypeHelper.IsGetArrayType(type);
         _variableService.CreateNewVariable(null, variableName, arrayType.First, constant, arrayType.Second, false, initializationValue, _engineImportService);
         _variableService.AllocateVariableState(variableName, 0, null);
         _statementVariableRef.AddConfiguredVariable(variableName);
     }
     catch (VariableExistsException e)
     {
         throw new ConfigurationException("Error creating variable: " + e.Message, e);
     }
     catch (VariableTypeException e)
     {
         throw new ConfigurationException("Error creating variable: " + e.Message, e);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds configured variables to the variable service.
 /// </summary>
 /// <param name="variableService">service to add to</param>
 /// <param name="variables">configured variables</param>
 /// <param name="engineImportService">The engine import service.</param>
 internal static void InitVariables(VariableService variableService, IDictionary <String, ConfigurationVariable> variables, EngineImportService engineImportService)
 {
     foreach (KeyValuePair <String, ConfigurationVariable> entry in variables)
     {
         try
         {
             var arrayType = TypeHelper.IsGetArrayType(entry.Value.VariableType);
             variableService.CreateNewVariable(null, entry.Key, arrayType.First, entry.Value.IsConstant, arrayType.Second, false, entry.Value.InitializationValue, engineImportService);
             variableService.AllocateVariableState(entry.Key, 0, null);
         }
         catch (VariableExistsException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
         catch (VariableTypeException e)
         {
             throw new ConfigurationException("Error configuring variables: " + e.Message, e);
         }
     }
 }