Beispiel #1
0
 public StmtMgmtCallablePair(
     string epl,
     EPCompiled compiled)
 {
     Epl = epl;
     Compiled = compiled;
 }
Beispiel #2
0
 public RegressionEnvironment Deploy(
     EPCompiled compiled,
     DeploymentOptions options)
 {
     Runtime.DeploymentService.Deploy(compiled, options);
     return this;
 }
Beispiel #3
0
        public static ModuleProviderCLPair Analyze(
            EPCompiled compiled,
            ClassLoader classLoaderParent,
            PathRegistry <String, ClassProvided> classProvidedPathRegistry)
        {
            var classLoader       = new PriorityClassLoader(classLoaderParent, compiled.Assemblies);
            var resourceClassName = compiled.Manifest.ModuleProviderClassName;

            // load module resource class
            Type clazz;

            try {
                clazz = classLoader.GetClass(resourceClassName);
            }
            catch (Exception e) {
                throw new EPException(e);
            }

            // instantiate
            ModuleProvider moduleResource;

            try {
                moduleResource = (ModuleProvider)TypeHelper.Instantiate(clazz);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception e) {
                throw new EPException(e);
            }

            return(new ModuleProviderCLPair(classLoader, moduleResource));
        }
Beispiel #4
0
        private static DeploymentInternal Deploy(
            bool recovery,
            string deploymentId,
            int statementIdFirstStatement,
            EPCompiled compiled,
            StatementNameRuntimeOption statementNameResolverRuntime,
            StatementUserObjectRuntimeOption userObjectResolverRuntime,
            StatementSubstitutionParameterOption substitutionParameterResolver,
            DeploymentClassLoaderOption deploymentClassLoaderOption,
            EPRuntimeSPI epRuntime)
        {
            // set variable local version
            epRuntime.ServicesContext.VariableManagementService.SetLocalVersion();

            try {
                return(DeploySafe(
                           recovery,
                           deploymentId,
                           statementIdFirstStatement,
                           compiled,
                           statementNameResolverRuntime,
                           userObjectResolverRuntime,
                           substitutionParameterResolver,
                           deploymentClassLoaderOption,
                           epRuntime));
            }
            catch (EPDeployException) {
                throw;
            }
            catch (Exception ex) {
                throw new EPDeployException(ex.Message, ex, -1);
            }
        }
Beispiel #5
0
            public void Run(RegressionEnvironment env)
            {
                SetupInfra(env, namedWindow);

                EPCompiled insertA = CompileRuntimePath(env, "A", "insert into MyInfra(c0, c1) values ('A1', 10)");
                EPCompiled insertB = CompileRuntimePath(env, "B", "insert into MyInfra(c2, c3) values (20, 'B1')");

                env.Runtime.FireAndForgetService.ExecuteQuery(insertA);
                env.Runtime.FireAndForgetService.ExecuteQuery(insertB);

                EPCompiled selectA = CompileRuntimePath(env, "A", "select * from MyInfra");
                EPCompiled selectB = CompileRuntimePath(env, "B", "select * from MyInfra");

                EPFireAndForgetQueryResult resultA = env.Runtime.FireAndForgetService.ExecuteQuery(selectA);

                EPAssertionUtil.AssertPropsPerRow(resultA.GetEnumerator(), "c0,c1".SplitCsv(), new object[][] {
                    new object[] { "A1", 10 }
                });

                EPFireAndForgetQueryResult resultB = env.Runtime.FireAndForgetService.ExecuteQuery(selectB);

                EPAssertionUtil.AssertPropsPerRow(resultB.GetEnumerator(), "c2,c3".SplitCsv(), new object[][] {
                    new object[] { 20, "B1" }
                });

                env.UndeployAll();
            }
Beispiel #6
0
	    /// <summary>
	    ///     Ctor.
	    /// </summary>
	    /// <param name="compiled">compiled module to deploy</param>
	    /// <param name="options">deployment options</param>
	    public EPDeploymentRolloutCompiled(
            EPCompiled compiled,
            DeploymentOptions options)
        {
            Compiled = compiled;
            Options = options ?? new DeploymentOptions();
        }
