You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/03/06 06:49:00 UTC

[GitHub] liubao68 commented on a change in pull request #568: [SCB-352] Support provider operation level flow control

liubao68 commented on a change in pull request #568: [SCB-352] Support provider operation level flow control
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/568#discussion_r172423155
 
 

 ##########
 File path: handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/config/QpsDynamicConfigWatcher.java
 ##########
 @@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.qps.config;
+
+import java.util.Map;
+
+import org.apache.servicecomb.core.definition.OperationMeta;
+import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.apache.servicecomb.qps.QpsController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.eventbus.EventBus;
+import com.netflix.config.DynamicProperty;
+
+/**
+ * Watch qps config and refresh corresponding {@link org.apache.servicecomb.qps.QpsController}.
+ */
+public class QpsDynamicConfigWatcher {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(QpsDynamicConfigWatcher.class);
+
+  public static final String SEPARATOR = ".";
+
+  private final EventBus eventBus = new EventBus();
+
+  /**
+   * Contains three kinds of keys which are corresponding to the actual qps configuration:
+   * <ul>
+   *   <li>microservice</li>
+   *   <li>microservice.schema</li>
+   *   <li>microservice.schema.operation</li>
+   * </ul>
+   */
+  private final Map<String, QpsController> qpsControllerMap = new ConcurrentHashMapEx<>();
+
+  private QpsController globalQpsController;
+
+  private String qpsLimitConfigKeyPrefix = "";
+
+  /**
+   * Register a new observer. Once the qps config is changed, observer will be noticed.
+   *
+   * @param subscriber the registered observer
+   */
+  public void register(Object subscriber) {
+    LOGGER.info("An observer is registered: [{}]", subscriber);
 
 Review comment:
   This will print an object address

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services