================ 状态数据同步 ================
437281
private void initTermin() {
        String path = StagePathUtils.getTerminRoot(getPipelineId());
        List<String> termins = zookeeper.getChildren(path);
        initTermin(termins);
    }
379968
function on(ele, type, callback) {
    let body = document.body;

    // 注册事件元素和类型
    if (!eventList[ele]) {
        eventList[ele] = {};
    }
    eventList[ele][type] = callback;

    /**
     * 在 body 元素上绑定事件, 统一管理事件
     */
    body.addEventListener(type, (e)=> {
        let eTag     = e.target,
            eleEvent = eventList[ele],
            eleList  = document.querySelectorAll(ele);

        // 向上冒泡匹配元素
        while (!([].indexOf.call(eleList, eTag) !== -1) && eTag !== body) {
            eTag = eTag.parentNode;
        }
        e.stopPropagation();
        e.preventDefault();
        if (eTag !== body && !!eleEvent) {
            if (!!eleEvent[type]) {
                eleEvent[type](eTag);

                // 如果当前元素事件属于需要被移除的事件，则在队列中进行删除
                if (offList.indexOf(ele + type) !== -1) {
                    delete eventList[ele][type];
                }
            }
        }
    });
}
926494
function initListener ( controller ) {

            // 记录是否允许所有事件的监听
        var isBegin = false,
            // 记录是否需要更新曲线
            isUpdateable = false,
            paper = controller.paper,
            currentBezier = null,
            currentPointGroup = null;

        paper.on( "mousedown", function ( e ) {

            var point = null;

            e.preventDefault();

            if ( !controller.drawState ) {
                return;
            }

            // 切换监听状态
            if ( !isBegin ) {
                isBegin = true;
                currentBezier = createBezier( paper );
                currentPointGroup = createPointGroup( paper );

                listenPointGroup( currentPointGroup, controller );

                //设置当前controller处理的贝塞尔曲线
                controller.setBezier( currentBezier );
                controller.setPointGroup( currentPointGroup );
            }

            isUpdateable = false;

            // 获取当前鼠标点击在用户坐标系上的映射点
            point = e.getPosition();

            updateBezier( controller, point );

        } );

        // 绘制时 更新控制点
        paper.on( "mousemove", function ( e ) {

            var point = null,
                bezierPoint = null;

            e.preventDefault();

            if ( !controller.drawState ) {
                return;
            }

            if ( !isBegin || isUpdateable ) {
                return;
            }

            point = e.getPosition();

            currentBezier.getLastPoint().setForward( point.x, point.y );
            currentPointGroup.getLastPoint().setForward( point.x, point.y );

        } );

        // 编辑时拖动更新
        paper.on( "mousemove", function ( e ) {

            var mousePoint = null,
                currentPoint = null,
                pointIndex = -1;

            e.preventDefault();

            // 不可编辑
            if ( !controller.editable ) {
                return;
            }

            mousePoint = e.getPosition();
            pointIndex = controller._modifyStatus.pointIndex;
            currentPoint = currentPointGroup.getPointByIndex( pointIndex );

            switch ( controller._modifyStatus.pointType ) {

                case PointGroup.TYPE_FORWARD:
                    currentPoint.setForward( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).setForward( mousePoint.x, mousePoint.y );
                    break;

                case PointGroup.TYPE_BACKWARD:
                    currentPoint.setBackward( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).setBackward( mousePoint.x, mousePoint.y );
                    break;

                case PointGroup.TYPE_VERTEX:
                    currentPoint.moveTo( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).moveTo( mousePoint.x, mousePoint.y );
                    break;

            }


        } );

        paper.on( "mouseup", function () {

            if ( controller.drawState ) {

                isUpdateable = isBegin;

            } else if ( controller.modifyState ) {

                controller.disableEdit();
                // 清空状态
                controller.clearModifySatus();

            }

        } );

    }
561343
function onTransitionAndAnimationEnd(e) {
    console.log(Constant._debugger, "------------------------------onTransitionAndAnimationEnd");
    /***
     * 如果当前页面的transition为material则肯定不会执行webkitTransitionEnd事件
     */
    if (e.type === "webkitTransitionEnd" && e.target.getAttribute("data-ct-data-role") !== "page") {
      return;
    }

    if (self.pageTransitionType) {
      if (self.pageTransitionType === "start") {
        delete self.pageTransitionType;
        pageStartTransitionEndCallback.call(self, e);
      } else if (self.pageTransitionType === "finish") {
        delete self.pageTransitionType;
        pageFinishTransitioneEndCallback.call(self, e);
      }
    }
  }
