/** * Returns an unmodifiable <code>List</code> of all of the <code>Locator</code>s that are hosted * by this VM. * * @deprecated as of 7.0 use {@link #getLocator} instead */ public static List<Locator> getLocators() { Locator result = getLocator(); if (result == null) { return Collections.emptyList(); } else { return Collections.singletonList(result); } }
public DistributionLocatorId(InetAddress address, Locator locator) { this(address, locator.getPort(), locator.getBindAddress() == null ? null : locator.getBindAddress().getHostAddress(), null, locator.getHostnameForClients()); }
/** * @return true if member contains one locator. From 7.0 only locator can be hosted in a JVM */ public boolean isLocator() { return Locator.hasLocator(); }
private static InternalDistributedSystem getIDS() { InternalDistributedSystem distributedSystem = InternalDistributedSystem.getAnyInstance(); if (distributedSystem == null) { Locator locator = Locator.getLocator(); if (locator == null) { return null; } return (InternalDistributedSystem) locator.getDistributedSystem(); } else { return distributedSystem; } } }
public static Integer createFirstLocatorWithDSId(int dsId) { if (Locator.hasLocator()) { Locator.getLocator().stop(); } AsyncEventQueueTestBase test = new AsyncEventQueueTestBase(); int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite(); Properties props = test.getDistributedSystemProperties(); props.setProperty(MCAST_PORT, "0"); // props.setProperty(DISTRIBUTED_SYSTEM_ID, "" + dsId); props.setProperty(LOCATORS, "localhost[" + port + "]"); props.setProperty(START_LOCATOR, "localhost[" + port + "],server=true,peer=true,hostname-for-clients=localhost"); test.startLocatorDistributedSystem(props); return port; }
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(); }
/** * Please note that dynamic addition of the sender id to region is not yet available. */ @Override public void addedDistributedSystem(int remoteDsId) { addCount++; List<Locator> locatorsConfigured = Locator.getLocators(); Locator locator = locatorsConfigured.get(0); Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator) locator).getlocatorMembershipListener().getAllLocatorsInfo(); System.out.println("Added : allSiteMetaData : " + allSiteMetaData); }
@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 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(); }
protected void stopLocator() { Locator locator = (Locator) remoteObjects.remove(LOCATOR_KEY); locator.stop(); }
public int getPort() { return loc.getPort(); }
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 String getHostnameForClients() { return loc.getHostnameForClients(); }
/** * Returns a brief description of this <code>Locator</code> */ @Override public String toString() { return String.format("Distribution Locator on %s", asString()); }
public String getBindAddress() { InetAddress bindAddress = loc.getBindAddress(); return bindAddress != null ? bindAddress.getCanonicalHostName() : null; }
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(); }
@Override public void removedDistributedSystem(int remoteDsId) { removeCount++; List<Locator> locatorsConfigured = Locator.getLocators(); Locator locator = locatorsConfigured.get(0); Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator) locator).getlocatorMembershipListener().getAllLocatorsInfo(); System.out.println("Removed : allSiteMetaData : " + allSiteMetaData); }
@Override public void run() { Locator locator = (Locator) remoteObjects.get(LOCATOR_KEY); if (locator != null) { try { locator.stop(); } catch (Exception e) { // do nothing } } Cache cache = (Cache) remoteObjects.get(CACHE_KEY); if (cache != null) { try { cache.close(); } catch (Exception e) { // do nothing } } remoteObjects.clear(); } };
/** * Get the string representation of this <code>Locator</code> in host[port] format. */ public String asString() { Object ba = this.bindAddress; if (ba == null) { try { ba = SocketCreator.getHostName(SocketCreator.getLocalHost()); } catch (java.net.UnknownHostException uh) { } } StringBuilder locatorString = new StringBuilder(String.valueOf(ba)); Integer port = getPort(); if (port != null && port.intValue() > 0) { locatorString.append('[').append(this.getPort()).append(']'); } return locatorString.toString(); }
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())); } }