use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleSecurityPermissions.
protected void handleSecurityPermissions(Node node) {
String onJoinOp = getAttribute(node, "on-join-operation");
if (onJoinOp != null) {
OnJoinPermissionOperationName onJoinPermissionOperation = OnJoinPermissionOperationName.valueOf(upperCaseInternal(onJoinOp));
config.getSecurityConfig().setOnJoinPermissionOperation(onJoinPermissionOperation);
}
for (Node child : childElements(node)) {
String nodeName = cleanNodeName(child);
PermissionType type = PermissionConfig.PermissionType.getType(nodeName);
if (type == null) {
throw new InvalidConfigurationException("Security permission type is not valid " + nodeName);
}
handleSecurityPermission(child, type);
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleServerSocketEndpointConfig.
protected void handleServerSocketEndpointConfig(ServerSocketEndpointConfig endpointConfig, Node node, String name) throws Exception {
endpointConfig.setName(name);
for (Node child : childElements(node)) {
String nodeName = cleanNodeName(child);
if (matches("port", nodeName)) {
handlePort(child, endpointConfig);
} else if (matches("public-address", nodeName)) {
String address = getTextContent(child);
endpointConfig.setPublicAddress(address);
} else if (matches("reuse-address", nodeName)) {
endpointConfig.setReuseAddress(getBooleanValue(getTextContent(child)));
} else {
handleEndpointConfigCommons(child, nodeName, endpointConfig);
}
}
switch(endpointConfig.getProtocolType()) {
case MEMBER:
ensureServerSocketEndpointConfig(endpointConfig);
config.getAdvancedNetworkConfig().setMemberEndpointConfig(endpointConfig);
break;
case CLIENT:
ensureServerSocketEndpointConfig(endpointConfig);
config.getAdvancedNetworkConfig().setClientEndpointConfig(endpointConfig);
break;
case REST:
ensureServerSocketEndpointConfig(endpointConfig);
config.getAdvancedNetworkConfig().setRestEndpointConfig((RestServerEndpointConfig) endpointConfig);
break;
case WAN:
config.getAdvancedNetworkConfig().addWanEndpointConfig(endpointConfig);
break;
case MEMCACHE:
config.getAdvancedNetworkConfig().setMemcacheEndpointConfig(endpointConfig);
break;
default:
throw new InvalidConfigurationException("Endpoint config has invalid protocol type " + endpointConfig.getProtocolType());
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleCacheNode.
void handleCacheNode(Node node, CacheSimpleConfig cacheConfig) throws Exception {
for (Node n : childElements(node)) {
String nodeName = cleanNodeName(n);
if (matches("key-type", nodeName)) {
cacheConfig.setKeyType(getAttribute(n, "class-name"));
} else if (matches("value-type", nodeName)) {
cacheConfig.setValueType(getAttribute(n, "class-name"));
} else if (matches("statistics-enabled", nodeName)) {
cacheConfig.setStatisticsEnabled(getBooleanValue(getTextContent(n)));
} else if (matches("management-enabled", nodeName)) {
cacheConfig.setManagementEnabled(getBooleanValue(getTextContent(n)));
} else if (matches("read-through", nodeName)) {
cacheConfig.setReadThrough(getBooleanValue(getTextContent(n)));
} else if (matches("write-through", nodeName)) {
cacheConfig.setWriteThrough(getBooleanValue(getTextContent(n)));
} else if (matches("cache-loader-factory", nodeName)) {
cacheConfig.setCacheLoaderFactory(getAttribute(n, "class-name"));
} else if (matches("cache-loader", nodeName)) {
cacheConfig.setCacheLoader(getAttribute(n, "class-name"));
} else if (matches("cache-writer-factory", nodeName)) {
cacheConfig.setCacheWriterFactory(getAttribute(n, "class-name"));
} else if (matches("cache-writer", nodeName)) {
cacheConfig.setCacheWriter(getAttribute(n, "class-name"));
} else if (matches("expiry-policy-factory", nodeName)) {
cacheConfig.setExpiryPolicyFactoryConfig(getExpiryPolicyFactoryConfig(n));
} else if (matches("cache-entry-listeners", nodeName)) {
cacheListenerHandle(n, cacheConfig);
} else if (matches("in-memory-format", nodeName)) {
cacheConfig.setInMemoryFormat(InMemoryFormat.valueOf(upperCaseInternal(getTextContent(n))));
} else if (matches("backup-count", nodeName)) {
cacheConfig.setBackupCount(getIntegerValue("backup-count", getTextContent(n)));
} else if (matches("async-backup-count", nodeName)) {
cacheConfig.setAsyncBackupCount(getIntegerValue("async-backup-count", getTextContent(n)));
} else if (matches("wan-replication-ref", nodeName)) {
cacheWanReplicationRefHandle(n, cacheConfig);
} else if (matches("eviction", nodeName)) {
cacheConfig.setEvictionConfig(getEvictionConfig(n, false, false));
} else if (matches("split-brain-protection-ref", nodeName)) {
cacheConfig.setSplitBrainProtectionName(getTextContent(n));
} else if (matches("partition-lost-listeners", nodeName)) {
cachePartitionLostListenerHandle(n, cacheConfig);
} else if (matches("merge-policy", nodeName)) {
MergePolicyConfig mpConfig = createMergePolicyConfig(n, cacheConfig.getMergePolicyConfig());
cacheConfig.setMergePolicyConfig(mpConfig);
} else if (matches("event-journal", nodeName)) {
EventJournalConfig eventJournalConfig = new EventJournalConfig();
handleViaReflection(n, cacheConfig, eventJournalConfig);
} else if (matches("hot-restart", nodeName)) {
cacheConfig.setHotRestartConfig(createHotRestartConfig(n));
} else if (matches("data-persistence", nodeName)) {
cacheConfig.setDataPersistenceConfig(createDataPersistenceConfig(n));
} else if (matches("disable-per-entry-invalidation-events", nodeName)) {
cacheConfig.setDisablePerEntryInvalidationEvents(getBooleanValue(getTextContent(n)));
} else if (matches("merkle-tree", nodeName)) {
handleViaReflection(n, cacheConfig, cacheConfig.getMerkleTreeConfig());
}
}
try {
checkCacheConfig(cacheConfig, null);
} catch (IllegalArgumentException e) {
throw new InvalidConfigurationException(e.getMessage());
}
config.addCacheConfig(cacheConfig);
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method invokeSetter.
private void invokeSetter(Object target, Node node, String argument) {
Method method = getMethod(target, "set" + toPropertyName(cleanNodeName(node)), true);
if (method == null) {
throw new InvalidConfigurationException("Invalid element/attribute name in the configuration: " + cleanNodeName(node));
}
Class<?> arg = method.getParameterTypes()[0];
Object coercedArg = arg == String.class ? argument : arg == int.class ? Integer.valueOf(argument) : arg == long.class ? Long.valueOf(argument) : arg == boolean.class ? getBooleanValue(argument) : null;
if (coercedArg == null) {
throw new HazelcastException(String.format("Method %s has unsupported argument type %s", method.getName(), arg.getSimpleName()));
}
try {
method.invoke(target, coercedArg);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleTcpIp.
private void handleTcpIp(Node node, boolean advancedNetworkConfig) {
NamedNodeMap attributes = node.getAttributes();
JoinConfig join = joinConfig(advancedNetworkConfig);
TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
for (int a = 0; a < attributes.getLength(); a++) {
Node att = attributes.item(a);
if (matches(att.getNodeName(), "enabled")) {
tcpIpConfig.setEnabled(getBooleanValue(getTextContent(att)));
} else if (matches(att.getNodeName(), "connection-timeout-seconds")) {
tcpIpConfig.setConnectionTimeoutSeconds(getIntegerValue("connection-timeout-seconds", getTextContent(att)));
}
}
Set<String> memberTags = new HashSet<>(Arrays.asList("interface", "member", "members"));
for (Node n : childElements(node)) {
if (matches(cleanNodeName(n), "member-list")) {
handleMemberList(n, advancedNetworkConfig);
} else if (matches(cleanNodeName(n), "required-member")) {
if (tcpIpConfig.getRequiredMember() != null) {
throw new InvalidConfigurationException("Duplicate required-member" + " definition found in the configuration. ");
}
tcpIpConfig.setRequiredMember(getTextContent(n));
} else if (memberTags.contains(cleanNodeName(n))) {
tcpIpConfig.addMember(getTextContent(n));
}
}
}
Aggregations