Search in sources :

Example 81 with TException

use of org.apache.thrift.TException in project pinpoint by naver.

the class AgentCommandController method getActiveThreadLightDump.

@RequestMapping(value = "/activeThreadLightDump", method = RequestMethod.GET)
public ModelAndView getActiveThreadLightDump(@RequestParam(value = "applicationName") String applicationName, @RequestParam(value = "agentId") String agentId, @RequestParam(value = "limit", required = false, defaultValue = "-1") int limit, @RequestParam(value = "threadName", required = false) String[] threadNameList, @RequestParam(value = "localTraceId", required = false) Long[] localTraceIdList) throws TException {
    if (!webProperties.isEnableActiveThreadDump()) {
        return createResponse(false, "Disable activeThreadDump option. 'config.enable.activeThreadDump=false'");
    }
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId);
    if (agentInfo == null) {
        return createResponse(false, String.format("Can't find suitable Agent(%s/%s)", applicationName, agentId));
    }
    TCmdActiveThreadLightDump threadDump = new TCmdActiveThreadLightDump();
    if (limit > 0) {
        threadDump.setLimit(limit);
    }
    if (threadNameList != null) {
        threadDump.setThreadNameList(Arrays.asList(threadNameList));
    }
    if (localTraceIdList != null) {
        threadDump.setLocalTraceIdList(Arrays.asList(localTraceIdList));
    }
    try {
        PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, threadDump);
        if (isSuccessResponse(pinpointRouteResponse)) {
            TBase<?, ?> result = pinpointRouteResponse.getResponse();
            if (result instanceof TCmdActiveThreadLightDumpRes) {
                TCmdActiveThreadLightDumpRes activeThreadDumpResponse = (TCmdActiveThreadLightDumpRes) result;
                List<TActiveThreadLightDump> activeThreadDumps = activeThreadDumpResponse.getThreadDumps();
                AgentActiveThreadDumpFactory factory = new AgentActiveThreadDumpFactory();
                AgentActiveThreadDumpList activeThreadDumpList = factory.create2(activeThreadDumps);
                Map<String, Object> responseData = createResponseData(activeThreadDumpList, activeThreadDumpResponse.getType(), activeThreadDumpResponse.getSubType(), activeThreadDumpResponse.getVersion());
                return createResponse(true, responseData);
            }
        }
        return handleFailedResponse(pinpointRouteResponse);
    } catch (TException e) {
        return createResponse(false, e.getMessage());
    }
}
Also used : AgentActiveThreadDumpList(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList) TException(org.apache.thrift.TException) TCmdActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump) AgentActiveThreadDumpFactory(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory) TCmdActiveThreadLightDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with TException

use of org.apache.thrift.TException in project pinpoint by naver.

the class SpanStreamSendDataPlaner method getSpanChunkBuffer0.

private byte[] getSpanChunkBuffer0() {
    if (spanChunkBuffer == null) {
        final TSpanChunk spanChunk = toSpanChunk(span);
        HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false, SpanStreamSendDataFactory.DEFAULT_UDP_MAX_BUFFER_SIZE, false).createSerializer();
        byte[] spanChunkBuffer;
        try {
            spanChunkBuffer = serializer.serialize(spanChunk);
            this.spanChunkBuffer = spanChunkBuffer;
            this.spanChunkSize = serializer.getInterBufferSize();
        } catch (TException e) {
            logger.warn("Spanchunk serializer failed. {}.", spanChunk);
        }
    }
    if (spanChunkBuffer == null) {
        return new byte[0];
    }
    return spanChunkBuffer;
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) TException(org.apache.thrift.TException) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)

Example 83 with TException

use of org.apache.thrift.TException in project pinpoint by naver.

the class BufferedUdpDataSender method startScheduledFlush.

private Thread startScheduledFlush() {
    final ThreadFactory threadFactory = new PinpointThreadFactory(SCHEDULED_FLUSH, true);
    final Thread thread = threadFactory.newThread(new Runnable() {

        @Override
        public void run() {
            final Thread currentThread = Thread.currentThread();
            while (!currentThread.isInterrupted()) {
                try {
                    chunkHeaderBufferedSerializer.flush();
                } catch (TException e) {
                    logger.warn("Failed to flush. caused={}", e.getMessage(), e);
                }
                try {
                    TimeUnit.MILLISECONDS.sleep(1000);
                } catch (InterruptedException ignored) {
                    currentThread.interrupt();
                }
            }
            logger.info("stop ScheduledFlush {} - {}", currentThread.getName(), currentThread.getId());
        }
    });
    logger.info("stop ScheduledFlush {} - {}", thread.getName(), thread.getId());
    thread.start();
    return thread;
}
Also used : TException(org.apache.thrift.TException) PinpointThreadFactory(com.navercorp.pinpoint.common.util.PinpointThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) PinpointThreadFactory(com.navercorp.pinpoint.common.util.PinpointThreadFactory)

