com.esotericsoftware.kryo.io.FastInput Java Examples

The following examples show how to use com.esotericsoftware.kryo.io.FastInput. 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: Http2JMeter.java    From jsflight with Apache License 2.0 6 votes vote down vote up
/**
 * Just to test IdGeneration Recording
 * @param file
 * @return
 * @throws Exception
 */
public List<IdRecordInfo> getIdRecords(String file) throws Exception
{
    List<IdRecordInfo> infos = new ArrayList<>();
    FastInput input = new FastInput(new FileInputStream(file));
    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());

    while (input.available() > 0)
    {
        InternalEventRecorder.InternalEventRecord record = kryo.readObject(input,
                InternalEventRecorder.InternalEventRecord.class);
        String tag = new String(record.tag).trim();
        if (tag.equalsIgnoreCase(IdRecordInfo.ID_RECORD_TAG))
        {
            infos.add((IdRecordInfo)record.data);
        }
    }

    return infos;
}
 
Example #2
Source File: Inputs.java    From Jupiter with Apache License 2.0 4 votes vote down vote up
public static Input getInput(byte[] bytes, int offset, int length) {
    return new FastInput(bytes, offset, length);
}
 
Example #3
Source File: Http2JMeter.java    From jsflight with Apache License 2.0 4 votes vote down vote up
public List<RestoredRequest> getRequests(String file, int limit) throws IOException
{
    List<RestoredRequest> requests = new ArrayList<>();
    FastInput input = new FastInput(new FileInputStream(file));

    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());
    while (input.available() > 0)
    {
        InternalEventRecorder.InternalEventRecord record = kryo.readObject(input,
                InternalEventRecorder.InternalEventRecord.class);

        String tag = new String(record.tag).trim();

        if (tag.equalsIgnoreCase(HttpRecorderHelper.HTTP_RECORDER_TAG))
        {
            HttpRecordInformation information = (HttpRecordInformation)record.data;
            RestoredRequest request = new RestoredRequest();

            if (information.params != null && information.params.length > 0)
            {
                FastInput paramsInput = new FastInput(new ByteArrayInputStream(information.params));

                request.parameters = kryo.readObject(paramsInput, HashMap.class);
                request.headers = kryo.readObject(paramsInput, HashMap.class);
                request.contentLength = kryo.readObjectOrNull(paramsInput, Integer.class);
                request.contentType = kryo.readObjectOrNull(paramsInput, String.class);
                request.uri = kryo.readObjectOrNull(paramsInput, String.class);
                request.method = kryo.readObjectOrNull(paramsInput, String.class);
                request.contextPath = kryo.readObjectOrNull(paramsInput, String.class);
                request.cookies = kryo.readObject(paramsInput, HashMap.class);
            }
            if (information.payload != null && information.payload.length > 0)
            {
                request.payload = new String(information.payload);
            }

            request.additional = information.additional;
            request.timestampNs = record.timestampNs;

            if (limit > 0 && requests.size() >= limit)
            {
                break;
            }
            requests.add(request);
        }
    }
    return requests;
}