Beispiel #7
0
            public void Run(RegressionEnvironment env)
            {
                SupportUpdateListener listener = new SupportUpdateListener();
                for (int i = 0; i < 100; i++) {
                    string epl = "@Name('s" + i + "') select * from SupportBean(TheString = '" + i + "' or IntPrimitive=" + i + ")";
                    EPCompiled compiled = env.Compile(epl);
                    env.Deploy(compiled).Statement("s" + i).AddListener(listener);
                }

                var delta = PerformanceObserver.TimeMillis(
                    () => {
                        // System.out.println("Starting " + DateTime.print(new Date()));
                        for (int i = 0; i < 10000; i++) {
                            env.SendEventBean(new SupportBean("100", 1));
                            Assert.IsTrue(listener.IsInvoked);
                            listener.Reset();
                        }
                    });
#if DEBUG
                Assert.That(delta, Is.LessThan(1500));
#else
				Assert.That(delta, Is.LessThan(500));
#endif

                env.UndeployAll();
            }
Beispiel #8
0
            public void Run(RegressionEnvironment env)
            {
#if false
                var resourceManager = env.Container.ResourceManager();
                var resourceName    = "regression/epcompiled_version_8.0.0.epl_dll_for_deployment";

                string file = FileUtil.FindClasspathFile(resourceName);
                if (file == null)
                {
                    throw new EPRuntimeException("Failed to find file " + resourceName);
                }

                EPCompiled compiled = EPCompiledIOUtil.Read(new File(file));

                var versionMismatchMsg =
                    "Major or minor version of compiler and runtime mismatch; The runtime version is 8.5.1 and the compiler version of the compiled unit is 8.0.0";
                AssertMessage(
                    Assert.Throws <EPDeployDeploymentVersionException>(
                        () => env.Runtime.DeploymentService.Deploy(compiled)),
                    versionMismatchMsg);

                var ex1 = Assert.Throws <EPDeployDeploymentVersionException>(
                    () => env.Runtime.DeploymentService.Rollout(Collections.SingletonList(new EPDeploymentRolloutCompiled(compiled))));
                Assert.AreEqual(0, ex1.RolloutItemNumber);
                AssertMessage(ex1, versionMismatchMsg);

                AssertMessage(
                    Assert.Throws <EPException>(
                        () => env.Runtime.FireAndForgetService.ExecuteQuery(compiled)),
                    "Major or minor version of compiler and runtime mismatch; The runtime version is 8.5.1 and the compiler version of the compiled unit is 8.0.0");
#endif
            }
 private static void TryInvalidDeploy(
     RegressionEnvironment env,
     EPCompiled compiled,
     string text,
     string moduleName)
 {
     var message = "A precondition is not satisfied: " +
                   text +
                   " has already been created for module '" +
                   moduleName +
                   "'";
     try {
         env.Runtime.DeploymentService.Deploy(compiled);
         Assert.Fail();
     }
     catch (EPDeployPreconditionException ex) {
         Assert.That(ex.RolloutItemNumber, Is.EqualTo(-1));
         if (!message.Equals("skip")) {
             SupportMessageAssertUtil.AssertMessage(ex.Message, message);
         }
     }
     catch (EPDeployException) {
         Assert.Fail();
     }
 }
Beispiel #10
0
        public static ModuleProviderResult Analyze(
            EPCompiled compiled,
            ImportService importService)
        {
            var resourceClassName = compiled.Manifest.ModuleProviderClassName;

            // load module resource class
            Type clazz;

            try {
                clazz = TypeHelper.ResolveType(resourceClassName, true);
            }
            catch (Exception e) {
                throw new EPException(e);
            }

            // instantiate
            ModuleProvider moduleResource;

            try {
                moduleResource = (ModuleProvider)TypeHelper.Instantiate(clazz);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception e) {
                throw new EPException(e);
            }

            return(new ModuleProviderResult(moduleResource));
        }
Beispiel #11
0
 private static void DeployWithOptionsWUndeploy(
     RegressionEnvironment env,
     EPCompiled compiled,
     DeploymentOptions options)
 {
     env.Deploy(compiled, options).UndeployAll();
 }
 public EPFireAndForgetPreparedQuery PrepareQuery(EPCompiled compiled)
 {
     var fafProvider = EPRuntimeHelperFAF.QueryMethod(compiled, _services);
     var queryMethodProvider = fafProvider.QueryMethodProvider;
     EPRuntimeHelperFAF.ValidateSubstitutionParams(queryMethodProvider);
     var queryMethod = queryMethodProvider.QueryMethod;
     queryMethod.Ready(_services.StatementContextRuntimeServices);
     return new EPPreparedQueryImpl(_serviceStatusProvider, queryMethodProvider, queryMethod, _services);
 }
Beispiel #13
0
 public void Run(RegressionEnvironment env)
 {
     string epl = "@Name('s0') select * from SupportBean(TheString = ?::string)";
     EPCompiled compiled = env.Compile(epl);
     DeploymentOptions options = new DeploymentOptions();
     options.WithStatementSubstitutionParameter(opt => opt.SetObject(1, "ax"));
     env.Deploy(compiled, options).AddListener("s0");
     RunAssertionSB(env, epl, EQUAL);
 }
