Search in sources :

Example 16 with InternalLocator

use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.

the class DUnitLauncher method startLocator.

private static int startLocator(Registry registry) throws IOException, NotBoundException {
    RemoteDUnitVMIF remote = (RemoteDUnitVMIF) registry.lookup("vm" + LOCATOR_VM_NUM);
    final File locatorLogFile = LOCATOR_LOG_TO_DISK ? new File("locator-" + locatorPort + ".log") : new File("");
    MethExecutorResult result = remote.executeMethodOnObject(new SerializableCallable() {

        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();
                internalLocator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
            } finally {
                System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
            }
            return locatorPort;
        }
    }, "call");
    if (result.getException() != null) {
        RuntimeException ex = new RuntimeException("Failed to start locator", result.getException());
        ex.printStackTrace();
        throw ex;
    }
    return (Integer) result.getResult();
}
Also used : InternalLocator(org.apache.geode.distributed.internal.InternalLocator) MethExecutorResult(hydra.MethExecutorResult) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) IOException(java.io.IOException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) File(java.io.File)

Example 17 with InternalLocator

use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.

the class ClusterConfigurationServiceUsingDirDUnitTest method preTearDownCacheTestCase.

@Override
public final void preTearDownCacheTestCase() throws Exception {
    for (int i = 0; i < 2; i++) {
        VM vm = getHost(0).getVM(i);
        vm.invoke("Removing shared configuration", () -> {
            InternalLocator locator = InternalLocator.getLocator();
            if (locator == null) {
                return;
            }
            ClusterConfigurationService sharedConfig = locator.getSharedConfiguration();
            if (sharedConfig != null) {
                sharedConfig.destroySharedConfiguration();
            }
        });
    }
}
Also used : InternalLocator(org.apache.geode.distributed.internal.InternalLocator) ClusterConfigurationService(org.apache.geode.distributed.internal.ClusterConfigurationService) VM(org.apache.geode.test.dunit.VM)

Example 18 with InternalLocator

use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.

the class WANTestBase method putRemoteSiteLocators.

public static void putRemoteSiteLocators(int remoteDsId, Set<String> remoteLocators) {
    List<Locator> locatorsConfigured = Locator.getLocators();
    Locator locator = locatorsConfigured.get(0);
    if (remoteLocators != null) {
        // Add fake remote locators to the locators map
        ((InternalLocator) locator).getlocatorMembershipListener().getAllServerLocatorsInfo().put(remoteDsId, remoteLocators);
    }
}
Also used : InternalLocator(org.apache.geode.distributed.internal.InternalLocator) Locator(org.apache.geode.distributed.Locator) InternalLocator(org.apache.geode.distributed.internal.InternalLocator)

Example 19 with InternalLocator

use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.

the class FetchSharedConfigurationStatusFunction method execute.

@Override
public void execute(FunctionContext context) {
    InternalLocator locator = InternalLocator.getLocator();
    InternalCache cache = GemFireCacheImpl.getInstance();
    DistributedMember member = cache.getDistributedSystem().getDistributedMember();
    SharedConfigurationStatus status = locator.getSharedConfigurationStatus().getStatus();
    String memberId = member.getName();
    if (StringUtils.isBlank(memberId)) {
        memberId = member.getId();
    }
    CliFunctionResult result = new CliFunctionResult(memberId, new String[] { status.name() });
    context.getResultSender().lastResult(result);
}
Also used : SharedConfigurationStatus(org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache)

Example 20 with InternalLocator

use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.

the class CacheServerLoadMessage method updateLocalLocators.

public void updateLocalLocators() {
    List locators = Locator.getLocators();
    for (int i = 0; i < locators.size(); i++) {
        InternalLocator l = (InternalLocator) locators.get(i);
        ServerLocator serverLocator = l.getServerLocatorAdvisee();
        if (serverLocator != null) {
            serverLocator.updateLoad(location, load, this.clientIds);
        }
    }
}
Also used : InternalLocator(org.apache.geode.distributed.internal.InternalLocator) ArrayList(java.util.ArrayList) List(java.util.List) ServerLocator(org.apache.geode.distributed.internal.ServerLocator)

Aggregations

InternalLocator (org.apache.geode.distributed.internal.InternalLocator)41 File (java.io.File)21 IOException (java.io.IOException)18 Properties (java.util.Properties)18 Test (org.junit.Test)17 VM (org.apache.geode.test.dunit.VM)16 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)15 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)15 Cache (org.apache.geode.cache.Cache)9 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)9 UnknownHostException (java.net.UnknownHostException)8 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)8 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)8 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)7 Locator (org.apache.geode.distributed.Locator)6 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)6 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)6 List (java.util.List)5 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)5 Set (java.util.Set)4