Esempio n. 1
0
        /// <summary>
        ///     Validate the variant stream definition.
        /// </summary>
        /// <param name="variantStreamname">the stream name</param>
        /// <param name="variantStreamConfig">the configuration information</param>
        /// <param name="repo">the event types</param>
        /// <returns>specification for variant streams</returns>
        private static VariantSpec ValidateVariantStream(
            string variantStreamname,
            ConfigurationCommonVariantStream variantStreamConfig,
            EventTypeRepositoryImpl repo)
        {
            if (variantStreamConfig.TypeVariance == TypeVariance.PREDEFINED) {
                if (variantStreamConfig.VariantTypeNames.IsEmpty()) {
                    throw new ConfigurationException(
                        "Invalid variant stream configuration, no event type name has been added and default type variance requires at least one type, for name '" +
                        variantStreamname +
                        "'");
                }
            }

            ISet<EventType> types = new LinkedHashSet<EventType>();
            foreach (var typeName in variantStreamConfig.VariantTypeNames) {
                var type = repo.GetTypeByName(typeName);
                if (type == null) {
                    throw new ConfigurationException(
                        "Event type by name '" +
                        typeName +
                        "' could not be found for use in variant stream configuration by name '" +
                        variantStreamname +
                        "'");
                }

                types.Add(type);
            }

            var eventTypes = types.ToArray();
            return new VariantSpec(eventTypes, variantStreamConfig.TypeVariance);
        }
Esempio n. 2
0
        public void TestInvalidConfig()
        {
            ConfigurationCommonVariantStream config = new ConfigurationCommonVariantStream();
            TryInvalidVarstream(config, "Failed compiler startup: Invalid variant stream configuration, no event type name has been added and default type variance requires at least one type, for name 'ABC'");

            config.AddEventTypeName("dummy");
            TryInvalidVarstream(config, "Failed compiler startup: Event type by name 'dummy' could not be found for use in variant stream configuration by name 'ABC'");
        }
Esempio n. 3
0
 private static void AddVariantStream(
     string name,
     ConfigurationCommonVariantStream config,
     EventTypeRepositoryImpl repo,
     EventTypeFactory eventTypeFactory)
 {
     var variantSpec = ValidateVariantStream(name, config, repo);
     var metadata = new EventTypeMetadata(
         name,
         null,
         EventTypeTypeClass.VARIANT,
         EventTypeApplicationType.VARIANT,
         NameAccessModifier.PRECONFIGURED,
         EventTypeBusModifier.BUS,
         false,
         new EventTypeIdPair(CRC32Util.ComputeCRC32(name), -1));
     var variantEventType = eventTypeFactory.CreateVariant(metadata, variantSpec);
     repo.AddType(variantEventType);
 }