Beispiel #14
0
 public MyUpdateListener(
     RegressionEnvironment env,
     int numThread)
 {
     this.env = env;
     this.numThread = numThread;
     compiled = env.Compile(
         "@Name('t" + numThread + "') select * from SupportMarketDataBean where Volume=" + numThread);
 }
        public EPFireAndForgetQueryResult ExecuteQuery(
            EPCompiled compiled,
            ContextPartitionSelector[] contextPartitionSelectors)
        {
            if (contextPartitionSelectors == null) {
                throw new ArgumentException("No context partition selectors provided");
            }

            return ExecuteQueryUnprepared(compiled, contextPartitionSelectors);
        }
 public void Add(
     string deploymentId,
     int statementIdFirstStatement,
     EPCompiled compiled,
     IDictionary<int, object> userObjectsRuntime,
     IDictionary<int, string> statementNamesWhenProvidedByAPI,
     IDictionary<int, IDictionary<int, object>> substitutionParameters)
 {
     // no action
 }
 public static EPDeployment Deploy(
     EPCompiled compiledStmt,
     EPRuntime runtime)
 {
     try {
         return runtime.DeploymentService.Deploy(compiledStmt);
     }
     catch (EPDeployException e) {
         throw new EPException(e);
     }
 }
Beispiel #18
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("@public @buseventtype create json schema SimpleJson(fruit string, size string, color string)");
                string     epl      = "@Name('s0') select fruit, size, color from SimpleJson#keepall";
                EPCompiled compiled = env.Compile(epl, new CompilerArguments(env.Runtime.RuntimePath));

                env.Deploy(compiled).AddListener("s0");

                RunAssertionSimple(env);

                env.UndeployAll();
            }
 public EPFireAndForgetPreparedQueryParameterized PrepareQueryWithParameters(EPCompiled compiled)
 {
     var fafProvider = EPRuntimeHelperFAF.QueryMethod(compiled, _services);
     var queryMethodProvider = fafProvider.QueryMethodProvider;
     var queryMethod = queryMethodProvider.QueryMethod;
     queryMethod.Ready(_services.StatementContextRuntimeServices);
     return new EPFireAndForgetPreparedQueryParameterizedImpl(
         _serviceStatusProvider,
         queryMethodProvider.SubstitutionFieldSetter,
         queryMethod,
         queryMethodProvider.QueryInformationals);
 }
Beispiel #20
0
            public void Run(RegressionEnvironment env)
            {
                string epl = "create schema MANE as MyAutoNameEvent;\n" +
                             "@Name('s0') select P0 from MANE;\n";
                EPCompiled compiled = env.CompileWBusPublicType(epl);
                env.Deploy(compiled).AddListener("s0");

                env.SendEventBean(new MyAutoNameEvent("test"), "MANE");
                Assert.AreEqual("test", env.Listener("s0").AssertOneGetNewAndReset().Get("P0"));

                env.UndeployAll();
            }
 public DeploymentRecoveryEntry(
     int statementIdFirstStatement,
     EPCompiled compiled,
     IDictionary<int, object> userObjectsRuntime,
     IDictionary<int, string> statementNamesWhenProvidedByAPI,
     IDictionary<int, IDictionary<int, object>> substitutionParameters)
 {
     StatementIdFirstStatement = statementIdFirstStatement;
     Compiled = compiled;
     UserObjectsRuntime = userObjectsRuntime;
     StatementNamesWhenProvidedByAPI = statementNamesWhenProvidedByAPI;
     SubstitutionParameters = substitutionParameters;
 }
Beispiel #22
0
 public static void TryInvalidDeploy(
     RegressionEnvironment env,
     EPCompiled unit,
     string expected)
 {
     try {
         env.Runtime.DeploymentService.Deploy(unit);
         Assert.Fail();
     }
     catch (EPDeployException ex) {
         AssertMessage(ex, expected);
     }
 }
Beispiel #23
0
 private static void DeployWithResolver(
     RegressionEnvironment env,
     EPCompiled compiled,
     string statementName,
     StatementSubstitutionParameterOption resolver)
 {
     var options = new DeploymentOptions().WithStatementSubstitutionParameter(resolver);
     options.StatementNameRuntime = context => statementName;
     try {
         env.Deployment.Deploy(compiled, options);
     }
     catch (EPDeployException e) {
         throw new EPRuntimeException(e);
     }
 }
Beispiel #24
0
 private static void TryInvalidSetObject(
     RegressionEnvironment env,
     EPCompiled compiled,
     Consumer<EPFireAndForgetPreparedQueryParameterized> query,
     string message)
 {
     var parameterized = env.Runtime.FireAndForgetService.PrepareQueryWithParameters(compiled);
     try {
         query.Invoke(parameterized);
         Assert.Fail();
     }
     catch (EPException ex) {
         AssertMessage(ex.Message, message);
     }
 }
            public void Run(RegressionEnvironment env)
            {
                // Class depending on create-class class
                RegressionPath path = new RegressionPath();
                string         epl  = "@public create inlined_class \"\"\"\n" +
                                      "    public class MyUtilX {\n" +
                                      "        public static string SomeFunction(string parameter) {\n" +
                                      "            return \"|\" + parameter + \"|\";\n" +
                                      "        }\n" +
                                      "    }\n" +
                                      "\"\"\"";
                EPCompiled compiled = env.Compile(epl);

                path.Add(compiled);

                string eplInvalid = "inlined_class \"\"\"\n" +
                                    "    public class MyClassY {\n" +
                                    "        public static string DoIt(string parameter) {\n" +
                                    "            return MyUtil.SomeFunction(\">\" + parameter + \"<\");\n" +
                                    "        }\n" +
                                    "    }\n" +
                                    "\"\"\" \n" +
                                    "select MyClassY.DoIt(TheString) as c0 from SupportBean\n";

                TryInvalidCompile(
                    env,
                    path,
                    eplInvalid,
                    "Exception processing statement: " +
                    "Failure during module compilation: " +
                    "[(4,20): error CS0103: The name 'MyUtil' does not exist in the current context]");

                // create-class depending on create-class
                eplInvalid = "create inlined_class \"\"\"\n" +
                             "    public class MyClassZ {\n" +
                             "        public static string DoIt(string parameter) {\n" +
                             "            return MyUtil.SomeFunction(\">\" + parameter + \"<\");\n" +
                             "        }\n" +
                             "    }\n" +
                             "\"\"\"";
                TryInvalidCompile(
                    env,
                    path,
                    eplInvalid,
                    "Exception processing statement: " +
                    "Failure during module compilation: " +
                    "[(4,20): error CS0103: The name 'MyUtil' does not exist in the current context]");
            }
 private EPFireAndForgetQueryResult ExecuteQueryUnprepared(
     EPCompiled compiled,
     ContextPartitionSelector[] contextPartitionSelectors)
 {
     var fafProvider = EPRuntimeHelperFAF.QueryMethod(compiled, _services);
     var queryMethodProvider = fafProvider.QueryMethodProvider;
     EPRuntimeHelperFAF.ValidateSubstitutionParams(queryMethodProvider);
     var queryMethod = queryMethodProvider.QueryMethod;
     queryMethod.Ready(_services.StatementContextRuntimeServices);
     var result = queryMethod.Execute(
         _serviceStatusProvider,
         queryMethodProvider.SubstitutionFieldSetter,
         contextPartitionSelectors,
         _services.ContextManagementService);
     return new EPQueryResultImpl(result);
 }
 private static void TryInvalidNotVisible(
     RegressionEnvironment env,
     EPCompiled compiled)
 {
     var path = new RegressionPath();
     path.Add(compiled);
     TryInvalidCompile(
         env,
         path,
         "select 1 from MySchema",
         "Failed to resolve event type, named window or table by name 'MySchema'");
     TryInvalidCompile(
         env,
         path,
         "select abc from SupportBean",
         "Failed to validate select-clause expression 'abc': Property named 'abc' is not valid in any stream");
     TryInvalidCompile(
         env,
         path,
         "context MyContext select * from SupportBean",
         "Context by name 'MyContext' could not be found");
     TryInvalidCompile(
         env,
         path,
         "on SupportBean update MyWindow set TheString = 'a'",
         "A named window or table 'MyWindow' has not been declared");
     TryInvalidCompile(
         env,
         path,
         "into table MyTable select count(*) as c from SupportBean",
         "Invalid into-table clause: Failed to find table by name 'MyTable'");
     TryInvalidCompile(
         env,
         path,
         "select MyExpr() from SupportBean",
         "Failed to validate select-clause expression 'MyExpr()': Unknown single-row function, expression declaration, script or aggregation function named 'MyExpr' could not be resolved");
     TryInvalidCompile(
         env,
         path,
         "select myscript(1) from SupportBean",
         "Failed to validate select-clause expression 'myscript(1)': Unknown single-row function, aggregation function or mapped or indexed property named 'myscript' could not be resolved");
     TryInvalidCompile(
         env,
         path,
         "select MyClassX.DoIt() from SupportBean",
         "Failed to validate select-clause expression 'MyClassX.DoIt()': Failed to resolve 'MyClassX.DoIt' to a property, single-row function, aggregation function, script, stream or class name");
 }
Beispiel #28
0
        private static void TryOptimizableBoolean(
            RegressionEnvironment env,
            RegressionPath path,
            string epl)
        {
            // test function returns lookup value and "Equals"
            int count = 10;
            for (int i = 0; i < count; i++) {
                EPCompiled compiled = env.Compile("@Name('s" + i + "')" + epl, path);
                EPDeploymentService admin = env.Runtime.DeploymentService;
                try {
                    admin.Deploy(compiled);
                }
                catch (EPDeployException) {
                    Assert.Fail();
                }
            }

            env.Milestone(0);

            SupportUpdateListener listener = new SupportUpdateListener();
            for (int i = 0; i < 10; i++) {
                env.Statement("s" + i).AddListener(listener);
            }

            var loops = 10000;
            var delta = PerformanceObserver.TimeMillis(
                () => {
                    SupportStaticMethodLib.ResetCountInvoked();
                    for (int i = 0; i < loops; i++) {
                        string key = "E_" + i % 100;
                        env.SendEventBean(new SupportBean(key, 0));
                        if (key.Equals("E_1")) {
                            Assert.AreEqual(count, listener.NewDataList.Count);
                            listener.Reset();
                        }
                        else {
                            Assert.IsFalse(listener.IsInvoked);
                        }
                    }
                });
            Assert.AreEqual(loops, SupportStaticMethodLib.CountInvoked);

            Assert.IsTrue(delta < 1000, "Delta is " + delta);
            env.UndeployAll();
        }
Beispiel #29
0
        public EPDeployment Deploy(
            EPCompiled compiled,
            DeploymentOptions options)
        {
            using (_services.Container.EnterContextualReflection()) {
                if (options == null)
                {
                    options = new DeploymentOptions();
                }

                ValidateRuntimeAlive();
                CheckManifest(-1, compiled.Manifest);

                DeploymentInternal deployerResult;

                using (GetDeploymentLock(options)) {
                    var statementIdRecovery = _services.EpServicesHA.StatementIdRecoveryService;
                    var currentStatementId  = statementIdRecovery.CurrentStatementId;
                    if (currentStatementId == null)
                    {
                        currentStatementId = 1;
                    }

                    var deploymentId = DeployerHelperResolver.DetermineDeploymentIdCheckExists(
                        -1,
                        options,
                        _runtime.ServicesContext.DeploymentLifecycleService);
                    deployerResult = Deployer.DeployFresh(
                        deploymentId,
                        currentStatementId.Value,
                        compiled,
                        options.StatementNameRuntime,
                        options.StatementUserObjectRuntime,
                        options.StatementSubstitutionParameter,
                        options.DeploymentClassLoaderOption,
                        _runtime);
                    statementIdRecovery.CurrentStatementId = currentStatementId + deployerResult.Statements.Length;

                    // dispatch event
                    DispatchOnDeploymentEvent(deployerResult, -1);
                }

                return(MakeDeployment(deployerResult));
            }
        }
Beispiel #30
0
        /// <summary>
        /// Write the compiled to a jar file. Overwrites the existing jar file.
        /// </summary>
        /// <param name="compiled">compiled</param>
        /// <param name="file">the target file</param>
        /// <throws>IOException when the write failed</throws>
        public static void Write(EPCompiled compiled, FileInfo file) {

	        Manifest manifest = new Manifest();
	        manifest.MainAttributes.Put(Attributes.Name.MANIFEST_VERSION, "1.0");
	        manifest.MainAttributes.Put(new Attributes.Name(MANIFEST_COMPILER_VERSION), compiled.Manifest.CompilerVersion);
	        manifest.MainAttributes.Put(new Attributes.Name(MANIFEST_MODULEPROVIDERCLASSNAME), compiled.Manifest.ModuleProviderClassName);
	        manifest.MainAttributes.Put(new Attributes.Name(MANIFEST_QUERYPROVIDERCLASSNAME), compiled.Manifest.QueryProviderClassName);

	        JarOutputStream target = new JarOutputStream(new FileOutputStream(file), manifest);

	        try {
	            foreach (KeyValuePair<string, byte[]> entry in compiled.Classes) {
	                Write(entry.Key, entry.Value, target);
	            }
	        } finally {
	            target.Close();
	        }
	    }