public bool ClearCache()
 {
     MerchantCache.Clear();
     TerminalCache.Clear();
     ProcessingFactory.Clear();
     FormFactory.Clear();
     return(true);
 }
 public OperationManagerService(PaymentSystemContext dbContext,
                                ProcessingFactory processingFactory,
                                TerminalSelectorService terminalSelector,
                                ILogger <OperationManagerService> logger,
                                RemoteContainerService <PaymentData> remoteContainer)
 {
     _dbContext         = dbContext;
     _processingFactory = processingFactory;
     _terminalSelector  = terminalSelector;
     _logger            = logger;
     _remoteContainer   = remoteContainer;
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int         orginalDataSetId  = -1;
                string      processMethodName = "";
                DataSetInfo dsInfo            = new DataSetInfo();
                Hashtable   htParas           = new Hashtable();

                // get all parameters
                foreach (string paraName in Request.QueryString.Keys)
                {
                    // if value of the parameter is not null or ""
                    if (Request.QueryString[paraName] != null && Request.QueryString[paraName].Trim() != "")
                    {
                        if (paraName.ToLower() == "id")     // get original dataset id
                        {
                            orginalDataSetId = int.Parse(Request.QueryString[paraName].Trim());
                        }
                        else if (paraName.ToLower() == "methodname")    // get dataset processing method name
                        {
                            processMethodName = Request.QueryString[paraName].Trim();
                        }
                        else if (paraName.ToLower() == "targetname")
                        {
                            dsInfo.Name = Request.QueryString[paraName].Trim();
                        }
                        else    // get other parameters
                        {
                            htParas[paraName] = Request.QueryString[paraName].Trim();
                        }
                    }
                }

                List <DataInfo> lsData = this.GetDataListByDataSetInfo(orginalDataSetId, null);
                if (lsData.Count < 1)
                {
                    Response.Write("no data!");
                    return;
                }
                List <DataInfo> lsDstData = null;
                ProcessingFactory.GetProcessingMethod(ProcessingMethod.CLUSTERING).Process(lsData, htParas, out lsDstData);
                DataSetManager dsMgr = new DataSetManager();
                DataSetInfo    ds    = dsMgr.GetDataSetInfoByData(lsDstData[0], "Jin Lu", dsInfo.Name, "test clustering");
                dsMgr.InsertDataSet(ds);

                DataManager dtMgr = new DataManager();
                dtMgr.CreateDataTable(ds);
                dtMgr.InsertDataList(lsDstData, ds);
            }
        }
        public void Launch(ConnectionPack input)
        {
            bool          _stateful      = false;
            bool          firstOP        = false;
            string        cmd            = input.Cmd;
            List <string> urls           = input.ListUrls;
            List <string> downstreamUrls = input.ReplicaUrlsOutput;

            // in order to make a custom import for the first operator
            if (input.RoutingTypeToReadFromFile != null)
            {
                firstOP = true;
            }

            // split command by keywords
            string pattern = @"INPUT OPS|REP FACT|ROUTING|ADDRESS|OPERATOR SPEC";

            string[] tokens = Regex.Split(cmd, pattern, RegexOptions.IgnoreCase).Where(s => s != String.Empty).ToArray <string>();

            // splitting by 5 keywords should generate 6 tokens
            if (tokens.Length != 6)
            {
                System.Console.WriteLine("Something went wrong while splitting the command!!!");
            }

            // tokens[0] -> operator name
            // tokens[1] -> input file or previous operator
            // tokens[2] -> replication factor
            // tokens[3] -> routing policy
            // tokens[4] -> list of slave's URLs
            // tokens[5] -> name of the transformation function (and possibly parameters)

            /*** create import object ***/
            AbstractFactory importFactory = new ImportFactory();
            Import          importObj     = null;

            // tokenize input
            string importPattern = @",|\s";

            string[] importTokens = Regex.Split(tokens[1], importPattern).Where(s => s != String.Empty).ToArray <string>();

            // list to collect possible file paths
            List <string> filePathsList = new List <string>();

            for (int i = 0; i < importTokens.Length; i++)
            {
                if (importTokens[i].StartsWith("OP")) // input comes from operator
                {
                    importObj = importFactory.GetImport(new string[] { "OpImport" }, null, 0, 0);
                    break;                         // assuming only one operator
                }
                if (importTokens[i].Contains(".")) // input comes from file
                {
                    filePathsList.Add(importTokens[i]);
                }
                else
                {
                    Console.WriteLine("Neither operator nor input file!!!");
                }
            }

            /*** create routing object ***/
            AbstractFactory routingFactory = new RoutingFactory();
            Route           routeObj;

            // tokenize routing policy
            string[] routingTokens;
            string   routingPattern = @"[)(\s]";

            if (input.RoutingType != null)
            {
                routingTokens = Regex.Split(input.RoutingType, routingPattern).Where(s => s != String.Empty).ToArray <string>();
            }
            else
            {
                routingTokens = Regex.Split("Output", routingPattern).Where(s => s != String.Empty).ToArray <string>();
            }

            routeObj = routingFactory.GetRouting(routingTokens, downstreamUrls, input.Semantic.ToLower());

            /*** create processing object ***/
            AbstractFactory processingFactory = new ProcessingFactory();
            Process         processObj;

            // tokenize processing function
            string processingPattern = @",|\s";

            string[] processingTokens = Regex.Split(tokens[5], processingPattern).Where(s => s != String.Empty).ToArray <string>();

            // if it's a count operator or a uniq - it needs state - for exactly-once
            _stateful = Stateful(processingTokens[0]);

            processObj = processingFactory.GetProcessing(processingTokens);

            string[] plainUrls = urls.ToArray().Where(s => s != String.Empty).ToArray <string>();

            bool wasNull = importObj == null;

            foreach (string url in plainUrls)
            {
                if (wasNull)
                {
                    // tokenize routing policy for the first operator
                    string[] merge = firstOP ? FileImportRouting(input.RoutingTypeToReadFromFile) : FileImportRouting(input.RoutingType);
                    // supports both import in the beginning or in the middle
                    if (input.RoutingType != null)
                    {
                        importObj = importFactory.GetImport(merge, filePathsList.ToArray(),
                                                            plainUrls.ToList().IndexOf(url), plainUrls.Length);
                    }
                    else
                    {
                        importObj = importFactory.GetImport(new string[] { "FileImport", "primary" }, filePathsList.ToArray(), plainUrls.ToList().IndexOf(url), plainUrls.Length);
                    }
                }

                System.Diagnostics.Process.Start(@"Slave.exe", SerializeObject(importObj) + " " + SerializeObject(routeObj) + " " +
                                                 SerializeObject(processObj) + " " + SerializeObject(url) + " " + SerializeObject(input.PuppetMasterUrl) + " " +
                                                 SerializeObject(input.IsLogFull) + " " + SerializeObject(input.Semantic.ToLower()) + " " +
                                                 SerializeObject(getSiblings(plainUrls, url)) + " " + SerializeObject(_stateful));
            }
        }