Esempio n. 4
0
        private static void Configure(Configuration configuration)
        {
            foreach (var clazz in new[] {
                typeof(SupportBean),
                typeof(SupportBeanVariantStream),
                typeof(SupportBeanVariantOne),
                typeof(SupportBeanVariantTwo),
                typeof(SupportBean_A),
                typeof(SupportBean_B),
                typeof(SupportBean_S0),
                typeof(SupportMarketDataBean)
            }) {
                configuration.Common.AddEventType(clazz);
            }

            IDictionary<string, object> types = new Dictionary<string, object>();
            types.Put("someprop", typeof(string));
            configuration.Common.AddEventType("MyEvent", types);
            configuration.Common.AddEventType("MySecondEvent", types);

            var myVariantTwoTypedSB = new ConfigurationCommonVariantStream();
            myVariantTwoTypedSB.AddEventTypeName("SupportBean");
            myVariantTwoTypedSB.AddEventTypeName("SupportBeanVariantStream");
            configuration.Common.AddVariantStream("MyVariantTwoTypedSB", myVariantTwoTypedSB);

            var myVariantAnyTyped = new ConfigurationCommonVariantStream();
            myVariantAnyTyped.TypeVariance = TypeVariance.ANY;
            configuration.Common.AddVariantStream("MyVariantAnyTyped", myVariantAnyTyped);
            Assert.IsTrue(configuration.Common.IsVariantStreamExists("MyVariantAnyTyped"));

            var myVariantTwoTyped = new ConfigurationCommonVariantStream();
            myVariantTwoTyped.AddEventTypeName("MyEvent");
            myVariantTwoTyped.AddEventTypeName("MySecondEvent");
            configuration.Common.AddVariantStream("MyVariantTwoTyped", myVariantTwoTyped);

            var myVariantTwoTypedSBVariant = new ConfigurationCommonVariantStream();
            myVariantTwoTypedSBVariant.AddEventTypeName("SupportBeanVariantStream");
            myVariantTwoTypedSBVariant.AddEventTypeName("SupportBean");
            configuration.Common.AddVariantStream("MyVariantTwoTypedSBVariant", myVariantTwoTypedSBVariant);

            var myVariantStreamTwo = new ConfigurationCommonVariantStream();
            myVariantStreamTwo.AddEventTypeName("SupportBeanVariantOne");
            myVariantStreamTwo.AddEventTypeName("SupportBeanVariantTwo");
            configuration.Common.AddVariantStream("MyVariantStreamTwo", myVariantStreamTwo);

            var myVariantStreamFour = new ConfigurationCommonVariantStream();
            myVariantStreamFour.AddEventTypeName("SupportBeanVariantStream");
            myVariantStreamFour.AddEventTypeName("SupportBean");
            configuration.Common.AddVariantStream("MyVariantStreamFour", myVariantStreamFour);

            var myVariantStreamFive = new ConfigurationCommonVariantStream();
            myVariantStreamFive.AddEventTypeName("SupportBean");
            myVariantStreamFive.AddEventTypeName("SupportBeanVariantStream");
            configuration.Common.AddVariantStream("MyVariantStreamFive", myVariantStreamFive);

            var varStreamABPredefined = new ConfigurationCommonVariantStream();
            varStreamABPredefined.AddEventTypeName("SupportBean_A");
            varStreamABPredefined.AddEventTypeName("SupportBean_B");
            configuration.Common.AddVariantStream("VarStreamABPredefined", varStreamABPredefined);

            var varStreamAny = new ConfigurationCommonVariantStream();
            varStreamAny.TypeVariance = TypeVariance.ANY;
            configuration.Common.AddVariantStream("VarStreamAny", varStreamAny);

            // test insert into staggered with map
            var configVariantStream = new ConfigurationCommonVariantStream();
            configVariantStream.TypeVariance = TypeVariance.ANY;
            configuration.Common.AddEventType("SupportBean", typeof(SupportBean));
            configuration.Common.AddEventType("SupportMarketDataBean", typeof(SupportMarketDataBean));
            configuration.Common.AddVariantStream("VarStreamMD", configVariantStream);

            configuration.Common.AddImportType(typeof(EventVariantStream));
        }
        private static void Configure(Configuration configuration)
        {
            foreach (var clazz in new[] {
                typeof(SupportBean),
                typeof(OrderBean),
                typeof(OrderWithItems),
                typeof(SupportBeanAtoFBase),
                typeof(SupportBean_A),
                typeof(SupportMarketDataBean),
                typeof(SupportSimpleBeanTwo),
                typeof(SupportSimpleBeanOne),
                typeof(SupportVariableSetEvent),
                typeof(SupportBean_S0),
                typeof(SupportBean_S1),
                typeof(SupportBeanRange),
                typeof(SupportBean_B),
                typeof(SupportOverrideOneA),
                typeof(SupportOverrideOne),
                typeof(SupportOverrideBase),
                typeof(SupportQueueEnter),
                typeof(SupportQueueLeave),
                typeof(SupportBeanAtoFBase),
                typeof(SupportBeanAbstractSub),
                typeof(SupportBean_ST0),
                typeof(SupportBeanTwo),
                typeof(SupportCountAccessEvent),
                typeof(BookDesc),
                typeof(SupportBean_Container),
                typeof(SupportEventWithManyArray),
                typeof(SupportEventWithIntArray)
            }) {
                configuration.Common.AddEventType(clazz);
            }

            IDictionary<string, object> outerMapInnerType = new Dictionary<string, object>();
            outerMapInnerType.Put("key", typeof(string));
            configuration.Common.AddEventType("InnerMap", outerMapInnerType);
            IDictionary<string, object> outerMap = new Dictionary<string, object>();
            outerMap.Put("innermap", "InnerMap");
            configuration.Common.AddEventType("OuterMap", outerMap);

            IDictionary<string, object> typesSimpleKeyValue = new Dictionary<string, object>();
            typesSimpleKeyValue.Put("key", typeof(string));
            typesSimpleKeyValue.Put("value", typeof(long));
            configuration.Common.AddEventType("MySimpleKeyValueMap", typesSimpleKeyValue);

            IDictionary<string, object> innerTypeOne = new Dictionary<string, object>();
            innerTypeOne.Put("i1", typeof(int));
            IDictionary<string, object> innerTypeTwo = new Dictionary<string, object>();
            innerTypeTwo.Put("i2", typeof(int));
            IDictionary<string, object> outerType = new Dictionary<string, object>();
            outerType.Put("one", "T1");
            outerType.Put("two", "T2");
            configuration.Common.AddEventType("T1", innerTypeOne);
            configuration.Common.AddEventType("T2", innerTypeTwo);
            configuration.Common.AddEventType("OuterType", outerType);

            IDictionary<string, object> types = new Dictionary<string, object>();
            types.Put("key", typeof(string));
            types.Put("primitive", typeof(long));
            types.Put("boxed", typeof(long?));
            configuration.Common.AddEventType("MyMapWithKeyPrimitiveBoxed", types);

            var dataType = BuildMap(
                new object[][] {
                    new object[] {"a", typeof(string)},
                    new object[] {"b", typeof(int)}
                });
            configuration.Common.AddEventType("MyMapAB", dataType);

            var legacy = new ConfigurationCommonEventTypeBean();
            legacy.CopyMethod = "MyCopyMethod";
            configuration.Common.AddEventType("SupportBeanCopyMethod", typeof(SupportBeanCopyMethod), legacy);

            configuration.Common.AddEventType("SimpleEventWithId", new string[]{"id"}, new object[]{ typeof(string) });

            configuration.Compiler.AddPlugInSingleRowFunction(
                "setBeanLongPrimitive999",
                typeof(InfraNamedWindowOnUpdate),
                "SetBeanLongPrimitive999");
            configuration.Compiler.AddPlugInSingleRowFunction(
                "increaseIntCopyDouble",
                typeof(InfraNamedWindowOnMerge),
                "IncreaseIntCopyDouble");

            var config = new ConfigurationCommonVariantStream();
            config.AddEventTypeName("SupportBean_A");
            config.AddEventTypeName("SupportBean_B");
            configuration.Common.AddVariantStream("VarStream", config);

            configuration.Common.Logging.IsEnableQueryPlan = true;
        }
Esempio n. 6
0
 private void TryInvalidVarstream(ConfigurationCommonVariantStream config, string expected)
 {
     TryInvalidConfigurationCompiler(SupportConfigFactory.GetConfiguration(), configuration => configuration.Common.AddVariantStream("ABC", config), expected);
 }