no message
This commit is contained in:
parent
5db840393e
commit
f71bb057a5
|
|
@ -14,11 +14,11 @@ public class ComponentCache {
|
|||
private static Cache<String, Integer> CACHE = CacheBuilder.newBuilder().maximumSize(1000).build();
|
||||
|
||||
public static int get(int applicationId, String componentName) {
|
||||
INodeComponentDAO dao = (INodeComponentDAO)DAOContainer.INSTANCE.get(INodeComponentDAO.class.getName());
|
||||
try {
|
||||
return CACHE.get(applicationId + Const.ID_SPLIT + componentName, () ->
|
||||
dao.getComponentId(applicationId, componentName)
|
||||
);
|
||||
return CACHE.get(applicationId + Const.ID_SPLIT + componentName, () -> {
|
||||
INodeComponentDAO dao = (INodeComponentDAO)DAOContainer.INSTANCE.get(INodeComponentDAO.class.getName());
|
||||
return dao.getComponentId(applicationId, componentName);
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ public class NodeComponentSpanListener implements EntrySpanListener, ExitSpanLis
|
|||
|
||||
@Override
|
||||
public void parseExit(SpanObject spanObject, int applicationId, int applicationInstanceId, String segmentId) {
|
||||
String componentName = ComponentsDefine.getComponentName(spanObject.getComponentId());
|
||||
String componentName = ComponentsDefine.getInstance().getComponentName(spanObject.getComponentId());
|
||||
createNodeComponent(spanObject, applicationId, componentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseEntry(SpanObject spanObject, int applicationId, int applicationInstanceId, String segmentId) {
|
||||
String componentName = ComponentsDefine.getComponentName(spanObject.getComponentId());
|
||||
String componentName = ComponentsDefine.getInstance().getComponentName(spanObject.getComponentId());
|
||||
createNodeComponent(spanObject, applicationId, componentName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.skywalking.apm.collector.agentstream.worker.storage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.skywalking.apm.collector.core.framework.Starter;
|
||||
import org.skywalking.apm.collector.stream.worker.WorkerException;
|
||||
import org.skywalking.apm.collector.stream.worker.impl.ExchangeWorker;
|
||||
|
|
@ -20,20 +22,9 @@ public class IDNameExchangeTimer implements Starter {
|
|||
logger.info("id and name exchange timer start");
|
||||
//TODO timer value config
|
||||
// final long timeInterval = EsConfig.Es.Persistence.Timer.VALUE * 1000;
|
||||
final long timeInterval = 3 * 1000;
|
||||
final long timeInterval = 3;
|
||||
|
||||
Thread exchangeThread = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
exchangeLastData();
|
||||
Thread.sleep(timeInterval);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
exchangeThread.setName("timerExchange");
|
||||
exchangeThread.start();
|
||||
Executors.newSingleThreadScheduledExecutor().schedule(() -> exchangeLastData(), timeInterval, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void exchangeLastData() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package org.skywalking.apm.collector.agentstream.worker.storage;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.skywalking.apm.collector.core.framework.Starter;
|
||||
import org.skywalking.apm.collector.storage.dao.DAOContainer;
|
||||
import org.skywalking.apm.collector.storage.dao.IBatchDAO;
|
||||
|
|
@ -23,20 +25,8 @@ public class PersistenceTimer implements Starter {
|
|||
logger.info("persistence timer start");
|
||||
//TODO timer value config
|
||||
// final long timeInterval = EsConfig.Es.Persistence.Timer.VALUE * 1000;
|
||||
final long timeInterval = 3 * 1000;
|
||||
|
||||
Thread persistenceThread = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
extractDataAndSave();
|
||||
Thread.sleep(timeInterval);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
persistenceThread.setName("timerPersistence");
|
||||
persistenceThread.start();
|
||||
final long timeInterval = 3;
|
||||
Executors.newSingleThreadScheduledExecutor().schedule(() -> extractDataAndSave(), timeInterval, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void extractDataAndSave() {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package org.skywalking.apm.network.trace.component;
|
|||
* @author wusheng
|
||||
*/
|
||||
public class ComponentsDefine {
|
||||
|
||||
public static final OfficialComponent TOMCAT = new OfficialComponent(1, "Tomcat");
|
||||
|
||||
public static final OfficialComponent HTTPCLIENT = new OfficialComponent(2, "HttpClient");
|
||||
|
|
@ -30,33 +31,39 @@ public class ComponentsDefine {
|
|||
|
||||
public static final OfficialComponent OKHTTP = new OfficialComponent(12, "OKHttp");
|
||||
|
||||
public static String getComponentName(int componentId) {
|
||||
if (TOMCAT.getId() == componentId) {
|
||||
return TOMCAT.getName();
|
||||
} else if (HTTPCLIENT.getId() == componentId) {
|
||||
return HTTPCLIENT.getName();
|
||||
} else if (DUBBO.getId() == componentId) {
|
||||
return DUBBO.getName();
|
||||
} else if (H2.getId() == componentId) {
|
||||
return H2.getName();
|
||||
} else if (MYSQL.getId() == componentId) {
|
||||
return MYSQL.getName();
|
||||
} else if (ORACLE.getId() == componentId) {
|
||||
return ORACLE.getName();
|
||||
} else if (REDIS.getId() == componentId) {
|
||||
return REDIS.getName();
|
||||
} else if (MOTAN.getId() == componentId) {
|
||||
return MOTAN.getName();
|
||||
} else if (MONGODB.getId() == componentId) {
|
||||
return MONGODB.getName();
|
||||
} else if (RESIN.getId() == componentId) {
|
||||
return RESIN.getName();
|
||||
} else if (FEIGN.getId() == componentId) {
|
||||
return FEIGN.getName();
|
||||
} else if (OKHTTP.getId() == componentId) {
|
||||
return OKHTTP.getName();
|
||||
} else {
|
||||
private static ComponentsDefine instance = new ComponentsDefine();
|
||||
|
||||
private String[] components;
|
||||
|
||||
public static ComponentsDefine getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ComponentsDefine() {
|
||||
components = new String[13];
|
||||
addComponent(TOMCAT);
|
||||
addComponent(HTTPCLIENT);
|
||||
addComponent(DUBBO);
|
||||
addComponent(H2);
|
||||
addComponent(MYSQL);
|
||||
addComponent(ORACLE);
|
||||
addComponent(REDIS);
|
||||
addComponent(MOTAN);
|
||||
addComponent(MONGODB);
|
||||
addComponent(RESIN);
|
||||
addComponent(FEIGN);
|
||||
addComponent(OKHTTP);
|
||||
}
|
||||
|
||||
private void addComponent(OfficialComponent component) {
|
||||
components[component.getId()] = component.getName();
|
||||
}
|
||||
|
||||
public String getComponentName(int componentId) {
|
||||
if (componentId > components.length - 1 || componentId == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return components[componentId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue