List of usage examples for org.apache.thrift TSerializer TSerializer
public TSerializer()
From source file:backtype.storm.serialization.GzipThriftSerializationDelegate.java
License:Apache License
@Override public byte[] serialize(Object object) { try {/*from www.j a v a 2s . co m*/ return Utils.gzip(new TSerializer().serialize((TBase) object)); } catch (TException e) { throw new RuntimeException(e); } }
From source file:backtype.storm.serialization.ThriftSerializationDelegate.java
License:Apache License
@Override public byte[] serialize(Object object) { try {//from w w w . j av a 2 s .com return new TSerializer().serialize((TBase) object); } catch (TException e) { throw new RuntimeException(e); } }
From source file:backtype.storm.utils.LocalState.java
License:Apache License
public synchronized void put(String key, TBase val, boolean cleanup) { Map<String, ThriftSerializedObject> curr = partialSnapshot(null); TSerializer ser = new TSerializer(); curr.put(key, serialize(val, ser)); persistInternal(curr, ser, cleanup); }
From source file:backtype.storm.utils.LocalState.java
License:Apache License
private void persistInternal(Map<String, ThriftSerializedObject> serialized, TSerializer ser, boolean cleanup) { try {/*from w ww. ja va 2 s .co m*/ if (ser == null) { ser = new TSerializer(); } byte[] toWrite = ser.serialize(new LocalStateData(serialized)); String newPath = _vs.createVersion(); File file = new File(newPath); FileUtils.writeByteArrayToFile(file, toWrite); if (toWrite.length != file.length()) { throw new IOException("Tried to serialize " + toWrite.length + " bytes to " + file.getCanonicalPath() + ", but " + file.length() + " bytes were written."); } _vs.succeedVersion(newPath); if (cleanup) _vs.cleanup(4); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:backtype.storm.utils.LocalState.java
License:Apache License
private void persist(Map<String, TBase> val, boolean cleanup) { try {/* www . j ava2s. co m*/ TSerializer ser = new TSerializer(); Map<String, ThriftSerializedObject> serialized = new HashMap<String, ThriftSerializedObject>(); for (Map.Entry<String, TBase> ent : val.entrySet()) { Object o = ent.getValue(); serialized.put(ent.getKey(), serialize(ent.getValue(), ser)); } persistInternal(serialized, ser, cleanup); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:co.cask.tephra.TransactionCodec.java
License:Apache License
public byte[] encode(Transaction tx) throws IOException { TTransaction thriftTx = TransactionConverterUtils.wrap(tx); TSerializer serializer = new TSerializer(); try {// ww w. j av a 2 s . co m return serializer.serialize(thriftTx); } catch (TException te) { throw new IOException(te); } }
From source file:com.helixleisure.candidates.test.SampleDataGenerator.java
License:Apache License
/** * Create and returns the Thrift {@link TSerializer} which is used for serializing the Thrift objects. * @return/*from w ww . j av a 2 s.c o m*/ */ public static TSerializer getSerializer() { if (ser == null) ser = new TSerializer(); return ser; }
From source file:com.helixleisure.candidates.test.ThriftSerializeDeserializeTest.java
License:Apache License
protected void setUp() throws Exception { super.setUp(); ser = new TSerializer(); des = new TDeserializer(); }
From source file:com.hopped.runner.rabbitmq.RPCClient.java
License:Open Source License
/** * @param request/*from w w w . j a v a 2 s. co m*/ * @return * @throws Exception */ public RunList getRunsByUser(RunRequest request) throws Exception { RunList response = new RunList(); String corrId = java.util.UUID.randomUUID().toString(); BasicProperties props = new BasicProperties.Builder().correlationId(corrId).replyTo(replyQueueName).build(); TSerializer serializer = new TSerializer(); channel.basicPublish("", requestQueueName, props, serializer.serialize(request)); while (true) { QueueingConsumer.Delivery delivery = consumer.nextDelivery(); if (delivery.getProperties().getCorrelationId().equals(corrId)) { TDeserializer deserializer = new TDeserializer(); deserializer.deserialize(response, delivery.getBody()); break; } } return response; }
From source file:com.inmobi.messaging.consumer.SampleTestConsumer.java
License:Apache License
private List<byte[]> createData() throws IOException, TException { Map<Long, Long> received = new HashMap<Long, Long>(); long time = System.currentTimeMillis() - 60000; long window = time - time % 60000; received.put(window, 100L);/*w w w . j ava 2 s .co m*/ AuditMessage packet = new AuditMessage(System.currentTimeMillis(), "testTopic", "publisher", "localhost", 1, received, received, null, null); TSerializer serializer = new TSerializer(); // serializer.serialize(packet); byte[] output = serializer.serialize(packet); List<byte[]> result = new ArrayList<byte[]>(); result.add(output); return result; }