use of org.apache.thrift.TException in project storm by apache.
the class Nimbus method getTopologyInfo.
@Override
public TopologyInfo getTopologyInfo(String id) throws NotAliveException, AuthorizationException, TException {
try {
getTopologyInfoCalls.mark();
GetInfoOptions options = new GetInfoOptions();
options.set_num_err_choice(NumErrorsChoice.ALL);
return getTopologyInfoWithOpts(id, options);
} catch (Exception e) {
LOG.warn("get topology ino exception. (topology id={})", id, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.thrift.TException in project storm by apache.
the class Nimbus method createStateInZookeeper.
@Override
public void createStateInZookeeper(String key) throws TException {
try {
IStormClusterState state = stormClusterState;
BlobStore store = blobStore;
NimbusInfo ni = nimbusHostPortInfo;
if (store instanceof LocalFsBlobStore) {
state.setupBlobstore(key, ni, getVersionForKey(key, ni, conf));
}
LOG.debug("Created state in zookeeper {} {} {}", state, store, ni);
} catch (Exception e) {
LOG.warn("Exception while creating state in zookeeper - key: " + key, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.thrift.TException in project hive by apache.
the class TBinarySortableProtocol method readString.
@Override
public String readString() throws TException {
if (readIsNull()) {
return null;
}
int i = 0;
while (true) {
readRawAll(bin, 0, 1);
if (bin[0] == 0) {
// End of string.
break;
}
if (bin[0] == 1) {
// Escaped byte, unescape it.
readRawAll(bin, 0, 1);
assert (bin[0] == 1 || bin[0] == 2);
bin[0] = (byte) (bin[0] - 1);
}
if (i == stringBytes.length) {
stringBytes = Arrays.copyOf(stringBytes, stringBytes.length * 2);
}
stringBytes[i] = bin[0];
i++;
}
try {
String r = new String(stringBytes, 0, i, "UTF-8");
return r;
} catch (UnsupportedEncodingException uex) {
throw new TException("JVM DOES NOT SUPPORT UTF-8: ", uex);
}
}
use of org.apache.thrift.TException in project hive by apache.
the class GetFunctionsOperation method runInternal.
@Override
public void runInternal() throws HiveSQLException {
setState(OperationState.RUNNING);
if (isAuthV2Enabled()) {
// get databases for schema pattern
IMetaStoreClient metastoreClient = getParentSession().getMetaStoreClient();
String schemaPattern = convertSchemaPattern(schemaName);
List<String> matchingDbs;
try {
matchingDbs = metastoreClient.getDatabases(schemaPattern);
} catch (TException e) {
setState(OperationState.ERROR);
throw new HiveSQLException(e);
}
// authorize this call on the schema objects
List<HivePrivilegeObject> privObjs = HivePrivilegeObjectUtils.getHivePrivDbObjects(matchingDbs);
String cmdStr = "catalog : " + catalogName + ", schemaPattern : " + schemaName;
authorizeMetaGets(HiveOperationType.GET_FUNCTIONS, privObjs, cmdStr);
}
try {
if ((null == catalogName || "".equals(catalogName)) && (null == schemaName || "".equals(schemaName))) {
Set<String> functionNames = FunctionRegistry.getFunctionNames(CLIServiceUtils.patternToRegex(functionName));
for (String functionName : functionNames) {
FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo(functionName);
Object[] rowData = new Object[] { // FUNCTION_CAT
null, // FUNCTION_SCHEM
null, // FUNCTION_NAME
functionInfo.getDisplayName(), // REMARKS
"", (functionInfo.isGenericUDTF() ? DatabaseMetaData.functionReturnsTable : // FUNCTION_TYPE
DatabaseMetaData.functionNoTable), functionInfo.getClass().getCanonicalName() };
rowSet.addRow(rowData);
}
}
setState(OperationState.FINISHED);
} catch (Exception e) {
setState(OperationState.ERROR);
throw new HiveSQLException(e);
}
}
use of org.apache.thrift.TException in project pinpoint by naver.
the class AgentCommandController method getActiveThreadDump.
@RequestMapping(value = "/activeThreadDump", method = RequestMethod.GET)
public ModelAndView getActiveThreadDump(@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));
}
TCmdActiveThreadDump threadDump = new TCmdActiveThreadDump();
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 TCmdActiveThreadDumpRes) {
TCmdActiveThreadDumpRes activeThreadDumpResponse = (TCmdActiveThreadDumpRes) result;
List<TActiveThreadDump> activeThreadDumps = activeThreadDumpResponse.getThreadDumps();
AgentActiveThreadDumpFactory factory = new AgentActiveThreadDumpFactory();
AgentActiveThreadDumpList activeThreadDumpList = factory.create1(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());
}
}
Aggregations