Java Code Examples for org.msgpack.core.MessageBufferPacker#packLong()
The following examples show how to use
org.msgpack.core.MessageBufferPacker#packLong() .
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: AbstractMaestroNote.java From maestro-java with Apache License 2.0 | 6 votes |
protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = MessagePack.newDefaultBufferPacker(); packer.packShort(noteType.getValue()); packer.packLong(maestroCommand.getValue()); correlate(); packer.packString(correlation.getCorrelationId()); packer.packString(correlation.getMessageId()); if (logger.isTraceEnabled()) { logger.trace("Packed this {} note with correlation id {} and message id {}", this.maestroCommand, correlation.getCorrelationId(), correlation.getMessageId()); } return packer; }
Example 2
Source File: LogResponse.java From maestro-java with Apache License 2.0 | 6 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); try { packer.packInt(locationType.getCode()); SerializationUtils.pack(packer, this.locationTypeInfo); packer.packString(fileName); packer.packInt(index); packer.packInt(total); packer.packLong(fileSize); packer.packString(fileHash); packData(packer); } catch (Exception e) { packer.close(); throw e; } return packer; }
Example 3
Source File: GetRequest.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(option.getValue()); return packer; }
Example 4
Source File: SetRequest.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(option.getValue()); packer.packString(this.value); return packer; }
Example 5
Source File: UserCommand1Request.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(option); if (payload != null) { packer.packString(this.payload); } return packer; }
Example 6
Source File: GetResponse.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(option.getValue()); packer.packString(value); return packer; }
Example 7
Source File: PingResponse.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(this.elapsed); return packer; }
Example 8
Source File: PingRequest.java From maestro-java with Apache License 2.0 | 5 votes |
protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(sec); packer.packLong(usec); return packer; }
Example 9
Source File: StatsResponse.java From maestro-java with Apache License 2.0 | 5 votes |
@Override protected MessageBufferPacker pack() throws IOException { MessageBufferPacker packer = super.pack(); packer.packLong(this.childCount); packer.packString(this.roleInfo); packer.packShort(this.statsType); packer.packString(this.timestamp); packer.packLong(this.count); packer.packDouble(this.rate); packer.packDouble(this.latency); return packer; }
Example 10
Source File: Serializer.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
/** * format: `[ValueType.id, value]` */ private void packPropertyValue(final MessageBufferPacker packer, final Object value) throws IOException { packer.packArrayHeader(2); if (value instanceof Boolean) { packer.packByte(ValueTypes.BOOLEAN.id); packer.packBoolean((Boolean) value); } else if (value instanceof String) { packer.packByte(ValueTypes.STRING.id); packer.packString((String) value); } else if (value instanceof Byte) { packer.packByte(ValueTypes.BYTE.id); packer.packByte((byte) value); } else if (value instanceof Short) { packer.packByte(ValueTypes.SHORT.id); packer.packShort((short) value); } else if (value instanceof Integer) { packer.packByte(ValueTypes.INTEGER.id); packer.packInt((int) value); } else if (value instanceof Long) { packer.packByte(ValueTypes.LONG.id); packer.packLong((long) value); } else if (value instanceof Float) { packer.packByte(ValueTypes.FLOAT.id); packer.packFloat((float) value); } else if (value instanceof Double) { packer.packByte(ValueTypes.DOUBLE.id); packer.packFloat((float) value); //msgpack doesn't support double, but we still want to deserialize it as a double later } else if (value instanceof List) { packer.packByte(ValueTypes.LIST.id); List listValue = (List) value; packer.packArrayHeader(listValue.size()); final Iterator listIter = listValue.iterator(); while (listIter.hasNext()) { packPropertyValue(packer, listIter.next()); } } else { throw new NotImplementedException("id type `" + value.getClass() + "` not yet supported"); } }
Example 11
Source File: Serializer.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
/** * format: two `Map<Label, Array<EdgeId>>`, i.e. one Map for `IN` and one for `OUT` edges */ private void packEdgeIds(final MessageBufferPacker packer, final Map<String, TLongSet> edgeIdsByLabel) throws IOException { packer.packMapHeader(edgeIdsByLabel.size()); for (Map.Entry<String, TLongSet> entry : edgeIdsByLabel.entrySet()) { final String label = entry.getKey(); packer.packString(label); final TLongSet edgeIds = entry.getValue(); packer.packArrayHeader(edgeIds.size()); final TLongIterator edgeIdIter = edgeIds.iterator(); while (edgeIdIter.hasNext()) { packer.packLong(edgeIdIter.next()); } } }
Example 12
Source File: DataDstMsgPack.java From xresloader with MIT License | 4 votes |
@SuppressWarnings("unchecked") private void writeData(MessageBufferPacker packer, Object data) throws IOException { // null if (null == data) { packer.packNil(); return; } // 字符串&二进制 if (data instanceof String) { packer.packString((String) data); return; } // 数字 // 枚举值已被转为Java Long,会在这里执行 if (data instanceof Integer) { packer.packInt((Integer) data); return; } if (data instanceof Long) { packer.packLong((long) data); return; } if (data instanceof Short) { packer.packLong((short) data); return; } if (data instanceof Float) { packer.packFloat((float) data); return; } if (data instanceof Double) { packer.packDouble((double) data); return; } if (data instanceof Byte) { packer.packByte((byte) data); return; } if (data instanceof java.math.BigInteger) { packer.packBigInteger((java.math.BigInteger) data); return; } // 布尔 if (data instanceof Boolean) { packer.packBoolean((Boolean) data); return; } // 列表 if (data instanceof List<?>) { packer.packArrayHeader(((List<?>) data).size()); for (Object subobj : (List<?>) data) { writeData(packer, subobj); } return; } // Hashmap if (data instanceof Map<?, ?>) { Map<?, ?> mp = (Map<?, ?>) data; ArrayList<Map.Entry<?, ?>> sorted_array = new ArrayList<Map.Entry<?, ?>>(); sorted_array.ensureCapacity(mp.size()); sorted_array.addAll(mp.entrySet()); sorted_array.sort((l, r) -> { if (l.getValue() instanceof Integer && r.getValue() instanceof Integer) { return ((Integer) l.getValue()).compareTo((Integer) r.getValue()); } if (l.getKey() instanceof Integer && r.getKey() instanceof Integer) { return ((Integer) l.getKey()).compareTo((Integer) r.getKey()); } else if (l.getKey() instanceof Long && r.getKey() instanceof Long) { return ((Long) l.getKey()).compareTo((Long) r.getKey()); } else { return l.getKey().toString().compareTo(r.getKey().toString()); } }); packer.packMapHeader(sorted_array.size()); for (Map.Entry<?, ?> item : sorted_array) { writeData(packer, item.getKey()); writeData(packer, item.getValue()); } return; } packer.packString(data.toString()); }