Skip to content

Commit

Permalink
fix codeReview comments
Browse files Browse the repository at this point in the history
  • Loading branch information
panxiaojun233 committed Feb 6, 2023
1 parent 4099daa commit ae09653
Show file tree
Hide file tree
Showing 31 changed files with 117 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Set;

import com.alibaba.csp.sentinel.traffic.rule.traffic.router.TrafficRouterRuleManager;
import com.alibaba.csp.sentinel.traffic.rule.router.TrafficRouterRuleManager;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public Map<String, String> getMetadata() {
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}

@Override
public String toString() {
return "Instance{" +
"appName='" + appName + '\'' +
", host='" + host + '\'' +
", port=" + port +
", metadata=" + metadata +
", targetInstance=" + targetInstance +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package com.alibaba.csp.sentinel.traffic;

/**
* The subscriber of traffic rule.
* The observer for remote provider app change event.
* @author panxiaojun233
*/
public interface TrafficRuleSubscriber {
public interface RemoteAppObserver {

void subscribe(String app);
void onRemoteAppAppears(String app);

void unSubscribe(String app);
void onRemoteAppDisappears(String app);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import java.util.concurrent.ThreadLocalRandom;

import com.alibaba.csp.sentinel.traffic.rule.TrafficRoutingRuleGroup;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.Route;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.RouteDetail;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.TrafficRouter;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.TrafficRouterRuleManager;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.destination.Destination;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.destination.RouteDestination;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.match.RequestMatch;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.match.StringMatch;
import com.alibaba.csp.sentinel.traffic.rule.vritual.workload.Subset;
import com.alibaba.csp.sentinel.traffic.rule.vritual.workload.VirtualWorkload;
import com.alibaba.csp.sentinel.traffic.rule.router.Route;
import com.alibaba.csp.sentinel.traffic.rule.router.RouteDetail;
import com.alibaba.csp.sentinel.traffic.rule.router.TrafficRouter;
import com.alibaba.csp.sentinel.traffic.rule.router.TrafficRouterRuleManager;
import com.alibaba.csp.sentinel.traffic.rule.router.destination.Destination;
import com.alibaba.csp.sentinel.traffic.rule.router.destination.RouteDestination;
import com.alibaba.csp.sentinel.traffic.rule.router.match.RequestMatch;
import com.alibaba.csp.sentinel.traffic.rule.router.match.StringMatch;
import com.alibaba.csp.sentinel.traffic.rule.workload.Subset;
import com.alibaba.csp.sentinel.traffic.rule.workload.VirtualWorkload;
import com.alibaba.csp.sentinel.util.StringUtil;

/**
Expand Down Expand Up @@ -170,7 +170,7 @@ protected List<RouteDestination> getRouteDestination(TrafficRoutingRuleGroup tra
protected List<RouteDestination> getRouteDestination(List<Route> routes, TrafficContext context) {

for (Route route : routes) {
List<RouteDetail> routeDetailList = route.getRoutedetail();
List<RouteDetail> routeDetailList = route.getRouteDetail();
if (routeDetailList != null && routeDetailList.size() > 0) {
for (RouteDetail routeDetail : routeDetailList) {
List<RequestMatch> requestMatchList = routeDetail.getMatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.LinkedList;
import java.util.List;

import com.alibaba.csp.sentinel.traffic.rule.traffic.router.TrafficRouter;
import com.alibaba.csp.sentinel.traffic.rule.vritual.workload.VirtualWorkload;
import com.alibaba.csp.sentinel.traffic.rule.router.TrafficRouter;
import com.alibaba.csp.sentinel.traffic.rule.workload.VirtualWorkload;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router;
package com.alibaba.csp.sentinel.traffic.rule.router;

import java.util.List;

import com.alibaba.csp.sentinel.traffic.rule.traffic.router.match.StringMatch;
import com.alibaba.csp.sentinel.traffic.rule.router.match.StringMatch;

/**
* @author panxiaojun233
*/
public class Route {
private String name;
private List<StringMatch> services;
private List<RouteDetail> routedetail;
private List<RouteDetail> routeDetail;

public String getName() {
return name;
Expand All @@ -43,20 +43,20 @@ public void setServices(List<StringMatch> services) {
this.services = services;
}

public List<RouteDetail> getRoutedetail() {
return routedetail;
public List<RouteDetail> getRouteDetail() {
return routeDetail;
}

public void setRoutedetail(List<RouteDetail> routedetail) {
this.routedetail = routedetail;
public void setRouteDetail(List<RouteDetail> routeDetail) {
this.routeDetail = routeDetail;
}

@Override
public String toString() {
return "DubboRoute{" +
return "Route{" +
"name='" + name + '\'' +
", services=" + services +
", routedetail=" + routedetail +
", routeDetail=" + routeDetail +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router;
package com.alibaba.csp.sentinel.traffic.rule.router;

import java.util.List;

import com.alibaba.csp.sentinel.traffic.rule.traffic.router.destination.RouteDestination;
import com.alibaba.csp.sentinel.traffic.rule.traffic.router.match.RequestMatch;
import com.alibaba.csp.sentinel.traffic.rule.router.destination.RouteDestination;
import com.alibaba.csp.sentinel.traffic.rule.router.match.RequestMatch;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router;
package com.alibaba.csp.sentinel.traffic.rule.router;

import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router;
package com.alibaba.csp.sentinel.traffic.rule.router;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import com.alibaba.csp.sentinel.spi.SpiLoader;
import com.alibaba.csp.sentinel.traffic.TrafficRuleSubscriber;
import com.alibaba.csp.sentinel.traffic.RemoteAppObserver;
import com.alibaba.csp.sentinel.traffic.rule.TrafficRoutingRuleGroup;

/**
Expand All @@ -28,7 +28,7 @@
public class TrafficRouterRuleManager {

private static final ConcurrentHashMap<String, Object> trafficRouterRuleListenerMap = new ConcurrentHashMap<>();
private static List<TrafficRuleSubscriber> subscribers = SpiLoader.of(TrafficRuleSubscriber.class)
private static List<RemoteAppObserver> subscribers = SpiLoader.of(RemoteAppObserver.class)
.loadInstanceList();
private static volatile TrafficRoutingRuleGroup trafficRoutingRuleGroup = new TrafficRoutingRuleGroup();
private static final Object object = new Object();
Expand All @@ -44,16 +44,16 @@ public static TrafficRoutingRuleGroup getTrafficRoutingRules() {
public static synchronized void register(String app) {
trafficRouterRuleListenerMap.put(app, object);

for (TrafficRuleSubscriber subscriber : subscribers) {
subscriber.subscribe(app);
for (RemoteAppObserver subscriber : subscribers) {
subscriber.onRemoteAppAppears(app);
}
}

public static synchronized void unregister(String app) {
trafficRouterRuleListenerMap.remove(app);
// todo unsubscribe
for (TrafficRuleSubscriber subscriber : subscribers) {
subscriber.unSubscribe(app);
for (RemoteAppObserver subscriber : subscribers) {
subscriber.onRemoteAppDisappears(app);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.destination;
package com.alibaba.csp.sentinel.traffic.rule.router.destination;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.destination;
package com.alibaba.csp.sentinel.traffic.rule.router.destination;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

/**
* @author panxiaojun233
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.traffic.rule.traffic.router.match;
package com.alibaba.csp.sentinel.traffic.rule.router.match;

import java.util.List;

Expand Down
Loading

0 comments on commit ae09653

Please sign in to comment.