Search in sources :

Example 6 with Locator

use of org.apache.geode.distributed.Locator in project geode by apache.

the class MyDistributedSystemListener method addedDistributedSystem.

/**
   * Please note that dynamic addition of the sender id to region is not yet available.
   */
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);
}
Also used : Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Set(java.util.Set)

Example 7 with Locator

use of org.apache.geode.distributed.Locator in project geode by apache.

the class MyDistributedSystemListener method removedDistributedSystem.

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);
}
Also used : Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Set(java.util.Set)

Example 8 with Locator

use of org.apache.geode.distributed.Locator in project geode by apache.

the class ReconnectDUnitTest method forceDisconnect.

public boolean forceDisconnect(VM vm) throws Exception {
    SerializableCallable fd = new SerializableCallable("crash distributed system") {

        public Object call() throws Exception {
            // since the system will disconnect and attempt to reconnect
            // a new system the old reference to DTC.system can cause
            // trouble, so we first null it out.
            nullSystem();
            final DistributedSystem msys = InternalDistributedSystem.getAnyInstance();
            final Locator oldLocator = Locator.getLocator();
            MembershipManagerHelper.crashDistributedSystem(msys);
            if (oldLocator != null) {
                WaitCriterion wc = new WaitCriterion() {

                    public boolean done() {
                        return msys.isReconnecting();
                    }

                    public String description() {
                        return "waiting for locator to start reconnecting: " + oldLocator;
                    }
                };
                Wait.waitForCriterion(wc, 10000, 50, true);
            }
            return true;
        }
    };
    if (vm != null) {
        return (Boolean) vm.invoke(fd);
    } else {
        return (Boolean) fd.call();
    }
}
Also used : ServerLocator(org.apache.geode.distributed.internal.ServerLocator) Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) DistributedSystem(org.apache.geode.distributed.DistributedSystem) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 9 with Locator

use of org.apache.geode.distributed.Locator in project geode by apache.

the class LocatorManagementDUnitTest method startLocator.

/**
   * Starts a locator with given configuration. If DS is already started it will use the same DS
   * 
   * @param vm reference to VM
   */
protected Integer startLocator(final VM vm, final int port) {
    return (Integer) vm.invoke(new SerializableCallable("Start Locator In VM") {

        public Object call() throws Exception {
            assertFalse(InternalLocator.hasLocator());
            Properties props = new Properties();
            props.setProperty(MCAST_PORT, "0");
            props.setProperty(LOCATORS, "");
            props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
            InetAddress bindAddr = null;
            try {
                bindAddr = InetAddress.getByName(getServerHostName(vm.getHost()));
            } catch (UnknownHostException uhe) {
                Assert.fail("While resolving bind address ", uhe);
            }
            Locator locator = null;
            try {
                File logFile = new File(getTestMethodName() + "-locator" + port + ".log");
                locator = Locator.startLocatorAndDS(port, logFile, bindAddr, props);
            } catch (IOException ex) {
                Assert.fail("While starting locator on port " + port, ex);
            }
            assertTrue(InternalLocator.hasLocator());
            return locator.getPort();
        }
    });
}
Also used : Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) UnknownHostException(java.net.UnknownHostException) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) IOException(java.io.IOException) Properties(java.util.Properties) InetAddress(java.net.InetAddress) File(java.io.File)

Example 10 with Locator

use of org.apache.geode.distributed.Locator in project geode by apache.

the class CacheServerManagementDUnitTest method startLocator.

protected void startLocator(Host vmHost, final int locatorPort, final String otherLocators) {
    disconnectFromDS();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, String.valueOf(0));
    props.setProperty(LOCATORS, otherLocators);
    props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
    props.setProperty(JMX_MANAGER_HTTP_PORT, "0");
    props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
    File logFile = new File(getUniqueName() + "-locator" + locatorPort + ".log");
    try {
        InetAddress bindAddr = InetAddress.getByName(NetworkUtils.getServerHostName(vmHost));
        Locator locator = Locator.startLocatorAndDS(locatorPort, logFile, bindAddr, props);
        remoteObjects.put(LOCATOR_KEY, locator);
    } catch (UnknownHostException uhe) {
        Assert.fail("While resolving bind address ", uhe);
    } catch (IOException ex) {
        Assert.fail("While starting locator on port " + locatorPort, ex);
    }
}
Also used : Locator(org.apache.geode.distributed.Locator) UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) File(java.io.File) InetAddress(java.net.InetAddress)

Aggregations

Locator (org.apache.geode.distributed.Locator)23 Properties (java.util.Properties)13 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)10 File (java.io.File)9 IOException (java.io.IOException)8 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)8 InetAddress (java.net.InetAddress)7 Test (org.junit.Test)5 UnknownHostException (java.net.UnknownHostException)4 Set (java.util.Set)4 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ConcurrentSkipListSet (java.util.concurrent.ConcurrentSkipListSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DiskStore (org.apache.geode.cache.DiskStore)2