-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 优化字符串拼接代码 2 修改用户指南 3 客户端链接增加client name 4 完善日志 bug修复 1 修复拓扑图展示客户端链接过多导致无法滚动的bug 2 fix 消费者retry流量收集失败导致正常流量停止收集的问题
- Loading branch information
yongfeigao
committed
Jul 22, 2019
1 parent
4c94903
commit 61c2e6e
Showing
16 changed files
with
141 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
mq-cloud/src/main/java/com/sohu/tv/mq/cloud/util/Jointer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.sohu.tv.mq.cloud.util; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* 拼接工具 refrence from com.google.common.base.Joiner | ||
* | ||
* @author yongfeigao | ||
* @date 2019年7月10日 | ||
*/ | ||
public class Jointer { | ||
// 拼接分隔符 | ||
private final String separator; | ||
|
||
public static final Jointer BY_COMMA = new Jointer(","); | ||
|
||
public static final Jointer BY_SEMICOLON = new Jointer(";"); | ||
|
||
public static final String BLANK = ""; | ||
|
||
private Jointer(String separator) { | ||
this.separator = separator; | ||
} | ||
|
||
/** | ||
* 遍历collection的对象获取其joinerValue进行拼接 | ||
* @param collection | ||
* @param joinerValue | ||
* @return String | ||
*/ | ||
public <E> String join(Collection<E> collection, JointerValue<E> joinerValue) { | ||
if (collection == null || collection.isEmpty()) { | ||
return ""; | ||
} | ||
StringBuilder buffer = new StringBuilder(); | ||
Iterator<E> iterator = collection.iterator(); | ||
buffer.append(joinerValue.getValue(iterator.next())); | ||
while (iterator.hasNext()) { | ||
buffer.append(separator); | ||
buffer.append(joinerValue.getValue(iterator.next())); | ||
} | ||
return buffer.toString(); | ||
} | ||
|
||
/** | ||
* 拼接返回值 | ||
* | ||
* @author yongfeigao | ||
* @date 2019年7月11日 | ||
* @param <T> | ||
*/ | ||
public interface JointerValue<T> { | ||
|
||
/** | ||
* 返回打算拼接的字符串 | ||
* @param t | ||
* @return | ||
*/ | ||
public String getValue(T t); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
mq-cloud/src/test/java/com/sohu/tv/mq/cloud/util/JointerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.sohu.tv.mq.cloud.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.sohu.tv.mq.cloud.bo.User; | ||
|
||
public class JointerTest { | ||
|
||
@Test | ||
public void testJoin() { | ||
List<User> userList = new ArrayList<User>(); | ||
User user = new User(); | ||
user.setEmail("[email protected]"); | ||
userList.add(user); | ||
|
||
user = new User(); | ||
user.setEmail("[email protected]"); | ||
userList.add(user); | ||
|
||
String result = Jointer.BY_COMMA.join(userList, u -> u.getEmail()); | ||
Assert.assertEquals("[email protected],[email protected]", result); | ||
} | ||
|
||
@Test | ||
public void testJoinBlank() { | ||
List<User> userList = new ArrayList<User>(); | ||
String result = Jointer.BY_COMMA.join(userList, u -> u.getEmail()); | ||
Assert.assertEquals("", result); | ||
|
||
userList = null; | ||
result = Jointer.BY_COMMA.join(userList, u -> u.getEmail()); | ||
Assert.assertEquals("", result); | ||
} | ||
|
||
@Test | ||
public void testJoinOne() { | ||
List<User> userList = new ArrayList<User>(); | ||
User user = new User(); | ||
user.setEmail("[email protected]"); | ||
userList.add(user); | ||
|
||
String result = Jointer.BY_COMMA.join(userList, u -> u.getEmail()); | ||
Assert.assertEquals("[email protected]", result); | ||
} | ||
} |