org.apache.thrift.TException Java Examples
The following examples show how to use
org.apache.thrift.TException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceHandler.java From jstorm with Apache License 2.0 | 6 votes |
@Override public Map<Integer, String> getTopologyTasksToSupervisorIds(String topologyName) throws TException { StormClusterState stormClusterState = data.getStormClusterState(); String topologyId = getTopologyId(topologyName); Map<Integer, String> ret = new HashMap<>(); try { Assignment assignment = stormClusterState.assignment_info(topologyId, null); Set<ResourceWorkerSlot> workers = assignment.getWorkers(); for (ResourceWorkerSlot worker : workers) { String supervisorId = worker.getNodeId(); for (Integer task : worker.getTasks()) { ret.put(task, supervisorId); } } } catch (Exception ex) { LOG.error("Error:", ex); } return ret; }
Example #2
Source File: BufferedProtocolReadToWrite.java From parquet-mr with Apache License 2.0 | 6 votes |
private boolean readOneList(TProtocol in, List<Action> buffer, ListType expectedType) throws TException { final TList list = in.readListBegin(); buffer.add(new Action() { @Override public void write(TProtocol out) throws TException { out.writeListBegin(list); } @Override public String toDebugString() { return "<e=" + list.elemType + ", s=" + list.size + ">{"; } }); boolean hasFieldsIgnored = readCollectionElements(in, list.size, list.elemType, buffer, expectedType.getValues().getType()); in.readListEnd(); buffer.add(LIST_END); return hasFieldsIgnored; }
Example #3
Source File: TListSentryPrivilegesForProviderResponse.java From incubator-sentry with Apache License 2.0 | 6 votes |
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TListSentryPrivilegesForProviderResponse struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(); struct.status.read(iprot); struct.setStatusIsSet(true); { org.apache.thrift.protocol.TSet _set101 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.privileges = new HashSet<String>(2*_set101.size); for (int _i102 = 0; _i102 < _set101.size; ++_i102) { String _elem103; // required _elem103 = iprot.readString(); struct.privileges.add(_elem103); } } struct.setPrivilegesIsSet(true); }
Example #4
Source File: FieldDescriptor.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void write(org.apache.thrift.protocol.TProtocol oprot, FieldDescriptor struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } if (struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeI32(struct.type.getValue()); oprot.writeFieldEnd(); } if (struct.isSetIdentity()) { oprot.writeFieldBegin(IDENTITY_FIELD_DESC); oprot.writeBool(struct.identity); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
Example #5
Source File: Ingress.java From warp10-platform with Apache License 2.0 | 6 votes |
void pushMetadataMessage(Metadata metadata) throws IOException { if (null == metadata) { pushMetadataMessage(null, null); return; } // // Compute class/labels Id // // 128bits metadata.setClassId(GTSHelper.classId(this.classKey, metadata.getName())); metadata.setLabelsId(GTSHelper.labelsId(this.labelsKey, metadata.getLabels())); TSerializer serializer = new TSerializer(new TCompactProtocol.Factory()); try { byte[] bytes = new byte[16]; GTSHelper.fillGTSIds(bytes, 0, metadata.getClassId(), metadata.getLabelsId()); pushMetadataMessage(bytes, serializer.serialize(metadata)); } catch (TException te) { throw new IOException("Unable to push metadata."); } }
Example #6
Source File: ThriftCallService.java From armeria with Apache License 2.0 | 6 votes |
private static void invokeAsynchronously(Object impl, ThriftFunction func, TBase<?, ?> args, CompletableRpcResponse reply) throws TException { final AsyncProcessFunction<Object, TBase<?, ?>, Object> f = func.asyncFunc(); if (func.isOneWay()) { f.start(impl, args, ONEWAY_CALLBACK); reply.complete(null); } else { f.start(impl, args, new AsyncMethodCallback<Object>() { @Override public void onComplete(Object response) { reply.complete(response); } @Override public void onError(Exception e) { reply.completeExceptionally(e); } }); } }
Example #7
Source File: TestWriteToken.java From warp10-platform with Apache License 2.0 | 6 votes |
@Test public void testTokenAESCorrupted() throws TException { // generate a token String uuid = UUID.randomUUID().toString(); String writeToken = tokenEncoder.deliverWriteToken("app", uuid, 32478, getKeyStore()); // corrupt the token (pick a random character and decrement it) int corruptedIndex = new Random().nextInt(60); writeToken = writeToken.substring(0, corruptedIndex) + (writeToken.charAt(corruptedIndex) - 1) + writeToken.substring(corruptedIndex + 1); final QuasarTokenFilter tokenFilter = new QuasarTokenFilter(getConfig(), getKeyStore()); try { tokenFilter.getWriteToken(writeToken); assert false; } catch (QuasarTokenException qte) { assert qte instanceof QuasarTokenInvalid; } }
Example #8
Source File: Column.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Column struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeBinary(struct.name); BitSet optionals = new BitSet(); if (struct.isSetValue()) { optionals.set(0); } if (struct.isSetTimestamp()) { optionals.set(1); } if (struct.isSetTtl()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetValue()) { oprot.writeBinary(struct.value); } if (struct.isSetTimestamp()) { oprot.writeI64(struct.timestamp); } if (struct.isSetTtl()) { oprot.writeI32(struct.ttl); } }
Example #9
Source File: PacketStreamer.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
public void write(org.apache.thrift.protocol.TProtocol oprot, getPackets_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); for (ByteBuffer _iter11 : struct.success) { oprot.writeBinary(_iter11); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
Example #10
Source File: ThriftNativeCodec.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request) throws IOException { Invocation invocation = (Invocation) request.getData(); TProtocol protocol = newProtocol(channel.getUrl(), buffer); try { protocol.writeMessageBegin(new TMessage( invocation.getMethodName(), TMessageType.CALL, thriftSeq.getAndIncrement())); protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args")); for (int i = 0; i < invocation.getParameterTypes().length; i++) { Class<?> type = invocation.getParameterTypes()[i]; } } catch (TException e) { throw new IOException(e.getMessage(), e); } }
Example #11
Source File: AckResult.java From DDMQ with Apache License 2.0 | 6 votes |
public void validate() throws org.apache.thrift.TException { // check for required fields if (consumerId == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'consumerId' was not present! Struct: " + toString()); } if (groupId == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'groupId' was not present! Struct: " + toString()); } if (cluster == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'cluster' was not present! Struct: " + toString()); } if (offsets == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'offsets' was not present! Struct: " + toString()); } // check for sub-struct validity }
Example #12
Source File: ThriftHBaseServiceHandler.java From hbase with Apache License 2.0 | 5 votes |
@Override public List<TResult> getMultiple(ByteBuffer table, List<TGet> gets) throws TIOError, TException { Table htable = getTable(table); try { return resultsFromHBase(htable.get(getsFromThrift(gets))); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
Example #13
Source File: MyQueryService.java From easy-mapper with Apache License 2.0 | 5 votes |
public void validate() throws TException { // check for required fields // check for sub-struct validity if (query != null) { query.validate(); } }
Example #14
Source File: ConfigurationService.java From xio with Apache License 2.0 | 5 votes |
@Override public void read(org.apache.thrift.protocol.TProtocol prot, removeIpRule_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.ipRule = new IpRule(); struct.ipRule.read(iprot); struct.setIpRuleIsSet(true); } }
Example #15
Source File: QueueService.java From luxun with Apache License 2.0 | 5 votes |
public ProduceResponse recv_produce() throws org.apache.thrift.TException { produce_result result = new produce_result(); receiveBase(result, "produce"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "produce failed: unknown result"); }
Example #16
Source File: Timestamp.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #17
Source File: SentryHDFSService.java From incubator-sentry with Apache License 2.0 | 5 votes |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #18
Source File: TTextProtocol.java From armeria with Apache License 2.0 | 5 votes |
/** * Write out the given value, either as a JSON name (meaning it's * escaped by quotes), or a value. The TypedParser knows how to * handle the writing. */ private <T> void writeNameOrValue(TypedParser<T> helper, T val) throws TException { getCurrentContext().write(); try { if (getCurrentContext().isMapKey()) { getCurrentWriter().writeFieldName(val.toString()); } else { helper.writeValue(getCurrentWriter(), val); } } catch (IOException ex) { throw new TException(ex); } }
Example #19
Source File: FieldValue.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #20
Source File: QueueService.java From luxun with Apache License 2.0 | 5 votes |
public void read(org.apache.thrift.protocol.TProtocol iprot, consume_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // CONSUME_REQUEST if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.consumeRequest = new ConsumeRequest(); struct.consumeRequest.read(iprot); struct.setConsumeRequestIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); }
Example #21
Source File: ConsumeResult.java From DDMQ with Apache License 2.0 | 5 votes |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #22
Source File: ThriftConnection.java From hbase with Apache License 2.0 | 5 votes |
@Override public String getClusterId() { try { Pair<THBaseService.Client, TTransport> client = clientBuilder.getClient(); return client.getFirst().getClusterId(); } catch (TException | IOException e) { LOG.error("Error fetching cluster ID: ", e); } return null; }
Example #23
Source File: SubmitOptions.java From jstorm with Apache License 2.0 | 5 votes |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #24
Source File: HelloService.java From thrift-mock with Apache License 2.0 | 5 votes |
public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } }
Example #25
Source File: ReplicaTest.java From circus-train with Apache License 2.0 | 5 votes |
@Test public void validateReplicaTableOnAMirroredTableFails() throws TException, IOException { try { existingReplicaTable.putToParameters(REPLICATION_EVENT.parameterName(), "previousEventId"); existingReplicaTable.putToParameters(REPLICATION_MODE.parameterName(), ReplicationMode.METADATA_MIRROR.name()); replica.validateReplicaTable(DB_NAME, TABLE_NAME); fail("Should have thrown InvalidReplicationModeException"); } catch (InvalidReplicationModeException e) { // Check that nothing was written to the metastore verify(mockMetaStoreClient).getTable(DB_NAME, TABLE_NAME); verify(mockMetaStoreClient).close(); verifyNoMoreInteractions(mockMetaStoreClient); } }
Example #26
Source File: TAlterSentryRoleGrantPrivilegeRequest.java From incubator-sentry with Apache License 2.0 | 5 votes |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
Example #27
Source File: ServerSelectorTest.java From das with Apache License 2.0 | 5 votes |
@Test(expected = RuntimeException.class) public void testNoAvailableInstance() throws TException { ServerSelector serverSelector = new ServerSelector( "appId", Arrays.asList(NO_AVAILABLE_INSTANCE_1, NO_AVAILABLE_INSTANCE_2), "dasClientVersion", "ppdaiClientVersion", "clientAddress" ); serverSelector.execute(REQUEST); fail(); }
Example #28
Source File: ChunkHeaderBufferedTBaseSerializer.java From pinpoint with Apache License 2.0 | 5 votes |
public void flush() throws TException { synchronized (transport) { if (flushHandler != null && transport.getBufferPosition() > Header.HEADER_PREFIX_SIZE) { flushHandler.handle(transport.getBuffer(), 0, transport.getBufferPosition()); } transport.flush(); writeChunkHeader = false; } }
Example #29
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void create_table() throws TException { Table table = new Table(); table.setDbName(DB_P); Table inboundTable = new Table(); inboundTable.setDbName("inbound"); when(primaryMapping.transformInboundTable(table)).thenReturn(inboundTable); handler.create_table(table); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).create_table(inboundTable); }
Example #30
Source File: NimbusBlobStore.java From jstorm with Apache License 2.0 | 5 votes |
@Override public int updateBlobReplication(String key, int replication) throws KeyNotFoundException { try { return client.getClient().updateBlobReplication(key, replication); } catch (KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }