private void checkConfigVersion(IdentifiedDataSerializable config) { Class<? extends IdentifiedDataSerializable> configClass = config.getClass(); Version currentClusterVersion = version; Version introducedIn = CONFIG_TO_VERSION.get(configClass); if (currentClusterVersion.isLessThan(introducedIn)) { throw new UnsupportedOperationException(format("Config '%s' is available since version '%s'. " + "Current cluster version '%s' does not allow dynamically adding '%1$s'.", configClass.getSimpleName(), introducedIn.toString(), currentClusterVersion.toString() )); } }
private void checkConfigVersion(IdentifiedDataSerializable config) { Class<? extends IdentifiedDataSerializable> configClass = config.getClass(); Version currentClusterVersion = version; Version introducedIn = CONFIG_TO_VERSION.get(configClass); if (currentClusterVersion.isLessThan(introducedIn)) { throw new UnsupportedOperationException(format("Config '%s' is available since version '%s'. " + "Current cluster version '%s' does not allow dynamically adding '%1$s'.", configClass.getSimpleName(), introducedIn.toString(), currentClusterVersion.toString() )); } }
private void render(DiagnosticsLogWriter writer, Version version) { writer.startSection("ClusterVersionChanged"); writer.writeEntry(version.toString()); writer.endSection(); }
private void handleGetClusterVersion(HttpGetCommand command) { String res = "{\"status\":\"${STATUS}\",\"version\":\"${VERSION}\"}"; Node node = textCommandService.getNode(); ClusterService clusterService = node.getClusterService(); res = res.replace("${STATUS}", "success"); res = res.replace("${VERSION}", clusterService.getClusterVersion().toString()); command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res)); }
private void handleGetClusterVersion(HttpGetCommand command) { String res = "{\"status\":\"${STATUS}\",\"version\":\"${VERSION}\"}"; Node node = textCommandService.getNode(); ClusterService clusterService = node.getClusterService(); res = res.replace("${STATUS}", "success"); res = res.replace("${VERSION}", clusterService.getClusterVersion().toString()); command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res)); }
private void render(DiagnosticsLogWriter writer, Version version) { writer.startSection("ClusterVersionChanged"); writer.writeEntry(version.toString()); writer.endSection(); }
@Override public JsonObject toJson() { JsonObject root = new JsonObject(); root.add("clusterState", clusterState.name()); root.add("nodeState", nodeState.name()); root.add("clusterVersion", clusterVersion.toString()); root.add("memberVersion", memberVersion.toString()); JsonObject weaknesses = new JsonObject(); for (Map.Entry<String, List<String>> entry : weakSecretsConfigs.entrySet()) { JsonArray values = new JsonArray(); for (String value : entry.getValue()) { values.add(value); } weaknesses.add(entry.getKey(), values); } root.add("weakConfigs", weaknesses); return root; }
private void handleChangeClusterVersion(HttpPostCommand command) throws UnsupportedEncodingException { byte[] data = command.getData(); String[] strList = bytesToString(data).split("&"); String groupName = URLDecoder.decode(strList[0], "UTF-8"); String groupPass = URLDecoder.decode(strList[1], "UTF-8"); String versionParam = URLDecoder.decode(strList[2], "UTF-8"); String res; try { Node node = textCommandService.getNode(); ClusterService clusterService = node.getClusterService(); GroupConfig groupConfig = node.getConfig().getGroupConfig(); if (!(groupConfig.getName().equals(groupName) && groupConfig.getPassword().equals(groupPass))) { res = response(ResponseType.FORBIDDEN); } else { Version version = Version.of(versionParam); clusterService.changeClusterVersion(version); res = response(ResponseType.SUCCESS, "version", clusterService.getClusterVersion().toString()); } } catch (Throwable throwable) { logger.warning("Error occurred while changing cluster version", throwable); res = exceptionResponse(throwable); } command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res)); }
@Override public JsonObject toJson() { JsonObject root = new JsonObject(); root.add("clusterState", clusterState.name()); root.add("nodeState", nodeState.name()); root.add("clusterVersion", clusterVersion.toString()); root.add("memberVersion", memberVersion.toString()); JsonObject weaknesses = new JsonObject(); for (Map.Entry<String, List<String>> entry : weakSecretsConfigs.entrySet()) { JsonArray values = new JsonArray(); for (String value : entry.getValue()) { values.add(value); } weaknesses.add(entry.getKey(), values); } root.add("weakConfigs", weaknesses); return root; }
private void handleChangeClusterVersion(HttpPostCommand command) throws UnsupportedEncodingException { byte[] data = command.getData(); String[] strList = bytesToString(data).split("&"); String res; try { Node node = textCommandService.getNode(); ClusterService clusterService = node.getClusterService(); if (authenticate(command, strList[0], strList.length > 1 ? strList[1] : null)) { String versionParam = URLDecoder.decode(strList[2], "UTF-8"); Version version = Version.of(versionParam); clusterService.changeClusterVersion(version); res = response(ResponseType.SUCCESS, "version", clusterService.getClusterVersion().toString()); } else { res = response(ResponseType.FORBIDDEN); } } catch (Throwable throwable) { logger.warning("Error occurred while changing cluster version", throwable); res = exceptionResponse(throwable); } command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res)); }