protected int startLocator(final String hostName, final String otherLocators) throws Exception { disconnectFromDS(); final int httpPort = AvailablePortHelper.getRandomAvailableTCPPort(); Properties props = new Properties(); props.put(MCAST_PORT, String.valueOf(0)); props.put(LOCATORS, otherLocators); props.put(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel()); props.put(ENABLE_CLUSTER_CONFIGURATION, "false"); props.put(HTTP_SERVICE_PORT, String.valueOf(httpPort)); File logFile = new File(""); InetAddress bindAddr = null; try { bindAddr = InetAddress.getByName(hostName); } catch (UnknownHostException uhe) { Assert.fail("While resolving bind address ", uhe); } Locator locator = Locator.startLocatorAndDS(0, logFile, bindAddr, props); remoteObjects.put(LOCATOR_KEY, locator); return locator.getPort(); }
@Override public Object call() throws IOException { Properties p = getDistributedSystemProperties(); // I never want this locator to end up starting a jmx manager // since it is part of the unit test framework p.setProperty(JMX_MANAGER, "false"); // Disable the shared configuration on this locator. // Shared configuration tests create their own locator p.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false"); // Tell the locator it's the first in the system for // faster boot-up System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true"); // disable auto-reconnect - tests fly by so fast that it will never be // able to do so successfully anyway p.setProperty(DISABLE_AUTO_RECONNECT, "true"); try { Locator.startLocatorAndDS(0, locatorLogFile, p); InternalLocator internalLocator = (InternalLocator) Locator.getLocator(); locatorPort = internalLocator.getPort(); } finally { System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY); } return locatorPort; } }, "call");
protected static void startLocator(final String name, int port, final Properties extraProps, final Properties javaProps, final String[] expectedExceptions) { try { Properties authProps = new Properties(); if (extraProps != null) { authProps.putAll(extraProps); } authProps.setProperty(MCAST_PORT, "0"); authProps.setProperty(LOCATORS, getIPLiteral() + "[" + port + "]"); authProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false"); clearStaticSSLContext(); setJavaProps(javaProps); File logFile = new File(name + "-locator" + port + ".log"); FileOutputStream logOut = new FileOutputStream(logFile); PrintStream logStream = new PrintStream(logOut); addIgnoredExceptions(expectedExceptions); logStream.flush(); locator = Locator.startLocatorAndDS(port, logFile, null, authProps); } catch (IOException ex) { fail("While starting locator on port " + port, ex); } }
public static void main(String[] args) { // On this locator, I am not expecting a listener to take any action, so a // empty listener is a passed System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", ""); System.out.println("Starting a locator with negative ds id -2"); Properties properties = new Properties(); properties.setProperty(MCAST_PORT, "0"); properties.setProperty(DISTRIBUTED_SYSTEM_ID, "" + (-2)); properties.setProperty(REMOTE_LOCATORS, "localhost[" + 10101 + "]"); properties.setProperty(LOG_LEVEL, "warning"); Locator locator = null; try { locator = Locator.startLocatorAndDS(30445, null, properties); } catch (IOException e) { e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Stoping locator"); locator.stop(); System.out.println("Locator stopped "); ExitCode.NORMAL.doSystemExit(); }
public static void main(String[] args) { // On this locator, I am not expecting a listener to take any action, so a empty listener is a // passed System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", ""); System.out.println("Starting a locator with negative ds id -1"); // start a stand alone locator with distributed-system-is = -1 Properties properties = new Properties(); properties.setProperty(MCAST_PORT, "0"); properties.setProperty(DISTRIBUTED_SYSTEM_ID, "" + (-1)); properties.setProperty(REMOTE_LOCATORS, "localhost[" + 20202 + "]"); properties.setProperty(LOG_LEVEL, "warning"); Locator locator = null; try { locator = Locator.startLocatorAndDS(40445, null, properties); } catch (IOException e) { e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // stop locator System.out.println("Stoping locator"); locator.stop(); System.out.println("Locator stopped "); ExitCode.NORMAL.doSystemExit(); }
public void startLocator() { try { // this will start a jmx manager and admin rest service by default locator = (InternalLocator) startLocatorAndDS(memberPort, null, properties); } catch (IOException e) { throw new UncheckedIOException(e); } // memberPort is by default zero, which translates to "randomly select an available port," // which is why it is updated here after being specified above. memberPort = locator.getPort(); DistributionConfig config = locator.getConfig(); jmxPort = config.getJmxManagerPort(); httpPort = config.getHttpServicePort(); if (config.getEnableClusterConfiguration()) { await() .untilAsserted(() -> assertTrue(locator.isSharedConfigurationRunning())); } }