use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class ConfigUpdateProgressEvent method toJson.
@Override
public JsonObject toJson() {
JsonObject json = super.toJson();
json.add("totalChangeCount", totalChangeCount);
json.add("appliedChangeCount", appliedChangeCount);
json.add("configName", namespace.getConfigName());
json.add("sectionName", namespace.getSectionName());
return json;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class HazelcastJsonUpsertTargetTest method test_set.
@Test
public void test_set() {
UpsertTarget target = new HazelcastJsonUpsertTarget();
UpsertInjector nullInjector = target.createInjector("null", QueryDataType.OBJECT);
UpsertInjector objectInjector = target.createInjector("object", QueryDataType.OBJECT);
UpsertInjector stringInjector = target.createInjector("string", QueryDataType.VARCHAR);
UpsertInjector booleanInjector = target.createInjector("boolean", QueryDataType.BOOLEAN);
UpsertInjector byteInjector = target.createInjector("byte", QueryDataType.TINYINT);
UpsertInjector shortInjector = target.createInjector("short", QueryDataType.SMALLINT);
UpsertInjector intInjector = target.createInjector("int", QueryDataType.INT);
UpsertInjector longInjector = target.createInjector("long", QueryDataType.BIGINT);
UpsertInjector floatInjector = target.createInjector("float", QueryDataType.REAL);
UpsertInjector doubleInjector = target.createInjector("double", QueryDataType.DOUBLE);
UpsertInjector decimalInjector = target.createInjector("decimal", QueryDataType.DECIMAL);
UpsertInjector timeInjector = target.createInjector("time", QueryDataType.TIME);
UpsertInjector dateInjector = target.createInjector("date", QueryDataType.DATE);
UpsertInjector timestampInjector = target.createInjector("timestamp", QueryDataType.TIMESTAMP);
UpsertInjector timestampTzInjector = target.createInjector("timestampTz", QueryDataType.TIMESTAMP_WITH_TZ_OFFSET_DATE_TIME);
target.init();
nullInjector.set(null);
objectInjector.set(new JsonObject());
stringInjector.set("string");
booleanInjector.set(true);
byteInjector.set((byte) 127);
shortInjector.set((short) 32767);
intInjector.set(2147483647);
longInjector.set(9223372036854775807L);
floatInjector.set(1234567890.1F);
doubleInjector.set(123451234567890.1D);
decimalInjector.set(new BigDecimal("9223372036854775.123"));
timeInjector.set(LocalTime.of(12, 23, 34));
dateInjector.set(LocalDate.of(2020, 9, 9));
timestampInjector.set(LocalDateTime.of(2020, 9, 9, 12, 23, 34, 100_000_000));
timestampTzInjector.set(OffsetDateTime.of(2020, 9, 9, 12, 23, 34, 200_000_000, UTC));
Object hazelcastJson = target.conclude();
assertThat(hazelcastJson).isEqualTo(new HazelcastJsonValue("{" + "\"null\":null" + ",\"object\":{}" + ",\"string\":\"string\"" + ",\"boolean\":true" + ",\"byte\":127" + ",\"short\":32767" + ",\"int\":2147483647" + ",\"long\":9223372036854775807" + ",\"float\":1.23456794E9" + ",\"double\":1.234512345678901E14" + ",\"decimal\":\"9223372036854775.123\"" + ",\"time\":\"12:23:34\"" + ",\"date\":\"2020-09-09\"" + ",\"timestamp\":\"2020-09-09T12:23:34.100\"" + ",\"timestampTz\":\"2020-09-09T12:23:34.200Z\"" + "}"));
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class AzureComputeApi method parsePrivateIpResponse.
private Map<String, AzureNetworkInterface> parsePrivateIpResponse(String response) {
Map<String, AzureNetworkInterface> interfaces = new HashMap<>();
for (JsonValue item : toJsonArray(Json.parse(response).asObject().get("value"))) {
Set<Tag> tagList = new HashSet<>();
JsonObject tags = toJsonObject(item.asObject().get("tags"));
for (String key : tags.asObject().names()) {
tagList.add(new Tag(key, tags.asObject().getString(key, null)));
}
JsonObject properties = item.asObject().get("properties").asObject();
if (properties.get("virtualMachine") != null) {
for (JsonValue ipConfiguration : toJsonArray(properties.get("ipConfigurations"))) {
JsonObject ipProps = ipConfiguration.asObject().get("properties").asObject();
String privateIp = ipProps.getString("privateIPAddress", null);
String publicIpId = toJsonObject(ipProps.get("publicIPAddress")).getString("id", null);
if (!isNullOrEmptyAfterTrim(privateIp)) {
interfaces.put(privateIp, new AzureNetworkInterface(privateIp, publicIpId, tagList));
}
}
}
}
return interfaces;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class AwsEcsApi method createBodyDescribeTasks.
private String createBodyDescribeTasks(String cluster, List<String> taskArns) {
JsonArray jsonArray = new JsonArray();
taskArns.stream().map(Json::value).forEach(jsonArray::add);
return new JsonObject().add("tasks", jsonArray).add("cluster", cluster).toString();
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class AzureMetadataApi method fillMetadata.
private void fillMetadata() {
if (metadata.isEmpty()) {
String urlString = String.format("%s/metadata/instance/compute?api-version=%s", endpoint, API_VERSION);
String response = callGet(urlString);
JsonObject jsonObject = Json.parse(response).asObject();
for (String property : jsonObject.names()) {
if (jsonObject.get(property).isString()) {
metadata.put(property, jsonObject.get(property).asString());
}
}
}
}
Aggregations