Search in sources :

Example 21 with Locator

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

the class WANTestBase method checkAllSiteMetaData.

public static void checkAllSiteMetaData(Map<Integer, Set<InetSocketAddress>> dsIdToLocatorAddresses) {
    List<Locator> locatorsConfigured = Locator.getLocators();
    Locator locator = locatorsConfigured.get(0);
    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> {
        Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator) locator).getlocatorMembershipListener().getAllLocatorsInfo();
        for (Map.Entry<Integer, Set<InetSocketAddress>> entry : dsIdToLocatorAddresses.entrySet()) {
            Set<DistributionLocatorId> foundLocatorIds = allSiteMetaData.get(entry.getKey());
            Set<InetSocketAddress> expectedLocators = entry.getValue();
            final Set<InetSocketAddress> foundLocators = foundLocatorIds.stream().map(distributionLocatorId -> new InetSocketAddress(distributionLocatorId.getHostnameForClients(), distributionLocatorId.getPort())).collect(Collectors.toSet());
            assertEquals(expectedLocators, foundLocators);
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EntryEvent(org.apache.geode.cache.EntryEvent) CacheListener(org.apache.geode.cache.CacheListener) Arrays(java.util.Arrays) AttributesFactory(org.apache.geode.cache.AttributesFactory) OrderPolicy(org.apache.geode.cache.wan.GatewaySender.OrderPolicy) LocalRegion(org.apache.geode.internal.cache.LocalRegion) GATEWAY_SSL_KEYSTORE_TYPE(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE_TYPE) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) GATEWAY_SSL_KEYSTORE(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE) InetAddress(java.net.InetAddress) Cache(org.apache.geode.cache.Cache) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) CacheTestCase(org.apache.geode.cache30.CacheTestCase) Future(java.util.concurrent.Future) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) Map(java.util.Map) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) REMOTE_LOCATORS(org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS) CacheServer(org.apache.geode.cache.server.CacheServer) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) Scope(org.apache.geode.cache.Scope) LOCATORS(org.apache.geode.distributed.ConfigurationProperties.LOCATORS) Shipment(org.apache.geode.internal.cache.execute.data.Shipment) CacheListenerAdapter(org.apache.geode.cache.util.CacheListenerAdapter) Set(java.util.Set) Category(org.junit.experimental.categories.Category) Executors(java.util.concurrent.Executors) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Serializable(java.io.Serializable) JUnit4DistributedTestCase(org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase) CacheServerStats(org.apache.geode.internal.cache.tier.sockets.CacheServerStats) Assert.assertFalse(org.junit.Assert.assertFalse) ConcurrentParallelGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderEventProcessor) GATEWAY_SSL_ENABLED(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_ENABLED) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) MCAST_PORT(org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT) Awaitility(org.awaitility.Awaitility) GATEWAY_SSL_CIPHERS(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_CIPHERS) GATEWAY_SSL_PROTOCOLS(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_PROTOCOLS) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) CacheFactory(org.apache.geode.cache.CacheFactory) Callable(java.util.concurrent.Callable) AttributesMutator(org.apache.geode.cache.AttributesMutator) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) RegionQueue(org.apache.geode.internal.cache.RegionQueue) ArrayList(java.util.ArrayList) LogWriterUtils(org.apache.geode.test.dunit.LogWriterUtils) Region(org.apache.geode.cache.Region) StringTokenizer(java.util.StringTokenizer) START_LOCATOR(org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR) CacheConfig(org.apache.geode.internal.cache.CacheConfig) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Properties(java.util.Properties) Assert.assertTrue(org.junit.Assert.assertTrue) GATEWAY_SSL_TRUSTSTORE_PASSWORD(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_TRUSTSTORE_PASSWORD) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) PRLocallyDestroyedException(org.apache.geode.internal.cache.partitioned.PRLocallyDestroyedException) TestUtil(org.apache.geode.util.test.TestUtil) File(java.io.File) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) ExecutionException(java.util.concurrent.ExecutionException) GatewayQueueEvent(org.apache.geode.cache.wan.GatewayQueueEvent) Assert.assertNull(org.junit.Assert.assertNull) GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GATEWAY_SSL_TRUSTSTORE(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_TRUSTSTORE) CacheServerTestUtil(org.apache.geode.internal.cache.tier.sockets.CacheServerTestUtil) Assert.assertEquals(org.junit.Assert.assertEquals) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Customer(org.apache.geode.internal.cache.execute.data.Customer) CONSERVE_SOCKETS(org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS) Wait(org.apache.geode.test.dunit.Wait) LOG_LEVEL(org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL) AvailablePort(org.apache.geode.internal.AvailablePort) RegionAttributes(org.apache.geode.cache.RegionAttributes) ParallelGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderEventProcessor) Assert(org.apache.geode.test.dunit.Assert) CustomerIDPartitionResolver(org.apache.geode.internal.cache.CustomerIDPartitionResolver) AsyncEventQueueImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl) ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) Assert.fail(org.junit.Assert.fail) ThreadFactory(java.util.concurrent.ThreadFactory) JMX_MANAGER(org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER) PoolManager(org.apache.geode.cache.client.PoolManager) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) GATEWAY_SSL_KEYSTORE_PASSWORD(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE_PASSWORD) OFF_HEAP_MEMORY_SIZE(org.apache.geode.distributed.ConfigurationProperties.OFF_HEAP_MEMORY_SIZE) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) JMX_MANAGER_HTTP_PORT(org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_HTTP_PORT) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) List(java.util.List) Invoke(org.apache.geode.test.dunit.Invoke) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) SimpleClass(org.apache.geode.pdx.SimpleClass) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) IgnoredException(org.apache.geode.test.dunit.IgnoredException) JMX_MANAGER_PORT(org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT) LocatorDiscoveryCallbackAdapter(org.apache.geode.cache.client.internal.LocatorDiscoveryCallbackAdapter) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) DiskStore(org.apache.geode.cache.DiskStore) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) HashMap(java.util.HashMap) DISTRIBUTED_SYSTEM_ID(org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID) HashSet(java.util.HashSet) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) CacheClosedException(org.apache.geode.cache.CacheClosedException) LocatorMembershipListener(org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) RegionFactory(org.apache.geode.cache.RegionFactory) LinkedList(java.util.LinkedList) ExecutorService(java.util.concurrent.ExecutorService) Pool(org.apache.geode.cache.client.Pool) Locator(org.apache.geode.distributed.Locator) Iterator(java.util.Iterator) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) Assert.assertNotNull(org.junit.Assert.assertNotNull) GATEWAY_SSL_REQUIRE_AUTHENTICATION(org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_REQUIRE_AUTHENTICATION) AvailablePortHelper(org.apache.geode.internal.AvailablePortHelper) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) JMX_MANAGER_START(org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START) CustId(org.apache.geode.internal.cache.execute.data.CustId) Order(org.apache.geode.internal.cache.execute.data.Order) ParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue) TimeUnit(java.util.concurrent.TimeUnit) DataPolicy(org.apache.geode.cache.DataPolicy) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) GatewaySender(org.apache.geode.cache.wan.GatewaySender) Collections(java.util.Collections) SimpleClass1(org.apache.geode.pdx.SimpleClass1) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Locator(org.apache.geode.distributed.Locator) Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) InetSocketAddress(java.net.InetSocketAddress) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with Locator

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

