use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class GemFireCacheImpl method requestSharedConfiguration.
/**
* Request the shared configuration from the locator(s) which have the Cluster config service
* running
*/
private ConfigurationResponse requestSharedConfiguration() {
final DistributionConfig config = this.system.getConfig();
if (!(this.dm instanceof DistributionManager)) {
return null;
}
// do nothing if this vm is/has locator or this is a client
if (this.dm.getDMType() == DistributionManager.LOCATOR_DM_TYPE || this.isClient || Locator.getLocator() != null) {
return null;
}
// can't simply return null if server is not using shared configuration, since we need to find
// out
// if the locator is running in secure mode or not, if yes, then we need to throw an exception
// if server is not using cluster config
Map<InternalDistributedMember, Collection<String>> scl = getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
// then do not make requests to the locators
if (scl.isEmpty()) {
logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_NO_LOCATORS_FOUND_WITH_SHARED_CONFIGURATION));
return null;
}
List<String> locatorConnectionStrings = getSharedConfigLocatorConnectionStringList();
try {
ConfigurationResponse response = ClusterConfigurationLoader.requestConfigurationFromLocators(this.system.getConfig(), locatorConnectionStrings);
// log the configuration received from the locator
logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_RECEIVED_SHARED_CONFIGURATION_FROM_LOCATORS));
logger.info(response.describeConfig());
Configuration clusterConfig = response.getRequestedConfiguration().get(ClusterConfigurationService.CLUSTER_CONFIG);
Properties clusterSecProperties = clusterConfig == null ? new Properties() : clusterConfig.getGemfireProperties();
// If not using shared configuration, return null or throw an exception is locator is secured
if (!config.getUseSharedConfiguration()) {
if (clusterSecProperties.containsKey(ConfigurationProperties.SECURITY_MANAGER)) {
throw new GemFireConfigException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION_2.toLocalizedString());
} else {
logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_NOT_USING_SHARED_CONFIGURATION));
return null;
}
}
Properties serverSecProperties = config.getSecurityProps();
// check for possible mis-configuration
if (isMisConfigured(clusterSecProperties, serverSecProperties, ConfigurationProperties.SECURITY_MANAGER) || isMisConfigured(clusterSecProperties, serverSecProperties, ConfigurationProperties.SECURITY_POST_PROCESSOR)) {
throw new GemFireConfigException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
}
return response;
} catch (ClusterConfigurationNotAvailableException e) {
throw new GemFireConfigException(LocalizedStrings.GemFireCache_SHARED_CONFIGURATION_NOT_AVAILABLE.toLocalizedString(), e);
} catch (UnknownHostException e) {
throw new GemFireConfigException(e.getLocalizedMessage(), e);
}
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class DistributedSystemDUnitTest method testSpecificTcpPort.
/**
* test the ability to set the port used to listen for tcp/ip connections
*/
@Test
public void testSpecificTcpPort() throws Exception {
Properties config = new Properties();
config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
config.setProperty(TCP_PORT, String.valueOf(this.tcpPort));
InternalDistributedSystem system = getSystem(config);
DistributionManager dm = (DistributionManager) system.getDistributionManager();
GMSMembershipManager mgr = (GMSMembershipManager) dm.getMembershipManager();
assertThat(mgr.getDirectChannelPort()).isEqualTo(this.tcpPort);
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class DistributedSystemDUnitTest method testUDPPortRange.
@Test
public void testUDPPortRange() throws Exception {
Properties config = new Properties();
config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
config.setProperty(MEMBERSHIP_PORT_RANGE, this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
InternalDistributedSystem system = getSystem(config);
DistributionManager dm = (DistributionManager) system.getDistributionManager();
InternalDistributedMember member = dm.getDistributionManagerId();
verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class DistributedLockServiceDUnitTest method testDestroyLockServiceAfterGrantResponse.
@Test
public void testDestroyLockServiceAfterGrantResponse() throws Throwable {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
final String serviceName = getUniqueName();
vm0.invoke(new SerializableRunnable("Create the grantor") {
public void run() {
connectDistributedSystem();
final DistributedLockService service = DistributedLockService.create(serviceName, dlstSystem);
// lock and unlock to make sure this vm is grantor
assertTrue(service.lock("obj", -1, -1));
service.unlock("obj");
}
});
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof DLockResponseMessage) {
DistributedLockService.destroy(serviceName);
}
}
});
connectDistributedSystem();
final DistributedLockService service = DistributedLockService.create(serviceName, dlstSystem);
try {
service.lock("obj", -1, -1);
fail("The lock service should have been destroyed");
} catch (LockServiceDestroyedException expected) {
// Do nothing
}
vm0.invoke(new SerializableRunnable("check to make sure the lock is not orphaned") {
public void run() {
final DistributedLockService service = DistributedLockService.getServiceNamed(serviceName);
// lock and unlock to make sure this vm is grantor
assertTrue(service.lock("obj", -1, -1));
service.unlock("obj");
}
});
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class AbstractExecution method executeFunctionOnLocalNode.
// Bug41118 : in case of lonerDistribuedSystem do local execution through
// main thread otherwise give execution to FunctionExecutor from
// DistributionManager
public void executeFunctionOnLocalNode(final Function fn, final FunctionContext cx, final ResultSender sender, DM dm, final boolean isTx) {
if (dm instanceof DistributionManager && !isTx) {
final DistributionManager newDM = (DistributionManager) dm;
newDM.getFunctionExcecutor().execute(new Runnable() {
public void run() {
executeFunctionLocally(fn, cx, sender, newDM);
if (!((InternalResultSender) sender).isLastResultReceived() && fn.hasResult()) {
((InternalResultSender) sender).setException(new FunctionException(LocalizedStrings.ExecuteFunction_THE_FUNCTION_0_DID_NOT_SENT_LAST_RESULT.toString(fn.getId())));
}
}
});
} else {
executeFunctionLocally(fn, cx, sender, dm);
if (!((InternalResultSender) sender).isLastResultReceived() && fn.hasResult()) {
((InternalResultSender) sender).setException(new FunctionException(LocalizedStrings.ExecuteFunction_THE_FUNCTION_0_DID_NOT_SENT_LAST_RESULT.toString(fn.getId())));
}
}
}
Aggregations