use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.
the class ClusterConfigurationServiceUsingDirDUnitTest method waitForSharedConfiguration.
private void waitForSharedConfiguration(final VM vm) {
vm.invoke("Waiting for shared configuration", () -> {
final InternalLocator locator = InternalLocator.getLocator();
await().until(() -> {
return locator.isSharedConfigurationRunning();
});
});
}
use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.
the class ClusterConfig method verifyLocator.
public void verifyLocator(MemberVM<Locator> locatorVM) {
Set<String> expectedGroupConfigs = this.getGroups().stream().map(ConfigGroup::getName).collect(toSet());
// verify info exists in memory
locatorVM.invoke(() -> {
InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
// verify no extra configs exist in memory
Set<String> actualGroupConfigs = sc.getEntireConfiguration().keySet();
assertThat(actualGroupConfigs).isEqualTo(expectedGroupConfigs);
for (ConfigGroup configGroup : this.getGroups()) {
// verify jars are as expected
Configuration config = sc.getConfiguration(configGroup.name);
assertThat(config.getJarNames()).isEqualTo(configGroup.getJars());
// verify property is as expected
if (StringUtils.isNotBlank(configGroup.getMaxLogFileSize())) {
Properties props = config.getGemfireProperties();
assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT)).isEqualTo(configGroup.getMaxLogFileSize());
}
// verify region is in the region xml
for (String regionName : configGroup.getRegions()) {
String regionXml = "<region name=\"" + regionName + "\"";
assertThat(config.getCacheXmlContent()).contains(regionXml);
}
}
});
File clusterConfigDir = new File(locatorVM.getWorkingDir(), "/cluster_config");
for (ConfigGroup configGroup : this.getGroups()) {
Set<String> actualFiles = toSetIgnoringHiddenFiles(new File(clusterConfigDir, configGroup.name).list());
Set<String> expectedFiles = configGroup.getAllFiles();
assertThat(actualFiles).isEqualTo(expectedFiles);
}
}
use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.
the class SerialGatewaySenderOperationsDUnitTest method testGatewaySenderNotRegisteredAsCacheServer.
@Test
public void testGatewaySenderNotRegisteredAsCacheServer() {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
createCacheInVMs(nyPort, vm2, vm3);
createReceiverInVMs(vm2, vm3);
createCacheInVMs(lnPort, vm4, vm5);
vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, true, null, true));
vm5.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, true, null, true));
startSenderInVMs("ln", vm4, vm5);
SerializableRunnable check = new SerializableRunnable("assert no cache servers") {
public void run() {
InternalLocator inl = (InternalLocator) Locator.getLocator();
ServerLocator server = inl.getServerLocatorAdvisee();
LogWriterUtils.getLogWriter().info("Server load map is " + server.getLoadMap());
assertTrue("expected an empty map but found " + server.getLoadMap(), server.getLoadMap().isEmpty());
QueueConnectionRequest request = new QueueConnectionRequest(ClientProxyMembershipID.getNewProxyMembership(InternalDistributedSystem.getConnectedInstance()), 1, new HashSet<>(), "", false);
QueueConnectionResponse response = (QueueConnectionResponse) server.processRequest(request);
assertTrue("expected no servers but found " + response.getServers(), response.getServers().isEmpty());
}
};
vm0.invoke(check);
vm1.invoke(check);
}
use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method setup.
private Object[] setup() throws IOException {
final int[] ports = getRandomAvailableTCPPorts(3);
final int locator1Port = ports[0];
final String locator1Name = "locator1-" + locator1Port;
final String locatorLogPath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + "locator-" + locator1Port + ".log";
VM locatorAndMgr = getHost(0).getVM(3);
Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
@Override
public Object call() throws IOException {
int httpPort;
int jmxPort;
String jmxHost;
try {
jmxHost = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ignore) {
jmxHost = "localhost";
}
final int[] ports = getRandomAvailableTCPPorts(2);
jmxPort = ports[0];
httpPort = ports[1];
final File locatorLogFile = new File(locatorLogPath);
final Properties locatorProps = new Properties();
locatorProps.setProperty(NAME, locator1Name);
locatorProps.setProperty(MCAST_PORT, "0");
locatorProps.setProperty(LOG_LEVEL, "config");
locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
locatorProps.setProperty(JMX_MANAGER, "true");
locatorProps.setProperty(JMX_MANAGER_START, "true");
locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS, String.valueOf(jmxHost));
locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return locator.isSharedConfigurationRunning();
}
@Override
public String description() {
return "Waiting for shared configuration to be started";
}
};
waitForCriterion(wc, TIMEOUT, INTERVAL, true);
final Object[] result = new Object[4];
result[0] = locator1Port;
result[1] = jmxHost;
result[2] = jmxPort;
result[3] = httpPort;
return result;
}
});
HeadlessGfsh gfsh = getDefaultShell();
String jmxHost = (String) result[1];
int jmxPort = (Integer) result[2];
int httpPort = (Integer) result[3];
connect(jmxHost, jmxPort, httpPort, gfsh);
// Create a cache in VM 1
VM dataMember = getHost(0).getVM(1);
dataMember.invoke(new SerializableCallable() {
@Override
public Object call() {
Properties localProps = new Properties();
localProps.setProperty(MCAST_PORT, "0");
localProps.setProperty(LOCATORS, "localhost[" + locator1Port + "]");
localProps.setProperty(NAME, "DataMember");
getSystem(localProps);
InternalCache cache = getCache();
assertNotNull(cache);
return getAllNormalMembers(cache);
}
});
return result;
}
use of org.apache.geode.distributed.internal.InternalLocator in project geode by apache.
the class DistributedMulticastRegionDUnitTest method startLocator.
private int startLocator() {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
final int locatorPort = ports[0];
VM locator1Vm = Host.getHost(0).getVM(locatorVM);
;
locator1Vm.invoke(new SerializableCallable() {
@Override
public Object call() {
final File locatorLogFile = new File(getTestMethodName() + "-locator-" + locatorPort + ".log");
final Properties locatorProps = new Properties();
locatorProps.setProperty(NAME, "LocatorWithMcast");
locatorProps.setProperty(MCAST_PORT, mcastport);
locatorProps.setProperty(MCAST_TTL, mcastttl);
locatorProps.setProperty(LOG_LEVEL, "info");
addDSProps(locatorProps);
// locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
try {
final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, null, null, locatorProps);
System.out.println("test Locator started " + locatorPort);
} catch (IOException ioex) {
fail("Unable to create a locator with a shared configuration");
}
return null;
}
});
return locatorPort;
}
Aggregations