313924
private static void packagingAction(Method[] methods, Object handlerBean) {
        if (ArrayUtils.isEmpty(methods)) {
            return;
        }
        // 参数唯一，且为public
        Predicate<Method> commonFilter = method -> Modifier.isPublic(method.getModifiers())
                && method.getParameterCount() == 1
                && Objects.isNull(handlerBean) == Modifier.isStatic(method.getModifiers());

        Arrays.stream(methods).filter(commonFilter).forEach(method -> ConverterContext.setAction(method, handlerBean));
    }
914647
function init() {
  const {supportCordova = false} = this.config;

  onReady = onReady.bind(this);

  /***
   * 如果开启了对cordova的支持
   */
  if (supportCordova) {
    /***
     * 如果开启了对cordova的支持，那么页面完成事件和cordova的deviceReady事件必须同时完成后才能支持后续代码
     */
    Promise.all([
      readyPromise(),
      DOMContentLoadedPromise(),
      devicereadyPromise()
    ]).then(() => {
      onReady();
      fireEvent(window.document, "DOMContentAndDeviceReady");
    }).catch((error) => {

    });
  }
  else {
    /***
     * 页面载入完成事件
     */
    $(window.document).ready(onReady);

    /***
     * 自动 init
     */
    window.addEventListener("DOMContentLoaded", onReady);
  }
}
1130990
public static void blockUntilReady() {
        Set<String> notReady = new HashSet<String>() {{
            addAll(EnvUtil.getDependencies());
        }};
        while (!notReady.isEmpty()) {
            LOG.info("等待被依赖组件'" + notReady + "'...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                LOG.error(e1);
            }
            for (String dependentApplication : EnvUtil.getDependencies()) {
                LOG.debug("这里每次均检查所有被依赖节点，而不是检查notReady集合");
                try {
                    ApplicationRouter.singleton.allInstances(dependentApplication);
                    notReady.remove(dependentApplication);
                } catch (ApplicationOfflineException | ApplicationUndefinedException e) {
                    LOG.info("受依赖组件未启动：" + dependentApplication);
                }
            }
        }
    }
174023
function (uri, fromUri, source) {
        if (!/^\./.test(uri) || EXTNAME_RE.test(uri)) {

            var line;

            // 如果只出现一次这个字符串，很容易确认模板错误行
            if (source.split(uri).length === 2) {
                source.split(/\n/).forEach(function (code, index) {
                    if (code.indexOf(uri) !== -1) {
                        line = index + 1;
                        source = code.trim();
                    }
                });
            }

            var error = {
                name: 'Syntax Error',
                line: line,
                source: source,
                message: 'Template must be a relative path, and can not have a suffix.'
            };

            if (fromUri) {
                error.filename = fromUri;
            }

            throw error;
        }
    }
40180
private HttpResponse forceSync() {
		// 非同步状态转为同步状态
		try {
			this.readBody(this.in);
		} catch (IORuntimeException e) {
			if (e.getCause() instanceof FileNotFoundException) {
				// 服务器无返回内容，忽略之
			} else {
				throw new HttpException(e);
			}
		} finally {
			if (this.isAsync) {
				this.isAsync = false;
			}
			this.close();
		}
		return this;
	}
588905
private void merger(Term fromTerm, int to, Map<String, Double> relationMap) {
        Term term = null;
        if (terms[to] != null) {
            term = terms[to];
            while (term != null) {
                // 关系式to.set(from)
                term.setPathScore(fromTerm, relationMap);
                term = term.next();
            }
        } else {
            char c = chars[to];
            TermNatures tn = DATDictionary.getItem(c).termNatures;
            if (tn == null || tn == TermNatures.NULL) {
                tn = TermNatures.NULL;
            }
            terms[to] = new Term(String.valueOf(c), to, tn);
            terms[to].setPathScore(fromTerm, relationMap);
        }
    }
