JedisClusterConstructorWithListHostAndPortArgInterceptor implements InstanceConstructorInterceptor { @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { StringBuilder redisConnInfo = new StringBuilder(); Set<HostAndPort> hostAndPorts = (Set<HostAndPort>) allArguments[0]; for (HostAndPort hostAndPort : hostAndPorts) { redisConnInfo.append(hostAndPort.toString()).append(";"); } objInst.setSkyWalkingDynamicField(PeerFormat.shorten(redisConnInfo.toString())); }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@Test public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {hostAndPortSet}); verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379;127.0.0.1:16379;"); }
@Test public void onHugeClusterConstruct() throws Exception { hostAndPortSet = new LinkedHashSet<HostAndPort>(); for (int i = 0; i < 100; i++) { hostAndPortSet.add(new HostAndPort("localhost", i)); } enhancedInstance = new EnhancedInstance() { private Object v; @Override public Object getSkyWalkingDynamicField() { return v; } @Override public void setSkyWalkingDynamicField(Object value) { this.v = value; } }; interceptor.onConstruct(enhancedInstance, new Object[] {hostAndPortSet}); Assert.assertTrue(enhancedInstance.getSkyWalkingDynamicField().toString().length() == 200); }