Search in sources :

Example 26 with PradarException

use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.

the class AfterTraceInterceptor method doAfter.

@Override
public final void doAfter(Advice advice) throws Throwable {
    if (!simulatorConfig.getBooleanProperty("plugin." + getPluginName() + ".trace.enabled", true)) {
        return;
    }
    ClusterTestUtils.validateClusterTest();
    Throwable throwable = null;
    try {
        afterFirst(advice);
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (Throwable t) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), t);
        throwable = t;
    }
    try {
        if (isClient(advice)) {
            endClientInvoke(advice);
        } else {
            endServerInvoke(advice);
        }
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (Throwable e) {
        if (Pradar.isClusterTest()) {
            LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
            throw new PressureMeasureError(e);
        }
    } finally {
        try {
            afterLast(advice);
        } catch (PradarException e) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (PressureMeasureError e) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (Throwable t) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), t);
            throwable = t;
        }
    }
    if (throwable != null && Pradar.isClusterTest()) {
        throw throwable;
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 27 with PradarException

use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.

the class BeforeTraceInterceptor method doBefore.

@Override
public final void doBefore(Advice advice) throws Throwable {
    if (!simulatorConfig.getBooleanProperty("plugin." + getPluginName() + ".trace.enabled", true)) {
        return;
    }
    ClusterTestUtils.validateClusterTest();
    Throwable throwable = null;
    try {
        beforeFirst(advice);
    } catch (PradarException e) {
        LOGGER.error("BeforeTraceInterceptor beforeFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (PressureMeasureError e) {
        LOGGER.error("BeforeTraceInterceptor beforeFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (Throwable t) {
        LOGGER.error("BeforeTraceInterceptor beforeFirst exec err:{}", this.getClass().getName(), t);
        throwable = t;
    }
    try {
        if (isClient(advice)) {
            startClientInvoke(advice);
        } else {
            startServerInvoke(advice);
        }
    } catch (PradarException e) {
        LOGGER.error("BeforeTraceInterceptor before exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (PressureMeasureError e) {
        LOGGER.error("BeforeTraceInterceptor before exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (Throwable e) {
        if (Pradar.isClusterTest()) {
            LOGGER.error("BeforeTraceInterceptor before exec err:{}", this.getClass().getName(), e);
            throw new PressureMeasureError(e);
        }
    } finally {
        try {
            beforeLast(advice);
        } catch (PradarException e) {
            LOGGER.error("BeforeTraceInterceptor beforeLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (PressureMeasureError e) {
            LOGGER.error("BeforeTraceInterceptor beforeLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (Throwable t) {
            LOGGER.error("BeforeTraceInterceptor beforeLast exec err:{}", this.getClass().getName(), t);
            throwable = t;
        }
    }
    if (throwable != null && Pradar.isClusterTest()) {
        throw throwable;
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 28 with PradarException

use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.

the class ReverseTraceInterceptor method doBefore.

@Override
public final void doBefore(Advice advice) throws Throwable {
    if (!simulatorConfig.getBooleanProperty("plugin." + getPluginName() + ".trace.enabled", true)) {
        return;
    }
    ClusterTestUtils.validateClusterTest();
    Throwable throwable = null;
    try {
        afterFirst(advice);
    } catch (PradarException e) {
        LOGGER.error("ReverseTraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (PressureMeasureError e) {
        LOGGER.error("ReverseTraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (Throwable t) {
        LOGGER.error("ReverseTraceInterceptor afterFirst exec err:{}", this.getClass().getName(), t);
        throwable = t;
    }
    try {
        if (isClient(advice)) {
            endClientInvoke(advice);
        } else {
            endServerInvoke(advice);
        }
    } catch (PradarException e) {
        LOGGER.error("ReverseTraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (PressureMeasureError e) {
        LOGGER.error("ReverseTraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (Pradar.isClusterTest()) {
            throw e;
        }
    } catch (Throwable e) {
        if (Pradar.isClusterTest()) {
            LOGGER.error("ReverseTraceInterceptor after exec err:{}", this.getClass().getName(), e);
            throw new PressureMeasureError(e);
        }
    } finally {
        try {
            afterLast(advice);
        } catch (PradarException e) {
            LOGGER.error("ReverseTraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (PressureMeasureError e) {
            LOGGER.error("ReverseTraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (Throwable t) {
            LOGGER.error("ReverseTraceInterceptor afterLast exec err:{}", this.getClass().getName(), t);
            throwable = t;
        }
    }
    if (throwable != null && Pradar.isClusterTest()) {
        throw throwable;
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 29 with PradarException

use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.

the class AdminAccessInfo method solveByConnection.

public static AdminAccessInfo solveByConnection(Connection connection) {
    String username;
    String password;
    String host;
    int port;
    Object object = Reflect.on(connection).getSilence("credentialsProvider");
    if (object != null) {
        // 低版本
        CredentialsProvider credentialsProvider = (CredentialsProvider) object;
        username = credentialsProvider.getUsername();
        password = credentialsProvider.getPassword();
    } else {
        username = Reflect.on(connection).getSilence("username");
        password = Reflect.on(connection).getSilence("password");
        if (username == null || password == null) {
            throw new PradarException("未支持的rabbitmq版本!无法获取rabbit连接用户名密码");
        }
    }
    InetAddress inetAddress = connection.getAddress();
    String virtualHost = Reflect.on(connection).get("_virtualHost");
    host = inetAddress.getHostAddress();
    port = Integer.parseInt("1" + connection.getPort());
    return new AdminAccessInfo(host, port, username, password, virtualHost);
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) CredentialsProvider(com.rabbitmq.client.impl.CredentialsProvider) InetAddress(java.net.InetAddress)

Example 30 with PradarException

use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.

the class ZkWithIpCacheSupport method putInZK.

private void putInZK(List<ConsumerApiResult> consumerApiResults) {
    try {
        if (zkClient.checkExists().forPath(zkDataPath) != null) {
            zkClient.delete().deletingChildrenIfNeeded().forPath(zkDataPath);
        }
        zkClient.create().creatingParentsIfNeeded().forPath(zkDataPath);
        Map<String, List<ConsumerApiResult>> ipGroupMap = ipGroup(consumerApiResults);
        for (Entry<String, List<ConsumerApiResult>> entry : ipGroupMap.entrySet()) {
            String ip = entry.getKey();
            String jsonStr = JSON.toJSONString(entry.getValue());
            byte[] bytes = jsonStr.getBytes("UTF-8");
            logger.info("[RabbitMQ] prepare put consumers data to zk ip {} total bytes(uncompressed) : {}", ip, bytes.length);
            zkClient.create().compressed().forPath(zkIpPath(ip), bytes);
            logger.info("[RabbitMQ] put consumers data to zk ip {} total bytes(uncompressed) : {}", ip, bytes.length);
        }
    } catch (Exception e) {
        throw new PradarException(e);
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) ArrayList(java.util.ArrayList) List(java.util.List) ZipException(java.util.zip.ZipException) KeeperException(org.apache.zookeeper.KeeperException) PradarException(com.pamirs.pradar.exception.PradarException)

Aggregations

PradarException (com.pamirs.pradar.exception.PradarException)46 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)34 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)7 ConsumeMessageContext (com.alibaba.rocketmq.client.hook.ConsumeMessageContext)6 MQTraceContext (com.pamirs.attach.plugin.alibaba.rocketmq.common.MQTraceContext)6 ZipException (java.util.zip.ZipException)6 ConsumeMessageContext (org.apache.rocketmq.client.hook.ConsumeMessageContext)6 KeeperException (org.apache.zookeeper.KeeperException)6 MQTraceContext (com.pamirs.attach.plugin.apache.rocketmq.common.MQTraceContext)5 MessageExt (com.alibaba.rocketmq.common.message.MessageExt)4 MQTraceBean (com.pamirs.attach.plugin.alibaba.rocketmq.common.MQTraceBean)4 MQTraceBean (com.pamirs.attach.plugin.apache.rocketmq.common.MQTraceBean)4 InetSocketAddress (java.net.InetSocketAddress)4 MessageExt (org.apache.rocketmq.common.message.MessageExt)4 MQTraceContext (com.pamirs.attach.plugin.pulsar.common.MQTraceContext)3 ConcurrentWeakHashMap (com.shulie.instrument.simulator.message.ConcurrentWeakHashMap)3 List (java.util.List)3 Map (java.util.Map)3 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)3