use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class XmlClientConfigBuilder method handleAWS.
private void handleAWS(Node node, ClientNetworkConfig clientNetworkConfig) {
ClientAwsConfig clientAwsConfig = handleAwsAttributes(node);
for (Node n : childElements(node)) {
String value = getTextContent(n).trim();
if ("secret-key".equals(cleanNodeName(n))) {
clientAwsConfig.setSecretKey(value);
} else if ("access-key".equals(cleanNodeName(n))) {
clientAwsConfig.setAccessKey(value);
} else if ("region".equals(cleanNodeName(n))) {
clientAwsConfig.setRegion(value);
} else if ("host-header".equals(cleanNodeName(n))) {
clientAwsConfig.setHostHeader(value);
} else if ("security-group-name".equals(cleanNodeName(n))) {
clientAwsConfig.setSecurityGroupName(value);
} else if ("tag-key".equals(cleanNodeName(n))) {
clientAwsConfig.setTagKey(value);
} else if ("tag-value".equals(cleanNodeName(n))) {
clientAwsConfig.setTagValue(value);
} else if ("inside-aws".equals(cleanNodeName(n))) {
clientAwsConfig.setInsideAws(getBooleanValue(value));
} else if ("iam-role".equals(cleanNodeName(n))) {
clientAwsConfig.setIamRole(value);
}
}
if (!clientAwsConfig.isInsideAws() && clientAwsConfig.getIamRole() != null) {
throw new InvalidConfigurationException("You cannot set IAM Role from outside EC2");
}
clientNetworkConfig.setAwsConfig(clientAwsConfig);
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class XmlClientConfigBuilder method parse.
@Override
protected Document parse(InputStream inputStream) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder builder = dbf.newDocumentBuilder();
try {
return builder.parse(inputStream);
} catch (Exception e) {
String msg = "Failed to parse Config Stream" + LINE_SEPARATOR + "Exception: " + e.getMessage() + LINE_SEPARATOR + "HazelcastClient startup interrupted.";
LOGGER.severe(msg);
throw new InvalidConfigurationException(e.getMessage(), e);
} finally {
IOUtil.closeResource(inputStream);
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class ClientFailoverDomConfigProcessor method buildConfig.
@Override
public void buildConfig(Node rootNode) {
for (Node node : childElements(rootNode)) {
String nodeName = cleanNodeName(node);
if (occurrenceSet.contains(nodeName)) {
throw new InvalidConfigurationException("Duplicate '" + nodeName + "' definition found in the configuration");
}
handleNode(node, nodeName);
if (!canOccurMultipleTimes(nodeName)) {
occurrenceSet.add(nodeName);
}
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class ClientFailoverDomConfigProcessor method handleClients.
protected void handleClients(Node node) {
for (Node child : childElements(node)) {
if (matches("client", cleanNodeName(child))) {
String clientPath = getTextContent(child);
try {
ClientConfig config = new XmlClientConfigBuilder(clientPath).build();
clientFailoverConfig.addClientConfig(config);
} catch (IOException e) {
throw new InvalidConfigurationException("Could not create the config from given path : " + clientPath, e);
}
}
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class YamlClientConfigBuilder method parseAndBuildConfig.
private void parseAndBuildConfig(ClientConfig config) throws Exception {
YamlMapping yamlRootNode;
try {
yamlRootNode = ((YamlMapping) YamlLoader.load(in));
} catch (Exception ex) {
throw new InvalidConfigurationException("Invalid YAML configuration", ex);
}
YamlNode clientRoot = yamlRootNode.childAsMapping(ClientConfigSections.HAZELCAST_CLIENT.getName());
if (clientRoot == null) {
clientRoot = yamlRootNode;
}
YamlDomChecker.check(clientRoot);
Node w3cRootNode = asW3cNode(clientRoot);
replaceVariables(w3cRootNode);
importDocuments(clientRoot);
if (shouldValidateTheSchema()) {
new YamlConfigSchemaValidator().validate((YamlMapping) clientRoot.parent());
}
new YamlClientDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
Aggregations