504873
function Context(ret) {
    this.ret = ret;

    // 初始化文件列表
    var fileMap = this.filePathMap = ret.src;

    // 初始化资源映射表
    var fileIdMap = this.fileIdMap = {};
    var fileUrlMap = this.fileUrlMap = {};
    var files = this.files = [];
    Object.keys(fileMap).forEach(function (subpath) {
        var file = fileMap[subpath];
        files.push(file);
        fileIdMap[file.id] = file;
        if (file.release) {
            fileUrlMap[file.getUrl()] = file;
        }
    });
    this.resIdMap = {};
    this.root = fis.project.getProjectPath();
    this.requireConfig = getAmdConfig();
    this.moduleConfig = amdHelper.initModuleConfig(this.requireConfig, this.root);
    this.toPackItems = [];
}
119071
function () {
            var _this = this;

            /* 滚动拉取图片 */
            domUtils.on($G('imageList'), 'scroll', function(e){
                var panel = this;
                if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
                    _this.getImageData();
                }
            });
            /* 选中图片 */
            domUtils.on(this.container, 'click', function (e) {
                var target = e.target || e.srcElement,
                    li = target.parentNode;

                if (li.tagName.toLowerCase() == 'li') {
                    if (domUtils.hasClass(li, 'selected')) {
                        domUtils.removeClasses(li, 'selected');
                    } else {
                        domUtils.addClass(li, 'selected');
                    }
                }
            });
        }
1109031
private void doDdl(DbLoadContext context, List<EventData> eventDatas) {
        for (final EventData data : eventDatas) {
            DataMedia dataMedia = ConfigHelper.findDataMedia(context.getPipeline(), data.getTableId());
            final DbDialect dbDialect = dbDialectFactory.getDbDialect(context.getIdentity().getPipelineId(),
                (DbMediaSource) dataMedia.getSource());
            Boolean skipDdlException = context.getPipeline().getParameters().getSkipDdlException();
            try {
                Boolean result = dbDialect.getJdbcTemplate().execute(new StatementCallback<Boolean>() {

                    public Boolean doInStatement(Statement stmt) throws SQLException, DataAccessException {
                        Boolean result = true;
                        if (dbDialect instanceof MysqlDialect && StringUtils.isNotEmpty(data.getDdlSchemaName())) {
                            // 如果mysql，执行ddl时，切换到在源库执行的schema上
                            // result &= stmt.execute("use " +
                            // data.getDdlSchemaName());

                            // 解决当数据库名称为关键字如"Order"的时候,会报错,无法同步
                            result &= stmt.execute("use `" + data.getDdlSchemaName() + "`");
                        }
                        result &= stmt.execute(data.getSql());
                        return result;
                    }
                });
                if (result) {
                    context.getProcessedDatas().add(data); // 记录为成功处理的sql
                } else {
                    context.getFailedDatas().add(data);
                }

            } catch (Throwable e) {
                if (skipDdlException) {
                    // do skip
                    logger.warn("skip exception for ddl : {} , caused by {}", data, ExceptionUtils.getFullStackTrace(e));
                } else {
                    throw new LoadException(e);
                }
            }

        }
    }
1030375
public function syncAllUserOpenIdsAction()
    {
        if ($this->isPhpunit()) {
            return $this->suc('单元测试下,不执行同步');
        }

        // 确保不超时
        set_time_limit(0);

        // 1. 获取默认微信账户,初始化变量
        $wei = wei();
        $account = $wei->wechatAccount->getCurrentAccount();
        $api = $account->createApiService();

        // 本次同步新增用户数
        $newCount = 0;

        // 缓存未命中数
        $cacheMiss = 0;

        // 记录开始时间
        $startTime = microtime(true);

        // 储存下次同步的OpenID
        $cacheKey = 'nextOpenId' . $account['id'];

        // 2. 通过上次最后同步的OpenID,获取这次要同步用户的OpenID
        $nextOpenId = $wei->cache->get($cacheKey) ?: null;
        $userOpenIds = $api->getUserOpenIds($nextOpenId);

        if (!$userOpenIds) {
            return $this->err($api->getResult());
        }

        // 记录下次要同步的OpenID
        $nextOpenId = $userOpenIds['count'] == 10000 ? $userOpenIds['next_openid'] : null;
        $wei->cache->set($cacheKey, $nextOpenId);

        if ($userOpenIds['count'] > 2000 && function_exists('fastcgi_finish_request')) {
            echo '用户超过2000个,请在日志查看同步结果';
            fastcgi_finish_request();
        }

        $this->logger->debug('GetUserOpenIds', [
            'total' => $userOpenIds['total'],
            'count' => $userOpenIds['count'],
        ]);

        // 3. 逐个检查用户是否存在,如果不存在,创建新用户
        foreach ($userOpenIds['data']['openid'] as $index => $openId) {
            $wei->cache->get(
                'wechatOpenId' . $openId,
                function () use ($wei, $openId, &$newCount, &$cacheMiss, $account) {
                    // 缓存未命中+1
                    ++$cacheMiss;

                    // 3.1 通过缓存,检查用户是否已经存在
                    $user = $wei->user()->findOrInit(['wechatOpenId' => $openId]);

                    // 3.2 用户不存在,则创建新用户
                    if ($user->isNew()) {
                        ++$newCount;
                        $user->save();
                    }

                    // 3.3 确保下次不会再同步该用户
                    return true;
                }
            );

            // 3.4 每同步50个用户,稍作休息0.1秒
            if ($index % 50 == 0) {
                $this->logger->debug('Synced 50 users');
                time_nanosleep(0, 100000000);
            }
        }

        $result = [
            'total' => $userOpenIds['total'],
            'newCount' => $newCount,
            'cacheMiss' => $cacheMiss,
            'cacheHitRate' => round(($userOpenIds['total'] - $cacheMiss) / $userOpenIds['total'], 2),
            'startTime' => date('Y-m-d H:i:s', $startTime),
            'costSeconds' => round(microtime(true) - $startTime, 1),
        ];

        $this->logger->info('Sync all user open ids result', $result);

        return $this->suc($result);
    }
1195781
public function init() {
		//触发应用开始事件
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_START));

		//初始化配置
		$this->registerFacdes();

		//设置时区
		$timezone = $this->make('config')->get('timezone', 'Asia/Shanghai');
		date_default_timezone_set($timezone);

		//设置调试模式
		$debugMode = $this->make('config')->get('debug') === true;
		$this->setDebugMode($debugMode);
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_READY));
	}
663832
private void handle(SelectionKey key) {
		// 有客户端接入此服务端
		if (key.isAcceptable()) {
			// 获取通道 转化为要处理的类型
			final ServerSocketChannel server = (ServerSocketChannel) key.channel();
			SocketChannel socketChannel;
			try {
				// 获取连接到此服务器的客户端通道
				socketChannel = server.accept();
			} catch (IOException e) {
				throw new IORuntimeException(e);
			}

			// SocketChannel通道的可读事件注册到Selector中
			registerChannel(selector, socketChannel, Operation.READ);
		}

		// 读事件就绪
		if (key.isReadable()) {
			final SocketChannel socketChannel = (SocketChannel) key.channel();
			read(socketChannel);

			// SocketChannel通道的可写事件注册到Selector中
			registerChannel(selector, socketChannel, Operation.WRITE);
		}

		// 写事件就绪
		if (key.isWritable()) {
			final SocketChannel socketChannel = (SocketChannel) key.channel();
			write(socketChannel);
			// SocketChannel通道的可读事件注册到Selector中
			registerChannel(selector, socketChannel, Operation.READ);
		}
	}
677413
function (element, type, handler, context) {
            var own = this;

            //非DOM元素不处理 handler 非function 不处理
            if (!(1 == element.nodeType || element.nodeType == 9 || element === window) || !vQ.isFunction(handler)) {
                return;
            }

            //多个事件处理
            if (vQ.isArray(type)) {
                return own._handleMultipleEvents(own.observe, element, type, handler);
            }

            var _handler = handler;

            //上下文对象处理
            if (context) {
                _handler = function () {
                    handler.apply(context, arguments);
                };
                own._contextHandler[handler.$$guid] = _handler;
                _handler.$$guid = handler.$$guid = handler.$$guid || own._guid++;
            }

            //调用原生方法绑定事件
            if (element.addEventListener) {
                element.addEventListener(type, _handler, false);
            } else {
                //IE等 自行托管事件

                // assign each event handler a unique ID
                if (!_handler.$$guid) _handler.$$guid = this._guid++;
                // create a hash table of event types for the element
                if (!element.events) element.events = {};
                // create a hash table of event handlers for each element/event pair
                var handlers = element.events[type];
                if (!handlers) {
                    handlers = element.events[type] = {};
                    // store the existing event handler (if there is one)
                    if (element['on' + type]) {
                        handlers[0] = element['on' + type];
                    }
                }
                // store the event handler in the hash table
                handlers[_handler.$$guid] = _handler;
                // assign a global event handler to do all the work
                element['on' + type] = own._handleEvent;
            }
        }