Refine search
public HazelcastMember build() { Config config = new Config(); config.getGroupConfig().setName("SonarQube"); NetworkConfig netConfig = config.getNetworkConfig(); netConfig .setPort(port) .setPortAutoIncrement(false) .setReuseAddress(true); netConfig.getInterfaces() .setEnabled(true) .setInterfaces(singletonList(requireNonNull(networkInterface, "Network interface is missing")));
Config config = new Config(); NetworkConfig networkConfig = config.getNetworkConfig(); networkConfig.setPort(10571); networkConfig.getInterfaces().addInterface("127.0.0.1"); JoinConfig joinConfig = networkConfig.getJoin(); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true); joinConfig.getTcpIpConfig().addMember("127.0.0.1:10572"); joinConfig.getTcpIpConfig().addMember("127.0.0.1:10573"); config.getMapConfig("*").setBackupCount(2); ClusterNode node1 = new ClusterNode(config); networkConfig = config.getNetworkConfig(); networkConfig.setPort(10572); networkConfig.getInterfaces().addInterface("127.0.0.1"); joinConfig = networkConfig.getJoin(); joinConfig.getMulticastConfig().setEnabled(false); networkConfig = config.getNetworkConfig(); networkConfig.setPort(10573); networkConfig.getInterfaces().addInterface("127.0.0.1"); joinConfig = networkConfig.getJoin(); joinConfig.getMulticastConfig().setEnabled(false);
NetworkConfig networkConfig = new NetworkConfig(); Setting<ListenSocketAddress> discovery_listen_address = CoreEdgeClusterSettings.discovery_listen_address; ListenSocketAddress hazelcastAddress = config.get( discovery_listen_address ); InterfacesConfig interfaces = new InterfacesConfig(); interfaces.addInterface( hazelcastAddress.getHostname() ); networkConfig.setInterfaces( interfaces ); networkConfig.setPort( hazelcastAddress.getPort() ); networkConfig.setJoin( joinConfig ); networkConfig.setPortAutoIncrement( false ); com.hazelcast.config.Config c = new com.hazelcast.config.Config(); c.setProperty( GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS, "10000" ); c.setProperty( GroupProperties.PROP_INITIAL_MIN_CLUSTER_SIZE, String.valueOf( minimumClusterSizeThatCanTolerateOneFaultForExpectedClusterSize() ) ); c.setProperty( GroupProperties.PROP_LOGGING_TYPE, "none" );
private Config initializeHazelcastConfig() throws Exception { Config hazelCastConfig = new Config(); logger.setLevel(Level.OFF); NetworkConfig networkConfig = new NetworkConfig(); networkConfig.setPortAutoIncrement(false); networkConfig.setPort(clusterPort); networkConfig.getInterfaces().addInterface(hostConvertedToIP); for (String networkInterface : networkConfig.getInterfaces().getInterfaces()) { InetAddress address = getResolvedAddressFromHost(networkInterface); if (address.isAnyLocalAddress()) { networkConfig.getInterfaces().setEnabled(true); hazelCastConfig.setProperty(HAZELCAST_SOCKET_BIND_ANY_PROPERTY, "false"); networkConfig.getInterfaces().setEnabled(true); networkConfig.getInterfaces().clear(); networkConfig.getInterfaces().addInterface(localIPv4);
private Config hazelcast() { Config conf = new Config(); conf.getNetworkConfig().setPort(hazelCastPort); conf.getNetworkConfig().setPortAutoIncrement(false); JoinConfig join = conf.getNetworkConfig().getJoin(); conf.getNetworkConfig().getInterfaces().setEnabled(true).addInterface(interf);
Config hzConfig = new Config(); InterfacesConfig iFaces = new InterfacesConfig(); for (String strIFace : iFacesArr) { iFaces.addInterface(strIFace.trim()); iFaces.setEnabled(true); hzConfig.getNetworkConfig().setInterfaces(iFaces); if (prop != -1) { log.info("-- Using Hazelcast port: " + prop); hzConfig.getNetworkConfig().setPort(prop);
private List<InterfaceDefinition> getInterfaces() { NetworkConfig networkConfig = config.getNetworkConfig(); TcpIpConfig tcpIpConfig = networkConfig.getJoin().getTcpIpConfig(); // address -> domain Map<String, String> addressDomainMap = createAddressToDomainMap(tcpIpConfig); // must preserve insertion order List<InterfaceDefinition> interfaceDefs = new ArrayList<InterfaceDefinition>(); if (networkConfig.getInterfaces().isEnabled()) { Collection<String> configInterfaces = networkConfig.getInterfaces().getInterfaces(); for (String configInterface : configInterfaces) { if (!AddressUtil.isIpAddress(configInterface)) { logger.warning("'" + configInterface + "' is not an IP address! Removing from interface list."); continue; } // add interfaces matching to members in TcpIpConfig appendMatchingInterfaces(interfaceDefs, addressDomainMap, configInterface); // add default interface definition interfaceDefs.add(new InterfaceDefinition(null, configInterface)); } logger.info("Interfaces is enabled, trying to pick one address matching to one of: " + interfaceDefs); } else if (tcpIpConfig.isEnabled()) { for (Entry<String, String> entry : addressDomainMap.entrySet()) { interfaceDefs.add(new InterfaceDefinition(entry.getValue(), entry.getKey())); } logger.info("Interfaces is disabled, trying to pick one address from TCP-IP config addresses: " + interfaceDefs); } return interfaceDefs; }
public void testHazelcast() throws Exception { Config config = new Config(); MapConfig mapConfig = new MapConfig(HazelcastCacheProvider.HAZELCAST_MAP_DEFINITION); MaxSizeConfig maxSizeConf = new MaxSizeConfig(16, MaxSizePolicy.USED_HEAP_SIZE); mapConfig.setMaxSizeConfig(maxSizeConf); mapConfig.setEvictionPolicy(EvictionPolicy.LRU); config.addMapConfig(mapConfig); config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true); config.getNetworkConfig() .getJoin() .getTcpIpConfig() .setMembers( config.getNetworkConfig().getInterfaces().addInterface("127.0.0.1"); HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config); HazelcastLoader loader1 = new HazelcastLoader();
@Bean public Config hazelcastConfig() { Config config = new Config(); config.getNetworkConfig().getInterfaces().setEnabled(true).addInterface("10.0.*.*"); JoinConfig joinConfig = config.getNetworkConfig().getJoin(); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getAwsConfig() .setEnabled(true) .setProperty("region", "eu-central-1") .setProperty("tag-key", "aws:cloudformation:stack-name") .setProperty("tag-value", "EC2ContainerService-test-cluster"); return config; }
private void deployClustered(final Logger logger, Handler<AsyncResult<Vertx>> fut) { if (hConfig == null) { hConfig = new Config(); if (clusterHost != null) { NetworkConfig network = hConfig.getNetworkConfig(); InterfacesConfig iFace = network.getInterfaces(); iFace.setEnabled(true).addInterface(clusterHost); hConfig.setProperty("hazelcast.logging.type", "slf4j");
Config hazelcastConfig = new FileSystemXmlConfig(hazelcastConfFilePath); if(hazelcastMembers!=null) { NetworkConfig network = hazelcastConfig.getNetworkConfig(); JoinConfig join = network.getJoin(); join.getMulticastConfig().setEnabled(false); TcpIpConfig tcpIp = join.getTcpIpConfig(); options.setClusterHost(clusterHost); NetworkConfig network = hazelcastConfig.getNetworkConfig(); InterfacesConfig interfaces = network.getInterfaces(); interfaces.setEnabled(true); interfaces.addInterface(clusterHost); hazelcastConfig.getNetworkConfig().getPublicAddress()); logger.info("Hazelcast tcp-ip members: " + hazelcastConfig.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
private void handleInterfaces(Node node) { NamedNodeMap attributes = node.getAttributes(); InterfacesConfig interfaces = config.getNetworkConfig().getInterfaces(); for (int a = 0; a < attributes.getLength(); a++) { Node att = attributes.item(a); if ("enabled".equals(att.getNodeName())) { String value = att.getNodeValue(); interfaces.setEnabled(getBooleanValue(value)); } } for (Node n : childElements(node)) { if ("interface".equals(lowerCaseInternal(cleanNodeName(n)))) { String value = getTextContent(n).trim(); interfaces.addInterface(value); } } }
final Collection<String> possibleMembers = getMembers(); final Set<Address> possibleAddresses = new HashSet<Address>(); final NetworkConfig networkConfig = config.getNetworkConfig(); for (String possibleMember : possibleMembers) { AddressHolder addressHolder = AddressUtil.getAddressHolder(possibleMember); try { boolean portIsDefined = addressHolder.getPort() != -1 || !networkConfig.isPortAutoIncrement(); int count = portIsDefined ? 1 : maxPortTryCount; int port = addressHolder.getPort() != -1 ? addressHolder.getPort() : networkConfig.getPort(); AddressMatcher addressMatcher = null; try { final InterfacesConfig interfaces = networkConfig.getInterfaces(); if (interfaces.isEnabled()) { final InetAddress[] inetAddresses = InetAddress.getAllByName(host); for (InetAddress inetAddress : inetAddresses) { if (AddressUtil.matchAnyInterface(inetAddress.getHostAddress(), interfaces.getInterfaces())) { addPossibleAddresses(possibleAddresses, host, inetAddress, port, count);
private static NetworkConfig createNetworkConfigs() { NetworkConfig networkConfig = new NetworkConfig(); InterfacesConfig interfaceConfig = new InterfacesConfig(); // add current host try { interfaceConfig.addInterface(InetAddress.getByName(OAuthServer.getHost()).getHostAddress()); } catch (UnknownHostException e) { log.error("cannot create hazelcast config", e); } interfaceConfig.setEnabled(true); networkConfig.setInterfaces(interfaceConfig); JoinConfig joinConfig = new JoinConfig(); TcpIpConfig tcpIps = new TcpIpConfig(); List<String> ips = createNodesList(); if (ips != null) { tcpIps.setMembers(ips); joinConfig.setTcpIpConfig(tcpIps); } tcpIps.setEnabled(true); MulticastConfig multicastConfig = new MulticastConfig(); multicastConfig.setEnabled(false); joinConfig.setMulticastConfig(multicastConfig); networkConfig.setJoin(joinConfig); return networkConfig; }
private static void interfacesConfigXmlGenerator(XmlGenerator gen, NetworkConfig netCfg) { InterfacesConfig interfaces = netCfg.getInterfaces(); gen.open("interfaces", "enabled", interfaces.isEnabled()); for (String i : interfaces.getInterfaces()) { gen.node("interface", i); } gen.close(); }
/** * Adds a collection of interfaces. * Clears the current collection and then adds all entries of new collection. * * @param interfaces the interfaces to set */ public InterfacesConfig setInterfaces(final Collection<String> interfaces) { clear(); this.interfaceSet.addAll(interfaces); return this; }
public static void main(String[] args) { CommandLineConf conf = new CommandLineConf(); conf.setIpAddress("127.0.0.1"); // create root beanFactory DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); // register bean definition for the command line ExternalBeanReferneceFactoryBean.setInstance("commandLineConf", conf); beanFactory.registerBeanDefinition( "commandLineConf", BeanDefinitionBuilder.rootBeanDefinition( ExternalBeanReferneceFactoryBean.class) .getBeanDefinition()); GenericApplicationContext rootAppContext = new GenericApplicationContext( beanFactory); rootAppContext.refresh(); // create the application context ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] { "/applicationContext.xml" }, rootAppContext); InterfacesConfig hazelcastInterface = (InterfacesConfig)appContext.getBean("hazelcastInterface"); System.out.println(hazelcastInterface.getInterfaces().get(0)); }
Config config = new Config(); NetworkConfig networkConfig = config.getNetworkConfig(); networkConfig.setPort(10571); networkConfig.getInterfaces().addInterface("127.0.0.1"); JoinConfig joinConfig = networkConfig.getJoin(); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true); ClusterNode node1 = new ClusterNode(config); config = new Config(); networkConfig = config.getNetworkConfig(); networkConfig.setPort(10572); networkConfig.getInterfaces().addInterface("127.0.0.1"); joinConfig = networkConfig.getJoin(); joinConfig.getMulticastConfig().setEnabled(false);
NetworkConfig networkConfig = new NetworkConfig(); InterfacesConfig interfaces = new InterfacesConfig(); interfaces.addInterface( hazelcastAddress.getHostname() ); interfaces.setEnabled( true ); networkConfig.setInterfaces( interfaces ); networkConfig.setPort( hazelcastAddress.getPort() ); networkConfig.setJoin( joinConfig ); networkConfig.setPortAutoIncrement( false ); com.hazelcast.config.Config c = new com.hazelcast.config.Config(); c.setProperty( OPERATION_CALL_TIMEOUT_MILLIS.getName(), String.valueOf( baseHazelcastTimeoutMillis ) ); c.setProperty( MERGE_NEXT_RUN_DELAY_SECONDS.getName(), String.valueOf( baseHazelcastTimeoutSeconds ) ); c.setProperty( MERGE_FIRST_RUN_DELAY_SECONDS.getName(), String.valueOf( baseHazelcastTimeoutSeconds ) ); c.setProperty( INITIAL_MIN_CLUSTER_SIZE.getName(), String.valueOf( HAZELCAST_MIN_CLUSTER ) );
private List<InterfaceDefinition> getInterfaces() { NetworkConfig networkConfig = config.getNetworkConfig(); TcpIpConfig tcpIpConfig = networkConfig.getJoin().getTcpIpConfig(); // address -> domain Map<String, String> addressDomainMap = createAddressToDomainMap(tcpIpConfig); // must preserve insertion order List<InterfaceDefinition> interfaceDefs = new ArrayList<InterfaceDefinition>(); if (networkConfig.getInterfaces().isEnabled()) { Collection<String> configInterfaces = networkConfig.getInterfaces().getInterfaces(); for (String configInterface : configInterfaces) { if (!AddressUtil.isIpAddress(configInterface)) { logger.warning("'" + configInterface + "' is not an IP address! Removing from interface list."); continue; } // add interfaces matching to members in TcpIpConfig appendMatchingInterfaces(interfaceDefs, addressDomainMap, configInterface); // add default interface definition interfaceDefs.add(new InterfaceDefinition(null, configInterface)); } logger.info("Interfaces is enabled, trying to pick one address matching to one of: " + interfaceDefs); } else if (tcpIpConfig.isEnabled()) { for (Entry<String, String> entry : addressDomainMap.entrySet()) { interfaceDefs.add(new InterfaceDefinition(entry.getValue(), entry.getKey())); } logger.info("Interfaces is disabled, trying to pick one address from TCP-IP config addresses: " + interfaceDefs); } return interfaceDefs; }