Example 84 with TException

use of org.apache.thrift.TException in project pinpoint by naver.

the class ActiveThreadCountWorker method active0.

private boolean active0(AgentInfo agentInfo) {
    synchronized (lock) {
        boolean active = false;
        try {
            ClientStreamChannelContext clientStreamChannelContext = agentService.openStream(agentInfo, COMMAND_INSTANCE, messageListener, stateChangeListener);
            if (clientStreamChannelContext == null) {
                setDefaultErrorMessage(StreamCode.CONNECTION_NOT_FOUND.name());
                workerActiveManager.addReactiveWorker(agentInfo);
            } else {
                if (clientStreamChannelContext.getCreateFailPacket() == null) {
                    streamChannel = clientStreamChannelContext.getStreamChannel();
                    setDefaultErrorMessage(TRouteResult.TIMEOUT.name());
                    active = true;
                } else {
                    StreamCreateFailPacket createFailPacket = clientStreamChannelContext.getCreateFailPacket();
                    setDefaultErrorMessage(createFailPacket.getCode().name());
                }
            }
        } catch (TException exception) {
            setDefaultErrorMessage(TRouteResult.NOT_SUPPORTED_REQUEST.name());
        }
        return active;
    }
}
Also used : TException(org.apache.thrift.TException) ClientStreamChannelContext(com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext) StreamCreateFailPacket(com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket)

Example 85 with TException

use of org.apache.thrift.TException in project druid by druid-io.

the class ThriftDeserialization method detectAndDeserialize.

/**
   * Deserializes byte-array into thrift object.
   * <p>
   * Supporting binary, compact and json protocols,
   * and the byte array could be or not be encoded by Base64.
   *
   * @param bytes     the byte-array to deserialize
   * @param thriftObj the output thrift object
   *
   * @return the output thrift object, or null if error occurs
   */
public static <T extends TBase> T detectAndDeserialize(final byte[] bytes, final T thriftObj) throws TException {
    Preconditions.checkNotNull(thriftObj);
    try {
        final byte[] src = decodeB64IfNeeded(bytes);
        final TProtocolFactory protocolFactory = TProtocolUtil.guessProtocolFactory(src, null);
        Preconditions.checkNotNull(protocolFactory);
        if (protocolFactory instanceof TCompactProtocol.Factory) {
            DESERIALIZER_COMPACT.get().deserialize(thriftObj, src);
        } else if (protocolFactory instanceof TBinaryProtocol.Factory) {
            DESERIALIZER_BINARY.get().deserialize(thriftObj, src);
        } else {
            DESERIALIZER_JSON.get().deserialize(thriftObj, src);
        }
    } catch (final IllegalArgumentException e) {
        throw new TException(e);
    }
    return thriftObj;
}
Also used : TException(org.apache.thrift.TException) TProtocolFactory(org.apache.thrift.protocol.TProtocolFactory) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) LoggerFactory(org.slf4j.LoggerFactory) TProtocolFactory(org.apache.thrift.protocol.TProtocolFactory)

Aggregations

TException (org.apache.thrift.TException)381 IOException (java.io.IOException)164 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)57 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)48 ArrayList (java.util.ArrayList)42 HashMap (java.util.HashMap)40 Table (org.apache.hadoop.hive.metastore.api.Table)38 Map (java.util.Map)30 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)29 AuthorizationException (org.apache.storm.generated.AuthorizationException)27 Test (org.junit.Test)26 List (java.util.List)25 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)24 UnknownHostException (java.net.UnknownHostException)23 TProtocol (org.apache.thrift.protocol.TProtocol)23 FileNotFoundException (java.io.FileNotFoundException)22 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)22 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)21 LoginException (javax.security.auth.login.LoginException)21 ConnectorException (com.netflix.metacat.common.server.connectors.exception.ConnectorException)20