use of org.apache.hbase.thirdparty.com.google.gson.JsonParser in project hbase by apache.
the class ProtobufMessageConverter method toJsonElement.
public static JsonElement toJsonElement(MessageOrBuilder messageOrBuilder, boolean removeType) throws InvalidProtocolBufferException {
String jsonString = toJsonString(messageOrBuilder);
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(jsonString);
if (removeType) {
removeTypeFromJson(element);
}
return element;
}
use of org.apache.hbase.thirdparty.com.google.gson.JsonParser in project hbase by apache.
the class ProcedureTestUtil method waitUntilProcedureWaitingTimeout.
public static void waitUntilProcedureWaitingTimeout(HBaseTestingUtil util, Class<? extends Procedure<?>> clazz, long timeout) throws IOException {
JsonParser parser = new JsonParser();
util.waitFor(timeout, () -> getProcedure(util, clazz, parser).filter(o -> ProcedureState.WAITING_TIMEOUT.name().equals(o.get("state").getAsString())).isPresent());
}
use of org.apache.hbase.thirdparty.com.google.gson.JsonParser in project hbase by apache.
the class ProcedureTestUtil method waitUntilProcedureTimeoutIncrease.
public static void waitUntilProcedureTimeoutIncrease(HBaseTestingUtil util, Class<? extends Procedure<?>> clazz, int times) throws IOException, InterruptedException {
JsonParser parser = new JsonParser();
long oldTimeout = 0;
int timeoutIncrements = 0;
for (; ; ) {
long timeout = getProcedure(util, clazz, parser).filter(o -> o.has("timeout")).map(o -> o.get("timeout").getAsLong()).orElse(-1L);
if (timeout > oldTimeout) {
LOG.info("Timeout incremented, was {}, now is {}, increments={}", timeout, oldTimeout, timeoutIncrements);
oldTimeout = timeout;
timeoutIncrements++;
if (timeoutIncrements > times) {
break;
}
}
Thread.sleep(1000);
}
}
Aggregations