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);
}
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);
}
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();
}
}
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();
}
});
}
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);
}
}
Aggregations