public static void main(String[] args) { System.out.println(UUIDUtil.randomUUID().toUpperCase()); }
/** * Generate a default configuration with meaningful default settings. The keystore password will be randomly generated and set. * * @return */ private static MeshOptions generateDefaultConfig() { MeshOptions options = new MeshOptions(); options.getAuthenticationOptions().setKeystorePassword(UUIDUtil.randomUUID()); options.setNodeName(MeshNameProvider.getInstance().getRandomName()); return options; }
@Test public void testModel() { ConflictWarning warning = new ConflictWarning(); warning.setNodeUuid(UUIDUtil.randomUUID()); System.out.println(warning.toJson()); JobWarningList warnings = new JobWarningList(); warnings.add(warning); String json = JsonUtil.toJson(warnings); System.out.println(json); JobWarningList remapped = JsonUtil.readValue(json, JobWarningList.class); assertEquals("node-conflict-resolution", remapped.getData().get(0).getType()); } }
@Override public Completable validateCreateViaTemplate(IndexInfo info) { JsonObject json = createIndexSettings(info); if (log.isDebugEnabled()) { log.debug("Validating index configuration {" + json.encodePrettily() + "}"); } String randomName = info.getIndexName() + UUIDUtil.randomUUID(); String templateName = randomName.toLowerCase(); json.put("template", templateName); return client.createIndexTemplate(templateName, json).async() .doOnSuccess(response -> { if (log.isDebugEnabled()) { log.debug("Created template {" + templateName + "} response: {" + response.toString() + "}"); } }).onErrorResumeNext(error -> { if (error instanceof HttpErrorException) { HttpErrorException re = (HttpErrorException) error; JsonObject errorInfo = re.getBodyObject(JsonObject::new); String reason = errorInfo.getJsonObject("error").getString("reason"); return Single.error(error(BAD_REQUEST, "schema_error_index_validation", reason)); } else { return Single.error(error(BAD_REQUEST, "schema_error_index_validation", error.getMessage())); } }).toCompletable() .andThen(client.deleteIndexTemplate(templateName).async().toCompletable()) .compose(withTimeoutAndLog("Template validation", false)); }
@Test public void testIsUUID() { String validUUID = "dd5e85cebb7311e49640316caf57479f"; String uuid = UUIDUtil.randomUUID(); System.out.println(uuid); assertTrue("The uuid {" + uuid + "} is not a valid uuid.", UUIDUtil.isUUID(uuid)); assertFalse(UUIDUtil.isUUID("")); assertFalse(UUIDUtil.isUUID("123")); assertFalse(UUIDUtil.isUUID("-1")); assertFalse(UUIDUtil.isUUID("1")); assertFalse(UUIDUtil.isUUID("0")); assertFalse(UUIDUtil.isUUID("/test/1235.html")); assertTrue(UUIDUtil.isUUID(validUUID)); assertFalse(UUIDUtil.isUUID(validUUID.replace("f", "z"))); }