Java Code Examples for org.msgpack.core.MessageUnpacker#unpackInt()

The following examples show how to use org.msgpack.core.MessageUnpacker#unpackInt() . 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: SerializationUtils.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public static Test unpackTest(final MessageUnpacker unpacker) throws IOException {
    int testNumber = unpacker.unpackInt();
    int testIteration = unpacker.unpackInt();
    String testName = unpacker.unpackString();
    String scriptName = unpacker.unpackString();

    final TestDetails testDetails = unpackTestDetails(unpacker);

    return new Test(testNumber, testIteration, testName, scriptName, testDetails);
}
 
Example 2
Source File: SerializationUtils.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public static SutDetails unpackSutDetails(final MessageUnpacker unpacker) throws IOException {
    int sutId = unpacker.unpackInt();
    String sutName = unpacker.unpackString();
    String sutVersion = unpacker.unpackString();
    String sutJvmVersion = unpacker.unpackString();
    String sutOtherInfo = unpacker.unpackString();
    String sutTags = unpacker.unpackString();
    String labName = unpacker.unpackString();
    String testTags = unpacker.unpackString();

    return new SutDetails(sutId, sutName, sutVersion, sutJvmVersion, sutOtherInfo, sutTags, labName, testTags);
}
 
Example 3
Source File: AbstractMaestroNotification.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public AbstractMaestroNotification(final MaestroCommand maestroCommand, final MessageUnpacker unpacker) throws IOException {
    super(MaestroNoteType.MAESTRO_TYPE_NOTIFICATION, maestroCommand, unpacker);

    id = unpacker.unpackString();
    final String memberName = unpacker.unpackString();
    final String groupName = unpacker.unpackString();

    final int role = unpacker.unpackInt();
    final String name = unpacker.unpackString();
    final String host = unpacker.unpackString();

    this.peerInfo = new WorkerPeer(Role.from(role), name, host,
            new DefaultGroupInfo(memberName, groupName));
}
 
Example 4
Source File: StatsResponse.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public StatsResponse(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_STATS, unpacker);

    childCount = unpacker.unpackInt();
    roleInfo = unpacker.unpackString();
    statsType = unpacker.unpackShort();

    timestamp = unpacker.unpackString();
    count = unpacker.unpackLong();
    rate = unpacker.unpackDouble();
    latency = unpacker.unpackDouble();
}
 
Example 5
Source File: MaestroNotification.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public MaestroNotification(final MaestroCommand maestroCommand, final MessageUnpacker unpacker) throws IOException {
    super(MaestroNoteType.MAESTRO_TYPE_NOTIFICATION, maestroCommand, unpacker);

    id = unpacker.unpackString();
    final String memberName = unpacker.unpackString();
    final String groupName = unpacker.unpackString();

    final int role = unpacker.unpackInt();
    final String name = unpacker.unpackString();
    final String host = unpacker.unpackString();

    this.peerInfo = new WorkerPeer(Role.from(role), name, host,
            new DefaultGroupInfo(memberName, groupName));
}
 
Example 6
Source File: MaestroData.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public MaestroData(final MaestroCommand maestroCommand, final MessageUnpacker unpacker) throws IOException {
    super(MaestroNoteType.MAESTRO_TYPE_DATA, maestroCommand, unpacker);

    id = unpacker.unpackString();


    final String memberName = unpacker.unpackString();
    final String groupName = unpacker.unpackString();

    final int role = unpacker.unpackInt();
    final String name = unpacker.unpackString();
    final String host = unpacker.unpackString();

    this.peerInfo = new WorkerPeer(Role.from(role), name, host,
            new DefaultGroupInfo(memberName, groupName));
}
 
Example 7
Source File: MaestroResponse.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public MaestroResponse(MaestroCommand maestroCommand, MessageUnpacker unpacker) throws IOException {
    super(MaestroNoteType.MAESTRO_TYPE_RESPONSE, maestroCommand, unpacker);

    id = unpacker.unpackString();


    final String memberName = unpacker.unpackString();
    final String groupName = unpacker.unpackString();

    final int role = unpacker.unpackInt();
    final String name = unpacker.unpackString();
    final String host = unpacker.unpackString();

    this.peerInfo = new WorkerPeer(Role.from(role), name, host,
            new DefaultGroupInfo(memberName, groupName));
}
 
Example 8
Source File: SerializationUtils.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public static ErrorCode unpackErrorCode(final MessageUnpacker unpacker) throws IOException {
    final int value = unpacker.unpackInt();

    return ErrorCode.from(value);
}
 
Example 9
Source File: Message.java    From locust4j with MIT License 4 votes vote down vote up
public Message(byte[] bytes) throws IOException {
    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bytes);

    int arrayHeader = unpacker.unpackArrayHeader();
    this.type = unpacker.unpackString();

    // unpack data
    if (unpacker.getNextFormat() != MessageFormat.NIL) {
        int mapSize = unpacker.unpackMapHeader();
        this.data = new HashMap<>(6);
        while (mapSize > 0) {
            String key = null;
            // unpack key
            if (unpacker.getNextFormat() == MessageFormat.NIL) {
                unpacker.unpackNil();
            } else {
                key = unpacker.unpackString();
            }
            // unpack value
            MessageFormat messageFormat = unpacker.getNextFormat();
            Object value;

            switch (messageFormat.getValueType()) {
                case BOOLEAN:
                    value = unpacker.unpackBoolean();
                    break;
                case FLOAT:
                    value = unpacker.unpackFloat();
                    break;
                case INTEGER:
                    value = unpacker.unpackInt();
                    break;
                case NIL:
                    value = null;
                    unpacker.unpackNil();
                    break;
                case STRING:
                    value = unpacker.unpackString();
                    break;
                default:
                    throw new IOException("Message received unsupported type: " + messageFormat.getValueType());
            }
            if (null != key) {
                this.data.put(key, value);
            }
            mapSize--;
        }

    } else {
        unpacker.unpackNil();
        this.data = null;
    }
    if (unpacker.getNextFormat() != MessageFormat.NIL) {
        this.nodeID = unpacker.unpackString();
    } else {
        unpacker.unpackNil();
        this.nodeID = null;
    }
    unpacker.close();
}
 
Example 10
Source File: SerializationUtils.java    From maestro-java with Apache License 2.0 3 votes vote down vote up
public static LocationTypeInfo unpackLocationTypeInfo(final MessageUnpacker unpacker) throws IOException {
    LocationTypeInfo ret = new LocationTypeInfo(unpacker.unpackInt());

    ret.setIndex(unpacker.unpackInt());

    return ret;
}