Skip to content

Commit

Permalink
What type of PR is this?
Browse files Browse the repository at this point in the history
 refactor the session-store
  • Loading branch information
yuzhi.lyz committed Dec 21, 2020
1 parent a2aaf1d commit 39954fb
Show file tree
Hide file tree
Showing 21 changed files with 560 additions and 834 deletions.
14 changes: 1 addition & 13 deletions .aci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,4 @@ STC扫描:
- export PATH=$PATH:/opt/taobao/java/bin:/opt/taobao/maven/bin
- java -version
- mvn -version
- mvn clean package -Dmaven.test.skip=true -Pdev

发布JAR包:
stage: 发布JAR包
plugin: ANT-BUILD
pluginConfig:
image: reg.docker.alibaba-inc.com/antb/jarbuild:0.0.1
script:
- java -version
- mvn -version
- sed -i '/<mirrors>/,/<\/mirrors>/d' /opt/taobao/maven_settings/settings-release.xml
- sed -i '/<profiles>/,/<\/profiles>/d' /opt/taobao/maven_settings/settings-release.xml
- mvn clean deploy -Dmaven.test.skip=true -s /opt/taobao/maven_settings/settings-release.xml -Pdev -Pantcode-release
- mvn clean package -Dmaven.test.skip=true -Pdev
3 changes: 2 additions & 1 deletion .master.aci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ STC扫描:
集成测试:
stage: 测试
plugin: LINKQ-IT # java集成测试插件
checkRule:
- passRate = 100
tools:
jdk: '1.8'
maven: 3.0.3
parameters:
encoding: UTF-8 # 编码设置
pluginConfig:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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 com.alipay.sofa.registry.common.model;

import com.alipay.sofa.registry.util.ParaCheckUtil;

import java.io.Serializable;
import java.util.Objects;

/**
*
* @author yuzhi.lyz
* @version v 0.1 2020-12-21 11:14 yuzhi.lyz Exp $
*/
public final class IPPort implements Serializable {
private final String ip;
private final int port;

private IPPort(String ip, int port) {
this.ip = ip;
this.port = port;
}

/**
* Getter method for property <tt>ip</tt>.
* @return property value of ip
*/
public String getIp() {
return ip;
}

/**
* Getter method for property <tt>port</tt>.
* @return property value of port
*/
public int getPort() {
return port;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof IPPort))
return false;
IPPort ipPort = (IPPort) o;
return port == ipPort.port && Objects.equals(ip, ipPort.ip);
}

@Override
public int hashCode() {
return Objects.hash(ip, port);
}

@Override
public String toString() {
return ip + ":" + port;
}

public static IPPort of(String ip, int port) {
ParaCheckUtil.checkNotBlank(ip, "ip");
ParaCheckUtil.checkIsPositive(port, "port");
return new IPPort(ip, port);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.alipay.sofa.registry.common.model.ConnectId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Sets;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public static void checkNonNegative(long v, String paraName) {
}
}

public static void checkIsPositive(long v, String paraName) {
if (v <= 0) {
throw new RuntimeException(String.format("%s is require positive, %d", paraName, v));
}
}

public static void checkContains(Set sets, Object param, String paraName)
throws RuntimeException {
if (!sets.contains(param)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.alipay.sofa.registry.task.listener.TaskEvent;
import com.alipay.sofa.registry.task.listener.TaskEvent.TaskType;
import com.alipay.sofa.registry.task.listener.TaskListenerManager;
import com.alipay.sofa.registry.util.ConcurrentUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;

Expand Down Expand Up @@ -103,12 +104,8 @@ private void fireReSubscriber() {
LOGGER.error("Open push switch first fetch task execute error", e);
}

try {
//wait 1 MINUTES for dataFetch task evict duplicate subscriber push
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException e) {
LOGGER.error("Wait for dataFetch Task Interrupted!");
}
//wait 1 MINUTES for dataFetch task evict duplicate subscriber push
ConcurrentUtils.sleepUninterruptibly(1, TimeUnit.MINUTES);

//fetch task process 1 minutes,can schedule execute fetch task
sessionServerConfig.setBeginDataFetchTask(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void waitingUnthrowable() {
}

private void fetchVersions() {
Collection<String> checkDataInfoIds = sessionInterests.getInterestDataInfoIds();
Collection<String> checkDataInfoIds = sessionInterests.getDataInfoIds();
Map<Integer/*slotId*/, Collection<String>/*dataInfoIds*/> map = calculateDataNode(checkDataInfoIds);
for (Map.Entry<Integer, Collection<String>> e : map.entrySet()) {
final int slotId = e.getKey();
Expand Down Expand Up @@ -318,7 +318,7 @@ public String toString() {

@Override
public void fetchChangDataProcess() {
Collection<String> checkDataInfoIds = sessionInterests.getInterestDataInfoIds();
Collection<String> checkDataInfoIds = sessionInterests.getDataInfoIds();
Map<Integer/*slotId*/, Collection<String>/*dataInfoIds*/> map = calculateDataNode(checkDataInfoIds);

map.forEach((slotId, dataInfoIds) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ public Map<String, Collection<? extends StoreData>> getSessionDataByDataInfoId(@
@PathParam("type") String type) {
Map<String, Collection<? extends StoreData>> serverList = new HashMap<>();
if (dataInfoId != null) {
Collection<Publisher> publishers = sessionDataStore
.getStoreDataByDataInfoId(dataInfoId);
Collection<Subscriber> subscribers = sessionInterests.getInterests(dataInfoId);
Collection<Watcher> watchers = sessionWatchers.getWatchers(dataInfoId);
Collection<Publisher> publishers = sessionDataStore.getDatas(dataInfoId);
Collection<Subscriber> subscribers = sessionInterests.getDatas(dataInfoId);
Collection<Watcher> watchers = sessionWatchers.getDatas(dataInfoId);
fillServerList(type, serverList, publishers, subscribers, watchers);
}

Expand Down Expand Up @@ -189,8 +188,8 @@ public Map<String, Object> getPushSwitch() {
@Produces(MediaType.APPLICATION_JSON)
public Collection<String> getDataInfoIdList() {
Collection<String> ret = new HashSet<>();
ret.addAll(sessionInterests.getInterestDataInfoIds());
ret.addAll(sessionDataStore.getStoreDataInfoIds());
ret.addAll(sessionInterests.getDataInfoIds());
ret.addAll(sessionDataStore.getDataInfoIds());
return ret;
}

Expand Down
Loading

0 comments on commit 39954fb

Please sign in to comment.