remove the logic of generated instance name in KafkaServiceManagementServiceClient prepare phase(#7357) (#7358)
This commit is contained in:
parent
da9426dd6e
commit
a7abb1f590
|
|
@ -38,6 +38,7 @@ Release Notes.
|
|||
* Chore: polish methods naming for `Spring-Kafka` plugins.
|
||||
* Remove plugins for ShardingSphere legacy version.
|
||||
* Update agent plugin for ElasticJob GA version
|
||||
* Remove the logic of generating instance name in `KafkaServiceManagementServiceClient` class.
|
||||
|
||||
#### OAP-Backend
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.skywalking.apm.agent.core.kafka;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -42,7 +41,6 @@ import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair;
|
|||
import org.apache.skywalking.apm.network.management.v3.InstancePingPkg;
|
||||
import org.apache.skywalking.apm.network.management.v3.InstanceProperties;
|
||||
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* A service management data(Instance registering properties and Instance pinging) reporter.
|
||||
|
|
@ -74,10 +72,6 @@ public class KafkaServiceManagementServiceClient implements BootService, Runnabl
|
|||
.setValue(Config.Agent.INSTANCE_PROPERTIES.get(key))
|
||||
.build());
|
||||
}
|
||||
|
||||
Config.Agent.INSTANCE_NAME = StringUtil.isEmpty(Config.Agent.INSTANCE_NAME)
|
||||
? UUID.randomUUID().toString().replaceAll("-", "") + "@" + OSUtil.getIPV4()
|
||||
: Config.Agent.INSTANCE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.skywalking.apm.agent.core.kafka;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.apache.skywalking.apm.agent.core.conf.Config;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
import org.junit.Test;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class KafkaServiceManagementServiceClientTest {
|
||||
|
||||
@Test
|
||||
public void testInstanceName() throws Exception {
|
||||
ServiceManager instance = ServiceManager.INSTANCE;
|
||||
Method loadAllServicesMethod = instance.getClass().getDeclaredMethod("loadAllServices");
|
||||
loadAllServicesMethod.setAccessible(true);
|
||||
Object loadAllServices = loadAllServicesMethod.invoke(instance);
|
||||
|
||||
Field bootedServicesField = instance.getClass().getDeclaredField("bootedServices");
|
||||
bootedServicesField.setAccessible(true);
|
||||
bootedServicesField.set(instance, loadAllServices);
|
||||
|
||||
Method prepare = instance.getClass().getDeclaredMethod("prepare");
|
||||
prepare.setAccessible(true);
|
||||
prepare.invoke(instance);
|
||||
|
||||
assertThat(StringUtil.isNotBlank(Config.Agent.INSTANCE_NAME), is(true));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue