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

The following examples show how to use org.msgpack.core.MessageUnpacker#unpackString() . 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: 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 2
Source File: AgentSourceRequest.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public AgentSourceRequest(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_AGENT_SOURCE, unpacker);

    this.sourceUrl = unpacker.unpackString();

    if (unpacker.hasNext()) {
        branch = unpacker.unpackString();
    }
}
 
Example 3
Source File: Deserializer.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
/**
 * format: `Map<Label, Array<EdgeId>>`
 */
private Map<String, long[]> unpackEdgeIdsByLabel(MessageUnpacker unpacker) throws IOException {
  int labelCount = unpacker.unpackMapHeader();
  Map<String, long[]> edgeIdsByLabel = new THashMap<>(labelCount);
  for (int i = 0; i < labelCount; i++) {
    String label = unpacker.unpackString();
    int edgeIdsCount = unpacker.unpackArrayHeader();
    long[] edgeIds = new long[edgeIdsCount];
    for (int j = 0; j < edgeIdsCount; j++) {
      edgeIds[j] = unpacker.unpackLong();
    }
    edgeIdsByLabel.put(label, edgeIds);
  }
  return edgeIdsByLabel;
}
 
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: Deserializer.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> unpackProperties(MessageUnpacker unpacker) throws IOException {
  int propertyCount = unpacker.unpackMapHeader();
  Map<String, Object> res = new THashMap<>(propertyCount);
  for (int i = 0; i < propertyCount; i++) {
    final String key = unpacker.unpackString();
    final Object unpackedProperty = unpackProperty(unpacker.unpackValue().asArrayValue());
    res.put(key, unpackedProperty);
  }
  return res;
}
 
Example 6
Source File: UserCommand1Request.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public UserCommand1Request(MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_USER_COMMAND_1, unpacker);

    if (unpacker.hasNext()) {
        this.option = unpacker.unpackLong();
    }

    if (unpacker.hasNext()) {
        this.payload = unpacker.unpackString();
    }
}
 
Example 7
Source File: LogRequest.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public LogRequest(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_LOG, unpacker);

    this.locationType = LocationType.byCode(unpacker.unpackInt());
    if (locationType == LocationType.ANY) {
        this.typeName = unpacker.unpackString();
    }
}
 
Example 8
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 9
Source File: DrainRequest.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
public DrainRequest(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_DRAIN, unpacker);

    this.duration = unpacker.unpackString();
    this.url = unpacker.unpackString();
    this.parallelCount = unpacker.unpackString();
    this.workerName = unpacker.unpackString();
}
 
Example 10
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 11
Source File: StartInspector.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public StartInspector(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_START_INSPECTOR, unpacker);

    this.payload = unpacker.unpackString();
}
 
Example 12
Source File: TestFailedNotification.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public TestFailedNotification(MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_NOTIFY_FAIL, unpacker);

    this.test = SerializationUtils.unpackTest(unpacker);
    this.message = unpacker.unpackString();
}
 
Example 13
Source File: DrainCompleteNotification.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public DrainCompleteNotification(MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_NOTIFY_DRAIN_COMPLETE, unpacker);

    successful = unpacker.unpackBoolean();
    message = unpacker.unpackString();
}
 
Example 14
Source File: TestStartedNotification.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public TestStartedNotification(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_NOTIFY_TEST_STARTED, unpacker);

    this.test = SerializationUtils.unpackTest(unpacker);
    this.message = unpacker.unpackString();
}
 
Example 15
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 16
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 17
Source File: AbnormalDisconnect.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public AbnormalDisconnect(MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_ABNORMAL_DISCONNECT, unpacker);

    message = unpacker.unpackString();
}
 
Example 18
Source File: SetRequest.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public SetRequest(MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_SET, unpacker);

    this.option = Option.from(unpacker.unpackLong());
    this.value = unpacker.unpackString();
}
 
Example 19
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 20
Source File: StartWorker.java    From maestro-java with Apache License 2.0 3 votes vote down vote up
public StartWorker(final MessageUnpacker unpacker) throws IOException {
    super(MaestroCommand.MAESTRO_NOTE_START_WORKER, unpacker);

    final String workerName = unpacker.unpackString();

    options = new WorkerStartOptions(workerName);
}