the class WANTestBase method checkAllSiteMetaDataFor3Sites.

public static Long checkAllSiteMetaDataFor3Sites(final Map<Integer, Set<String>> dsVsPort) {
    Awaitility.await().atMost(50, TimeUnit.SECONDS).until(() -> assertEquals("System is not initialized", true, (getSystemStatic() != null)));
    List<Locator> locatorsConfigured = Locator.getLocators();
    Locator locator = locatorsConfigured.get(0);
    LocatorMembershipListener listener = ((InternalLocator) locator).getlocatorMembershipListener();
    if (listener == null) {
        fail("No locator membership listener available. WAN is likely not enabled. Is this test in the WAN project?");
    }
    final Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = listener.getAllLocatorsInfo();
    System.out.println("allSiteMetaData : " + allSiteMetaData);
    Awaitility.await().atMost(300, TimeUnit.SECONDS).until(() -> {
        assertEquals(true, (dsVsPort.size() == allSiteMetaData.size()));
        boolean completeFlag = true;
        for (Map.Entry<Integer, Set<String>> entry : dsVsPort.entrySet()) {
            Set<DistributionLocatorId> locators = allSiteMetaData.get(entry.getKey());
            for (String locatorInMetaData : entry.getValue()) {
                DistributionLocatorId locatorId = new DistributionLocatorId(locatorInMetaData);
                if (!locators.contains(locatorId)) {
                    completeFlag = false;
                    break;
                }
            }
            if (false == completeFlag) {
                break;
            }
        }
        assertEquals("Expected site Metadata: " + dsVsPort + " but actual meta data: " + allSiteMetaData, true, completeFlag);
    });
    return System.currentTimeMillis();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) LocatorMembershipListener(org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 23 with Locator

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

the class MemberCommandsDUnitTest method testListMemberWithNoCache.

/**
   * Tests the execution of "list member" command, when no cache is created
   *
   * @throws IOException
   * @throws ClassNotFoundException
   */
@Test
public void testListMemberWithNoCache() throws IOException, ClassNotFoundException {
    final Host host = Host.getHost(0);
    final VM[] servers = { host.getVM(0), host.getVM(1) };
    final int[] openPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1);
    final File logFile = new File(getUniqueName() + "-locator" + openPorts[0] + ".log");
    Locator locator = Locator.startLocator(openPorts[0], logFile);
    try {
        final Properties props = createProperties(host, openPorts[0]);
        CommandProcessor commandProcessor = new CommandProcessor();
        Result result = commandProcessor.createCommandStatement(CliStrings.LIST_MEMBER, EMPTY_ENV).process();
        getLogWriter().info("#SB" + getResultAsString(result));
        assertEquals(true, result.getStatus().equals(Status.ERROR));
    } finally {
        // fix for bug 46562
        locator.stop();
    }
}
Also used : Locator(org.apache.geode.distributed.Locator) VM(org.apache.geode.test.dunit.VM) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Host(org.apache.geode.test.dunit.Host) Properties(java.util.Properties) File(java.io.File) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

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